Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate static and dynamic libs by filename #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,32 @@ file(GLOB WINDOWS_INCLUDE windows/*.hpp)
# Used to help with the creation of the srcML library.
# - LIB_NAME is the name of the library and target
# - LIB_TYPE is either STATIC or SHARED.
# - LIB_OUTPUT_NAME is the output filename for the compiled library.
#
macro(build_lib LIB_NAME LIB_TYPE)
macro(build_lib LIB_NAME LIB_TYPE LIB_OUTPUT_NAME)

add_library(${LIB_NAME} ${LIB_TYPE} ${HANDLER_SOURCE} ${HANDLER_INCLUDE} ${WINDOWS_SOURCE} ${WINDOWS_INCLUDE})

if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
set_target_properties(${LIB_NAME} PROPERTIES OUTPUT_NAME libsrcsax LINK_FLAGS_DEBUG "/SAFESEH:NO")
elseif(APPLE)
set_target_properties(${LIB_NAME} PROPERTIES OUTPUT_NAME srcsax MACOSX_RPATH OFF)
else()
set_target_properties(${LIB_NAME} PROPERTIES OUTPUT_NAME srcsax)
endif()
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
set_target_properties(${LIB_NAME} PROPERTIES OUTPUT_NAME ${LIB_OUTPUT_NAME} LINK_FLAGS_DEBUG "/SAFESEH:NO")
elseif(APPLE)
set_target_properties(${LIB_NAME} PROPERTIES OUTPUT_NAME ${LIB_OUTPUT_NAME} MACOSX_RPATH OFF)
else()
set_target_properties(${LIB_NAME} PROPERTIES OUTPUT_NAME ${LIB_OUTPUT_NAME})
endif()

endmacro()

find_package(LibXml2 REQUIRED)

build_lib(srcsax_static STATIC)
if(WIN32)
build_lib(srcsax_static STATIC srcsax_static)
else()
build_lib(srcsax_static STATIC srcsax)
endif()
target_link_libraries(srcsax_static PRIVATE LibXml2::LibXml2)

build_lib(srcsax_shared SHARED)
build_lib(srcsax_shared SHARED srcsax)
target_link_libraries(srcsax_shared PRIVATE LibXml2::LibXml2)

install(TARGETS srcsax_shared srcsax_static RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
Expand Down