diff options
author | Brad King <brad.king@kitware.com> | 2015-09-16 14:24:16 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-09-17 14:21:32 (GMT) |
commit | e134e53b47fc9f0337529ce2b6851cec6319a8af (patch) | |
tree | a712dc8248b379139ca900a531f7a37bddc44057 /Tests | |
parent | da00be6359055ffdb2067a9ec1e817eb782ad145 (diff) | |
download | CMake-e134e53b47fc9f0337529ce2b6851cec6319a8af.zip CMake-e134e53b47fc9f0337529ce2b6851cec6319a8af.tar.gz CMake-e134e53b47fc9f0337529ce2b6851cec6319a8af.tar.bz2 |
Add support for *.manifest source files with MSVC tools
Classify .manifest sources separately, add dependencies on them, and
pass them to the MS manifest tool to merge with linker-generated
manifest files.
Inspired-by: Gilles Khouzam <gillesk@microsoft.com>
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/MSManifest/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/MSManifest/Subdir/CMakeLists.txt | 9 | ||||
-rw-r--r-- | Tests/MSManifest/Subdir/check.cmake | 6 | ||||
-rw-r--r-- | Tests/MSManifest/Subdir/main.c | 1 | ||||
-rw-r--r-- | Tests/MSManifest/Subdir/test.manifest.in | 4 | ||||
-rw-r--r-- | Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake | 19 | ||||
-rw-r--r-- | Tests/RunCMake/BuildDepends/C-Exe-Manifest.step1.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/BuildDepends/C-Exe-Manifest.step2.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/BuildDepends/RunCMakeTest.cmake | 11 | ||||
-rw-r--r-- | Tests/RunCMake/BuildDepends/check.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/BuildDepends/main.c | 1 |
12 files changed, 72 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 2c6a42c..fff04ce 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -276,6 +276,7 @@ if(BUILD_TESTING) if(TEST_RESOURCES) ADD_TEST_MACRO(VSResource VSResource) endif() + ADD_TEST_MACRO(MSManifest MSManifest) ADD_TEST_MACRO(Simple Simple) ADD_TEST_MACRO(PreOrder PreOrder) ADD_TEST_MACRO(MissingSourceFile MissingSourceFile) diff --git a/Tests/MSManifest/CMakeLists.txt b/Tests/MSManifest/CMakeLists.txt new file mode 100644 index 0000000..300cfa6 --- /dev/null +++ b/Tests/MSManifest/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.3) +project(MSManifest C) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +add_subdirectory(Subdir) diff --git a/Tests/MSManifest/Subdir/CMakeLists.txt b/Tests/MSManifest/Subdir/CMakeLists.txt new file mode 100644 index 0000000..a47cf00 --- /dev/null +++ b/Tests/MSManifest/Subdir/CMakeLists.txt @@ -0,0 +1,9 @@ +configure_file(test.manifest.in test.manifest) +add_executable(MSManifest main.c ${CMAKE_CURRENT_BINARY_DIR}/test.manifest) + +if(MSVC AND NOT MSVC_VERSION LESS 1400) + add_custom_command(TARGET MSManifest POST_BUILD VERBATIM + COMMAND ${CMAKE_COMMAND} -Dexe=$<TARGET_FILE:MSManifest> + -P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake + ) +endif() diff --git a/Tests/MSManifest/Subdir/check.cmake b/Tests/MSManifest/Subdir/check.cmake new file mode 100644 index 0000000..b7b6841 --- /dev/null +++ b/Tests/MSManifest/Subdir/check.cmake @@ -0,0 +1,6 @@ +file(STRINGS "${exe}" content REGEX "name=\"Kitware.CMake.MSManifestTest\"") +if(content) + message(STATUS "Expected manifest content found:\n ${content}") +else() + message(FATAL_ERROR "Expected manifest content not found in\n ${exe}") +endif() diff --git a/Tests/MSManifest/Subdir/main.c b/Tests/MSManifest/Subdir/main.c new file mode 100644 index 0000000..78f2de1 --- /dev/null +++ b/Tests/MSManifest/Subdir/main.c @@ -0,0 +1 @@ +int main(void) { return 0; } diff --git a/Tests/MSManifest/Subdir/test.manifest.in b/Tests/MSManifest/Subdir/test.manifest.in new file mode 100644 index 0000000..540961a --- /dev/null +++ b/Tests/MSManifest/Subdir/test.manifest.in @@ -0,0 +1,4 @@ +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> + <assemblyIdentity type="win32" version="1.0.0.0" + name="Kitware.CMake.MSManifestTest"/> +</assembly> diff --git a/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake new file mode 100644 index 0000000..ef33012 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake @@ -0,0 +1,19 @@ +enable_language(C) + +add_executable(main main.c ${CMAKE_CURRENT_BINARY_DIR}/test.manifest) + +if(MSVC AND NOT MSVC_VERSION LESS 1400) + set(EXTRA_CHECK [[ +file(STRINGS "$<TARGET_FILE:main>" content REGEX "name=\"Kitware.CMake.C-Exe-Manifest-step[0-9]\"") +if(NOT "${content}" MATCHES "name=\"Kitware.CMake.C-Exe-Manifest-step${check_step}\"") + set(RunCMake_TEST_FAILED "Binary has no manifest with name=\"Kitware.CMake.C-Exe-Manifest-step${check_step}\":\n ${content}") +endif() +]]) +endif() + +file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +set(check_pairs + \"$<TARGET_FILE:main>|${CMAKE_CURRENT_BINARY_DIR}/test.manifest\" + ) +${EXTRA_CHECK} +") diff --git a/Tests/RunCMake/BuildDepends/C-Exe-Manifest.step1.cmake b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.step1.cmake new file mode 100644 index 0000000..c0b939d --- /dev/null +++ b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.step1.cmake @@ -0,0 +1,6 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/test.manifest" [[ +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> + <assemblyIdentity type="win32" version="1.0.0.0" + name="Kitware.CMake.C-Exe-Manifest-step1"/> +</assembly> +]]) diff --git a/Tests/RunCMake/BuildDepends/C-Exe-Manifest.step2.cmake b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.step2.cmake new file mode 100644 index 0000000..a75bf21 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.step2.cmake @@ -0,0 +1,6 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/test.manifest" [[ +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> + <assemblyIdentity type="win32" version="1.0.0.0" + name="Kitware.CMake.C-Exe-Manifest-step2"/> +</assembly> +]]) diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index 98132cc..8782ba9 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -14,6 +14,9 @@ function(run_BuildDepends CASE) set(RunCMake-check-file check.cmake) set(check_step 1) run_cmake_command(${CASE}-build1 ${CMAKE_COMMAND} --build . --config Debug) + if(run_BuildDepends_skip_step_2) + return() + endif() execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1.125) # handle 1s resolution include(${RunCMake_SOURCE_DIR}/${CASE}.step2.cmake OPTIONAL) set(check_step 2) @@ -21,3 +24,11 @@ function(run_BuildDepends CASE) endfunction() run_BuildDepends(C-Exe) +if(NOT RunCMake_GENERATOR MATCHES "Visual Studio [67]|Xcode") + if(RunCMake_GENERATOR MATCHES "Visual Studio 10") + # VS 10 forgets to re-link when a manifest changes + set(run_BuildDepends_skip_step_2 1) + endif() + run_BuildDepends(C-Exe-Manifest) + unset(run_BuildDepends_skip_step_2) +endif() diff --git a/Tests/RunCMake/BuildDepends/check.cmake b/Tests/RunCMake/BuildDepends/check.cmake index be6debc..26a9eb6 100644 --- a/Tests/RunCMake/BuildDepends/check.cmake +++ b/Tests/RunCMake/BuildDepends/check.cmake @@ -1,5 +1,8 @@ if(EXISTS ${RunCMake_TEST_BINARY_DIR}/check-debug.cmake) include(${RunCMake_TEST_BINARY_DIR}/check-debug.cmake) + if(RunCMake_TEST_FAILED) + return() + endif() foreach(exe IN LISTS check_exes) execute_process(COMMAND ${exe} RESULT_VARIABLE res) if(NOT res EQUAL ${check_step}) diff --git a/Tests/RunCMake/BuildDepends/main.c b/Tests/RunCMake/BuildDepends/main.c new file mode 100644 index 0000000..78f2de1 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/main.c @@ -0,0 +1 @@ +int main(void) { return 0; } |