16038
|
1 |
set(configure_cmake_args)
|
16021
|
2 |
if(CMAKE_C_COMPILER)
|
16038
|
3 |
list(APPEND configure_cmake_args "C_COMPILER" "${CMAKE_C_COMPILER}")
|
16021
|
4 |
endif()
|
|
5 |
if(CMAKE_CXX_COMPILER)
|
16038
|
6 |
list(APPEND configure_cmake_args "CXX_COMPILER" "${CMAKE_CXX_COMPILER}")
|
|
7 |
endif()
|
|
8 |
if(CMAKE_C_COMPILER_TARGET)
|
|
9 |
list(APPEND configure_cmake_args "C_COMPILER_TARGET" "${CMAKE_C_COMPILER_TARGET}")
|
|
10 |
endif()
|
|
11 |
if(CMAKE_CXX_COMPILER_TARGET)
|
|
12 |
list(APPEND configure_cmake_args "CXX_COMPILER_TARGET" "${CMAKE_CXX_COMPILER_TARGET}")
|
16021
|
13 |
endif()
|
|
14 |
if(CMAKE_GENERATOR_PLATFORM)
|
16038
|
15 |
list(APPEND configure_cmake_args "GENERATOR_PLATFORM" "${CMAKE_GENERATOR_PLATFORM}")
|
|
16 |
endif()
|
|
17 |
if(CMAKE_OSX_ARCHITECTURES)
|
|
18 |
list(APPEND configure_cmake_args OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}")
|
|
19 |
endif()
|
|
20 |
if(CMAKE_TOOLCHAIN_FILE)
|
|
21 |
list(APPEND configure_cmake_args TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}")
|
16021
|
22 |
endif()
|
|
23 |
|
|
24 |
add_test(NAME "output_directory_build"
|
|
25 |
COMMAND
|
|
26 |
${CMAKE_COMMAND}
|
|
27 |
-P "${CMAKE_SOURCE_DIR}/test/ConfigureAndBuild.cmake"
|
|
28 |
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/output directory"
|
|
29 |
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/build"
|
|
30 |
GENERATOR "${CMAKE_GENERATOR}"
|
|
31 |
RUST_TOOLCHAIN "${Rust_TOOLCHAIN}"
|
|
32 |
CARGO_TARGET "${Rust_CARGO_TARGET}"
|
|
33 |
SYSTEM_NAME "${CMAKE_SYSTEM_NAME}"
|
16038
|
34 |
${configure_cmake_args}
|
16021
|
35 |
|
|
36 |
COMMAND_EXPAND_LISTS
|
|
37 |
)
|
|
38 |
set_tests_properties("output_directory_build" PROPERTIES FIXTURES_SETUP "build_fixture_output_directory")
|
|
39 |
if(CORROSION_TESTS_INSTALL_CORROSION)
|
|
40 |
set_tests_properties("output_directory_build" PROPERTIES FIXTURES_REQUIRED "fixture_corrosion_install")
|
|
41 |
endif()
|
|
42 |
|
16038
|
43 |
foreach(output_approach targetprop var targetprop_pdb_fallback)
|
16021
|
44 |
if(output_approach STREQUAL "targetprop")
|
|
45 |
set(rust_proj_suffix "1")
|
|
46 |
elseif(output_approach STREQUAL "var")
|
|
47 |
set(rust_proj_suffix "2")
|
16038
|
48 |
elseif(output_approach STREQUAL "targetprop_pdb_fallback")
|
|
49 |
set(rust_proj_suffix "3")
|
16021
|
50 |
else()
|
|
51 |
message(FATAL_ERROR "specify rust project suffix for new output approach ${output_approach}")
|
|
52 |
endif()
|
|
53 |
|
|
54 |
set(bin_name "rust_bin${rust_proj_suffix}${CMAKE_EXECUTABLE_SUFFIX}")
|
|
55 |
|
|
56 |
add_test(NAME output_directory_bin_${output_approach}
|
|
57 |
COMMAND
|
|
58 |
"${CMAKE_COMMAND}"
|
|
59 |
-P "${CMAKE_CURRENT_SOURCE_DIR}/TestFileExists.cmake"
|
|
60 |
"${CMAKE_CURRENT_BINARY_DIR}/build/custom_bin_${output_approach}/${bin_name}"
|
|
61 |
)
|
|
62 |
set_tests_properties("output_directory_bin_${output_approach}" PROPERTIES FIXTURES_REQUIRED "build_fixture_output_directory")
|
|
63 |
|
|
64 |
set(lib_name "rust_lib${rust_proj_suffix}")
|
|
65 |
|
|
66 |
set(static_lib_name "${CMAKE_STATIC_LIBRARY_PREFIX}${lib_name}${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
|
67 |
|
|
68 |
add_test(NAME output_directory_staticlib_${output_approach}
|
|
69 |
COMMAND
|
|
70 |
"${CMAKE_COMMAND}"
|
|
71 |
-P "${CMAKE_CURRENT_SOURCE_DIR}/TestFileExists.cmake"
|
|
72 |
"${CMAKE_CURRENT_BINARY_DIR}/build/custom_archive_${output_approach}/${static_lib_name}"
|
|
73 |
)
|
|
74 |
set_tests_properties("output_directory_staticlib_${output_approach}" PROPERTIES FIXTURES_REQUIRED "build_fixture_output_directory")
|
|
75 |
|
|
76 |
if(MINGW)
|
|
77 |
# Windows-GNU defines "lib" as prefix for DLLs, but cargo creates foo.dll instead of libfoo.dll
|
|
78 |
set(dynamic_lib_prefix "")
|
|
79 |
else()
|
|
80 |
set(dynamic_lib_prefix "${CMAKE_SHARED_LIBRARY_PREFIX}")
|
|
81 |
endif()
|
|
82 |
set(dynamic_lib_name "${dynamic_lib_prefix}${lib_name}${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
|
83 |
|
|
84 |
add_test(NAME output_directory_cdylib_${output_approach}
|
|
85 |
COMMAND
|
|
86 |
"${CMAKE_COMMAND}"
|
|
87 |
-P "${CMAKE_CURRENT_SOURCE_DIR}/TestFileExists.cmake"
|
|
88 |
"${CMAKE_CURRENT_BINARY_DIR}/build/custom_lib_${output_approach}/${dynamic_lib_name}"
|
|
89 |
)
|
|
90 |
set_tests_properties("output_directory_cdylib_${output_approach}" PROPERTIES FIXTURES_REQUIRED "build_fixture_output_directory")
|
|
91 |
|
|
92 |
if(WIN32)
|
|
93 |
set(implib_name ${CMAKE_IMPORT_LIBRARY_PREFIX}${lib_name}${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
|
94 |
|
|
95 |
add_test(NAME output_directory_implib_${output_approach}
|
|
96 |
COMMAND
|
|
97 |
"${CMAKE_COMMAND}"
|
|
98 |
-P "${CMAKE_CURRENT_SOURCE_DIR}/TestFileExists.cmake"
|
|
99 |
# Implib is an ARCHIVE artifact, see:
|
|
100 |
# https://cmake.org/cmake/help/v3.25/manual/cmake-buildsystem.7.html#archive-output-artifacts
|
|
101 |
"${CMAKE_CURRENT_BINARY_DIR}/build/custom_archive_${output_approach}/${implib_name}"
|
|
102 |
)
|
|
103 |
set_tests_properties("output_directory_implib_${output_approach}" PROPERTIES FIXTURES_REQUIRED "build_fixture_output_directory")
|
|
104 |
|
|
105 |
if(MSVC)
|
|
106 |
if(output_approach STREQUAL "targetprop")
|
|
107 |
set(expected_lib_pdb_path "custom_lib_pdb_targetprop")
|
|
108 |
set(expected_bin_pdb_path "custom_bin_pdb_targetprop")
|
|
109 |
elseif(output_approach STREQUAL "var")
|
|
110 |
# When using a CMAKE_ variable instead of a target property, both targets
|
|
111 |
# end up in the same directory.
|
|
112 |
set(expected_lib_pdb_path "custom_binlib_pdb_var")
|
|
113 |
set(expected_bin_pdb_path "custom_binlib_pdb_var")
|
16038
|
114 |
elseif(output_approach STREQUAL "targetprop_pdb_fallback")
|
|
115 |
set(expected_lib_pdb_path "custom_lib_targetprop_pdb_fallback")
|
|
116 |
set(expected_bin_pdb_path "custom_bin_targetprop_pdb_fallback")
|
16021
|
117 |
else()
|
|
118 |
message(FATAL_ERROR "specify rust project suffix for new output approach ${output_approach}")
|
|
119 |
endif()
|
|
120 |
|
|
121 |
set(lib_pdb_name "${lib_name}.pdb")
|
|
122 |
add_test(NAME output_directory_cdylib_pdb_${output_approach}
|
|
123 |
COMMAND
|
|
124 |
"${CMAKE_COMMAND}"
|
|
125 |
-P "${CMAKE_CURRENT_SOURCE_DIR}/TestFileExists.cmake"
|
|
126 |
"${CMAKE_CURRENT_BINARY_DIR}/build/${expected_lib_pdb_path}/${lib_pdb_name}"
|
|
127 |
)
|
|
128 |
set_tests_properties("output_directory_cdylib_pdb_${output_approach}" PROPERTIES FIXTURES_REQUIRED "build_fixture_output_directory")
|
|
129 |
|
|
130 |
set(bin_pdb_name "rust_bin${rust_proj_suffix}.pdb")
|
|
131 |
add_test(NAME output_directory_bin_pdb_${output_approach}
|
|
132 |
COMMAND
|
|
133 |
"${CMAKE_COMMAND}"
|
|
134 |
-P "${CMAKE_CURRENT_SOURCE_DIR}/TestFileExists.cmake"
|
|
135 |
"${CMAKE_CURRENT_BINARY_DIR}/build/${expected_bin_pdb_path}/${bin_pdb_name}"
|
|
136 |
)
|
|
137 |
set_tests_properties("output_directory_bin_pdb_${output_approach}" PROPERTIES FIXTURES_REQUIRED "build_fixture_output_directory")
|
|
138 |
endif()
|
|
139 |
endif()
|
|
140 |
|
|
141 |
endforeach()
|
|
142 |
|
|
143 |
add_test(NAME postbuild_custom_command
|
|
144 |
COMMAND
|
|
145 |
"${CMAKE_COMMAND}"
|
|
146 |
-P "${CMAKE_CURRENT_SOURCE_DIR}/TestFileExists.cmake"
|
|
147 |
"${CMAKE_CURRENT_BINARY_DIR}/build/another_dir/moved_bin"
|
|
148 |
)
|
|
149 |
set_tests_properties("postbuild_custom_command" PROPERTIES FIXTURES_REQUIRED "build_fixture_output_directory")
|
|
150 |
|
|
151 |
add_test(NAME "output_directory_cleanup" COMMAND "${CMAKE_COMMAND}" -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/build")
|
|
152 |
set_tests_properties("output_directory_cleanup" PROPERTIES FIXTURES_CLEANUP "build_fixture_output_directory")
|
16038
|
153 |
|
|
154 |
|