Fix incremental issues in CMake build so rebuilds don't consistently happen (#1169)

* Fix incremental issues in CMake build so rebuilds don't consistently happen

Issues with source link and the resource manifest generation were causing many relinks to occur when not necessary

* Fix nit, fix a few organization issues in generated solution

* Fix build without logging
This commit is contained in:
Thad House 2021-01-19 09:24:49 -08:00 коммит произвёл GitHub
Родитель 35adbae31a
Коммит 4ecc6947e8
9 изменённых файлов: 34 добавлений и 25 удалений

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

@ -148,7 +148,8 @@ if (QUIC_SOURCE_LINK AND MSVC)
if ("${CMAKE_C_COMPILER_VERSION}" VERSION_GREATER_EQUAL "19.20")
include(${PROJECT_SOURCE_DIR}/cmake/SourceLink.cmake)
file(TO_NATIVE_PATH "${PROJECT_BINARY_DIR}/source_link.json" SOURCE_LINK_JSON)
source_link(${PROJECT_SOURCE_DIR} ${SOURCE_LINK_JSON})
file(TO_NATIVE_PATH "${PROJECT_SOURCE_DIR}/cmake/source_link.json.in" SOURCE_LINK_JSON_INPUT)
source_link(${PROJECT_SOURCE_DIR} ${SOURCE_LINK_JSON} ${SOURCE_LINK_JSON_INPUT})
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /INCREMENTAL:NO")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /INCREMENTAL:NO")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /INCREMENTAL:NO")
@ -179,7 +180,6 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${QUIC_OUTPUT_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${QUIC_OUTPUT_DIR})
set(QUIC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/inc)
set(MANIFESTED_HEADER_FILENAME ${QUIC_BUILD_DIR}/inc/MsQuicEtw.h)
if (WIN32)
set(QUIC_WARNING_FLAGS /WX /W4 /sdl CACHE INTERNAL "")
@ -215,19 +215,23 @@ endif()
if(WIN32)
# Generate the MsQuicEtw header file.
file(MAKE_DIRECTORY ${QUIC_BUILD_DIR}/inc)
file(WRITE ${QUIC_BUILD_DIR}/inc/MsQuicEtw.rc)
include_directories(${QUIC_BUILD_DIR}/inc)
add_custom_command(
OUTPUT ${QUIC_BUILD_DIR}/inc/MsQuicEtw.h
OUTPUT ${QUIC_BUILD_DIR}/inc/MsQuicEtw.rc
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/manifest/MsQuicEtw.man
COMMAND mc.exe -um -h ${QUIC_BUILD_DIR}/inc -r ${QUIC_BUILD_DIR}/inc ${CMAKE_CURRENT_SOURCE_DIR}/src/manifest/MsQuicEtw.man)
add_custom_target(MsQuicEtw
DEPENDS ${QUIC_BUILD_DIR}/inc/MsQuicEtw.h
DEPENDS ${QUIC_BUILD_DIR}/inc/MsQuicEtw.rc)
add_custom_target(MsQuicEtw_HeaderBuild
DEPENDS ${QUIC_BUILD_DIR}/inc/MsQuicEtw.h)
set_property(TARGET MsQuicEtw PROPERTY FOLDER "libraries")
set_property(TARGET MsQuicEtw_HeaderBuild PROPERTY FOLDER "helpers")
add_library(MsQuicEtw_Header INTERFACE)
target_include_directories(MsQuicEtw_Header INTERFACE ${QUIC_BUILD_DIR}/inc)
add_dependencies(MsQuicEtw_Header MsQuicEtw_HeaderBuild)
add_library(MsQuicEtw_Resource OBJECT ${QUIC_BUILD_DIR}/inc/MsQuicEtw.rc)
set_property(TARGET MsQuicEtw_Resource PROPERTY FOLDER "helpers")
if (QUIC_UWP_BUILD)
list(APPEND QUIC_COMMON_DEFINES WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP QUIC_UWP_BUILD)
@ -383,6 +387,7 @@ if(QUIC_TLS STREQUAL "openssl")
set(OPENSSL_DIR ${QUIC_BUILD_DIR}/openssl)
add_library(OpenSSL_Crypto STATIC IMPORTED)
set_property(TARGET OpenSSL_Crypto PROPERTY FOLDER "libraries")
set_target_properties(OpenSSL_Crypto PROPERTIES
IMPORTED_LOCATION_DEBUG ${OPENSSL_DIR}/debug/lib/libcrypto${CMAKE_STATIC_LIBRARY_SUFFIX}
IMPORTED_LOCATION_RELEASE ${OPENSSL_DIR}/release/lib/libcrypto${CMAKE_STATIC_LIBRARY_SUFFIX}
@ -391,6 +396,7 @@ if(QUIC_TLS STREQUAL "openssl")
MAP_IMPORTED_CONFIG_RELWITHDEBINFO RELEASE)
add_library(OpenSSL STATIC IMPORTED)
set_property(TARGET OpenSSL PROPERTY FOLDER "libraries")
set_target_properties(OpenSSL PROPERTIES
IMPORTED_LOCATION_DEBUG ${OPENSSL_DIR}/debug/lib/libssl${CMAKE_STATIC_LIBRARY_SUFFIX}
IMPORTED_LOCATION_RELEASE ${OPENSSL_DIR}/release/lib/libssl${CMAKE_STATIC_LIBRARY_SUFFIX}
@ -423,8 +429,10 @@ if(QUIC_TLS STREQUAL "openssl")
add_custom_target(mkdir_openssl_build_debug
COMMAND if not exist \"${QUIC_BUILD_DIR}/submodules/openssl/debug\" mkdir \"${QUIC_BUILD_DIR}/submodules/openssl/debug\" 2> NUL)
set_property(TARGET mkdir_openssl_build_debug PROPERTY FOLDER "helpers")
add_custom_target(mkdir_openssl_build_release
COMMAND if not exist \"${QUIC_BUILD_DIR}/submodules/openssl/release\" mkdir \"${QUIC_BUILD_DIR}/submodules/openssl/release\" 2> NUL)
set_property(TARGET mkdir_openssl_build_release PROPERTY FOLDER "helpers")
add_custom_command(
DEPENDS mkdir_openssl_build_debug
@ -442,9 +450,11 @@ if(QUIC_TLS STREQUAL "openssl")
DEPENDS $<IF:$<CONFIG:Debug>,${QUIC_BUILD_DIR}/submodules/openssl/debug/makefile,${QUIC_BUILD_DIR}/submodules/openssl/release/makefile>
WORKING_DIRECTORY $<IF:$<CONFIG:Debug>,${QUIC_BUILD_DIR}/submodules/openssl/debug,${QUIC_BUILD_DIR}/submodules/openssl/release>
COMMAND nmake install_dev)
set_property(TARGET OpenSSL_Build PROPERTY FOLDER "helpers")
add_library(OpenSSL_Build_Tgt INTERFACE)
add_dependencies(OpenSSL_Build_Tgt OpenSSL_Build)
set_property(TARGET OpenSSL_Build_Tgt PROPERTY FOLDER "helpers")
target_link_libraries(OpenSSL INTERFACE OpenSSL_Build_Tgt)
endif()
@ -515,7 +525,7 @@ if (QUIC_ENABLE_LOGGING)
function(add_clog_library)
CLOG_GENERATE_TARGET(${ARGV})
target_link_libraries(${ARGV0} PRIVATE inc)
set_property(TARGET ${ARGV0} PROPERTY FOLDER "clog")
set_property(TARGET ${ARGV0} PROPERTY FOLDER "helpers")
endfunction()
else()
function(add_clog_library)
@ -529,6 +539,10 @@ if(QUIC_TLS STREQUAL "mitls")
add_subdirectory(submodules/everest/msquic/msvc/evercrypt)
add_subdirectory(submodules/everest/msquic/msvc/mitls)
add_subdirectory(submodules/everest/msquic/msvc/quiccrypto)
set_property(TARGET kremlib PROPERTY FOLDER "libraries")
set_property(TARGET evercrypt PROPERTY FOLDER "libraries")
set_property(TARGET mitls PROPERTY FOLDER "libraries")
set_property(TARGET quiccrypto PROPERTY FOLDER "libraries")
endif()
if(QUIC_CODE_CHECK)

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

@ -33,7 +33,7 @@ endif()
# REPO_ROOT is the path to the repository where code it stored.
#
# SOURCE_LINK_JSON_PATH is the file to output the json
function(source_link REPO_ROOT SOURCE_LINK_JSON_PATH)
function(source_link REPO_ROOT SOURCE_LINK_JSON_PATH SOURCE_LINK_JSON_INPUT_PATH)
if (NOT (IS_DIRECTORY ${REPO_ROOT}))
message(FATAL_ERROR "\"${REPO_ROOT}\" is not a directory")
endif()
@ -74,7 +74,7 @@ function(source_link REPO_ROOT SOURCE_LINK_JSON_PATH)
string(APPEND OUTPUT "}\n")
string(APPEND OUTPUT "}\n")
file(WRITE ${SOURCE_LINK_JSON_PATH} ${OUTPUT})
configure_file(${SOURCE_LINK_JSON_INPUT_PATH} ${SOURCE_LINK_JSON_PATH})
endfunction()

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

@ -0,0 +1 @@
@OUTPUT@

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

@ -2,7 +2,7 @@
# Licensed under the MIT License.
if(WIN32)
set(SOURCES winuser/dllmain.c winuser/msquic.rc ${QUIC_BUILD_DIR}/inc/MsQuicEtw.rc)
set(SOURCES winuser/dllmain.c winuser/msquic.rc $<TARGET_OBJECTS:MsQuicEtw_Resource>)
else()
set(SOURCES linux/init.c)
endif()

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

@ -53,6 +53,9 @@ endif()
# Allow CLOG to preprocess all the source files.
add_clog_library(core.clog DYNAMIC ${SOURCES})
if(QUIC_ENABLE_LOGGING)
set_property(TARGET core.clog.provider PROPERTY FOLDER "helpers")
endif()
add_library(core STATIC ${SOURCES})
@ -61,7 +64,3 @@ target_link_libraries(core PUBLIC core.clog inc)
target_link_libraries(core PRIVATE warnings)
set_property(TARGET core PROPERTY FOLDER "libraries")
if(WIN32)
add_dependencies(core MsQuicEtw)
endif()

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

@ -20,7 +20,7 @@ endif()
if(QUIC_ENABLE_LOGGING)
if(WIN32)
add_dependencies(inc INTERFACE MsQuicEtw)
target_link_libraries(inc INTERFACE MsQuicEtw_Header)
else()
target_link_libraries(inc INTERFACE ${LTTNGUST_LIBRARIES})
endif()

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

@ -25,7 +25,3 @@ target_include_directories(perflib PUBLIC ${CMAKE_CURRENT_LIST_DIR})
if (MSVC)
target_compile_options(perflib PUBLIC /wd4459)
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
add_dependencies(perflib MsQuicEtw)
endif()

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

@ -61,6 +61,9 @@ endif()
# Allow CLOG to preprocess all the source files.
add_clog_library(platform.clog DYNAMIC ${SOURCES})
if(QUIC_ENABLE_LOGGING)
set_property(TARGET platform.clog.provider PROPERTY FOLDER "helpers")
endif()
add_library(platform STATIC ${SOURCES})

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

@ -28,7 +28,3 @@ target_link_libraries(testlib PUBLIC testlib.clog)
target_link_libraries(testlib PRIVATE inc warnings)
set_property(TARGET testlib PROPERTY FOLDER "tests")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
add_dependencies(platform MsQuicEtw)
endif()