Files
TinyORM/cmake/CommonModules/TinyMsvcParallel.cmake
silverqx 60ecf78a71 cmake revisited/enhanced all include()-s
- added include_guard() everywhere where it's appropriate
 - get rid of many duplicate and unnecessary include()-s as they were
   already in the scope
 - moved some include()-s around
2024-11-28 17:40:46 +01:00

30 lines
1.3 KiB
CMake

include_guard(GLOBAL)
# Allow per-translation-unit parallel builds when using MSVC
function(tiny_msvc_parallel description)
if(CMAKE_GENERATOR MATCHES "Visual Studio" AND
(CMAKE_C_COMPILER_ID MATCHES "MSVC|Intel" OR
CMAKE_CXX_COMPILER_ID MATCHES "MSVC|Intel")
)
set(MSVC_PARALLEL ON CACHE STRING "${description}")
# This conditions are correct (revisited), the else() branch is invoked even if
# the MSVC_PARALLEL == ON, the if() branch is only invoked if MSVC_PARALLEL
# contains a number.
if(MSVC_PARALLEL)
if(MSVC_PARALLEL GREATER 0)
string(APPEND CMAKE_C_FLAGS " /MP${CMake_MSVC_PARALLEL}") # Cannot contain space between
string(APPEND CMAKE_CXX_FLAGS " /MP${CMake_MSVC_PARALLEL}")
else()
string(APPEND CMAKE_C_FLAGS " /MP")
string(APPEND CMAKE_CXX_FLAGS " /MP")
endif()
endif()
endif()
endfunction()
# TODO so this doesn't work, anyway it has to be refactored, use target_compile_options() instead of string(APPEND CMAKE_C_FLAGS silverqx
# TODO make it dependent on cmake_disable_precompile_headers and MSVC; after long time - I don't understand why it needs to depend on the cmake_disable_precompile_headers but it has to have a reason if I wrote or noted it this way silverqx