diff options
author | DDoSolitary <DDoSolitary@gmail.com> | 2021-01-23 11:30:39 +0800 |
---|---|---|
committer | DDoSolitary <DDoSolitary@gmail.com> | 2021-02-04 18:04:15 +0800 |
commit | 06799453835d2c6608c074823ccfc399ccc0c525 (patch) | |
tree | bcf4b0d1c4e357f60d1a030822a4227c1f39a8f3 /src | |
parent | b90cc79cbe40309d0a54d0b53a93778fa5b06f31 (diff) | |
download | libssh-06799453835d2c6608c074823ccfc399ccc0c525.tar.gz libssh-06799453835d2c6608c074823ccfc399ccc0c525.tar.xz libssh-06799453835d2c6608c074823ccfc399ccc0c525.zip |
cmake: Avoid setting compiler flags directly
Calling set_target_properties directly overrides previously set flags,
so replace them with target_compile_definitions and target_link_options.
Signed-off-by: DDoSolitary <DDoSolitary@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0a91b45b..4f350d9d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -354,7 +354,7 @@ target_link_libraries(ssh PRIVATE ${LIBSSH_LINK_LIBRARIES}) if (WIN32 AND NOT BUILD_SHARED_LIBS) - set_target_properties(ssh PROPERTIES COMPILE_FLAGS "-DLIBSSH_STATIC") + target_compile_definitions(ssh PUBLIC "LIBSSH_STATIC") endif () add_library(ssh::ssh ALIAS ssh) @@ -365,9 +365,7 @@ if (WITH_SYMBOL_VERSIONING AND HAVE_LD_VERSION_SCRIPT) set(MAP_PATH "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_dev.map") endif (ABIMAP_FOUND) - set_target_properties(ssh - PROPERTIES LINK_FLAGS - "-Wl,--version-script,\"${MAP_PATH}\"") + target_link_libraries(ssh PRIVATE "-Wl,--version-script,\"${MAP_PATH}\"") endif (WITH_SYMBOL_VERSIONING AND HAVE_LD_VERSION_SCRIPT) set_target_properties(ssh @@ -381,12 +379,12 @@ set_target_properties(ssh ) if (WITH_VISIBILITY_HIDDEN) - set_target_properties(ssh PROPERTIES COMPILE_FLAGS "-fvisibility=hidden") + set_target_properties(ssh PROPERTIES C_VISIBILITY_PRESET hidden) endif (WITH_VISIBILITY_HIDDEN) if (MINGW) - set_target_properties(ssh PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup") - set_target_properties(ssh PROPERTIES COMPILE_FLAGS "-D_POSIX_SOURCE") + target_link_libraries(ssh PRIVATE "-Wl,--enable-stdcall-fixup") + target_compile_definitions(ssh PRIVATE "_POSIX_SOURCE") endif () @@ -435,12 +433,7 @@ if (BUILD_STATIC_LIB) ) if (WIN32) - set_target_properties( - ssh-static - PROPERTIES - COMPILE_FLAGS - "-DLIBSSH_STATIC" - ) + target_compile_definitions(ssh-static PUBLIC "LIBSSH_STATIC") endif (WIN32) endif (BUILD_STATIC_LIB) |