From 2aa4a641b61c6d9d805c7a85b649671d4b55cd27 Mon Sep 17 00:00:00 2001 From: Christian <43907599+chris0x44@users.noreply.github.com> Date: Tue, 9 Oct 2018 23:20:23 +0200 Subject: [PATCH] Enable precompiled headers for test/functional (#891) --- Release/tests/functional/http/client/CMakeLists.txt | 13 +++++++++++++ Release/tests/functional/json/CMakeLists.txt | 13 +++++++++++++ .../tests/functional/pplx/pplx_test/CMakeLists.txt | 13 +++++++++++++ Release/tests/functional/streams/CMakeLists.txt | 13 +++++++++++++ Release/tests/functional/uri/CMakeLists.txt | 13 +++++++++++++ Release/tests/functional/utils/CMakeLists.txt | 13 +++++++++++++ 6 files changed, 78 insertions(+) diff --git a/Release/tests/functional/http/client/CMakeLists.txt b/Release/tests/functional/http/client/CMakeLists.txt index 17cf4eff81..1cf9b6e6f5 100644 --- a/Release/tests/functional/http/client/CMakeLists.txt +++ b/Release/tests/functional/http/client/CMakeLists.txt @@ -32,6 +32,19 @@ else() target_link_libraries(httpclient_test PRIVATE httptest_utilities) endif() +if(MSVC) + get_target_property(_srcs httpclient_test SOURCES) + + if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*") + set_property(SOURCE stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") + set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") + endif() + + set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h") + target_sources(httpclient_test PRIVATE stdafx.cpp) + target_compile_options(httpclient_test PRIVATE /Yustdafx.h /Zm200) +endif() + if(NOT WIN32) cpprest_find_boost() target_link_libraries(httpclient_test PRIVATE cpprestsdk_boost_internal) diff --git a/Release/tests/functional/json/CMakeLists.txt b/Release/tests/functional/json/CMakeLists.txt index 379a6bd4bf..c9dccfcfeb 100644 --- a/Release/tests/functional/json/CMakeLists.txt +++ b/Release/tests/functional/json/CMakeLists.txt @@ -16,3 +16,16 @@ if(UNIX AND NOT APPLE) cpprest_find_boost() target_link_libraries(json_test PRIVATE cpprestsdk_boost_internal) endif() + +if(MSVC) + get_target_property(_srcs json_test SOURCES) + + if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*") + set_property(SOURCE stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") + set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") + endif() + + set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h") + target_sources(json_test PRIVATE stdafx.cpp) + target_compile_options(json_test PRIVATE /Yustdafx.h /Zm200) +endif() diff --git a/Release/tests/functional/pplx/pplx_test/CMakeLists.txt b/Release/tests/functional/pplx/pplx_test/CMakeLists.txt index 01c56f7522..a51776989b 100644 --- a/Release/tests/functional/pplx/pplx_test/CMakeLists.txt +++ b/Release/tests/functional/pplx/pplx_test/CMakeLists.txt @@ -6,3 +6,16 @@ set(SOURCES ) add_casablanca_test(pplx_test SOURCES) + +if(MSVC) + get_target_property(_srcs pplx_test SOURCES) + + if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*") + set_property(SOURCE stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") + set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") + endif() + + set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h") + target_sources(pplx_test PRIVATE stdafx.cpp) + target_compile_options(pplx_test PRIVATE /Yustdafx.h /Zm200) +endif() diff --git a/Release/tests/functional/streams/CMakeLists.txt b/Release/tests/functional/streams/CMakeLists.txt index 4b11173b18..d2b6858f15 100644 --- a/Release/tests/functional/streams/CMakeLists.txt +++ b/Release/tests/functional/streams/CMakeLists.txt @@ -24,3 +24,16 @@ if(NOT WIN32 OR CPPREST_WEBSOCKETS_IMPL STREQUAL "wspp") target_include_directories(streams_test PRIVATE $) endif() endif() + +if(MSVC) + get_target_property(_srcs streams_test SOURCES) + + if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*") + set_property(SOURCE stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") + set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") + endif() + + set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h") + target_sources(streams_test PRIVATE stdafx.cpp) + target_compile_options(streams_test PRIVATE /Yustdafx.h /Zm200) +endif() diff --git a/Release/tests/functional/uri/CMakeLists.txt b/Release/tests/functional/uri/CMakeLists.txt index f869e24d18..86cd0e867a 100644 --- a/Release/tests/functional/uri/CMakeLists.txt +++ b/Release/tests/functional/uri/CMakeLists.txt @@ -12,3 +12,16 @@ set(SOURCES ) add_casablanca_test(uri_test SOURCES) + +if(MSVC) + get_target_property(_srcs uri_test SOURCES) + + if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*") + set_property(SOURCE stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") + set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") + endif() + + set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h") + target_sources(uri_test PRIVATE stdafx.cpp) + target_compile_options(uri_test PRIVATE /Yustdafx.h /Zm200) +endif() diff --git a/Release/tests/functional/utils/CMakeLists.txt b/Release/tests/functional/utils/CMakeLists.txt index ff175283f8..ff5d4cb49c 100644 --- a/Release/tests/functional/utils/CMakeLists.txt +++ b/Release/tests/functional/utils/CMakeLists.txt @@ -13,3 +13,16 @@ add_casablanca_test(utils_test SOURCES) if(CMAKE_COMPILER_IS_GNUCXX) target_compile_options(utils_test PRIVATE "-Wno-deprecated-declarations") endif() + +if(MSVC) + get_target_property(_srcs utils_test SOURCES) + + if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*") + set_property(SOURCE stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") + set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch") + endif() + + set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h") + target_sources(utils_test PRIVATE stdafx.cpp) + target_compile_options(utils_test PRIVATE /Yustdafx.h /Zm200) +endif()