Skip to content

Commit c9f6a96

Browse files
committed
Only set the policy before the project command
1 parent d6d373b commit c9f6a96

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

CMakeLists.txt

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
cmake_minimum_required(VERSION 3.8.2)
55

6+
# Enable CMAKE_MSVC_RUNTIME_LIBRARY on Windows.
7+
cmake_policy(SET CMP0091 NEW)
8+
69
# Default to the last updated version from version.txt.
710
file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.txt" VERSION_FILE)
811
file(READ "${VERSION_FILE}" LATEST_VERSION)
@@ -25,31 +28,35 @@ if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
2528
endif()
2629
endif()
2730

31+
project(cppgraphqlgen VERSION ${LATEST_VERSION})
32+
33+
set(CMAKE_CXX_STANDARD 17)
34+
35+
set(GRAPHQL_INSTALL_INCLUDE_DIR include CACHE PATH "Header file install directory")
36+
set(GRAPHQL_INSTALL_TOOLS_DIR bin CACHE PATH "schemagen install directory")
37+
set(GRAPHQL_INSTALL_CMAKE_DIR lib/cmake CACHE PATH "CMake config files install directory")
38+
set(GRAPHQL_INSTALL_CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES} CACHE STRING "Configurations which perform a full install")
39+
40+
option(BUILD_SHARED_LIBS "Build shared libraries instead of static libs" OFF)
41+
2842
if(VCPKG_TARGET_TRIPLET)
2943
message(STATUS "Using ${VCPKG_TARGET_TRIPLET} triplet with vcpkg")
44+
3045
if(MSVC)
3146
# Match the MSVC runtime if we're using VCPKG with static libraries.
32-
cmake_policy(SET CMP0091 NEW)
3347
if(VCPKG_TARGET_TRIPLET MATCHES [[^.+-static$]])
3448
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
49+
message(STATUS "Using MSVC runtime static library")
3550
else()
3651
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
52+
message(STATUS "Using MSVC runtime DLL")
3753
endif()
38-
message(STATUS "Using ${CMAKE_MSVC_RUNTIME_LIBRARY} to match ${VCPKG_TARGET_TRIPLET}")
54+
55+
add_custom_target(output_msvc_runtime ALL
56+
${CMAKE_COMMAND} -E echo "Using ${CMAKE_MSVC_RUNTIME_LIBRARY} MSVC runtime to match ${VCPKG_TARGET_TRIPLET}")
3957
endif()
4058
endif()
4159

42-
project(cppgraphqlgen VERSION ${LATEST_VERSION})
43-
44-
set(CMAKE_CXX_STANDARD 17)
45-
46-
set(GRAPHQL_INSTALL_INCLUDE_DIR include CACHE PATH "Header file install directory")
47-
set(GRAPHQL_INSTALL_TOOLS_DIR bin CACHE PATH "schemagen install directory")
48-
set(GRAPHQL_INSTALL_CMAKE_DIR lib/cmake CACHE PATH "CMake config files install directory")
49-
set(GRAPHQL_INSTALL_CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES} CACHE STRING "Configurations which perform a full install")
50-
51-
option(BUILD_SHARED_LIBS "Build shared libraries instead of static libs" OFF)
52-
5360
function(add_bigobj_flag target)
5461
if(MSVC)
5562
# MSVC requires the /bigobj flag if the number of sections gets too big.

0 commit comments

Comments
 (0)