From 34179cc8cb9e50e9e6474c1bd767230de7cb81f3 Mon Sep 17 00:00:00 2001 From: kimwalisch Date: Tue, 9 Apr 2024 08:25:55 +0200 Subject: [PATCH] Refactor --- CMakeLists.txt | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34fde7ae..84bc037c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,23 @@ if(NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS) message(FATAL_ERROR "One or both of BUILD_SHARED_LIBS or BUILD_STATIC_LIBS must be set to ON") endif() +# Set default build type to Release ################################## + +if(NOT CMAKE_VERSION VERSION_LESS 3.9) + get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +elseif(CMAKE_CONFIGURATION_TYPES) + set(isMultiConfig TRUE) +endif() + +if(NOT isMultiConfig AND NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release CACHE STRING + "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) +endif() + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(ENABLE_ASSERT "ENABLE_ASSERT") +endif() + # primesieve binary source files ##################################### set(BIN_SRC src/app/CmdOptions.cpp @@ -96,27 +113,6 @@ if(WITH_MULTIARCH) include("${PROJECT_SOURCE_DIR}/cmake/multiarch_avx512_vbmi2.cmake") endif() -# Set default build type to Release ################################## - -# We do this after the C++ compilation tests above (include *.cmake) -# so that those tests are compiled without optimization flags -# which should speed up the cmake configure step. - -if(NOT CMAKE_VERSION VERSION_LESS 3.9) - get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -elseif(CMAKE_CONFIGURATION_TYPES) - set(isMultiConfig TRUE) -endif() - -if(NOT isMultiConfig AND NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release CACHE STRING - "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) -endif() - -if(CMAKE_BUILD_TYPE STREQUAL "Debug") - set(ENABLE_ASSERT "ENABLE_ASSERT") -endif() - # libprimesieve (shared library) ##################################### find_package(Threads REQUIRED QUIET)