fix SxS debug-release builds with Visual Studio (#1220)

* On basic_string_view_support: fix SxS debug-release builds with Visual Studio
place precompiled header implicitly in Debug/Release path with VS and explicitly in bin dir otherwise
standardize pch setup across libraries with helper function

* nudge pipeline to rerun
This commit is contained in:
Jason Hartman 2019-08-22 19:33:30 -07:00 коммит произвёл Billy O'Neal
Родитель 44c491889d
Коммит 265d681743
10 изменённых файлов: 31 добавлений и 104 удалений

Просмотреть файл

@ -202,6 +202,28 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries)
function(configure_pch target precompile_header precomile_source) # optional additional compile arguments
if(MSVC)
get_target_property(_srcs ${target} SOURCES)
set(pch_output_filepath_arg)
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*")
set_property(SOURCE ${precomile_source} APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/${target}.pch")
set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${target}.pch")
set(pch_output_filepath_arg "/Fp${CMAKE_CURRENT_BINARY_DIR}/${target}.pch")
else()
# Don't specify output file so that VS may choose a config spefic location.
# Otherwise Debug/Release builds will interfere with one another.
endif()
set_source_files_properties(${precomile_source} PROPERTIES COMPILE_FLAGS "/Yc${precompile_header}")
target_sources(${target} PRIVATE ${precomile_source})
# Note: as ${precomile_source} is also a SOURCE for ${target}, the below options will also be applied.
# ${precomile_source} has /Yc option that will cause the shared /Yu to be ignored.
target_compile_options(${target} PRIVATE /Yu${precompile_header} ${pch_output_filepath_arg} ${ARGN})
endif()
endfunction()
# These settings can be used by the test targets
set(Casablanca_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(Casablanca_LIBRARY cpprest)

Просмотреть файл

@ -10,13 +10,4 @@ add_executable(blackjackserver
target_link_libraries(blackjackserver cpprest)
if(MSVC)
get_target_property(_srcs blackjackserver SOURCES)
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*")
set_property(SOURCE stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/blackjack-server-stdafx.pch")
set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/blackjack-server-stdafx.pch")
endif()
set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Fpblackjack-server-stdafx.pch /Zm120")
target_sources(blackjackserver PRIVATE stdafx.cpp)
target_compile_options(blackjackserver PRIVATE /Yustdafx.h /Fpblackjack-server-stdafx.pch /Zm120)
endif()
configure_pch(blackjackserver stdafx.h stdafx.cpp /Zm120)

Просмотреть файл

@ -174,18 +174,7 @@ else()
message(FATAL_ERROR "Invalid implementation")
endif()
if(MSVC)
get_target_property(_srcs cpprest SOURCES)
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*")
set_property(SOURCE pch/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(pch/stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Zm120")
target_sources(cpprest PRIVATE pch/stdafx.cpp)
target_compile_options(cpprest PRIVATE /Yustdafx.h /Zm120)
endif()
configure_pch(cpprest stdafx.h pch/stdafx.cpp /Zm120)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if(WERROR)

Просмотреть файл

@ -32,18 +32,7 @@ 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}/client-tests-stdafx.pch")
set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/client-tests-stdafx.pch")
endif()
set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Fpclient-tests-stdafx.pch")
target_sources(httpclient_test PRIVATE stdafx.cpp)
target_compile_options(httpclient_test PRIVATE /Yustdafx.h /Fpclient-tests-stdafx.pch)
endif()
configure_pch(httpclient_test stdafx.h stdafx.cpp)
if(NOT WIN32)
cpprest_find_boost()

Просмотреть файл

@ -22,14 +22,5 @@ if(NOT WINDOWS_STORE AND NOT WINDOWS_PHONE)
target_link_libraries(httplistener_test PRIVATE httptest_utilities)
endif()
if(MSVC)
get_target_property(_srcs httplistener_test SOURCES)
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*")
set_property(SOURCE stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/listener-tests-stdafx.pch")
set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/listener-tests-stdafx.pch")
endif()
set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Fplistener-tests-stdafx.pch")
target_sources(httplistener_test PRIVATE stdafx.cpp)
target_compile_options(httplistener_test PRIVATE /Yustdafx.h /Fplistener-tests-stdafx.pch)
endif()
configure_pch(httplistener_test stdafx.h stdafx.cpp)
endif()

Просмотреть файл

@ -16,15 +16,4 @@ if(UNIX AND NOT APPLE)
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}/json-tests-stdafx.pch")
set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/json-tests-stdafx.pch")
endif()
set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Fpjson-tests-stdafx.pch")
target_sources(json_test PRIVATE stdafx.cpp)
target_compile_options(json_test PRIVATE /Yustdafx.h /Fpjson-tests-stdafx.pch)
endif()
configure_pch(json_test stdafx.h stdafx.cpp)

Просмотреть файл

@ -6,15 +6,4 @@ 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}/pplx-tests-stdafx.pch")
set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pplx-tests-stdafx.pch")
endif()
set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Fppplx-tests-stdafx.pch")
target_sources(pplx_test PRIVATE stdafx.cpp)
target_compile_options(pplx_test PRIVATE /Yustdafx.h /Fppplx-tests-stdafx.pch)
endif()
configure_pch(pplx_test stdafx.h stdafx.cpp)

Просмотреть файл

@ -24,15 +24,4 @@ if(NOT WIN32 OR CPPREST_WEBSOCKETS_IMPL STREQUAL "wspp")
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}/streams-tests-stdafx.pch")
set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/streams-tests-stdafx.pch")
endif()
set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Fpstreams-tests-stdafx.pch")
target_sources(streams_test PRIVATE stdafx.cpp)
target_compile_options(streams_test PRIVATE /Yustdafx.h /Fpstreams-tests-stdafx.pch)
endif()
configure_pch(streams_test stdafx.h stdafx.cpp)

Просмотреть файл

@ -13,15 +13,4 @@ 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}/uri-tests-stdafx.pch")
set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/uri-tests-stdafx.pch")
endif()
set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Fpuri-tests-stdafx.pch")
target_sources(uri_test PRIVATE stdafx.cpp)
target_compile_options(uri_test PRIVATE /Yustdafx.h /Fpuri-tests-stdafx.pch)
endif()
configure_pch(uri_test stdafx.h stdafx.cpp)

Просмотреть файл

@ -13,15 +13,4 @@ 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}/utils-tests-stdafx.pch")
set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/utils-tests-stdafx.pch")
endif()
set_source_files_properties(stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h /Fputils-tests-stdafx.pch")
target_sources(utils_test PRIVATE stdafx.cpp)
target_compile_options(utils_test PRIVATE /Yustdafx.h /Fputils-tests-stdafx.pch)
endif()
configure_pch(utils_test stdafx.h stdafx.cpp)