@@ -4,22 +4,23 @@ project(iniparser VERSION 4.2.2)
4
4
5
5
include (GNUInstallDirs )
6
6
include (CMakePackageConfigHelpers )
7
+ include (CMakeDependentOption )
7
8
8
9
option (
9
10
BUILD_SHARED_LIBS
10
11
"Build using shared libraries"
11
12
ON )
12
- option (
13
- BUILD_STATIC_LIBS
14
- "Build using static libraries"
15
- ON )
13
+ # For packaging by tools like bitbake, shared and static libs should be build
14
+ # at once
15
+ CMAKE_DEPENDENT_OPTION ( BUILD_STATIC_LIBS "Build static libs" ON
16
+ "BUILD_SHARED_LIBS" OFF )
16
17
if (BUILD_SHARED_LIBS )
17
18
list (
18
19
APPEND
19
20
TARGET_TYPES
20
21
"shared" )
21
22
endif ()
22
- if (BUILD_STATIC_LIBS )
23
+ if (BUILD_STATIC_LIBS OR NOT BUILD_SHARED_LIBS )
23
24
list (
24
25
APPEND
25
26
TARGET_TYPES
@@ -132,7 +133,10 @@ if(BUILD_TESTING)
132
133
${CMAKE_CURRENT_SOURCE_DIR} /test/test_dictionary.c
133
134
${CMAKE_CURRENT_SOURCE_DIR} /test/test_iniparser.c )
134
135
135
- target_link_libraries (${TEST_NAME} "${PROJECT_NAME} -static" )
136
+ foreach (TARGET_TYPE ${TARGET_TYPES} )
137
+ # if BUILD_STATIC_LIBS=ON shared takes precedence
138
+ target_link_libraries (${TEST_NAME} "${PROJECT_NAME} -${TARGET_TYPE} " )
139
+ endforeach ()
136
140
137
141
target_include_directories (
138
142
${TEST_NAME}
@@ -158,7 +162,7 @@ if(BUILD_EXAMPLES)
158
162
add_executable (parse ${CMAKE_CURRENT_SOURCE_DIR} /example/parse.c )
159
163
160
164
foreach (TARGET_TYPE ${TARGET_TYPES} )
161
- # if BUILD_STATIC_WITH_SHARED_LIBS =ON shared takes precedence
165
+ # if BUILD_STATIC_LIBS =ON shared takes precedence
162
166
target_link_libraries (iniexample ${PROJECT_NAME} -${TARGET_TYPE} )
163
167
target_link_libraries (iniwrite ${PROJECT_NAME} -${TARGET_TYPE} )
164
168
target_link_libraries (parse ${PROJECT_NAME} -${TARGET_TYPE} )
0 commit comments