From 689b66b2be74b9c80c600e9e342f4a5bbda5dcae Mon Sep 17 00:00:00 2001 From: OLEGSHA Date: Sun, 20 Nov 2022 14:17:08 +0300 Subject: [PATCH] TMP / added SIM_ID --- CMakeLists.txt | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 989d66d..0094270 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,33 +51,43 @@ target_include_directories(progressia PRIVATE ${generated}/embedded_resources) # Compilation settings -if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR - CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set(gcc_like_compiler TRUE) +# Determine command line style +if (DEFINED compiler_cl_dialect) + # Do nothing +elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(compiler_cl_dialect "GCC") +elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(compiler_cl_dialect "MSVC") +elseif (CMAKE_CXX_SIMULATE_ID STREQUAL "GCC") + set(compiler_cl_dialect "GCC") +elseif (CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") + set(compiler_cl_dialect "MSVC") +elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + # On Linux, clang does not have SIMULATE_ID + set(compiler_cl_dialect "GCC") +elseif(WIN32) + message(WARNING "Could not determine compiler command line dialect, guessing MSVC") + set(compiler_cl_dialect "MSVC") else() - set(gcc_like_compiler FALSE) + message(WARNING "Could not determine compiler command line dialect, guessing GCC") + set(compiler_cl_dialect "GCC") endif() set_property(TARGET progressia PROPERTY CXX_STANDARD 17) set_property(TARGET progressia PROPERTY CXX_STANDARD_REQUIRED ON) # Do Windows-specific tweaks for release builds -if (WIN32 AND DEFINED BUILD_ID) +if (WIN32 AND NOT BUILD_ID STREQUAL "dev") set_target_properties(progressia PROPERTIES WIN32_EXECUTABLE true) - if (gcc_like_compiler) + if (compiler_cl_dialect STREQUAL "GCC") target_link_options(progressia PRIVATE -static-libstdc++ -static-libgcc) - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + elseif (compiler_cl_dialect STREQUAL "MSVC") target_link_options(progressia PRIVATE /entry:mainCRTStartup) message(WARNING "Release builds with MSVC are not supported") endif() endif() -# Extra options for gcc -- we're using this for extra static analisys for now -if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_compile_options(progressia PRIVATE -Wall -Wextra -Wpedantic -Werror) -endif() - # Pass configuration options file(MAKE_DIRECTORY "${generated}/config") configure_file(${PROJECT_SOURCE_DIR}/main/config.h.in