From f27df9732ce62ecf89f12b6d392c2d1ab4b7fbac Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Wed, 13 Sep 2017 10:20:51 -0400 Subject: [PATCH] add option to enable linking with static C runtime when compiling with MSVC, #214 --- CMakeLists.txt | 4 +++- benchmarks/CMakeLists.txt | 3 +-- samples/CMakeLists.txt | 3 +-- source/CMakeLists.txt | 3 +-- tests/CMakeLists.txt | 3 +-- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cb7a053..0761378d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,9 @@ option(BENCHMARKS "Set to ON to build performance benchmarks (in ./benchmarks)" option(PYTHON "Set to ON to build Arrow conversion functions (in ./python)" OFF) # Platform specific options -if(NOT MSVC) +if(MSVC) + option(STATIC_CRT "Link with the static version of MSVCRT (/MD[d])" OFF) +else() option(COVERAGE "Generate coverage data using gcov" OFF) endif() diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 726db779..4ab93935 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -10,8 +10,7 @@ if(NOT COMBINED_PROJECT) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../source ${CMAKE_CURRENT_BINARY_DIR}/source) endif() -if(MSVC AND STATIC) - # Link with static C runtime +if(STATIC_CRT) include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/ucm.cmake) ucm_set_runtime(STATIC) endif() diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 0b0d7e50..f8ad70da 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -10,8 +10,7 @@ if(NOT COMBINED_PROJECT) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../source ${CMAKE_CURRENT_BINARY_DIR}/source) endif() -if(MSVC AND STATIC) - # Link with static C runtime +if(STATIC_CRT) include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/ucm.cmake) ucm_set_runtime(STATIC) endif() diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index dd21e095..ded96a82 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -45,8 +45,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas") # ignore Windows and GCC pragmas endif() -if(MSVC AND STATIC) - # Link with static C runtime +if(STATIC_CRT) include(${XLNT_ROOT_DIR}/cmake/ucm.cmake) ucm_set_runtime(STATIC) endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ffd025b7..20add02b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -9,8 +9,7 @@ if(NOT COMBINED_PROJECT) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../source ${CMAKE_CURRENT_BINARY_DIR}/source) endif() -if(MSVC AND STATIC) - # Link with static C runtime +if(STATIC_CRT) include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/ucm.cmake) ucm_set_runtime(STATIC) endif()