Commit 6588f752 authored by Ghislain MARY's avatar Ghislain MARY

Do not include dependencies in the link interface when building a shared...

Do not include dependencies in the link interface when building a shared library + Allow building both shared and static libraries.
parent bef85020
......@@ -30,6 +30,8 @@ set(BELCARD_MICRO_VERSION "1")
set(BELCARD_VERSION "${BELCARD_MAJOR_VERSION}.${BELCARD_MINOR_VERSION}.${BELCARD_MICRO_VERSION}")
set(BELCARD_SO_VERSION "1")
option(ENABLE_SHARED "Build shared library." ON)
option(ENABLE_STATIC "Build static library." ON)
option(ENABLE_UNIT_TESTS "Enable compilation of unit tests." YES)
macro(apply_compile_flags SOURCE_FILES)
......
......@@ -45,23 +45,42 @@ apply_compile_flags(BELCARD_SOURCE_FILES_C "CPP" "C")
apply_compile_flags(BELCARD_SOURCE_FILES_CXX "CPP" "CXX")
if(ENABLE_STATIC)
add_library(belcard STATIC ${BELCARD_HEADER_FILES} ${BELCARD_SOURCE_FILES_C} ${BELCARD_SOURCE_FILES_CXX})
else()
add_library(belcard-static STATIC ${BELCARD_HEADER_FILES} ${BELCARD_SOURCE_FILES_C} ${BELCARD_SOURCE_FILES_CXX})
target_link_libraries(belcard-static ${BELR_LIBRARIES} ${BCTOOLBOX_LIBRARIES})
endif()
if(ENABLE_SHARED)
add_library(belcard SHARED ${BELCARD_HEADER_FILES} ${BELCARD_SOURCE_FILES_C} ${BELCARD_SOURCE_FILES_CXX})
if(APPLE)
set_target_properties(belcard PROPERTIES LINK_FLAGS "-stdlib=libc++")
endif()
set_target_properties(belcard PROPERTIES LINK_FLAGS "-stdlib=libc++")
endif()
set_target_properties(belcard PROPERTIES VERSION ${BELCARD_SO_VERSION})
target_link_libraries(belcard PRIVATE ${BELR_LIBRARIES} ${BCTOOLBOX_LIBRARIES})
if(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/belcard.pdb
DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
endif()
endif()
target_link_libraries(belcard ${BELR_LIBRARIES} ${BCTOOLBOX_LIBRARIES})
install(TARGETS belcard EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
if(ENABLE_STATIC)
install(TARGETS belcard-static EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
if(ENABLE_SHARED)
install(TARGETS belcard EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
install(FILES ${BELCARD_HEADER_FILES}
DESTINATION include/belcard
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment