summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/cpack_gen/freebsd.rst4
-rw-r--r--Help/prop_sf/COMPILE_FLAGS.rst7
-rw-r--r--Help/prop_sf/COMPILE_OPTIONS.rst7
-rw-r--r--Help/prop_tgt/COMPILE_OPTIONS.rst10
-rw-r--r--Help/prop_tgt/IMPORTED_OBJECTS.rst22
-rw-r--r--Help/release/dev/compile-options-order.rst7
-rw-r--r--Help/variable/CMAKE_CONFIGURATION_TYPES.rst6
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS.rst5
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst7
-rw-r--r--Modules/FindOpenSSL.cmake4
-rw-r--r--Modules/FindPkgConfig.cmake4
-rw-r--r--Modules/Internal/CPack/CPackDeb.cmake2
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx10
-rw-r--r--Tests/CMakeLists.txt5
-rw-r--r--Tests/CompileOptions/CMakeLists.txt28
-rw-r--r--Tests/CompileOptions/main.cpp18
-rw-r--r--Tests/RunCMake/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_empty_target.cmake17
-rw-r--r--Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/FindPkgConfig/pc-empty/lib/pkgconfig/empty.pc5
-rw-r--r--Tests/RunCMake/target_compile_options/Order-build-stdout.txt3
-rw-r--r--Tests/RunCMake/target_compile_options/Order.cmake19
-rw-r--r--Tests/RunCMake/target_compile_options/RunCMakeTest.cmake13
-rw-r--r--Tests/RunCMake/target_compile_options/order.c7
25 files changed, 178 insertions, 40 deletions
diff --git a/Help/cpack_gen/freebsd.rst b/Help/cpack_gen/freebsd.rst
index 2c93569..f429bc5 100644
--- a/Help/cpack_gen/freebsd.rst
+++ b/Help/cpack_gen/freebsd.rst
@@ -74,7 +74,7 @@ the RPM information (e.g. package license).
* Default:
- :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` (this may be set already
- for Debian packaging, so we may as well re-use it).
+ for Debian packaging, so it is used as a fallback).
.. variable:: CPACK_FREEBSD_PACKAGE_WWW
@@ -87,7 +87,7 @@ the RPM information (e.g. package license).
- :variable:`CMAKE_PROJECT_HOMEPAGE_URL`, or if that is not set,
:variable:`CPACK_DEBIAN_PACKAGE_HOMEPAGE` (this may be set already
- for Debian packaging, so we may as well re-use it).
+ for Debian packaging, so it is used as a fallback).
.. versionadded:: 3.12
The ``CMAKE_PROJECT_HOMEPAGE_URL`` variable.
diff --git a/Help/prop_sf/COMPILE_FLAGS.rst b/Help/prop_sf/COMPILE_FLAGS.rst
index c211b89..eefe7bf 100644
--- a/Help/prop_sf/COMPILE_FLAGS.rst
+++ b/Help/prop_sf/COMPILE_FLAGS.rst
@@ -4,8 +4,11 @@ COMPILE_FLAGS
Additional flags to be added when compiling this source file.
The ``COMPILE_FLAGS`` property, managed as a string, sets additional compiler
-flags used to build source files. Use :prop_sf:`COMPILE_DEFINITIONS` to pass
-additional preprocessor definitions.
+flags used that will be added to the list of compile flags when this source
+file builds. The flags will be added after target-wide flags (except in
+some cases not supported by the :generator:`Visual Studio 9 2008` generator).
+
+Use :prop_sf:`COMPILE_DEFINITIONS` to pass additional preprocessor definitions.
Contents of ``COMPILE_FLAGS`` may use "generator expressions"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
diff --git a/Help/prop_sf/COMPILE_OPTIONS.rst b/Help/prop_sf/COMPILE_OPTIONS.rst
index a694c3e..84c543a 100644
--- a/Help/prop_sf/COMPILE_OPTIONS.rst
+++ b/Help/prop_sf/COMPILE_OPTIONS.rst
@@ -5,9 +5,10 @@ COMPILE_OPTIONS
List of additional options to pass to the compiler.
-This property holds a :ref:`semicolon-separated list <CMake Language Lists>` of options
-and will be added to the list of compile flags when this
-source file builds.
+This property holds a :ref:`semicolon-separated list <CMake Language Lists>`
+of options and will be added to the list of compile flags when this source
+file builds. The options will be added after target-wide options (except in
+some cases not supported by the :generator:`Visual Studio 9 2008` generator).
Contents of ``COMPILE_OPTIONS`` may use "generator expressions" with the
syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual
diff --git a/Help/prop_tgt/COMPILE_OPTIONS.rst b/Help/prop_tgt/COMPILE_OPTIONS.rst
index 4bc190a..0fd6aac 100644
--- a/Help/prop_tgt/COMPILE_OPTIONS.rst
+++ b/Help/prop_tgt/COMPILE_OPTIONS.rst
@@ -3,9 +3,13 @@ COMPILE_OPTIONS
List of options to pass to the compiler.
-This property holds a :ref:`semicolon-separated list <CMake Language Lists>` of options
-specified so far for its target. Use the :command:`target_compile_options`
-command to append more options.
+This property holds a :ref:`semicolon-separated list <CMake Language Lists>`
+of options specified so far for its target. Use the
+:command:`target_compile_options` command to append more options.
+The options will be added after after flags in the
+:variable:`CMAKE_<LANG>_FLAGS` and :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>`
+variables, but before those propagated from dependencies by the
+:prop_tgt:`INTERFACE_COMPILE_OPTIONS` property.
This property is initialized by the :prop_dir:`COMPILE_OPTIONS` directory
property when a target is created, and is used by the generators to set
diff --git a/Help/prop_tgt/IMPORTED_OBJECTS.rst b/Help/prop_tgt/IMPORTED_OBJECTS.rst
index f3577eb..d71c219 100644
--- a/Help/prop_tgt/IMPORTED_OBJECTS.rst
+++ b/Help/prop_tgt/IMPORTED_OBJECTS.rst
@@ -68,26 +68,24 @@ architecture:
# /path/to/somewhere/objects-iphonesimulator/x86_64/func.o
In some cases, you may want to have configuration-specific object files
-as well. The :variable:`CMAKE_CFG_INTDIR` variable can be a convenient
-way of capturing this in combination with the SDK:
+as well. The ``$(CONFIGURATION)`` Xcode variable is often used for this and
+can be used in conjunction with the others mentioned above:
.. code-block:: cmake
add_library(someObjs OBJECT IMPORTED)
set_property(TARGET someObjs PROPERTY IMPORTED_OBJECTS
- "/path/to/somewhere/${CMAKE_CFG_INTDIR}/$(CURRENT_ARCH)/func.o"
+ "/path/to/somewhere/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/$(CURRENT_ARCH)/func.o"
)
# Example paths:
# /path/to/somewhere/Release-iphoneos/arm64/func.o
# /path/to/somewhere/Debug-iphonesimulator/x86_64/func.o
-When any Xcode variable or :variable:`CMAKE_CFG_INTDIR` is used, CMake is
-not able to fully evaluate the path(s) at configure time. One consequence
-of this is that the configuration-specific
-:prop_tgt:`IMPORTED_OBJECTS_<CONFIG>` properties cannot be used, since
-CMake cannot determine whether an object file exists at a particular
-``<CONFIG>`` location. The ``IMPORTED_OBJECTS`` property must be used for
-these situations and the configuration-specific aspects of the path must be
-handled by using :variable:`CMAKE_CFG_INTDIR` or with another Xcode variable
-``$(CONFIGURATION)``.
+When any Xcode variable is used, CMake is not able to fully evaluate the
+path(s) at configure time. One consequence of this is that the
+configuration-specific :prop_tgt:`IMPORTED_OBJECTS_<CONFIG>` properties cannot
+be used, since CMake cannot determine whether an object file exists at a
+particular ``<CONFIG>`` location. The ``IMPORTED_OBJECTS`` property must be
+used for these situations and the configuration-specific aspects of the path
+should be handled by the ``$(CONFIGURATION)`` Xcode variable.
diff --git a/Help/release/dev/compile-options-order.rst b/Help/release/dev/compile-options-order.rst
new file mode 100644
index 0000000..2e182cd
--- /dev/null
+++ b/Help/release/dev/compile-options-order.rst
@@ -0,0 +1,7 @@
+compile-options-order
+---------------------
+
+* The :ref:`Visual Studio Generators` for VS 2010 and above now place
+ per-source preprocessor definitions after target-wide preprocssor
+ definitions. This makes VS consistent with the :ref:`Ninja Generators`
+ and the :ref:`Makefile Generators`.
diff --git a/Help/variable/CMAKE_CONFIGURATION_TYPES.rst b/Help/variable/CMAKE_CONFIGURATION_TYPES.rst
index 34e99eb..8fcc798 100644
--- a/Help/variable/CMAKE_CONFIGURATION_TYPES.rst
+++ b/Help/variable/CMAKE_CONFIGURATION_TYPES.rst
@@ -6,5 +6,7 @@ Specifies the available build types on multi-config generators.
This specifies what build types (configurations) will be available
such as ``Debug``, ``Release``, ``RelWithDebInfo`` etc. This has reasonable
defaults on most platforms, but can be extended to provide other build
-types. See also :variable:`CMAKE_BUILD_TYPE` for details of managing
-configuration data, and :variable:`CMAKE_CFG_INTDIR`.
+types.
+
+See :variable:`CMAKE_BUILD_TYPE` for specifying the configuration with
+single-config generators.
diff --git a/Help/variable/CMAKE_LANG_FLAGS.rst b/Help/variable/CMAKE_LANG_FLAGS.rst
index 11864f8..2784397 100644
--- a/Help/variable/CMAKE_LANG_FLAGS.rst
+++ b/Help/variable/CMAKE_LANG_FLAGS.rst
@@ -18,3 +18,8 @@ This is initialized for each language from environment variables:
This value is a command-line string fragment. Therefore, multiple options
should be separated by spaces, and options with spaces should be quoted.
+
+The flags in this variable will be passed to the compiler before those
+in the per-configuration :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variant,
+and before flags added by the :command:`add_compile_options` or
+:command:`target_compile_options` commands.
diff --git a/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst b/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst
index 628b62b..f0900fd 100644
--- a/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst
+++ b/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst
@@ -1,6 +1,9 @@
CMAKE_<LANG>_FLAGS_<CONFIG>
---------------------------
-.. versionadded:: 3.11
-
Flags for language ``<LANG>`` when building for the ``<CONFIG>`` configuration.
+
+The flags in this variable will be passed to the compiler after those
+in the :variable:`CMAKE_<LANG>_FLAGS` variable, but before flags added
+by the :command:`add_compile_options` or :command:`target_compile_options`
+commands.
diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake
index b1afa5f..8474e05 100644
--- a/Modules/FindOpenSSL.cmake
+++ b/Modules/FindOpenSSL.cmake
@@ -123,6 +123,10 @@ function(_OpenSSL_target_add_dependencies target)
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads )
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS} )
endif()
+ if(WIN32 AND OPENSSL_USE_STATIC_LIBS)
+ set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ws2_32 )
+ set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES crypt32 )
+ endif()
endfunction()
if (UNIX)
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index 38c8da7..3bc9dba 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -265,9 +265,7 @@ endfunction()
# create an imported target from all the information returned by pkg-config
function(_pkg_create_imp_target _prefix _imp_target_global)
- # only create the target if it is linkable, i.e. no executables
- if (NOT TARGET PkgConfig::${_prefix}
- AND ( ${_prefix}_INCLUDE_DIRS OR ${_prefix}_LINK_LIBRARIES OR ${_prefix}_LDFLAGS_OTHER OR ${_prefix}_CFLAGS_OTHER ))
+ if (NOT TARGET PkgConfig::${_prefix})
if(${_imp_target_global})
set(_global_opt "GLOBAL")
else()
diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake
index 2ef0489..2ceab10 100644
--- a/Modules/Internal/CPack/CPackDeb.cmake
+++ b/Modules/Internal/CPack/CPackDeb.cmake
@@ -557,7 +557,7 @@ function(cpack_deb_prepare_package_vars)
string(APPEND _description_failure_message
" or CPACK_DEBIAN_${_local_component_name}_DESCRIPTION")
endif()
- message(FATAL_ERROR _description_failure_message)
+ message(FATAL_ERROR "${_description_failure_message}")
endif()
# Ok, description has set. According to the `Debian Policy Manual`_ the first
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 3fd94d6..7915a9c 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 20)
-set(CMake_VERSION_PATCH 20210607)
+set(CMake_VERSION_PATCH 20210608)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 937b4ce..505d58a 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -418,7 +418,9 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions(
}
std::ostringstream oss;
- const char* sep = "";
+ if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {
+ oss << "%(" << tag << ")";
+ }
std::vector<std::string>::const_iterator de =
cmRemoveDuplicates(this->Defines);
for (std::string const& di : cmMakeRange(this->Defines.cbegin(), de)) {
@@ -437,11 +439,7 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions(
}
}
// Store the flag in the project file.
- oss << sep << define;
- sep = ";";
- }
- if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {
- oss << ";%(" << tag << ")";
+ oss << ';' << define;
}
this->OutputFlag(fout, indent, tag, oss.str());
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 38b4301..331f637 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -489,6 +489,11 @@ if(BUILD_TESTING)
if(CMAKE_Fortran_COMPILER)
set(CompileOptions_BUILD_OPTIONS -DTEST_FORTRAN=1)
endif()
+ if(_isMultiConfig)
+ set(CompileOptions_CTEST_OPTIONS --build-config $<CONFIGURATION>)
+ else()
+ set(CompileOptions_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=$<CONFIGURATION>)
+ endif()
ADD_TEST_MACRO(CompileOptions CompileOptions)
ADD_TEST_MACRO(CompatibleInterface CompatibleInterface)
ADD_TEST_MACRO(AliasTarget AliasTarget)
diff --git a/Tests/CompileOptions/CMakeLists.txt b/Tests/CompileOptions/CMakeLists.txt
index cd6cacd..96bafea 100644
--- a/Tests/CompileOptions/CMakeLists.txt
+++ b/Tests/CompileOptions/CMakeLists.txt
@@ -1,5 +1,11 @@
-cmake_minimum_required(VERSION 2.8.12)
-
+cmake_minimum_required(VERSION 3.0)
+if(POLICY CMP0092)
+ cmake_policy(SET CMP0092 NEW)
+endif()
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(NOT _isMultiConfig AND NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build" FORCE)
+endif()
project(CompileOptions)
add_library(testlib other.cpp)
@@ -49,6 +55,24 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|Borland|Embarcadero" AND NOT "${CMAK
)
endif()
+if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|AppleClang|MSVC)$")
+ target_compile_definitions(CompileOptions PRIVATE "DO_FLAG_TESTS")
+ if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|AppleClang)$")
+ string(APPEND CMAKE_CXX_FLAGS " -w")
+ endif()
+ string(APPEND CMAKE_CXX_FLAGS " -DFLAG_A=1 -DFLAG_B=1")
+ string(APPEND CMAKE_CXX_FLAGS_DEBUG " -DFLAG_A=2 -DFLAG_C=1")
+ string(APPEND CMAKE_CXX_FLAGS_RELEASE " -DFLAG_A=2 -DFLAG_C=1")
+ string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -DFLAG_A=2 -DFLAG_C=1")
+ string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL " -DFLAG_A=2 -DFLAG_C=1")
+ set_property(TARGET CompileOptions APPEND PROPERTY COMPILE_OPTIONS "-DFLAG_B=2" "-DFLAG_C=2" "-DFLAG_D=1")
+ set_property(TARGET testlib APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "-DFLAG_D=2")
+ if(NOT CMAKE_GENERATOR MATCHES "^Visual Studio 9")
+ set_property(TARGET testlib APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "-DFLAG_E=1")
+ set_property(SOURCE main.cpp PROPERTY COMPILE_OPTIONS "-DFLAG_E=2")
+ endif()
+endif()
+
target_link_libraries(CompileOptions testlib)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
diff --git a/Tests/CompileOptions/main.cpp b/Tests/CompileOptions/main.cpp
index ebc1017..23ce197 100644
--- a/Tests/CompileOptions/main.cpp
+++ b/Tests/CompileOptions/main.cpp
@@ -37,6 +37,24 @@
# endif
#endif
+#ifdef DO_FLAG_TESTS
+# if FLAG_A != 2
+# error "FLAG_A is not 2"
+# endif
+# if FLAG_B != 2
+# error "FLAG_B is not 2"
+# endif
+# if FLAG_C != 2
+# error "FLAG_C is not 2"
+# endif
+# if FLAG_D != 2
+# error "FLAG_D is not 2"
+# endif
+# if defined(FLAG_E) && FLAG_E != 2
+# error "FLAG_E is not 2"
+# endif
+#endif
+
#include <string.h>
int main()
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index d02d7a2..670abbc 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -595,7 +595,10 @@ set_property(TEST RunCMake.target_link_options APPEND
add_RunCMake_test(target_compile_definitions)
add_RunCMake_test(target_compile_features)
-add_RunCMake_test(target_compile_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID})
+add_RunCMake_test(target_compile_options
+ -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}
+ -DCMAKE_C_SIMULATE_ID=${CMAKE_C_SIMULATE_ID}
+ )
add_RunCMake_test(target_include_directories)
add_RunCMake_test(target_sources)
add_RunCMake_test(CheckCompilerFlag -DCMake_TEST_CUDA=${CMake_TEST_CUDA}
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_empty_target.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_empty_target.cmake
new file mode 100644
index 0000000..cb3dd69
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_empty_target.cmake
@@ -0,0 +1,17 @@
+# Prepare environment to reuse empty.pc
+file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-empty/lib/pkgconfig" PC_PATH)
+if(UNIX)
+ string(REPLACE "\\ " " " PC_PATH "${PC_PATH}")
+endif()
+set(ENV{PKG_CONFIG_PATH} "${PC_PATH}")
+
+find_package(PkgConfig REQUIRED)
+pkg_search_module(Empty REQUIRED empty IMPORTED_TARGET)
+
+if(NOT Empty_MODULE_NAME STREQUAL "empty")
+ message(FATAL_ERROR "Wrong value for Empty_MODULE_NAME. Expected: empty, got: ${Empty_MODULE_NAME}")
+endif()
+
+if(NOT TARGET PkgConfig::Empty)
+ message(FATAL_ERROR "PkgConfig::Empty target not created")
+endif()
diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
index 4e6eef6..e7f008c 100644
--- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
@@ -29,4 +29,5 @@ if (PKG_CONFIG_FOUND)
run_cmake(FindPkgConfig_IMPORTED_TARGET)
run_cmake(FindPkgConfig_VERSION_OPERATORS)
run_cmake(FindPkgConfig_GET_MATCHING_MODULE_NAME)
+ run_cmake(FindPkgConfig_empty_target)
endif ()
diff --git a/Tests/RunCMake/FindPkgConfig/pc-empty/lib/pkgconfig/empty.pc b/Tests/RunCMake/FindPkgConfig/pc-empty/lib/pkgconfig/empty.pc
new file mode 100644
index 0000000..954c5f8
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-empty/lib/pkgconfig/empty.pc
@@ -0,0 +1,5 @@
+Name: Empty
+Description: Dummy package to test empty target
+Version: 1.0
+Libs:
+Cflags:
diff --git a/Tests/RunCMake/target_compile_options/Order-build-stdout.txt b/Tests/RunCMake/target_compile_options/Order-build-stdout.txt
new file mode 100644
index 0000000..c210ff2
--- /dev/null
+++ b/Tests/RunCMake/target_compile_options/Order-build-stdout.txt
@@ -0,0 +1,3 @@
+-w +-O +-O0 [^
+]*-O1 +-O2 +-O3 [^
+]*CMakeFiles[\/]order\.dir[\/](Custom[\/])?order\.c\.o
diff --git a/Tests/RunCMake/target_compile_options/Order.cmake b/Tests/RunCMake/target_compile_options/Order.cmake
new file mode 100644
index 0000000..3d59b16
--- /dev/null
+++ b/Tests/RunCMake/target_compile_options/Order.cmake
@@ -0,0 +1,19 @@
+get_property (isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(isMultiConfig)
+ set(CMAKE_CONFIGURATION_TYPES "Custom" CACHE STRING "" FORCE)
+else()
+ set(CMAKE_BUILD_TYPE "Custom" CACHE STRING "" FORCE)
+endif()
+enable_language(C)
+
+string(APPEND CMAKE_C_FLAGS " -w -O")
+set(CMAKE_C_FLAGS_CUSTOM "-O0")
+
+add_executable(order order.c)
+set_property(TARGET order APPEND PROPERTY COMPILE_OPTIONS -O1)
+
+add_library(iface INTERFACE)
+set_property(TARGET iface APPEND PROPERTY INTERFACE_COMPILE_OPTIONS -O2)
+target_link_libraries(order PRIVATE iface)
+
+set_property(SOURCE order.c PROPERTY COMPILE_OPTIONS -O3)
diff --git a/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake b/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake
index 9f51a9a..806ae79 100644
--- a/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake
@@ -19,3 +19,16 @@ if (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
run_cmake_target(CMP0101-BEFORE_keyword OLD CMP0101_OLD)
run_cmake_target(CMP0101-BEFORE_keyword NEW CMP0101_NEW)
endif()
+
+function(run_Order)
+ run_cmake_with_options(Order)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Order-build)
+ set(RunCMake_TEST_OUTPUT_MERGE 1)
+ run_cmake_command(Order-build ${CMAKE_COMMAND} --build . --verbose --config Custom)
+endfunction()
+if(RunCMake_GENERATOR MATCHES "Ninja|Make" AND
+ CMAKE_C_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$" AND
+ NOT CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
+ run_Order()
+endif()
diff --git a/Tests/RunCMake/target_compile_options/order.c b/Tests/RunCMake/target_compile_options/order.c
new file mode 100644
index 0000000..1bd81ea
--- /dev/null
+++ b/Tests/RunCMake/target_compile_options/order.c
@@ -0,0 +1,7 @@
+#ifndef __OPTIMIZE__
+# error "Optimizations not enabled!"
+#endif
+int main(void)
+{
+ return 0;
+}