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

Fix disabling dynamic/shared version of RTTR #247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ if (USE_PCH)
endif()
endif()

if(NOT BUILD_RTTR_DYNAMIC)
message(WARNING "Disabling the dynamic/shared version of RTTR will also disable Benchmarks, Examples, and Unit Tests.")
set(BUILD_BENCHMARKS FALSE)
set(BUILD_EXAMPLES FALSE)
set(BUILD_UNIT_TESTS FALSE)
endif()

include(config)
include(3rd_party_libs)

Expand Down
80 changes: 41 additions & 39 deletions src/rttr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,50 +128,52 @@ if (BUILD_STATIC)
endif()

if (BUILD_WITH_STATIC_RUNTIME_LIBS)
add_library(rttr_core_s SHARED ${UnityBuild} ${SRC_FILES} ${HPP_FILES})
add_library(RTTR::Core_STL ALIAS rttr_core_s)

target_compile_definitions(rttr_core_s PRIVATE RTTR_DLL_EXPORTS)
target_compile_definitions(rttr_core_s PUBLIC RTTR_DLL)
if (${BUILD_RTTR_DYNAMIC})
add_library(rttr_core_s SHARED ${UnityBuild} ${SRC_FILES} ${HPP_FILES})
add_library(RTTR::Core_STL ALIAS rttr_core_s)

target_compile_definitions(rttr_core_s PRIVATE RTTR_DLL_EXPORTS)
target_compile_definitions(rttr_core_s PUBLIC RTTR_DLL)

target_include_directories(rttr_core_s PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
$<INSTALL_INTERFACE:include>)
target_include_directories(rttr_core_s PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
$<INSTALL_INTERFACE:include>)

target_link_libraries(rttr_core_s PRIVATE ${CMAKE_DL_LIBS})

set_target_properties(rttr_core_s PROPERTIES
VERSION ${RTTR_VERSION} SOVERSION ${RTTR_VERSION}
EXPORT_NAME Core_STL
CXX_STANDARD ${MAX_CXX_STANDARD}
DEBUG_POSTFIX ${RTTR_DEBUG_POSTFIX}
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN 1)
target_link_libraries(rttr_core_s PRIVATE ${CMAKE_DL_LIBS})
set_target_properties(rttr_core_s PROPERTIES
VERSION ${RTTR_VERSION} SOVERSION ${RTTR_VERSION}
EXPORT_NAME Core_STL
CXX_STANDARD ${MAX_CXX_STANDARD}
DEBUG_POSTFIX ${RTTR_DEBUG_POSTFIX}
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN 1)

if(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
target_compile_features(rttr_core_s PUBLIC cxx_std_11) # at least c++11 is needed to compile RTTR
endif()

set_compiler_warnings(rttr_core_s)
if(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
target_compile_features(rttr_core_s PUBLIC cxx_std_11) # at least c++11 is needed to compile RTTR
endif()
set_compiler_warnings(rttr_core_s)

if (MSVC)
target_compile_options(rttr_core_s PUBLIC "/MT$<$<CONFIG:Debug>:d>")
elseif(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(rttr_core_s PROPERTIES LINK_FLAGS ${GNU_STATIC_LINKER_FLAGS})
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set_target_properties(rttr_core_s PROPERTIES LINK_FLAGS ${CLANG_STATIC_LINKER_FLAGS})
else()
message(SEND_ERROR "Do not know how to statically link against the standard library with this compiler.")
endif()
if (MSVC)
target_compile_options(rttr_core_s PUBLIC "/MT$<$<CONFIG:Debug>:d>")
elseif(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(rttr_core_s PROPERTIES LINK_FLAGS ${GNU_STATIC_LINKER_FLAGS})
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set_target_properties(rttr_core_s PROPERTIES LINK_FLAGS ${CLANG_STATIC_LINKER_FLAGS})
else()
message(SEND_ERROR "Do not know how to statically link against the standard library with this compiler.")
endif()

if (BUILD_INSTALLER)
install_pdb_files(rttr_core_s)
install(TARGETS rttr_core_s EXPORT rttr_targets
RUNTIME DESTINATION ${RTTR_RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${RTTR_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${RTTR_ARCHIVE_INSTALL_DIR}
FRAMEWORK DESTINATION ${RTTR_FRAMEWORK_INSTALL_DIR})
if (BUILD_INSTALLER)
install_pdb_files(rttr_core_s)
install(TARGETS rttr_core_s EXPORT rttr_targets
RUNTIME DESTINATION ${RTTR_RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${RTTR_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${RTTR_ARCHIVE_INSTALL_DIR}
FRAMEWORK DESTINATION ${RTTR_FRAMEWORK_INSTALL_DIR})
endif()
endif()

if (BUILD_STATIC)
Expand Down