summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-07-31 14:50:08 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-07-31 14:50:23 (GMT)
commit7518fd6074c7544fb7f4694b102514fb0cc9f42c (patch)
treefe8293cecd776c28819e36457ef5cd9ebd1ecb46 /Tests
parent307b2dbadd011aa7403a315cd5e817efffb3eedf (diff)
parentb66c494ca465766a6a46fc508d0ddd02b667873c (diff)
downloadCMake-7518fd6074c7544fb7f4694b102514fb0cc9f42c.zip
CMake-7518fd6074c7544fb7f4694b102514fb0cc9f42c.tar.gz
CMake-7518fd6074c7544fb7f4694b102514fb0cc9f42c.tar.bz2
Merge topic 'test-target-property-init'
b66c494ca4 Tests/RunCMake/property_init: test 'with_exports' properties efad4391e5 Tests/RunCMake/property_init: test 'with_commands' properties 5f1bf85f84 Tests/RunCMake/property_init: test 'with_artifact' properties 02972ed9e8 Tests/RunCMake/property_init: test 'shared_library' properties 653a32aa72 Tests/RunCMake/property_init: test 'pic_targets' properties 141049cf16 Tests/RunCMake/property_init: test 'normal' properties bc318ceb7f Tests/RunCMake/property_init: test 'non_imported' properties 0b56e3fedd Tests/RunCMake/property_init: test 'normal_non_imported' properties ... Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !8655
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/property_init/Always.cmake15
-rw-r--r--Tests/RunCMake/property_init/CMakeLists.txt9
-rw-r--r--Tests/RunCMake/property_init/CompileSources.cmake274
-rw-r--r--Tests/RunCMake/property_init/Executable.cmake25
-rw-r--r--Tests/RunCMake/property_init/ImportedTargets.cmake9
-rw-r--r--Tests/RunCMake/property_init/LibraryArtifact.cmake10
-rw-r--r--Tests/RunCMake/property_init/Linkable.cmake12
-rw-r--r--Tests/RunCMake/property_init/NonImportedNormalTarget.cmake9
-rw-r--r--Tests/RunCMake/property_init/NonImportedTarget.cmake11
-rw-r--r--Tests/RunCMake/property_init/NormalTarget.cmake10
-rw-r--r--Tests/RunCMake/property_init/PICTargets.cmake21
-rw-r--r--Tests/RunCMake/property_init/RunCMakeTest.cmake16
-rw-r--r--Tests/RunCMake/property_init/SharedLibrary.cmake12
-rw-r--r--Tests/RunCMake/property_init/TargetsWithArtifact.cmake19
-rw-r--r--Tests/RunCMake/property_init/TargetsWithCommands.cmake13
-rw-r--r--Tests/RunCMake/property_init/TargetsWithExports.cmake51
-rw-r--r--Tests/RunCMake/property_init/library.c4
-rw-r--r--Tests/RunCMake/property_init/main.c4
-rw-r--r--Tests/RunCMake/property_init/util.cmake191
20 files changed, 716 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 280b81e..f8b84b2 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -536,6 +536,7 @@ add_RunCMake_test(option)
add_RunCMake_test(PrintHelpers)
add_RunCMake_test(project -DCMake_TEST_RESOURCES=${CMake_TEST_RESOURCES})
add_RunCMake_test(project_injected)
+add_RunCMake_test(property_init)
add_RunCMake_test(DependencyProviders)
add_RunCMake_test(return)
add_RunCMake_test(separate_arguments)
diff --git a/Tests/RunCMake/property_init/Always.cmake b/Tests/RunCMake/property_init/Always.cmake
new file mode 100644
index 0000000..db23563
--- /dev/null
+++ b/Tests/RunCMake/property_init/Always.cmake
@@ -0,0 +1,15 @@
+set(properties
+ # property expected alias
+ # Test a property which should never be initialized.
+ "notset" "<UNSET>" "<SAME>"
+
+ # Build graph properties
+ "VERIFY_INTERFACE_HEADER_SETS" "TRUE" "<SAME>"
+
+ # Metadata
+ "FOLDER" "folder" "<SAME>"
+ )
+
+prepare_target_types(always ${all_target_types})
+
+run_property_tests(always properties)
diff --git a/Tests/RunCMake/property_init/CMakeLists.txt b/Tests/RunCMake/property_init/CMakeLists.txt
new file mode 100644
index 0000000..51883af
--- /dev/null
+++ b/Tests/RunCMake/property_init/CMakeLists.txt
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 3.12)
+project(${RunCMake_TEST} C)
+
+set(main_sources main.c)
+set(library_sources library.c)
+
+include(util.cmake)
+
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/property_init/CompileSources.cmake b/Tests/RunCMake/property_init/CompileSources.cmake
new file mode 100644
index 0000000..e8c5554
--- /dev/null
+++ b/Tests/RunCMake/property_init/CompileSources.cmake
@@ -0,0 +1,274 @@
+set(dir "${CMAKE_CURRENT_BINARY_DIR}")
+
+set(properties
+ # property expected alias
+ # Compilation properties
+ "COMPILE_WARNING_AS_ERROR" "ON" "<SAME>"
+ "INTERPROCEDURAL_OPTIMIZATION" "OFF" "<SAME>"
+ "NO_SYSTEM_FROM_IMPORTED" "ON" "<SAME>"
+ "VISIBILITY_INLINES_HIDDEN" "ON" "<SAME>"
+ ## Features
+ ### PCH
+ "DISABLE_PRECOMPILE_HEADERS" "ON" "<SAME>"
+ "PCH_WARN_INVALID" "OFF" "<SAME>"
+ "PCH_INSTANTIATE_TEMPLATES" "OFF" "<SAME>"
+ ## Platforms
+ ### Android
+ "ANDROID_API" "9" "<SAME>"
+ "ANDROID_API_MIN" "9" "<SAME>"
+ "ANDROID_ARCH" "arm64-v8a" "<SAME>"
+ "ANDROID_ASSETS_DIRECTORIES" "${dir}" "<SAME>"
+ "ANDROID_JAVA_SOURCE_DIR" "${dir}" "<SAME>"
+ "ANDROID_STL_TYPE" "system" "<SAME>"
+ ### macOS
+ "OSX_ARCHITECTURES" "arm64" "<SAME>"
+ ### Windows
+ "MSVC_DEBUG_INFORMATION_FORMAT" "Embedded" "<SAME>"
+ "MSVC_RUNTIME_LIBRARY" "MultiThreaded" "<SAME>"
+ "VS_JUST_MY_CODE_DEBUGGING" "ON" "<SAME>"
+ ### OpenWatcom
+ "WATCOM_RUNTIME_LIBRARY" "MultiThreaded" "<SAME>"
+ ## Language
+ ### CUDA
+ "CUDA_SEPARABLE_COMPILATION" "ON" "<SAME>"
+ "CUDA_ARCHITECTURES" "naive" "<SAME>"
+ ### Fortran
+ "Fortran_FORMAT" "FREE" "<SAME>"
+ "Fortran_MODULE_DIRECTORY" "${dir}" "<SAME>"
+ "Fortran_COMPILER_LAUNCHER" "ccache" "<SAME>"
+ "Fortran_PREPROCESS" "ON" "<SAME>"
+ "Fortran_VISIBILITY_PRESET" "hidden" "<SAME>"
+ ### HIP
+ "HIP_ARCHITECTURES" "gfx801" "<SAME>"
+ ### ISPC
+ "ISPC_COMPILER_LAUNCHER" "ccache" "<SAME>"
+ "ISPC_HEADER_DIRECTORY" "${dir}" "<SAME>"
+ "ISPC_HEADER_SUFFIX" "_i.h" "<SAME>"
+ "ISPC_INSTRUCTION_SETS" "avx2-i32x4" "<SAME>"
+ ### Swift
+ "Swift_LANGUAGE_VERSION" "2.3" "<SAME>"
+ "Swift_MODULE_DIRECTORY" "${dir}" "<SAME>"
+ ### moc
+ "AUTOMOC" "OFF" "<SAME>"
+ "AUTOMOC_COMPILER_PREDEFINES" "OFF" "<SAME>"
+ "AUTOMOC_MACRO_NAMES" "MOC_CLASS" "<SAME>"
+ "AUTOMOC_MOC_OPTIONS" "-v" "<SAME>"
+ "AUTOMOC_PATH_PREFIX" "moc_" "<SAME>"
+ "AUTOMOC_EXECUTABLE" "automoc" "<SAME>"
+ ### uic
+ "AUTOUIC" "OFF" "<SAME>"
+ "AUTOUIC_OPTIONS" "-v" "<SAME>"
+ "AUTOUIC_SEARCH_PATHS" "${dir}" "<SAME>"
+ "AUTOUIC_EXECUTABLE" "autouic" "<SAME>"
+ ### rcc
+ "AUTORCC" "OFF" "<SAME>"
+ "AUTORCC_OPTIONS" "-v" "<SAME>"
+ "AUTORCC_EXECUTABLE" "autorcc" "<SAME>"
+
+ # Linking properties
+ "LINK_SEARCH_START_STATIC" "-Bstatic" "<SAME>"
+ "LINK_SEARCH_END_STATIC" "-Bdynamic" "<SAME>"
+ ## Dependent library lookup
+ "MACOSX_RPATH" "@loader_path/" "<SAME>"
+ ### Build
+ "BUILD_RPATH" "../lib" "<SAME>"
+ "BUILD_RPATH_USE_ORIGIN" "ON" "<SAME>"
+ "SKIP_BUILD_RPATH" "ON" "<SAME>"
+ "BUILD_WITH_INSTALL_RPATH" "ON" "<SAME>"
+ "BUILD_WITH_INSTALL_NAME_DIR" "@rpath/" "<SAME>"
+ ### Install
+ "INSTALL_NAME_DIR" "@rpath/" "<SAME>"
+ "INSTALL_REMOVE_ENVIRONMENT_RPATH" "ON" "<SAME>"
+ "INSTALL_RPATH" "@rpath/" "<SAME>"
+ "INSTALL_RPATH_USE_LINK_PATH" "ON" "<SAME>"
+ ## Platforms
+ ### Android
+ "ANDROID_JAR_DIRECTORIES" "${dir}" "<SAME>"
+ "ANDROID_JAR_DEPENDENCIES" "${dir}/foo.jar" "<SAME>"
+ "ANDROID_NATIVE_LIB_DIRECTORIES" "${dir}" "<SAME>"
+ "ANDROID_NATIVE_LIB_DEPENDENCIES" "${dir}/native.a" "<SAME>"
+ "ANDROID_PROGUARD" "ON" "<SAME>"
+ "ANDROID_PROGUARD_CONFIG_PATH" "proguard.props" "<SAME>"
+ "ANDROID_SECURE_PROPS_PATH" "secure.props" "<SAME>"
+ ### iOS
+ "IOS_INSTALL_COMBINED" "ON" "<SAME>"
+ ### Windows
+ "GNUtoMS" "ON" "<SAME>"
+ "WIN32_EXECUTABLE" "OFF" "<SAME>"
+ ## Languages
+ ### C
+ "C_LINKER_LAUNCHER" "ccache" "<SAME>"
+ ### C++
+ "CXX_LINKER_LAUNCHER" "ccache" "<SAME>"
+ ### CUDA
+ "CUDA_RESOLVE_DEVICE_SYMBOLS" "ON" "<SAME>"
+ "CUDA_RUNTIME_LIBRARY" "Static" "<SAME>"
+ ### HIP
+ "HIP_RUNTIME_LIBRARY" "SHARED" "<SAME>"
+ ### Objective C
+ "OBJC_LINKER_LAUNCHER" "ccache" "<SAME>"
+ ### Objective C++
+ "OBJCXX_LINKER_LAUNCHER" "ccache" "<SAME>"
+
+ # Static analysis
+ ## C
+ "C_CLANG_TIDY" "clang-tidy" "<SAME>"
+ "C_CLANG_TIDY_EXPORT_FIXES_DIR" "${dir}" "<SAME>"
+ "C_CPPLINT" "cpplint" "<SAME>"
+ "C_CPPCHECK" "cppcheck" "<SAME>"
+ "C_INCLUDE_WHAT_YOU_USE" "iwyu" "<SAME>"
+ ## C++
+ "CXX_CLANG_TIDY" "clang-tidy" "<SAME>"
+ "CXX_CLANG_TIDY_EXPORT_FIXES_DIR" "${dir}" "<SAME>"
+ "CXX_CPPLINT" "cpplint" "<SAME>"
+ "CXX_CPPCHECK" "cppcheck" "<SAME>"
+ "CXX_INCLUDE_WHAT_YOU_USE" "iwyu" "<SAME>"
+ ## Objective C
+ "OBJC_CLANG_TIDY" "clang-tidy" "<SAME>"
+ "OBJC_CLANG_TIDY_EXPORT_FIXES_DIR" "${dir}" "<SAME>"
+ ## Objective C++
+ "OBJCXX_CLANG_TIDY" "clang-tidy" "<SAME>"
+ "OBJCXX_CLANG_TIDY_EXPORT_FIXES_DIR" "${dir}" "<SAME>"
+ ## Linking
+ "LINK_WHAT_YOU_USE" "lwyu" "<SAME>"
+
+ # Build graph properties
+ "LINK_DEPENDS_NO_SHARED" "OFF" "<SAME>"
+ "UNITY_BUILD" "OFF" "<SAME>"
+ "UNITY_BUILD_UNIQUE_ID" "unity" "<SAME>"
+ "UNITY_BUILD_BATCH_SIZE" "10" "<SAME>"
+ "UNITY_BUILD_MODE" "GROUP" "<SAME>"
+ "OPTIMIZE_DEPENDENCIES" "ON" "<SAME>"
+ ## Android
+ "ANDROID_ANT_ADDITIONAL_OPTIONS" "-v" "<SAME>"
+ "ANDROID_PROCESS_MAX" "2" "<SAME>"
+ "ANDROID_SKIP_ANT_STEP" "ON" "<SAME>"
+ ## Autogen
+ "AUTOGEN_ORIGIN_DEPENDS" "OFF" "<SAME>"
+ "AUTOGEN_PARALLEL" "ON" "<SAME>"
+ "AUTOGEN_USE_SYSTEM_INCLUDE" "ON" "<SAME>"
+ ## moc
+ "AUTOMOC_DEPEND_FILTERS" "FIRST<SEMI>SECOND" "<SAME>"
+ ## C++
+ "CXX_SCAN_FOR_MODULES" "ON" "<SAME>"
+ ## Ninja
+ "JOB_POOL_COMPILE" "compile_pool" "<SAME>"
+ "JOB_POOL_LINK" "link_pool" "<SAME>"
+ "JOB_POOL_PRECOMPILE_HEADER" "pch_pool" "<SAME>"
+ ## Visual Studio
+ "VS_NO_COMPILE_BATCHING" "ON" "<SAME>"
+ "VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION" "10.0.10240.0" "<SAME>"
+
+ # Output location properties
+ "ARCHIVE_OUTPUT_DIRECTORY" "${dir}" "<SAME>"
+ "COMPILE_PDB_OUTPUT_DIRECTORY" "${dir}" "<SAME>"
+ "LIBRARY_OUTPUT_DIRECTORY" "${dir}" "<SAME>"
+ "PDB_OUTPUT_DIRECTORY" "${dir}" "<SAME>"
+ "RUNTIME_OUTPUT_DIRECTORY" "${dir}" "<SAME>"
+
+ # macOS bundle properties
+ "FRAMEWORK" "OFF" "<SAME>"
+ "FRAMEWORK_MULTI_CONFIG_POSTFIX" ".mcpostfix" "<SAME>"
+ "MACOSX_BUNDLE" "OFF" "<SAME>"
+
+ # Usage requirement properties
+ "LINK_INTERFACE_LIBRARIES" "c" "<SAME>"
+
+ # Metadata
+ "EXPORT_COMPILE_COMMANDS" "OFF" "<SAME>"
+ )
+
+if (CMAKE_HOST_APPLE) # compile-guarded in CMake
+ if (CMAKE_GENERATOR STREQUAL "Xcode")
+ list(APPEND properties
+ # property expected alias
+ # Xcode properties
+ "XCODE_SCHEME_ADDRESS_SANITIZER" "ON" "<SAME>"
+ "XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN" "ON" "<SAME>"
+ "XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING" "ON" "<SAME>"
+ "XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE" "ON" "<SAME>"
+ "XCODE_SCHEME_THREAD_SANITIZER" "ON" "<SAME>"
+ "XCODE_SCHEME_THREAD_SANITIZER_STOP" "ON" "<SAME>"
+ "XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER" "ON" "<SAME>"
+ "XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP" "ON" "<SAME>"
+ "XCODE_SCHEME_LAUNCH_CONFIGURATION" "ON" "<SAME>"
+ "XCODE_SCHEME_ENABLE_GPU_API_VALIDATION" "ON" "<SAME>"
+ "XCODE_SCHEME_ENABLE_GPU_SHADER_VALIDATION" "ON" "<SAME>"
+ "XCODE_SCHEME_WORKING_DIRECTORY" "ON" "<SAME>"
+ "XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER" "ON" "<SAME>"
+ "XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP" "ON" "<SAME>"
+ "XCODE_SCHEME_MALLOC_SCRIBBLE" "ON" "<SAME>"
+ "XCODE_SCHEME_MALLOC_GUARD_EDGES" "ON" "<SAME>"
+ "XCODE_SCHEME_GUARD_MALLOC" "ON" "<SAME>"
+ "XCODE_SCHEME_LAUNCH_MODE" "ON" "<SAME>"
+ "XCODE_SCHEME_ZOMBIE_OBJECTS" "ON" "<SAME>"
+ "XCODE_SCHEME_MALLOC_STACK" "ON" "<SAME>"
+ "XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE" "ON" "<SAME>"
+ "XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS" "ON" "<SAME>"
+ "XCODE_SCHEME_ENVIRONMENT" "ON" "<SAME>"
+ "XCODE_LINK_BUILD_PHASE_MODE" "BUILT_ONLY" "<SAME>"
+ )
+ endif ()
+endif ()
+
+macro (add_language_properties lang std)
+ list(APPEND properties
+ # property expected alias
+ "${lang}_COMPILER_LAUNCHER" "ccache" "<SAME>"
+ "${lang}_STANDARD" "${std}" "<SAME>"
+ "${lang}_STANDARD_REQUIRED" "TRUE" "<SAME>"
+ "${lang}_EXTENSIONS" "FALSE" "<SAME>"
+ "${lang}_VISIBILITY_PRESET" "hidden" "<SAME>"
+ )
+endmacro ()
+
+# Mock up knowing the standard flag. This doesn't actually build, so nothing
+# should care at this point.
+set(CMAKE_Cc_std_11_STANDARD_COMPILE_OPTION "-std=c11")
+
+add_language_properties(C c_std_11)
+add_language_properties(CXX cxx_std_11)
+add_language_properties(CUDA cuda_std_11)
+add_language_properties(HIP hip_std_11)
+add_language_properties(OBJC c_std_99)
+add_language_properties(OBJCXX cxx_std_11)
+
+# Set up pools for properties set above.
+if (CMAKE_GENERATOR MATCHES "Ninja")
+ set_property(GLOBAL APPEND
+ PROPERTY
+ JOB_POOLS
+ compile_pool=1
+ link_pool=1
+ pch_pool=1)
+endif ()
+
+prepare_target_types(can_compile_sources
+ EXECUTABLE SHARED STATIC MODULE OBJECT)
+
+run_property_tests(can_compile_sources properties)
+
+set(properties_with_defaults
+ # property expected alias
+ "PCH_WARN_INVALID" "ON" "<SAME>"
+ "PCH_INSTANTIATE_TEMPLATES" "ON" "<SAME>"
+ "ISPC_HEADER_SUFFIX" "_ispc.h" "<SAME>"
+ "SKIP_BUILD_RPATH" "OFF" "<SAME>"
+ "BUILD_WITH_INSTALL_RPATH" "OFF" "<SAME>"
+ "INSTALL_RPATH" "" "<SAME>"
+ "INSTALL_RPATH_USE_LINK_PATH" "OFF" "<SAME>"
+ "UNITY_BUILD_BATCH_SIZE" "8" "<SAME>"
+ "UNITY_BUILD_MODE" "BATCH" "<SAME>"
+ )
+
+if (CMAKE_HOST_APPLE)
+ if (CMAKE_GENERATOR STREQUAL "Xcode")
+ list(APPEND properties_with_defaults
+ # property expected alias
+ "XCODE_LINK_BUILD_PHASE_MODE" "NONE" "<SAME>"
+ )
+ endif ()
+endif ()
+
+set(with_defaults 1)
+run_property_tests(can_compile_sources properties_with_defaults)
diff --git a/Tests/RunCMake/property_init/Executable.cmake b/Tests/RunCMake/property_init/Executable.cmake
new file mode 100644
index 0000000..ede0e4b
--- /dev/null
+++ b/Tests/RunCMake/property_init/Executable.cmake
@@ -0,0 +1,25 @@
+set(dir "${CMAKE_CURRENT_BINARY_DIR}")
+
+set(properties
+ # property expected alias
+ # Compilation properties
+ ## Platforms
+ ### Windows
+ "VS_DEBUGGER_COMMAND" "vsdbg" "<SAME>"
+ "VS_DEBUGGER_COMMAND_ARGUMENTS" "/?" "<SAME>"
+ "VS_DEBUGGER_ENVIRONMENT" "env=val" "<SAME>"
+ "VS_DEBUGGER_WORKING_DIRECTORY" "${dir}" "<SAME>"
+
+ # Linking properties
+ ## Platforms
+ ### Android
+ "ANDROID_GUI" "OFF" "<SAME>"
+
+ # Metadata
+ "CROSSCOMPILING_EMULATOR" "emu" "<SAME>"
+ )
+
+prepare_target_types(executable
+ EXECUTABLE
+ IMPORTED_EXECUTABLE)
+run_property_tests(executable properties)
diff --git a/Tests/RunCMake/property_init/ImportedTargets.cmake b/Tests/RunCMake/property_init/ImportedTargets.cmake
new file mode 100644
index 0000000..0b51998
--- /dev/null
+++ b/Tests/RunCMake/property_init/ImportedTargets.cmake
@@ -0,0 +1,9 @@
+set(properties
+ # property expected alias
+ "SYSTEM" "ON" "<SAME>"
+ )
+
+prepare_target_types(imported
+ IMPORTED_EXECUTABLE IMPORTED_INTERFACE IMPORTED_MODULE IMPORTED_OBJECT IMPORTED_SHARED IMPORTED_STATIC)
+set(with_defaults 1)
+run_property_tests(imported properties)
diff --git a/Tests/RunCMake/property_init/LibraryArtifact.cmake b/Tests/RunCMake/property_init/LibraryArtifact.cmake
new file mode 100644
index 0000000..942b433
--- /dev/null
+++ b/Tests/RunCMake/property_init/LibraryArtifact.cmake
@@ -0,0 +1,10 @@
+per_config(properties
+ # property expected alias
+ # Linking properties
+ "_POSTFIX" "test" "<UNSET>"
+ )
+
+prepare_target_types(library_with_artifact
+ MODULE SHARED STATIC
+ IMPORTED_MODULE IMPORTED_SHARED IMPORTED_STATIC)
+run_property_tests(library_with_artifact properties)
diff --git a/Tests/RunCMake/property_init/Linkable.cmake b/Tests/RunCMake/property_init/Linkable.cmake
new file mode 100644
index 0000000..e5d75d1
--- /dev/null
+++ b/Tests/RunCMake/property_init/Linkable.cmake
@@ -0,0 +1,12 @@
+per_config(properties
+ # property expected alias
+ # Linking properties
+ ## Platforms
+ ### macOS
+ "FRAMEWORK_MULTI_CONFIG_POSTFIX_" ".fw" "<UNSET>"
+ )
+
+prepare_target_types(linkable
+ EXECUTABLE SHARED STATIC
+ IMPORTED_EXECUTABLE IMPORTED_SHARED IMPORTED_STATIC)
+run_property_tests(linkable properties)
diff --git a/Tests/RunCMake/property_init/NonImportedNormalTarget.cmake b/Tests/RunCMake/property_init/NonImportedNormalTarget.cmake
new file mode 100644
index 0000000..cf3b726
--- /dev/null
+++ b/Tests/RunCMake/property_init/NonImportedNormalTarget.cmake
@@ -0,0 +1,9 @@
+set(properties
+ # property expected alias
+ # Linking properties
+ "LINK_LIBRARIES_ONLY_TARGETS" "OFF" "<SAME>"
+ )
+
+prepare_target_types(normal_non_imported
+ EXECUTABLE SHARED STATIC MODULE OBJECT INTERFACE)
+run_property_tests(normal_non_imported properties)
diff --git a/Tests/RunCMake/property_init/NonImportedTarget.cmake b/Tests/RunCMake/property_init/NonImportedTarget.cmake
new file mode 100644
index 0000000..7e2e22c
--- /dev/null
+++ b/Tests/RunCMake/property_init/NonImportedTarget.cmake
@@ -0,0 +1,11 @@
+set(properties
+ # property expected alias
+ # Compilation properties
+ ## Language
+ ### CSharp
+ "DOTNET_SDK" "Microsoft.NET.Sdk" "<SAME>"
+ )
+
+prepare_target_types(non_imported
+ EXECUTABLE SHARED STATIC MODULE OBJECT INTERFACE CUSTOM)
+run_property_tests(non_imported properties)
diff --git a/Tests/RunCMake/property_init/NormalTarget.cmake b/Tests/RunCMake/property_init/NormalTarget.cmake
new file mode 100644
index 0000000..99507cf
--- /dev/null
+++ b/Tests/RunCMake/property_init/NormalTarget.cmake
@@ -0,0 +1,10 @@
+per_config(properties
+ # property expected alias
+ # Usage requirement properties
+ "MAP_IMPORTED_CONFIG_" "Release" "<UNSET>"
+ )
+
+prepare_target_types(normal
+ EXECUTABLE INTERFACE MODULE OBJECT SHARED STATIC
+ IMPORTED_EXECUTABLE IMPORTED_INTERFACE IMPORTED_MODULE IMPORTED_OBJECT IMPORTED_SHARED IMPORTED_STATIC)
+run_property_tests(normal properties)
diff --git a/Tests/RunCMake/property_init/PICTargets.cmake b/Tests/RunCMake/property_init/PICTargets.cmake
new file mode 100644
index 0000000..6c99505
--- /dev/null
+++ b/Tests/RunCMake/property_init/PICTargets.cmake
@@ -0,0 +1,21 @@
+set(properties
+ # property expected alias
+ # Compilation properties
+ "POSITION_INDEPENDENT_CODE" "True" "<SAME>"
+ )
+
+prepare_target_types(pic_targets
+ EXECUTABLE MODULE OBJECT SHARED STATIC
+ IMPORTED_MODULE IMPORTED_SHARED)
+run_property_tests(pic_targets properties)
+
+set(APPEND properties_with_defaults
+ # property expected alias
+ "POSITION_INDEPENDENT_CODE" "True" "<SAME>"
+ )
+
+prepare_target_types(pic_default_targets
+ MODULE SHARED
+ IMPORTED_MODULE IMPORTED_SHARED)
+set(with_defaults 1)
+run_property_tests(pic_default_targets properties_with_defaults)
diff --git a/Tests/RunCMake/property_init/RunCMakeTest.cmake b/Tests/RunCMake/property_init/RunCMakeTest.cmake
new file mode 100644
index 0000000..310da72
--- /dev/null
+++ b/Tests/RunCMake/property_init/RunCMakeTest.cmake
@@ -0,0 +1,16 @@
+include(RunCMake)
+
+run_cmake(Always)
+run_cmake(CompileSources)
+run_cmake(Executable)
+run_cmake(ImportedTargets)
+run_cmake(LibraryArtifact)
+run_cmake(Linkable)
+run_cmake(NonImportedNormalTarget)
+run_cmake(NonImportedTarget)
+run_cmake(NormalTarget)
+run_cmake(PICTargets)
+run_cmake(SharedLibrary)
+run_cmake(TargetsWithArtifact)
+run_cmake(TargetsWithCommands)
+run_cmake(TargetsWithExports)
diff --git a/Tests/RunCMake/property_init/SharedLibrary.cmake b/Tests/RunCMake/property_init/SharedLibrary.cmake
new file mode 100644
index 0000000..49715a4
--- /dev/null
+++ b/Tests/RunCMake/property_init/SharedLibrary.cmake
@@ -0,0 +1,12 @@
+set(dir "${CMAKE_CURRENT_BINARY_DIR}")
+
+set(properties
+ # property expected alias
+ # Linking properties
+ "DLL_NAME_WITH_SOVERSION" "OFF" "<SAME>"
+ )
+
+prepare_target_types(shared_library
+ SHARED
+ IMPORTED_SHARED)
+run_property_tests(shared_library properties)
diff --git a/Tests/RunCMake/property_init/TargetsWithArtifact.cmake b/Tests/RunCMake/property_init/TargetsWithArtifact.cmake
new file mode 100644
index 0000000..0c19ea3
--- /dev/null
+++ b/Tests/RunCMake/property_init/TargetsWithArtifact.cmake
@@ -0,0 +1,19 @@
+set(dir "${CMAKE_CURRENT_BINARY_DIR}")
+
+per_config(properties
+ # property expected alias
+ # Compilation properties
+ "INTERPROCEDURAL_OPTIMIZATION_" "OFF" "<UNSET>"
+
+ # Output location properties
+ "ARCHIVE_OUTPUT_DIRECTORY_" "${dir}" "<UNSET>"
+ "COMPILE_PDB_OUTPUT_DIRECTORY_" "${dir}" "<UNSET>"
+ "LIBRARY_OUTPUT_DIRECTORY_" "${dir}" "<UNSET>"
+ "PDB_OUTPUT_DIRECTORY_" "${dir}" "<UNSET>"
+ "RUNTIME_OUTPUT_DIRECTORY_" "${dir}" "<UNSET>"
+ )
+
+prepare_target_types(with_artifact
+ EXECUTABLE MODULE SHARED STATIC
+ IMPORTED_EXECUTABLE IMPORTED_MODULE IMPORTED_SHARED IMPORTED_STATIC)
+run_property_tests(with_artifact properties)
diff --git a/Tests/RunCMake/property_init/TargetsWithCommands.cmake b/Tests/RunCMake/property_init/TargetsWithCommands.cmake
new file mode 100644
index 0000000..4db0ca3
--- /dev/null
+++ b/Tests/RunCMake/property_init/TargetsWithCommands.cmake
@@ -0,0 +1,13 @@
+set(properties
+ # property expected alias
+ # Compilation properties
+ ## Language
+ ### CSharp
+ "DOTNET_TARGET_FRAMEWORK" "netcoreapp2.1" "<SAME>"
+ "DOTNET_TARGET_FRAMEWORK_VERSION" "v4.5" "<SAME>"
+ )
+
+prepare_target_types(with_commands
+ EXECUTABLE MODULE OBJECT SHARED STATIC CUSTOM
+ IMPORTED_EXECUTABLE IMPORTED_MODULE IMPORTED_OBJECT IMPORTED_SHARED IMPORTED_STATIC)
+run_property_tests(with_commands properties)
diff --git a/Tests/RunCMake/property_init/TargetsWithExports.cmake b/Tests/RunCMake/property_init/TargetsWithExports.cmake
new file mode 100644
index 0000000..9b2e213
--- /dev/null
+++ b/Tests/RunCMake/property_init/TargetsWithExports.cmake
@@ -0,0 +1,51 @@
+set(properties
+ # property expected alias
+ # Linking properties
+ ## Platforms
+ ### AIX
+ "AIX_EXPORT_ALL_SYMBOLS" "OFF" "<SAME>"
+ ### Windows
+ "WINDOWS_EXPORT_ALL_SYMBOLS" "OFF" "<SAME>"
+ )
+
+prepare_target_types(symbol_export_target
+ EXECUTABLE SHARED
+ IMPORTED_EXECUTABLE IMPORTED_SHARED)
+run_property_tests(symbol_export_target properties)
+
+# `ENABLE_EXPORTS` has a more complicated initialization.
+set(properties
+ # property expected alias
+ # Linking properties
+ "ENABLE_EXPORTS" "OFF" "<SAME>"
+ )
+
+prepare_target_types(executable
+ EXECUTABLE
+ IMPORTED_EXECUTABLE)
+set(iteration "-ENABLE_EXPORTS")
+run_property_tests(executable_target properties)
+
+set(with_defaults 1)
+
+set(CMAKE_SHARED_LIBRARY_ENABLE_EXPORTS OFF)
+set(properties
+ # property expected alias
+ # Linking properties
+ "ENABLE_EXPORTS" "OFF" "<SAME>"
+ )
+
+set(iteration "-SHARED_LIBRARY_ENABLE_EXPORTS")
+run_property_tests(shared_library_target properties)
+unset(CMAKE_SHARED_LIBRARY_ENABLE_EXPORTS)
+
+set(CMAKE_EXECUTABLE_ENABLE_EXPORTS OFF)
+set(properties
+ # property expected alias
+ # Linking properties
+ "ENABLE_EXPORTS" "OFF" "<SAME>"
+ )
+
+set(iteration "-EXECUTABLE_ENABLE_EXPORTS")
+run_property_tests(executable_target properties)
+unset(CMAKE_EXECUTABLE_ENABLE_EXPORTS)
diff --git a/Tests/RunCMake/property_init/library.c b/Tests/RunCMake/property_init/library.c
new file mode 100644
index 0000000..ad6a649
--- /dev/null
+++ b/Tests/RunCMake/property_init/library.c
@@ -0,0 +1,4 @@
+int foo(int arg)
+{
+ return arg;
+}
diff --git a/Tests/RunCMake/property_init/main.c b/Tests/RunCMake/property_init/main.c
new file mode 100644
index 0000000..14917b7
--- /dev/null
+++ b/Tests/RunCMake/property_init/main.c
@@ -0,0 +1,4 @@
+int main(int argc, char* argv[])
+{
+ return argc - 1;
+}
diff --git a/Tests/RunCMake/property_init/util.cmake b/Tests/RunCMake/property_init/util.cmake
new file mode 100644
index 0000000..7edc6f9
--- /dev/null
+++ b/Tests/RunCMake/property_init/util.cmake
@@ -0,0 +1,191 @@
+set(all_target_types
+ "EXECUTABLE"
+
+ "IMPORTED_EXECUTABLE"
+
+ "INTERFACE"
+ "MODULE"
+ "OBJECT"
+ "SHARED"
+ "STATIC"
+
+ "IMPORTED_INTERFACE"
+ "IMPORTED_MODULE"
+ "IMPORTED_OBJECT"
+ "IMPORTED_SHARED"
+ "IMPORTED_STATIC"
+
+ "CUSTOM")
+
+function (prepare_target_types name)
+ set("${name}" "${ARGN}" PARENT_SCOPE)
+ list(REMOVE_ITEM all_target_types ${ARGN})
+ set("not_${name}" "${all_target_types}" PARENT_SCOPE)
+endfunction ()
+
+function (per_config variable)
+ prepare_properties("${property_table}" properties expected_values expected_alias)
+
+ get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ if (is_multi_config)
+ set(configs "${CMAKE_CONFIGURATION_TYPES}")
+ else ()
+ if (NOT CMAKE_BUILD_TYPE STREQUAL "")
+ set(configs "${CMAKE_BUILD_TYPE}")
+ endif ()
+ endif ()
+
+ foreach (property expected alias IN ZIP_LISTS expected_properties expected_values expected_alias)
+ if (property MATCHES "^_")
+ set(prepend 1)
+ elseif (property MATCHES "_$")
+ set(prepend 0)
+ else ()
+ message(SEND_ERROR
+ "Per-config properties must have a `_` at one end of their name: '${property}'")
+ endif ()
+ foreach (config IN LISTS configs)
+ if (prepend)
+ list(APPEND "${variable}"
+ "${config}_${property}" "${value}/${config}" "${alias}")
+ else ()
+ list(APPEND "${variable}"
+ "${property}_${config}" "${value}/${config}" "${alias}")
+ endif ()
+ endforeach ()
+ endforeach ()
+
+ set("${variable}" "${${variable}}" PARENT_SCOPE)
+endfunction ()
+
+function (make_target name type)
+ if (type STREQUAL "EXECUTABLE")
+ add_executable("${name}")
+ target_sources("${name}" PRIVATE ${main_sources})
+ elseif (type STREQUAL "IMPORTED_EXECUTABLE")
+ add_executable("${name}" IMPORTED)
+ set_property(TARGET "${name}" PROPERTY IMPORTED_LOCATION "${CMAKE_COMMAND}")
+ elseif (type STREQUAL "CUSTOM")
+ add_custom_target("${name}" COMMAND "${CMAKE_EXECUTABLE}" -E echo "${name}")
+ elseif (type MATCHES "IMPORTED_")
+ string(REPLACE "IMPORTED_" "" type "${type}")
+ add_library("${name}" IMPORTED ${type})
+ if (NOT type STREQUAL "INTERFACE")
+ set_property(TARGET "${name}" PROPERTY IMPORTED_LOCATION "${default_library_location}")
+ endif ()
+ else ()
+ add_library("${name}" ${type})
+ target_sources("${name}" PRIVATE ${library_sources})
+ endif ()
+
+ if (type MATCHES "EXECUTABLE")
+ add_executable("alias::${name}" ALIAS "${name}")
+ elseif (NOT type STREQUAL "CUSTOM")
+ add_library("alias::${name}" ALIAS "${name}")
+ endif ()
+endfunction ()
+
+function (check_property target property expected)
+ if (NOT TARGET "${target}")
+ message(SEND_ERROR
+ "No such target '${target}'")
+ return ()
+ endif ()
+
+ get_property(is_set TARGET "${target}" PROPERTY "${property}" SET)
+ if (is_set)
+ get_property(actual TARGET "${target}" PROPERTY "${property}")
+ endif ()
+ if (expected STREQUAL "<UNSET>")
+ if (is_set)
+ message(SEND_ERROR
+ "Target '${target}' should not have '${property}' set at all, but is '${actual}'")
+ endif ()
+ elseif (is_set AND NOT expected STREQUAL actual)
+ message(SEND_ERROR
+ "Target '${target}' should have '${property}' set to '${expected}', but is '${actual}'")
+ elseif (NOT is_set)
+ message(SEND_ERROR
+ "Target '${target}' should have '${property}' set to '${expected}', but is not set at all")
+ endif ()
+endfunction ()
+
+function (prepare_properties table output_properties output_expected output_alias)
+ set(_properties)
+ set(_expected)
+ set(_alias)
+
+ set(variable "_properties")
+ foreach (item IN LISTS "${table}")
+ list(APPEND "${variable}" "${item}")
+ if (variable STREQUAL "_properties")
+ set(variable "_expected")
+ elseif (variable STREQUAL "_expected")
+ set(variable "_alias")
+ elseif (variable STREQUAL "_alias")
+ set(variable "_properties")
+ else ()
+ message(FATAL_ERROR
+ "Failed to track property table parsing")
+ endif ()
+ endforeach ()
+ if (NOT variable STREQUAL "_properties")
+ message(FATAL_ERROR
+ "Table does not have a multiple of 3 items")
+ endif ()
+
+ set("${output_properties}" "${_properties}" PARENT_SCOPE)
+ set("${output_expected}" "${_expected}" PARENT_SCOPE)
+ set("${output_alias}" "${_alias}" PARENT_SCOPE)
+endfunction ()
+
+# Contextual variables:
+# iteration: make unique target names
+# with_defaults: if set, do not set variables, but instead test internal
+# default calculations
+function (run_property_tests applied_types property_table)
+ prepare_properties("${property_table}" expected_properties expected_values expected_alias)
+
+ if (NOT with_defaults)
+ foreach (property expected IN ZIP_LISTS expected_properties expected_values)
+ string(REPLACE "<SEMI>" ";" expected "${expected}")
+ set("CMAKE_${property}" "${expected}")
+ endforeach ()
+ endif ()
+
+ foreach (target_type IN LISTS "${applied_types}")
+ set(target_name "${RunCMake_TEST}${iteration}-${target_type}")
+ if (with_defaults)
+ string(APPEND target_name "-defaults")
+ endif ()
+ make_target("${target_name}" "${target_type}")
+ foreach (property expected alias IN ZIP_LISTS expected_properties expected_values expected_alias)
+ string(REPLACE "<SEMI>" ";" expected "${expected}")
+ check_property("${target_name}" "${property}" "${expected}")
+ if (NOT target_type STREQUAL "CUSTOM")
+ if (alias STREQUAL "<SAME>")
+ check_property("alias::${target_name}" "${property}" "${expected}")
+ elseif (alias STREQUAL "<UNSET>")
+ check_property("alias::${target_name}" "${property}" "<UNSET>")
+ else ()
+ message(FATAL_ERROR
+ "Invalid `alias` entry for property '${property}': '${alias}'")
+ endif ()
+ endif ()
+ endforeach ()
+ endforeach ()
+
+ foreach (target_type IN LISTS "not_${applied_types}")
+ set(target_name "${RunCMake_TEST}${iteration}-${target_type}-unset")
+ if (with_defaults)
+ string(APPEND target_name "-defaults")
+ endif ()
+ make_target("${target_name}" "${target_type}")
+ foreach (property IN LISTS expected_properties)
+ check_property("${target_name}" "${property}" "<UNSET>")
+ if (NOT target_type STREQUAL "CUSTOM")
+ check_property("alias::${target_name}" "${property}" "<UNSET>")
+ endif ()
+ endforeach ()
+ endforeach ()
+endfunction ()