Tests/IntermediateDirStrategy: test install paths when using SHORT

See: #27233
This commit is contained in:
Ben Boeckel
2025-09-17 14:23:15 -04:00
parent a3ccb05430
commit 1980e47192
6 changed files with 56 additions and 0 deletions

View File

@@ -1,2 +1,6 @@
cmake_minimum_required(VERSION 3.10)
project(${RunCMake_TEST} NONE)
if (NOT RunCMake_TEST MATCHES "IntDirStrategy")
include(${RunCMake_TEST}.cmake)
endif ()

View File

@@ -0,0 +1,10 @@
enable_language(C)
set(info "")
# Forward information about the C++ compile features.
string(APPEND info "\
set(CMAKE_C_OUTPUT_EXTENSION \"${CMAKE_C_OUTPUT_EXTENSION}\")
")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" "${info}")

View File

@@ -27,3 +27,25 @@ foreach (kind IN ITEMS Object Autogen)
run_cmake_intdir_strategy(IntDirStrategyEnv ${strategy} ${kind})
endforeach ()
endforeach ()
# The following tests perform installation of `OBJECT` libraries which does not
# work with multi-arch compilation under Xcode.
if (RunCMake_GENERATOR STREQUAL "Xcode" AND "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]")
return ()
endif ()
run_cmake(Inspect)
include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake")
function(run_install_test case)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build)
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE:STRING=Debug "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/fake_install")
run_cmake(${case})
set(RunCMake_TEST_NO_CLEAN 1)
run_cmake_command(${case}-build ${CMAKE_COMMAND} --build . --config Debug)
run_cmake_command(${case}-install ${CMAKE_COMMAND} --install . --config Debug --prefix "${RunCMake_TEST_BINARY_DIR}/real_install")
endfunction()
if (RunCMake_GENERATOR MATCHES "(Ninja|Makefiles|Visual Studio)")
run_install_test(ShortObjectDoesntChangeInstall)
endif ()

View File

@@ -0,0 +1,11 @@
set(subdir "subdir/")
set(ext_suffix ".c")
if (RunCMake_GENERATOR MATCHES "(Visual Studio|Xcode)")
set(ext_suffix "")
set(subdir "")
endif ()
set(path "${RunCMake_TEST_BINARY_DIR}/real_install/lib/objlib/objects-Debug/objlib/${subdir}obj${ext_suffix}${CMAKE_C_OUTPUT_EXTENSION}")
if (NOT EXISTS "${path}")
list(APPEND RunCMake_TEST_FAILED
"Expected install object '${path}' does not exist")
endif ()

View File

@@ -0,0 +1,5 @@
set(CMAKE_INTERMEDIATE_DIR_STRATEGY SHORT CACHE STRING "" FORCE)
enable_language(C)
add_library(objlib OBJECT subdir/obj.c)
install(TARGETS objlib OBJECTS DESTINATION lib/objlib)

View File

@@ -0,0 +1,4 @@
int f(int a)
{
return a;
}