mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-02-07 14:40:12 +00:00
CMake improvements: Move _FORTIFY_SOURCE=2 definition to targets, do not apply in Debug mode. Make use of add_compile_definitions() instead of add_definitions() when available
This commit is contained in:
commit
c504b16568
@ -274,8 +274,12 @@ endif()
|
|||||||
|
|
||||||
# allow 'large' files in 32 bit builds
|
# allow 'large' files in 32 bit builds
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
|
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)
|
add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# If this is an out-of-tree build, do not pollute the original source directory
|
# If this is an out-of-tree build, do not pollute the original source directory
|
||||||
if(${GNSSSDR_BINARY_DIR} MATCHES ${GNSSSDR_SOURCE_DIR})
|
if(${GNSSSDR_BINARY_DIR} MATCHES ${GNSSSDR_SOURCE_DIR})
|
||||||
|
@ -9,9 +9,6 @@
|
|||||||
# Project setup
|
# Project setup
|
||||||
########################################################################
|
########################################################################
|
||||||
cmake_minimum_required(VERSION 2.8.12...3.25)
|
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")
|
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose build type: None Debug Release RelWithDebInfo MinSizeRel")
|
||||||
project(volk_gnsssdr)
|
project(volk_gnsssdr)
|
||||||
enable_language(CXX)
|
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")
|
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)
|
if(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
|
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(/W1) # reduce warnings
|
||||||
add_compile_options(/wo4309)
|
add_compile_options(/wo4309)
|
||||||
add_compile_options(/wd4752)
|
add_compile_options(/wd4752)
|
||||||
@ -237,11 +238,11 @@ endif()
|
|||||||
|
|
||||||
# allow 'large' files in 32 bit builds
|
# allow 'large' files in 32 bit builds
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
add_definitions(-D_LARGEFILE_SOURCE
|
if(CMAKE_VERSION VERSION_GREATER 3.12.0)
|
||||||
-D_FILE_OFFSET_BITS=64
|
add_compile_definitions(_LARGEFILE_SOURCE _FILE_OFFSET_BITS=64 _LARGE_FILES)
|
||||||
-D_LARGE_FILES
|
else()
|
||||||
-D_FORTIFY_SOURCE=2
|
add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES)
|
||||||
)
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
@ -319,7 +320,11 @@ if(MSVC)
|
|||||||
endif()
|
endif()
|
||||||
set(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking")
|
set(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking")
|
||||||
if(BOOST_ALL_DYN_LINK)
|
if(BOOST_ALL_DYN_LINK)
|
||||||
|
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
|
add_definitions(-DBOOST_ALL_DYN_LINK) # setup boost auto-linking in msvc
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
unset(BOOST_REQUIRED_COMPONENTS) # empty components list for static link
|
unset(BOOST_REQUIRED_COMPONENTS) # empty components list for static link
|
||||||
endif()
|
endif()
|
||||||
|
@ -590,6 +590,11 @@ if(NOT (ENABLE_STATIC_LIBS AND (CMAKE_GENERATOR STREQUAL Xcode)))
|
|||||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
PUBLIC $<INSTALL_INTERFACE:include>
|
PUBLIC $<INSTALL_INTERFACE:include>
|
||||||
)
|
)
|
||||||
|
if(UNIX)
|
||||||
|
target_compile_definitions(volk_gnsssdr
|
||||||
|
PUBLIC $<$<CONFIG:Release>:_FORTIFY_SOURCE=2>$<$<CONFIG:RelWithDebInfo>:_FORTIFY_SOURCE=2>
|
||||||
|
)
|
||||||
|
endif()
|
||||||
if(USE_CPU_FEATURES)
|
if(USE_CPU_FEATURES)
|
||||||
if(CPUFEATURES_FOUND)
|
if(CPUFEATURES_FOUND)
|
||||||
target_include_directories(volk_gnsssdr
|
target_include_directories(volk_gnsssdr
|
||||||
@ -603,6 +608,7 @@ if(NOT (ENABLE_STATIC_LIBS AND (CMAKE_GENERATOR STREQUAL Xcode)))
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Configure target properties
|
# Configure target properties
|
||||||
if(ORC_FOUND)
|
if(ORC_FOUND)
|
||||||
target_link_libraries(volk_gnsssdr PRIVATE ${ORC_LIBRARIES})
|
target_link_libraries(volk_gnsssdr PRIVATE ${ORC_LIBRARIES})
|
||||||
@ -659,7 +665,11 @@ if(ENABLE_STATIC_LIBS)
|
|||||||
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
|
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
|
if(UNIX)
|
||||||
|
target_compile_definitions(volk_gnsssdr_static
|
||||||
|
PUBLIC $<$<CONFIG:Release>:_FORTIFY_SOURCE=2>$<$<CONFIG:RelWithDebInfo>:_FORTIFY_SOURCE=2>
|
||||||
|
)
|
||||||
|
endif()
|
||||||
set_target_properties(volk_gnsssdr_static PROPERTIES OUTPUT_NAME volk_gnsssdr)
|
set_target_properties(volk_gnsssdr_static PROPERTIES OUTPUT_NAME volk_gnsssdr)
|
||||||
|
|
||||||
install(TARGETS volk_gnsssdr_static
|
install(TARGETS volk_gnsssdr_static
|
||||||
|
Loading…
x
Reference in New Issue
Block a user