Skip to content

Commit

Permalink
Don't in-place upper-case CMake build and config types.
Browse files Browse the repository at this point in the history
Source: intel#233
  • Loading branch information
afoxman committed Dec 27, 2023
1 parent 7282c36 commit 3a9af50
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ find_package(PkgConfig QUIET)

if (NOT CMAKE_BUILD_TYPE)
message(STATUS "Default build type 'Release with debug info'")
set(CMAKE_BUILD_TYPE RELWITHDEBINFO CACHE STRING "" FORCE )
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "" FORCE)
else()
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
message(STATUS "Build type ${CMAKE_BUILD_TYPE}")
endif()

if(CMAKE_BUILD_TYPE MATCHES RELEASE|RELWITHDEBINFO|MINSIZEREL)
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC)
string(TOUPPER ${CMAKE_CONFIGURATION_TYPES} CMAKE_CONFIGURATION_TYPES_UC)

if(CMAKE_BUILD_TYPE_UC MATCHES RELEASE|RELWITHDEBINFO|MINSIZEREL)
message(STATUS "using release build")
set(RELEASE_BUILD TRUE)
else()
Expand All @@ -47,12 +49,11 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BINDIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${LIBDIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${LIBDIR}")
# Second, for multi-config builds (e.g. msvc)
foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string (TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES_UC})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${BINDIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${LIBDIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${LIBDIR}")
endforeach (OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
endforeach()


if(CMAKE_GENERATOR STREQUAL Xcode)
Expand Down Expand Up @@ -140,7 +141,7 @@ option(WINDOWS_ICC "Use Intel C++ Compiler on Windows, default off, requires ICC
# TODO: per platform config files?

# remove CMake's idea of optimisation
foreach (CONFIG ${CMAKE_BUILD_TYPE} ${CMAKE_CONFIGURATION_TYPES})
foreach (CONFIG ${CMAKE_BUILD_TYPE_UC} ${CMAKE_CONFIGURATION_TYPES_UC})
string(REGEX REPLACE "-O[^ ]*" "" CMAKE_C_FLAGS_${CONFIG} "${CMAKE_C_FLAGS_${CONFIG}}")
string(REGEX REPLACE "-O[^ ]*" "" CMAKE_CXX_FLAGS_${CONFIG} "${CMAKE_CXX_FLAGS_${CONFIG}}")
endforeach ()
Expand All @@ -165,7 +166,7 @@ if(MSVC OR MSVC_IDE)
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} /EHsc ${MSVC_WARNS}")
set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} /EHsc ${MSVC_WARNS} /wd4800 -DBOOST_DETAIL_NO_CONTAINER_FWD")
if(OPTIMISE)
if (NOT CMAKE_BUILD_TYPE MATCHES MINSIZEREL)
if (NOT CMAKE_BUILD_TYPE_UC MATCHES MINSIZEREL)
set(OPT_C_FLAG "/O2")
set(OPT_CXX_FLAG "/O2")
else ()
Expand Down Expand Up @@ -233,7 +234,7 @@ else()
endif()

if(OPTIMISE)
if (NOT CMAKE_BUILD_TYPE MATCHES MINSIZEREL)
if (NOT CMAKE_BUILD_TYPE_UC MATCHES MINSIZEREL)
set(OPT_C_FLAG "-O3")
set(OPT_CXX_FLAG "-O2")
else ()
Expand Down

0 comments on commit 3a9af50

Please sign in to comment.