From ff070018a799f584f8ebc51738c086e355b882d9 Mon Sep 17 00:00:00 2001 From: Matt Schulte Date: Wed, 27 Mar 2019 15:36:32 -0700 Subject: [PATCH] Fixes cmake config break on CMake 3.11 and no nasm (#195) --- CMakeLists.txt | 3 ++- cmake/MSVCStaticCrt.cmake | 10 +++++++--- extern/libjpeg-turbo/CMakeLists.txt | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a31d102d..f9c45604 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,8 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") include(MSVCStaticCrt) include(MSVCLinkerFlags) - add_compile_options("$<$>:/ZH:SHA_256>") # Embed hash of source files + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /ZH:SHA_256") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZH:SHA_256") endif() # Find all dependencies diff --git a/cmake/MSVCStaticCrt.cmake b/cmake/MSVCStaticCrt.cmake index 1e26de64..5b591ff7 100644 --- a/cmake/MSVCStaticCrt.cmake +++ b/cmake/MSVCStaticCrt.cmake @@ -15,7 +15,11 @@ if ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") string(REGEX REPLACE "/MDd" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") # Link against the static crt - add_compile_options( - "$<$>,$>:/MTd>" - "$<$>,$>>:/MT>") + if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MTd") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MTd") + else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MT") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT") + endif() endif() \ No newline at end of file diff --git a/extern/libjpeg-turbo/CMakeLists.txt b/extern/libjpeg-turbo/CMakeLists.txt index dfd2a5bb..b2fd5995 100644 --- a/extern/libjpeg-turbo/CMakeLists.txt +++ b/extern/libjpeg-turbo/CMakeLists.txt @@ -1,6 +1,7 @@ if (NOT TARGET turbojpeg) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") - add_compile_options("$<$>:-D_CRT_SECURE_NO_WARNINGS>") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D_CRT_SECURE_NO_WARNINGS") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS") endif() set(ENABLE_STATIC ON CACHE BOOL "Force libjpeg to enable static lib" FORCE)