diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad77d9d32..aa5052c51 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: build: [ Debug, Release ] include: - build: Debug - flags: -DPHASAR_BUILD_DYNLIB=ON + flags: -DPHASAR_BUILD_DYNLIB=ON -DPHASAR_ENABLE_SANITIZERS=ON - build: Release flags: -DPHASAR_ENABLE_DYNAMIC_LOG=OFF @@ -74,7 +74,6 @@ jobs: -DCMAKE_BUILD_TYPE=${{ matrix.build }} \ -DBUILD_SWIFT_TESTS=ON \ -DPHASAR_DEBUG_LIBDEPS=ON \ - -DPHASAR_ENABLE_SANITIZERS=ON \ ${{ matrix.flags }} \ -G Ninja cmake --build . diff --git a/CMakeLists.txt b/CMakeLists.txt index a0ffe8e33..816b3c6d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,14 +49,13 @@ set(PHASAR_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PHASAR_SRC_DIR}/cmake") include("phasar_macros") -if (NOT CMAKE_BUILD_TYPE) +if (NOT CMAKE_BUILD_TYPE AND NOT GENERATOR_IS_MULTI_CONFIG) + message(STATUS "No CMAKE_BUILD_TYPE specified, setting it to Debug") set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build mode ('Debug' or 'Release', default is 'Debug')" FORCE) endif () option(CMAKE_VISIBILITY_INLINES_HIDDEN "Hide inlined functions from the DSO table (default ON)" ON) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP -fstack-protector-strong -ffunction-sections -fdata-sections -pipe") - # NOTE: Use gcc -march=native -Q --help=target | grep -- '-march=' | cut -f3 # to check the architecture detected by match=native set(PHASAR_TARGET_ARCH "" CACHE STRING "Optimize the build for the given target architecture, e.g. -march=native. Most useful in Release builds. Disabled by default") @@ -87,32 +86,25 @@ endif() # TODO: Once available, we may want to use -fextend-lifetimes on Debug- and RelWithDebInfo builds to improve debugging experience # https://reviews.llvm.org/D157613 -if(CMAKE_BUILD_TYPE STREQUAL "Debug") - message(STATUS "Selected Debug Build") - add_cxx_compile_options( - -Og - -fno-omit-frame-pointer - ) -elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") - message(STATUS "Selected Optimized Debug Build (RelWithDebInfo") - add_cxx_compile_options( - -fno-omit-frame-pointer - ) -else() - message(STATUS "Selected Release Build") +string(APPEND CMAKE_CXX_FLAGS " -MP -fstack-protector-strong -ffunction-sections -fdata-sections -pipe") +string(APPEND CMAKE_CXX_FLAGS_DEBUG " -Og -fno-omit-frame-pointer") +string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -fno-omit-frame-pointer") +string(APPEND CMAKE_CXX_FLAGS_RELEASE "") + +message(STATUS "Selected ${CMAKE_BUILD_TYPE} Build") +# LTO +if (GENERATOR_IS_MULTI_CONFIG OR CMAKE_BUILD_TYPE STREQUAL "Release") include(CheckIPOSupported) check_ipo_supported(RESULT LTO_SUPPORTED OUTPUT LTO_SUPPORT_ERROR) if(LTO_SUPPORTED) - message(STATUS "IPO/LTO enabled") - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) # LTO + message(STATUS "IPO/LTO enabled in Release mode") + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON) # LTO else() message(STATUS "IPO/LTO not supported: ${LTO_SUPPORT_ERROR}") endif() - endif() - # Some preprocessor symbols that need to be available in phasar sources, but should not be installed add_cxx_compile_definitions(PHASAR_SRC_DIR="${CMAKE_SOURCE_DIR}") add_cxx_compile_definitions(PHASAR_BUILD_DIR="${CMAKE_BINARY_DIR}")