Skip to content

Commit

Permalink
Allow for multi-config (not tested)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianbs96 committed Oct 4, 2023
1 parent 319d22b commit 7674e70
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 .
Expand Down
32 changes: 12 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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}")
Expand Down

0 comments on commit 7674e70

Please sign in to comment.