mirror of
https://github.com/oatpp/oatpp-swagger.git
synced 2024-11-21 03:12:00 +08:00
Add option to link with MSVC static runtime (OFF by default)
Remove quotes on CMake add_subdirectory calls
This commit is contained in:
parent
7735b53090
commit
967643332c
@ -22,6 +22,7 @@ option(OATPP_DIR_SRC "Path to oatpp module directory (sources)")
|
||||
option(OATPP_DIR_LIB "Path to directory with liboatpp (directory containing ex: liboatpp.so or liboatpp.dynlib)")
|
||||
option(OATPP_BUILD_TESTS "Build tests for this module" ON)
|
||||
option(OATPP_INSTALL "Install module binaries" ON)
|
||||
option(OATPP_MSVC_LINK_STATIC_RUNTIME "MSVC: Link with static runtime (/MT and /MTd)." OFF)
|
||||
|
||||
set(OATPP_MODULES_LOCATION "INSTALLED" CACHE STRING "Location where to find oatpp modules. can be [INSTALLED|EXTERNAL|CUSTOM]")
|
||||
|
||||
@ -99,9 +100,12 @@ message("\n#####################################################################
|
||||
|
||||
include(cmake/module-utils.cmake)
|
||||
|
||||
add_subdirectory("src")
|
||||
include(cmake/msvc-runtime.cmake)
|
||||
configure_msvc_runtime()
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
if(OATPP_BUILD_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory("test")
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
36
cmake/msvc-runtime.cmake
Normal file
36
cmake/msvc-runtime.cmake
Normal file
@ -0,0 +1,36 @@
|
||||
macro(configure_msvc_runtime)
|
||||
if(MSVC)
|
||||
# Set compiler options.
|
||||
set(variables
|
||||
CMAKE_C_FLAGS
|
||||
CMAKE_C_FLAGS_DEBUG
|
||||
CMAKE_C_FLAGS_MINSIZEREL
|
||||
CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS
|
||||
CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
|
||||
if(OATPP_MSVC_LINK_STATIC_RUNTIME)
|
||||
message(STATUS "MSVC: using statically-linked runtime (/MT and /MTd).")
|
||||
foreach(variable ${variables})
|
||||
if(${variable} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}")
|
||||
endif()
|
||||
endforeach()
|
||||
else()
|
||||
message(STATUS "MSVC: using dynamically-linked runtime (/MD and /MDd).")
|
||||
foreach(variable ${variables})
|
||||
if(${variable} MATCHES "/MT")
|
||||
string(REGEX REPLACE "/MT" "/MD" ${variable} "${${variable}}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
foreach(variable ${variables})
|
||||
set(${variable} "${${variable}}" CACHE STRING "MSVC_${variable}" FORCE)
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro(configure_msvc_runtime)
|
Loading…
Reference in New Issue
Block a user