Skip to content

Commit

Permalink
CMakeLists.txt: don't force the build of a shared library
Browse files Browse the repository at this point in the history
Building a shared library doesn't work on all platforms, so instead,
let CMake rely on the standard BUILD_SHARED_LIBS variable to decide
whether a static or shared library should be built.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  • Loading branch information
tpetazzoni committed Sep 3, 2017
1 parent d7cf836 commit 58edd50
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@ set(CGI_SRC
)

# create binary
add_library(${PROJECT_NAME}-shared SHARED ${CGI_SRC})
set_target_properties(${PROJECT_NAME}-shared PROPERTIES
add_library(${PROJECT_NAME} ${CGI_SRC})
set_target_properties(${PROJECT_NAME} PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${PROJECT_VERSION}
)

# install binary
install(TARGETS ${PROJECT_NAME}-shared
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)

# install cmake targets
Expand Down
6 changes: 3 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ add_executable(cgi-test
test.c
)
target_link_libraries(cgi-test
"${PROJECT_NAME}-shared"
"${PROJECT_NAME}"
)
add_test(escape_special_chars
cgi-test escape_special_chars
Expand All @@ -39,7 +39,7 @@ add_executable(cgi-test-slist
test_slist.c
)
target_link_libraries(cgi-test-slist
"${PROJECT_NAME}-shared"
"${PROJECT_NAME}"
)
add_test(slist_add
cgi-test-slist add
Expand Down Expand Up @@ -70,7 +70,7 @@ add_executable(cgi-test-trim
trim.c
)
target_link_libraries(cgi-test-trim
"${PROJECT_NAME}-shared"
"${PROJECT_NAME}"
)
add_test(test_ltrim
cgi-test-trim ltrim
Expand Down

0 comments on commit 58edd50

Please sign in to comment.