From 0497f57268e8be7af69d37e24fa356e441c0d5f6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 1 Nov 2015 09:09:25 +0100 Subject: cmake: less linkage boilerplate --- cmake/opentrack-macros.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cmake/opentrack-macros.cmake') diff --git a/cmake/opentrack-macros.cmake b/cmake/opentrack-macros.cmake index e43dc3b5..46cf3c61 100644 --- a/cmake/opentrack-macros.cmake +++ b/cmake/opentrack-macros.cmake @@ -66,7 +66,8 @@ macro(opentrack_library n dir) set_target_properties(${n} PROPERTIES LINK_FLAGS "${link-flags} ${opentrack-foolib_LINK}" COMPILE_FLAGS "${opentrack-foolib_COMPILE}") set(link-flags) endif() - string(REPLACE "-" "_" n_ ${n}) + string(REGEX REPLACE "^opentrack-" "" n_ ${n}) + string(REPLACE "-" "_" n_ ${n_}) target_compile_definitions(${n} PRIVATE "BUILD_${n_}") if(NOT opentrack-foolib_STATIC) install(TARGETS ${n} RUNTIME DESTINATION . LIBRARY DESTINATION .) -- cgit v1.2.3 From 5a2ddaf39cf5ad86cf43d8a01f51989b5e3afa49 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 1 Nov 2015 09:20:17 +0100 Subject: cmake: export only needed symbols --- cmake/opentrack-macros.cmake | 22 +++++++++++++++------- csv/CMakeLists.txt | 2 +- opentrack-compat/CMakeLists.txt | 2 +- pose-widget/CMakeLists.txt | 2 +- qxt-mini/CMakeLists.txt | 2 +- spline-widget/CMakeLists.txt | 2 +- 6 files changed, 20 insertions(+), 12 deletions(-) (limited to 'cmake/opentrack-macros.cmake') diff --git a/cmake/opentrack-macros.cmake b/cmake/opentrack-macros.cmake index 46cf3c61..9be09397 100644 --- a/cmake/opentrack-macros.cmake +++ b/cmake/opentrack-macros.cmake @@ -32,7 +32,7 @@ endfunction() macro(opentrack_library n dir) cmake_parse_arguments(opentrack-foolib - "NO-LIBRARY;STATIC;NO-COMPAT;NO-LINKER-SCRIPT" + "NO-LIBRARY;STATIC;NO-COMPAT;NO-LINKER-SCRIPT;LINKAGE" "LINK;COMPILE;GNU-LINK;GNU-COMPILE" "" ${ARGN} @@ -54,17 +54,25 @@ macro(opentrack_library n dir) endif() target_link_libraries(${n} ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE AND NOT opentrack-foolib_NO-LINKER-SCRIPT) - SET_TARGET_PROPERTIES(${n} PROPERTIES + set_target_properties(${n} PROPERTIES LINK_FLAGS "${opentrack-foolib_LINK} ${opentrack-foolib_GNU-LINK} -Wl,--as-needed -Wl,--version-script=\"${CMAKE_SOURCE_DIR}/opentrack-compat/${version-script}-version-script.txt\"" COMPILE_FLAGS "${opentrack-foolib_COMPILE} ${opentrack-foolib_GNU-COMPILE} -fvisibility=hidden -fvisibility-inlines-hidden" ) else() - set(link-flags) - if(MSVC) - set(link-flags "${msvc-subsystem} /DEBUG /OPT:ICF") + set(c-props) + set(l-props) + if(opentrack-foolib_LINKAGE AND CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) + set(c-props "${opentrack-foolib_COMPILE} ${opentrack-foolib_GNU-COMPILE} -fvisibility=hidden -fvisibility-inlines-hidden") + set(l-props "${opentrack-foolib_LINK} ${opentrack-foolib_GNU-LINK} -Wl,--as-needed") + else() + if(MSVC) + set(l-props "${msvc-subsystem} /DEBUG /OPT:ICF") + endif() endif() - set_target_properties(${n} PROPERTIES LINK_FLAGS "${link-flags} ${opentrack-foolib_LINK}" COMPILE_FLAGS "${opentrack-foolib_COMPILE}") - set(link-flags) + set_target_properties(${n} PROPERTIES + LINK_FLAGS "${l-props} ${opentrack-foolib_LINK}" + COMPILE_FLAGS "${c-props} ${opentrack-foolib_COMPILE}" + ) endif() string(REGEX REPLACE "^opentrack-" "" n_ ${n}) string(REPLACE "-" "_" n_ ${n_}) diff --git a/csv/CMakeLists.txt b/csv/CMakeLists.txt index 7e80317c..7bafc7ff 100644 --- a/csv/CMakeLists.txt +++ b/csv/CMakeLists.txt @@ -1 +1 @@ -opentrack_boilerplate(opentrack-csv NO-LINKER-SCRIPT) +opentrack_boilerplate(opentrack-csv NO-LINKER-SCRIPT LINKAGE) diff --git a/opentrack-compat/CMakeLists.txt b/opentrack-compat/CMakeLists.txt index a92f4f31..37d53e6c 100644 --- a/opentrack-compat/CMakeLists.txt +++ b/opentrack-compat/CMakeLists.txt @@ -1,4 +1,4 @@ -opentrack_boilerplate(opentrack-compat NO-COMPAT NO-LINKER-SCRIPT) +opentrack_boilerplate(opentrack-compat NO-COMPAT NO-LINKER-SCRIPT LINKAGE) if(NOT WIN32 AND NOT APPLE) target_link_libraries(opentrack-compat rt) endif() diff --git a/pose-widget/CMakeLists.txt b/pose-widget/CMakeLists.txt index 66cafef7..e48660d7 100644 --- a/pose-widget/CMakeLists.txt +++ b/pose-widget/CMakeLists.txt @@ -1 +1 @@ -opentrack_boilerplate(opentrack-pose-widget NO-LINKER-SCRIPT) +opentrack_boilerplate(opentrack-pose-widget NO-LINKER-SCRIPT LINKAGE) diff --git a/qxt-mini/CMakeLists.txt b/qxt-mini/CMakeLists.txt index 5de29cd1..a8b8fb1d 100644 --- a/qxt-mini/CMakeLists.txt +++ b/qxt-mini/CMakeLists.txt @@ -1,5 +1,5 @@ if(UNIX OR APPLE) - opentrack_boilerplate(opentrack-qxt-mini NO-LINKER-SCRIPT NO-COMPAT) + opentrack_boilerplate(opentrack-qxt-mini NO-LINKER-SCRIPT NO-COMPAT LINKAGE) if(NOT APPLE) target_link_libraries(opentrack-qxt-mini X11) else() diff --git a/spline-widget/CMakeLists.txt b/spline-widget/CMakeLists.txt index 93958f50..4d951f92 100644 --- a/spline-widget/CMakeLists.txt +++ b/spline-widget/CMakeLists.txt @@ -1 +1 @@ -opentrack_boilerplate(opentrack-spline-widget NO-LINKER-SCRIPT NO-COMPAT) +opentrack_boilerplate(opentrack-spline-widget NO-LINKER-SCRIPT NO-COMPAT LINKAGE) -- cgit v1.2.3 From 9da1484e6c1bbd130a6b618f72efb0acf222e548 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 3 Nov 2015 09:58:13 +0100 Subject: cmake: can use default hidden visibility on apple --- cmake/opentrack-macros.cmake | 8 ++++++-- gui/CMakeLists.txt | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'cmake/opentrack-macros.cmake') diff --git a/cmake/opentrack-macros.cmake b/cmake/opentrack-macros.cmake index 9be09397..d84f9175 100644 --- a/cmake/opentrack-macros.cmake +++ b/cmake/opentrack-macros.cmake @@ -53,9 +53,13 @@ macro(opentrack_library n dir) target_link_libraries(${n} opentrack-api opentrack-compat) endif() target_link_libraries(${n} ${MY_QT_LIBS}) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE AND NOT opentrack-foolib_NO-LINKER-SCRIPT) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT opentrack-foolib_NO-LINKER-SCRIPT) + set(l-flags) + if(NOT APPLE) + set(l-flags "-Wl,--as-needed -Wl,--version-script=\"${CMAKE_SOURCE_DIR}/opentrack-compat/${version-script}-version-script.txt\"") + endif() set_target_properties(${n} PROPERTIES - LINK_FLAGS "${opentrack-foolib_LINK} ${opentrack-foolib_GNU-LINK} -Wl,--as-needed -Wl,--version-script=\"${CMAKE_SOURCE_DIR}/opentrack-compat/${version-script}-version-script.txt\"" + LINK_FLAGS "${opentrack-foolib_LINK} ${opentrack-foolib_GNU-LINK} ${l-flags}" COMPILE_FLAGS "${opentrack-foolib_COMPILE} ${opentrack-foolib_GNU-COMPILE} -fvisibility=hidden -fvisibility-inlines-hidden" ) else() diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 7fec9a15..d34ea981 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -41,9 +41,11 @@ endif() set(c-props) set(l-props) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) +if(CMAKE_COMPILER_IS_GNUCXX) set(c-props "-fvisibility=hidden -fvisibility-inlines-hidden") - set(l-props "-Wl,--as-needed") + if(NOT APPLE) + set(l-props "-Wl,--as-needed") + endif() endif() set_target_properties(opentrack PROPERTIES -- cgit v1.2.3