summaryrefslogtreecommitdiffhomepage
path: root/cmake
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-05-17 18:01:32 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-05-17 18:01:32 +0200
commit7a014a9494bcc52a8df53e333d51650d7dfcad0f (patch)
tree100d1831a010a16379258c40869afcdc56143e28 /cmake
parent4ee6c132309100d6d68951b33a1d8bdf21177571 (diff)
cmake: work for shared library destructors
Remove linker script usage. I'm worried about the potential interaction with shared libraries' _fini symbol for global destruction. Further, add -fuse-cxa-atexit in order to run the global destructors to begin with. This works on LLVM and GNU. MSVC doesn't export symbols by default.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/opentrack-macros.cmake37
1 files changed, 14 insertions, 23 deletions
diff --git a/cmake/opentrack-macros.cmake b/cmake/opentrack-macros.cmake
index 00e1ae30..988ab9af 100644
--- a/cmake/opentrack-macros.cmake
+++ b/cmake/opentrack-macros.cmake
@@ -35,7 +35,7 @@ endfunction()
macro(opentrack_library n dir)
cmake_parse_arguments(opentrack-foolib
- "NO-LIBRARY;STATIC;NO-COMPAT;NO-LINKER-SCRIPT;LINKAGE"
+ "NO-LIBRARY;STATIC;NO-COMPAT"
"LINK;COMPILE;GNU-LINK;GNU-COMPILE"
""
${ARGN}
@@ -56,31 +56,22 @@ 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 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} ${l-flags}"
- COMPILE_FLAGS "${opentrack-foolib_COMPILE} ${opentrack-foolib_GNU-COMPILE} -fvisibility=hidden -fvisibility-inlines-hidden"
- )
+ set(c-props)
+ set(l-props)
+ if(CMAKE_COMPILER_IS_GNUCXX)
+ set(c-props "-fvisibility=hidden -fuse-cxa-atexit ${opentrack-foolib_GNU-COMPILE}")
+ endif()
+ if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
+ set(l-props "${opentrack-foolib_GNU-LINK} -Wl,--as-needed")
else()
- 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()
+ if(MSVC)
+ set(l-props "${msvc-subsystem} /DEBUG /OPT:ICF")
endif()
- set_target_properties(${n} PROPERTIES
- LINK_FLAGS "${l-props} ${opentrack-foolib_LINK}"
- COMPILE_FLAGS "${c-props} ${opentrack-foolib_COMPILE}"
- )
endif()
+ set_target_properties(${n} PROPERTIES
+ LINK_FLAGS "${l-props} ${opentrack-foolib_LINK}"
+ COMPILE_FLAGS "${c-props} ${opentrack-foolib_COMPILE}"
+ )
string(REGEX REPLACE "^opentrack-" "" n_ ${n})
string(REPLACE "-" "_" n_ ${n_})
target_compile_definitions(${n} PRIVATE "BUILD_${n_}")