From 306ddde049fd472ba9eb5f6c2ecb1aa2fcc511a7 Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Sun, 24 Dec 2023 13:54:17 +0200 Subject: [PATCH] Fix cmake for msvc --- CMakeLists.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e6d3e7f..9be358dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,10 +34,6 @@ elseif(CMAKE_CXX_STANDARD LESS 17) endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) -# make sure __cplusplus is defined when using msvc and enable parallel build -if(MSVC) - string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus /MP") -endif() set(CMAKE_CXX_EXTENSIONS OFF) @@ -129,14 +125,20 @@ if(SPDLOG_BUILD_SHARED) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() -# place dlls in the same directory as the executables on msvc -if(BUILD_SHARED_LIBS AND MSVC) +if(MSVC) + # place dlls and libs and executables in the same directory set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$) - set(CMAKE_PDB_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$) + set(CMAKE_PDB_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$) + + # make sure __cplusplus is defined + add_compile_options(/Zc:__cplusplus) + # enable parallel build for the solution + add_compile_options(/MP) endif() + message(STATUS "spdlog version: ${SPDLOG_VERSION}") message(STATUS "spdlog build type: " ${CMAKE_BUILD_TYPE}) message(STATUS "spdlog build shared: " ${BUILD_SHARED_LIBS})