diff --git a/CMakeLists.txt b/CMakeLists.txt index 8662fe08f..0e3ec93fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -274,7 +274,11 @@ endif() # allow 'large' files in 32 bit builds if(UNIX) - add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES) + if(CMAKE_VERSION VERSION_GREATER 3.12.0) + add_compile_definitions(_LARGEFILE_SOURCE _FILE_OFFSET_BITS=64 _LARGE_FILES) + else() + add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES) + endif() endif() # If this is an out-of-tree build, do not pollute the original source directory diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt index 8a8f2e76e..3ca3f822f 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -9,9 +9,6 @@ # Project setup ######################################################################## cmake_minimum_required(VERSION 2.8.12...3.25) -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") -endif() set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose build type: None Debug Release RelWithDebInfo MinSizeRel") project(volk_gnsssdr) enable_language(CXX) @@ -227,7 +224,11 @@ endif() set(CROSSCOMPILE_MULTILIB ${CROSSCOMPILE_MULTILIB} CACHE STRING "Define \"true\" if you have and want to use multiple C development libs installed for cross compile") if(MSVC) - add_definitions(-D_USE_MATH_DEFINES) # enables math constants on all supported versions of MSVC + if(CMAKE_VERSION VERSION_GREATER 3.12.0) + add_compile_definitions(_USE_MATH_DEFINES) # enables math constants on all supported versions of MSVC + else() + add_definitions(-D_USE_MATH_DEFINES) # enables math constants on all supported versions of MSVC + endif() add_compile_options(/W1) # reduce warnings add_compile_options(/wo4309) add_compile_options(/wd4752) @@ -237,11 +238,11 @@ endif() # allow 'large' files in 32 bit builds if(UNIX) - add_definitions(-D_LARGEFILE_SOURCE - -D_FILE_OFFSET_BITS=64 - -D_LARGE_FILES - -D_FORTIFY_SOURCE=2 - ) + if(CMAKE_VERSION VERSION_GREATER 3.12.0) + add_compile_definitions(_LARGEFILE_SOURCE _FILE_OFFSET_BITS=64 _LARGE_FILES) + else() + add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES) + endif() endif() @@ -319,7 +320,11 @@ if(MSVC) endif() set(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking") if(BOOST_ALL_DYN_LINK) - add_definitions(-DBOOST_ALL_DYN_LINK) # setup boost auto-linking in msvc + if(CMAKE_VERSION VERSION_GREATER 3.12.0) + add_compile_definitions(BOOST_ALL_DYN_LINK) # enables math constants on all supported versions of MSVC + else() + add_definitions(-DBOOST_ALL_DYN_LINK) # setup boost auto-linking in msvc + endif() else() unset(BOOST_REQUIRED_COMPONENTS) # empty components list for static link endif() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt index ae570c455..142708787 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt @@ -590,6 +590,11 @@ if(NOT (ENABLE_STATIC_LIBS AND (CMAKE_GENERATOR STREQUAL Xcode))) PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC $ ) + if(UNIX) + target_compile_definitions(volk_gnsssdr + PUBLIC $<$:_FORTIFY_SOURCE=2>$<$:_FORTIFY_SOURCE=2> + ) + endif() if(USE_CPU_FEATURES) if(CPUFEATURES_FOUND) target_include_directories(volk_gnsssdr @@ -603,6 +608,7 @@ if(NOT (ENABLE_STATIC_LIBS AND (CMAKE_GENERATOR STREQUAL Xcode))) ) endif() endif() + # Configure target properties if(ORC_FOUND) target_link_libraries(volk_gnsssdr PRIVATE ${ORC_LIBRARIES}) @@ -659,7 +665,11 @@ if(ENABLE_STATIC_LIBS) PRIVATE ${CMAKE_CURRENT_BINARY_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) - + if(UNIX) + target_compile_definitions(volk_gnsssdr_static + PUBLIC $<$:_FORTIFY_SOURCE=2>$<$:_FORTIFY_SOURCE=2> + ) + endif() set_target_properties(volk_gnsssdr_static PROPERTIES OUTPUT_NAME volk_gnsssdr) install(TARGETS volk_gnsssdr_static