diff options
35 files changed, 429 insertions, 48 deletions
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 9066d97..e0dbdeb 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -47,6 +47,8 @@ Variables that Provide Information /variable/CMAKE_JOB_POOL_COMPILE /variable/CMAKE_JOB_POOL_LINK /variable/CMAKE_LINK_LIBRARY_SUFFIX + /variable/CMAKE_LINK_SEARCH_END_STATIC + /variable/CMAKE_LINK_SEARCH_START_STATIC /variable/CMAKE_MAJOR_VERSION /variable/CMAKE_MAKE_PROGRAM /variable/CMAKE_MATCH_COUNT diff --git a/Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst index 29991eb..12f8bb7 100644 --- a/Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG.rst @@ -11,3 +11,6 @@ per-configuration subdirectory to the specified directory. This property is initialized by the value of the :variable:`CMAKE_ARCHIVE_OUTPUT_DIRECTORY_<CONFIG>` variable if it is set when a target is created. + +Contents of ``ARCHIVE_OUTPUT_DIRECTORY_<CONFIG>`` may use +:manual:`generator expressions <cmake-generator-expressions(7)>`. diff --git a/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst index 6fc0142..28dd404 100644 --- a/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst @@ -11,3 +11,6 @@ per-configuration subdirectory to the specified directory. This property is initialized by the value of the :variable:`CMAKE_LIBRARY_OUTPUT_DIRECTORY_<CONFIG>` variable if it is set when a target is created. + +Contents of ``LIBRARY_OUTPUT_DIRECTORY_<CONFIG>`` may use +:manual:`generator expressions <cmake-generator-expressions(7)>`. diff --git a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst b/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst index fe105bd..cf9c871 100644 --- a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst +++ b/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst @@ -10,5 +10,9 @@ paths are not known or (in some cases) are in implicit link directories for the platform. By default CMake adds an option at the end of the library list (if necessary) to set the linker search type back to its starting type. This property switches the final linker -search type to -Bstatic regardless of how it started. See also -LINK_SEARCH_START_STATIC. +search type to -Bstatic regardless of how it started. + +This property is initialized by the value of the variable +CMAKE_LINK_SEARCH_END_STATIC if it is set when a target is created. + +See also LINK_SEARCH_START_STATIC. diff --git a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst b/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst index ca899fe..2e0f9bd 100644 --- a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst +++ b/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst @@ -11,4 +11,9 @@ directories for the platform. By default the linker search type is assumed to be -Bdynamic at the beginning of the library list. This property switches the assumption to -Bstatic. It is intended for use when linking an executable statically (e.g. with the GNU -static -option). See also LINK_SEARCH_END_STATIC. +option). + +This property is initialized by the value of the variable +CMAKE_LINK_SEARCH_START_STATIC if it is set when a target is created. + +See also LINK_SEARCH_END_STATIC. diff --git a/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst index c100346..94fb277 100644 --- a/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst @@ -11,3 +11,6 @@ per-configuration subdirectory to the specified directory. This property is initialized by the value of the :variable:`CMAKE_RUNTIME_OUTPUT_DIRECTORY_<CONFIG>` variable if it is set when a target is created. + +Contents of ``RUNTIME_OUTPUT_DIRECTORY_<CONFIG>`` may use +:manual:`generator expressions <cmake-generator-expressions(7)>`. diff --git a/Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt b/Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt index 0b3d31c..3ae5448 100644 --- a/Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt +++ b/Help/prop_tgt/XXX_OUTPUT_DIRECTORY.txt @@ -1,8 +1,11 @@ Output directory in which to build |XXX| target files. This property specifies the directory into which |xxx| target files -should be built. Multi-configuration generators (VS, Xcode) append a -per-configuration subdirectory to the specified directory. +should be built. The property value may use +:manual:`generator expressions <cmake-generator-expressions(7)>`. +Multi-configuration generators (VS, Xcode) append a per-configuration +subdirectory to the specified directory unless a generator expression +is used. This property is initialized by the value of the variable |CMAKE_XXX_OUTPUT_DIRECTORY| if it is set when a target is created. diff --git a/Help/release/dev/OUTPUT_DIRECTORY-genex.rst b/Help/release/dev/OUTPUT_DIRECTORY-genex.rst new file mode 100644 index 0000000..8b839c0 --- /dev/null +++ b/Help/release/dev/OUTPUT_DIRECTORY-genex.rst @@ -0,0 +1,7 @@ +OUTPUT_DIRECTORY-genex +---------------------- + +* The :prop_tgt:`ARCHIVE_OUTPUT_DIRECTORY`, + :prop_tgt:`LIBRARY_OUTPUT_DIRECTORY`, and + :prop_tgt:`RUNTIME_OUTPUT_DIRECTORY` target properties learned to + support :manual:`generator expressions <cmake-generator-expressions(7)>`. diff --git a/Help/release/dev/add-link-search-static-properties-defaults.rst b/Help/release/dev/add-link-search-static-properties-defaults.rst new file mode 100644 index 0000000..98dda30 --- /dev/null +++ b/Help/release/dev/add-link-search-static-properties-defaults.rst @@ -0,0 +1,9 @@ +add-link-search-static-properties-defaults +------------------------------------------ + +* New :variable:`CMAKE_LINK_SEARCH_START_STATIC` and + :variable:`CMAKE_LINK_SEARCH_END_STATIC` variables were + introduced to initialize the + :prop_tgt:`LINK_SEARCH_START_STATIC` and + :prop_tgt:`LINK_SEARCH_END_STATIC` target properties, + respectively. diff --git a/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst new file mode 100644 index 0000000..8a9951d --- /dev/null +++ b/Help/variable/CMAKE_LINK_SEARCH_END_STATIC.rst @@ -0,0 +1,18 @@ +CMAKE_LINK_SEARCH_END_STATIC +---------------------------- + +End a link line such that static system libraries are used. + +Some linkers support switches such as -Bstatic and -Bdynamic to +determine whether to use static or shared libraries for -lXXX options. +CMake uses these options to set the link type for libraries whose full +paths are not known or (in some cases) are in implicit link +directories for the platform. By default CMake adds an option at the +end of the library list (if necessary) to set the linker search type +back to its starting type. This property switches the final linker +search type to -Bstatic regardless of how it started. + +This variable is used to initialize the target property +LINK_SEARCH_END_STATIC for all targets. + +See also CMAKE_LINK_SEARCH_START_STATIC. diff --git a/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst new file mode 100644 index 0000000..715db4b --- /dev/null +++ b/Help/variable/CMAKE_LINK_SEARCH_START_STATIC.rst @@ -0,0 +1,19 @@ +CMAKE_LINK_SEARCH_START_STATIC +------------------------------ + +Assume the linker looks for static libraries by default. + +Some linkers support switches such as -Bstatic and -Bdynamic to +determine whether to use static or shared libraries for -lXXX options. +CMake uses these options to set the link type for libraries whose full +paths are not known or (in some cases) are in implicit link +directories for the platform. By default the linker search type is +assumed to be -Bdynamic at the beginning of the library list. This +property switches the assumption to -Bstatic. It is intended for use +when linking an executable statically (e.g. with the GNU -static +option). + +This variable is used to initialize the target property +LINK_SEARCH_START_STATIC for all targets. + +See also CMAKE_LINK_SEARCH_END_STATIC. diff --git a/Modules/Compiler/GNU-DetermineCompiler.cmake b/Modules/Compiler/GNU-DetermineCompiler.cmake index 261f148..6ddc566 100644 --- a/Modules/Compiler/GNU-DetermineCompiler.cmake +++ b/Modules/Compiler/GNU-DetermineCompiler.cmake @@ -3,7 +3,9 @@ set(_compiler_id_pp_test "defined(__GNUC__)") set(_compiler_id_version_compute " # define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__GNUC__) -# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__GNUC_MINOR__) +# if defined(__GNUC_MINOR__) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__GNUC_MINOR__) +# endif # if defined(__GNUC_PATCHLEVEL__) # define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__GNUC_PATCHLEVEL__) # endif") diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 7545d94..434ef58 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -2,26 +2,40 @@ # FindOpenSSL # ----------- # -# Try to find the OpenSSL encryption library +# Find the OpenSSL encryption library. # -# Once done this will define +# Imported Targets +# ^^^^^^^^^^^^^^^^ # -# :: +# This module defines the following :prop_tgt:`IMPORTED` targets: # -# OPENSSL_ROOT_DIR - Set this variable to the root installation of OpenSSL +# ``OpenSSL::SSL`` +# The OpenSSL ``ssl`` library, if found. +# ``OpenSSL::Crypto`` +# The OpenSSL ``crypto`` library, if found. # +# Result Variables +# ^^^^^^^^^^^^^^^^ # +# This module will set the following variables in your project: # -# Read-Only variables: +# ``OPENSSL_FOUND`` +# System has the OpenSSL library. +# ``OPENSSL_INCLUDE_DIR`` +# The OpenSSL include directory. +# ``OPENSSL_CRYPTO_LIBRARY`` +# The OpenSSL crypto library. +# ``OPENSSL_SSL_LIBRARY`` +# The OpenSSL SSL library. +# ``OPENSSL_LIBRARIES`` +# All OpenSSL libraries. +# ``OPENSSL_VERSION`` +# This is set to ``$major.$minor.$revision$patch`` (e.g. ``0.9.8s``). # -# :: +# Hints +# ^^^^^ # -# OPENSSL_FOUND - System has the OpenSSL library -# OPENSSL_INCLUDE_DIR - The OpenSSL include directory -# OPENSSL_CRYPTO_LIBRARY - The OpenSSL crypto library -# OPENSSL_SSL_LIBRARY - The OpenSSL SSL library -# OPENSSL_LIBRARIES - All OpenSSL libraries -# OPENSSL_VERSION - This is set to $major.$minor.$revision$patch (eg. 0.9.8s) +# Set ``OPENSSL_ROOT_DIR`` to the root directory of an OpenSSL installation. #============================================================================= # Copyright 2006-2009 Kitware, Inc. @@ -337,3 +351,66 @@ else () endif () mark_as_advanced(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES) + +if(OPENSSL_FOUND) + if(NOT TARGET OpenSSL::Crypto AND + (EXISTS "${OPENSSL_CRYPTO_LIBRARY}" OR + EXISTS "${LIB_EAY_LIBRARY_DEBUG}" OR + EXISTS "${LIB_EAY_LIBRARY_RELEASE}") + ) + add_library(OpenSSL::Crypto UNKNOWN IMPORTED) + set_target_properties(OpenSSL::Crypto PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}") + if(EXISTS "${OPENSSL_CRYPTO_LIBRARY}") + set_target_properties(OpenSSL::Crypto PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${OPENSSL_CRYPTO_LIBRARY}") + endif() + if(EXISTS "${LIB_EAY_LIBRARY_DEBUG}") + set_property(TARGET OpenSSL::Crypto APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(OpenSSL::Crypto PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" + IMPORTED_LOCATION_DEBUG "${LIB_EAY_LIBRARY_DEBUG}") + endif() + if(EXISTS "${LIB_EAY_LIBRARY_RELEASE}") + set_property(TARGET OpenSSL::Crypto APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(OpenSSL::Crypto PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" + IMPORTED_LOCATION_RELEASE "${LIB_EAY_LIBRARY_RELEASE}") + endif() + endif() + if(NOT TARGET OpenSSL::SSL AND + (EXISTS "${OPENSSL_SSL_LIBRARY}" OR + EXISTS "${SSL_EAY_LIBRARY_DEBUG}" OR + EXISTS "${SSL_EAY_LIBRARY_RELEASE}") + ) + add_library(OpenSSL::SSL UNKNOWN IMPORTED) + set_target_properties(OpenSSL::SSL PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}") + if(EXISTS "${OPENSSL_SSL_LIBRARY}") + set_target_properties(OpenSSL::SSL PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${OPENSSL_SSL_LIBRARY}") + endif() + if(EXISTS "${SSL_EAY_LIBRARY_DEBUG}") + set_property(TARGET OpenSSL::SSL APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(OpenSSL::SSL PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" + IMPORTED_LOCATION_DEBUG "${SSL_EAY_LIBRARY_DEBUG}") + endif() + if(EXISTS "${SSL_EAY_LIBRARY_RELEASE}") + set_property(TARGET OpenSSL::SSL APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(OpenSSL::SSL PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" + IMPORTED_LOCATION_RELEASE "${SSL_EAY_LIBRARY_RELEASE}") + endif() + if(TARGET OpenSSL::Crypto) + set_target_properties(OpenSSL::SSL PROPERTIES + INTERFACE_LINK_LIBRARIES OpenSSL::Crypto) + endif() + endif() +endif() diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 53c17f1..526a62e 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -192,9 +192,9 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma # give out status message telling checked module if (NOT ${_is_silent}) if (_pkg_check_modules_cnt EQUAL 1) - message(STATUS "checking for module '${_pkg_check_modules_list}'") + message(STATUS "Checking for module '${_pkg_check_modules_list}'") else() - message(STATUS "checking for modules '${_pkg_check_modules_list}'") + message(STATUS "Checking for modules '${_pkg_check_modules_list}'") endif() endif() @@ -327,7 +327,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma # evaluate result and tell failures if (_pkgconfig_retval) if(NOT ${_is_silent}) - message(STATUS " package '${_pkg_check_modules_pkg}' not found") + message(STATUS " Package '${_pkg_check_modules_pkg}' not found") endif() set(_pkg_check_modules_failed 1) @@ -361,7 +361,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" LIBDIR "" --variable=libdir ) if (NOT ${_is_silent}) - message(STATUS " found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}") + message(STATUS " Found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}") endif () endforeach() @@ -529,7 +529,7 @@ macro(pkg_search_module _prefix _module0) _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN}) if (NOT ${_pkg_is_silent}) - message(STATUS "checking for one of the modules '${_pkg_modules_alt}'") + message(STATUS "Checking for one of the modules '${_pkg_modules_alt}'") endif () # iterate through all modules and stop at the first working one. diff --git a/Modules/Platform/HP-UX.cmake b/Modules/Platform/HP-UX.cmake index 65cc731..581301b 100644 --- a/Modules/Platform/HP-UX.cmake +++ b/Modules/Platform/HP-UX.cmake @@ -33,18 +33,11 @@ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES # Initialize C and CXX link type selection flags. These flags are # used when building a shared library, shared module, or executable # that links to other libraries to select whether to use the static or -# shared versions of the libraries. Note that C modules and shared -# libs are built using ld directly so we leave off the "-Wl," portion. -foreach(type SHARED_LIBRARY SHARED_MODULE) - set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-a archive") - set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-a default") -endforeach() -foreach(type EXE) - set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-a,archive") - set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-a,default") -endforeach() +# shared versions of the libraries. foreach(type SHARED_LIBRARY SHARED_MODULE EXE) - set(CMAKE_${type}_LINK_STATIC_CXX_FLAGS "-Wl,-a,archive") - set(CMAKE_${type}_LINK_DYNAMIC_CXX_FLAGS "-Wl,-a,default") + foreach(lang C CXX) + set(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS "-Wl,-a,archive") + set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-a,default") + endforeach() endforeach() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 04813b0..24b8f24 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150812) +set(CMake_VERSION_PATCH 20150817) #set(CMake_VERSION_RC 1) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c16472e..6ba0eed 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -522,9 +522,10 @@ bool cmComputeLinkInformation::Compute() // libraries are found. const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); - if(cmSystemTools::IsOn(lss)) + if(lss) { - this->SetCurrentLinkType(LinkStatic); + this->SetCurrentLinkType( + cmSystemTools::IsOn(lss) ? LinkStatic : LinkShared); } else { @@ -760,7 +761,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, return; } - cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt); + cmGeneratorTarget *gtgt = 0; // Get a full path to the dependent shared library. // Add it to the runtime path computation so that the target being @@ -862,7 +863,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() const char* lss = this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; - this->CurrentLinkType = this->StartLinkType; + this->CurrentLinkType = LinkUnknown; + this->SetCurrentLinkType(this->StartLinkType); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 316d85c..49b3239 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -66,6 +66,8 @@ struct cmTarget::OutputInfo std::string OutDir; std::string ImpDir; std::string PdbDir; + bool empty() const + { return OutDir.empty() && ImpDir.empty() && PdbDir.empty(); } }; //---------------------------------------------------------------------------- @@ -306,6 +308,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("CXX_STANDARD", 0); this->SetPropertyDefault("CXX_STANDARD_REQUIRED", 0); this->SetPropertyDefault("CXX_EXTENSIONS", 0); + this->SetPropertyDefault("LINK_SEARCH_START_STATIC", 0); + this->SetPropertyDefault("LINK_SEARCH_END_STATIC", 0); } // Collect the set of configuration types. @@ -2602,19 +2606,35 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo( config_upper = cmSystemTools::UpperCase(config); } typedef cmTargetInternals::OutputInfoMapType OutputInfoMapType; - OutputInfoMapType::const_iterator i = + OutputInfoMapType::iterator i = this->Internal->OutputInfoMap.find(config_upper); if(i == this->Internal->OutputInfoMap.end()) { + // Add empty info in map to detect potential recursion. OutputInfo info; + OutputInfoMapType::value_type entry(config_upper, info); + i = this->Internal->OutputInfoMap.insert(entry).first; + + // Compute output directories. this->ComputeOutputDir(config, false, info.OutDir); this->ComputeOutputDir(config, true, info.ImpDir); if(!this->ComputePDBOutputDir("PDB", config, info.PdbDir)) { info.PdbDir = info.OutDir; } - OutputInfoMapType::value_type entry(config_upper, info); - i = this->Internal->OutputInfoMap.insert(entry).first; + + // Now update the previously-prepared map entry. + i->second = info; + } + else if(i->second.empty()) + { + // An empty map entry indicates we have been called recursively + // from the above block. + this->Makefile->GetCMakeInstance()->IssueMessage( + cmake::FATAL_ERROR, + "Target '" + this->GetName() + "' OUTPUT_DIRECTORY depends on itself.", + this->GetBacktrace()); + return 0; } return &i->second; } @@ -3495,7 +3515,10 @@ bool cmTarget::ComputeOutputDir(const std::string& config, if(const char* config_outdir = this->GetProperty(configProp)) { // Use the user-specified per-configuration output directory. - out = config_outdir; + cmGeneratorExpression ge; + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(config_outdir); + out = cge->Evaluate(this->Makefile, config); // Skip per-configuration subdirectory. conf = ""; @@ -3503,7 +3526,17 @@ bool cmTarget::ComputeOutputDir(const std::string& config, else if(const char* outdir = this->GetProperty(propertyName)) { // Use the user-specified output directory. - out = outdir; + cmGeneratorExpression ge; + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(outdir); + out = cge->Evaluate(this->Makefile, config); + + // Skip per-configuration subdirectory if the value contained a + // generator expression. + if (out != outdir) + { + conf = ""; + } } else if(this->GetType() == cmTarget::EXECUTABLE) { diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 5781a9e..35b29bf 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1333,6 +1333,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindJsonCpp) endif() + if(CMake_TEST_FindOpenSSL) + add_subdirectory(FindOpenSSL) + endif() + # Matlab module if(CMake_TEST_FindMatlab) ADD_TEST_MACRO(FindMatlab.basic_checks ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>) diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index df3f178..7fdfaa8 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -105,6 +105,19 @@ target_link_libraries(testLib4 add_executable(testExe3 testExe3.c) set_property(TARGET testExe3 PROPERTY MACOSX_BUNDLE 1) +# Test <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_DIRECTORY[_<CONFIG>] properties with generator expressions +add_executable(testExe4 testExe4.c) +target_link_libraries(testExe4 testExe1lib) +set_property(TARGET testLib7 PROPERTY ARCHIVE_OUTPUT_DIRECTORY_DEBUG testLib7D-$<CONFIG>) +set_property(TARGET testLib7 PROPERTY ARCHIVE_OUTPUT_DIRECTORY_RELEASE testLib7R-$<CONFIG>) +set_property(TARGET testLib7 PROPERTY ARCHIVE_OUTPUT_DIRECTORY testLib7-$<CONFIG>) +set_property(TARGET testLib5 PROPERTY LIBRARY_OUTPUT_DIRECTORY_DEBUG testLib5D-$<CONFIG>) +set_property(TARGET testLib5 PROPERTY LIBRARY_OUTPUT_DIRECTORY_RELEASE testLib5R-$<CONFIG>) +set_property(TARGET testLib5 PROPERTY LIBRARY_OUTPUT_DIRECTORY testLib5-$<CONFIG>) +set_property(TARGET testExe4 PROPERTY RUNTIME_OUTPUT_DIRECTORY_DEBUG testExe4D-$<CONFIG>) +set_property(TARGET testExe4 PROPERTY RUNTIME_OUTPUT_DIRECTORY_RELEASE testExe4R-$<CONFIG>) +set_property(TARGET testExe4 PROPERTY RUNTIME_OUTPUT_DIRECTORY testExe4-$<CONFIG>) + # Test cyclic dependencies. add_library(testLibCycleA STATIC testLibCycleA1.c testLibCycleA2.c testLibCycleA3.c) @@ -450,7 +463,7 @@ install(FILES # Install and export from install tree. install( TARGETS - testExe1 testLib1 testLib2 testExe2 testLib3 testLib4 testExe3 + testExe1 testLib1 testLib2 testExe2 testLib3 testLib4 testExe3 testExe4 testExe2lib testLib4lib testLib4libdbg testLib4libopt testLib6 testLib7 testLibCycleA testLibCycleB @@ -511,7 +524,7 @@ export(TARGETS testExe1 testLib1 testLib2 testLib3 NAMESPACE bld_ FILE ExportBuildTree.cmake ) -export(TARGETS testExe2 testLib4 testLib5 testLib6 testLib7 testExe3 testExe2lib +export(TARGETS testExe2 testLib4 testLib5 testLib6 testLib7 testExe3 testExe4 testExe2lib testLib4lib testLib4libdbg testLib4libopt testLibCycleA testLibCycleB testLibPerConfigDest diff --git a/Tests/ExportImport/Export/testExe4.c b/Tests/ExportImport/Export/testExe4.c new file mode 100644 index 0000000..731057e --- /dev/null +++ b/Tests/ExportImport/Export/testExe4.c @@ -0,0 +1,24 @@ +#include <stdio.h> + +int main(int argc, const char* argv[]) +{ + if(argc < 2) + { + fprintf(stderr, "Must specify output file.\n"); + return 1; + } + { + FILE* f = fopen(argv[1], "w"); + if(f) + { + fprintf(f, "int generated_by_testExe4() { return 0; }\n"); + fclose(f); + } + else + { + fprintf(stderr, "Error writing to %s\n", argv[1]); + return 1; + } + } + return 0; +} diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index a74bad1..0f56495 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -19,11 +19,17 @@ add_custom_command( COMMAND exp_testExe3 ${Import_BINARY_DIR}/exp_generated3.c DEPENDS exp_testExe3 ) +add_custom_command( + OUTPUT ${Import_BINARY_DIR}/exp_generated4.c + COMMAND exp_testExe4 ${Import_BINARY_DIR}/exp_generated4.c + DEPENDS exp_testExe4 + ) add_executable(imp_testExe1 imp_testExe1.c ${Import_BINARY_DIR}/exp_generated.c ${Import_BINARY_DIR}/exp_generated3.c + ${Import_BINARY_DIR}/exp_generated4.c ) # Try linking to a library imported from the install tree. @@ -53,11 +59,17 @@ add_custom_command( COMMAND bld_testExe3 ${Import_BINARY_DIR}/bld_generated3.c DEPENDS bld_testExe3 ) +add_custom_command( + OUTPUT ${Import_BINARY_DIR}/bld_generated4.c + COMMAND bld_testExe4 ${Import_BINARY_DIR}/bld_generated4.c + DEPENDS bld_testExe4 + ) add_executable(imp_testExe1b imp_testExe1.c ${Import_BINARY_DIR}/bld_generated.c ${Import_BINARY_DIR}/bld_generated3.c + ${Import_BINARY_DIR}/bld_generated4.c ) # Try linking to a library imported from the build tree. diff --git a/Tests/ExportImport/Import/A/imp_testExe1.c b/Tests/ExportImport/Import/A/imp_testExe1.c index 56cdd2c..0a74309 100644 --- a/Tests/ExportImport/Import/A/imp_testExe1.c +++ b/Tests/ExportImport/Import/A/imp_testExe1.c @@ -1,5 +1,6 @@ extern int generated_by_testExe1(); extern int generated_by_testExe3(); +extern int generated_by_testExe4(); extern int testLib2(); extern int testLib3(); extern int testLib4(); @@ -24,5 +25,5 @@ int main() return (testLib2() + generated_by_testExe1() + testLib3() + testLib4() + testLib5() + testLib6() + testLib7() + testLibCycleA1() + testLibPerConfigDest() - + generated_by_testExe3() + testLib4lib() + testLib4libcfg()); + + generated_by_testExe3() + generated_by_testExe4() + testLib4lib() + testLib4libcfg()); } diff --git a/Tests/FindOpenSSL/CMakeLists.txt b/Tests/FindOpenSSL/CMakeLists.txt new file mode 100644 index 0000000..66b3fb2 --- /dev/null +++ b/Tests/FindOpenSSL/CMakeLists.txt @@ -0,0 +1,9 @@ +add_test(NAME FindOpenSSL.rand COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindOpenSSL/rand" + "${CMake_BINARY_DIR}/Tests/FindOpenSSL/rand" + ${build_generator_args} + --build-project FindOpenSSL_rand + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V + ) diff --git a/Tests/FindOpenSSL/rand/CMakeLists.txt b/Tests/FindOpenSSL/rand/CMakeLists.txt new file mode 100644 index 0000000..520d5d2 --- /dev/null +++ b/Tests/FindOpenSSL/rand/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.0) +project(FindOpenSSL_rand CXX) +include(CTest) + +find_package(OpenSSL REQUIRED) + +add_executable(tstopensslrand_tgt main.cc) +target_link_libraries(tstopensslrand_tgt OpenSSL::SSL) +add_test(NAME tstopensslrand_tgt COMMAND tstopensslrand_tgt) + +add_executable(tstopensslrand_var main.cc) +target_link_libraries(tstopensslrand_var ${OPENSSL_LIBRARIES}) +target_include_directories(tstopensslrand_var PRIVATE ${OPENSSL_INCLUDE_DIR}) +add_test(NAME tstopensslrand_var COMMAND tstopensslrand_var) diff --git a/Tests/FindOpenSSL/rand/main.cc b/Tests/FindOpenSSL/rand/main.cc new file mode 100644 index 0000000..a5d1ac0 --- /dev/null +++ b/Tests/FindOpenSSL/rand/main.cc @@ -0,0 +1,22 @@ +#include <openssl/rand.h> + +int main() +{ + // return value + int retval = 1; + + // bytes buffer + unsigned char buf[1024]; + + // random bytes + int rezval = RAND_bytes(buf, sizeof(buf)); /* 1 succes, 0 otherwise */ + + // check result + if(rezval == 1) + { + retval = 0; + } + + // return code + return retval; +} diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index cba3941..21fc851 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -25,6 +25,7 @@ run_cmake(COMPILE_LANGUAGE-add_executable) run_cmake(COMPILE_LANGUAGE-add_library) run_cmake(COMPILE_LANGUAGE-add_test) run_cmake(COMPILE_LANGUAGE-unknown-lang) +run_cmake(TARGET_FILE-recursion) run_cmake(ImportedTarget-TARGET_PDB_FILE) if(LINKER_SUPPORTS_PDB) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-stderr.txt new file mode 100644 index 0000000..5b15526 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at TARGET_FILE-recursion.cmake:[0-9]+ \(add_executable\): + Target 'empty1' OUTPUT_DIRECTORY depends on itself. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake new file mode 100644 index 0000000..7633be1 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE-recursion.cmake @@ -0,0 +1,3 @@ +enable_language(C) +add_executable(empty1 empty.c) +set_property(TARGET empty1 PROPERTY RUNTIME_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:empty1>) diff --git a/Tests/RunCMake/set_property/LINK_SEARCH_STATIC.cmake b/Tests/RunCMake/set_property/LINK_SEARCH_STATIC.cmake new file mode 100644 index 0000000..70d2fee --- /dev/null +++ b/Tests/RunCMake/set_property/LINK_SEARCH_STATIC.cmake @@ -0,0 +1,73 @@ +project(LinkSearchStatic) + +set(CMAKE_LINK_SEARCH_START_STATIC ON) +add_executable(LinkSearchStartStaticInit1 LinkStatic.c) +get_target_property(LSSS LinkSearchStartStaticInit1 + LINK_SEARCH_START_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_START_STATIC") +endif() +unset(CMAKE_LINK_SEARCH_START_STATIC) + +add_executable(LinkSearchStartStaticSet1 LinkStatic.c) +set_target_properties(LinkSearchStartStaticSet1 PROPERTIES + LINK_SEARCH_START_STATIC ON) +get_target_property(LSSS LinkSearchStartStaticSet1 + LINK_SEARCH_START_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly set LINK_SEARCH_START_STATIC") +endif() + +set(CMAKE_LINK_SEARCH_START_STATIC OFF) +add_executable(LinkSearchStartStaticInit2 LinkStatic.c) +get_target_property(LSSS LinkSearchStartStaticInit2 + LINK_SEARCH_START_STATIC) +if(LSSS) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_START_STATIC") +endif() +unset(CMAKE_LINK_SEARCH_START_STATIC) + +add_executable(LinkSearchStartStaticSet2 LinkStatic.c) +set_target_properties(LinkSearchStartStaticSet2 PROPERTIES + LINK_SEARCH_START_STATIC OFF) +get_target_property(LSSS LinkSearchStartStaticSet2 + LINK_SEARCH_START_STATIC) +if(LSSS) + message(FATAL_ERROR "Failed to correctly set LINK_SEARCH_START_STATIC") +endif() + +set(CMAKE_LINK_SEARCH_END_STATIC ON) +add_executable(LinkSearchEndStaticInit1 LinkStatic.c) +get_target_property(LSES LinkSearchEndStaticInit1 + LINK_SEARCH_END_STATIC) +if(NOT LSES) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_END_STATIC") +endif() +unset(CMAKE_LINK_SEARCH_END_STATIC) + +add_executable(LinkSearchEndStaticSet1 LinkStatic.c) +set_target_properties(LinkSearchEndStaticSet1 PROPERTIES + LINK_SEARCH_END_STATIC ON) +get_target_property(LSSS LinkSearchEndStaticSet1 + LINK_SEARCH_END_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly set LINK_SEARCH_END_STATIC") +endif() + +set(CMAKE_LINK_SEARCH_END_STATIC OFF) +add_executable(LinkSearchEndStaticInit2 LinkStatic.c) +get_target_property(LSES LinkSearchEndStaticInit2 + LINK_SEARCH_END_STATIC) +if(LSES) + message(FATAL_ERROR "Failed to correctly initialize LINK_SEARCH_END_STATIC") +endif() +unset(CMAKE_LINK_SEARCH_END_STATIC) + +add_executable(LinkSearchEndStaticSet2 LinkStatic.c) +set_target_properties(LinkSearchEndStaticSet2 PROPERTIES + LINK_SEARCH_END_STATIC ON) +get_target_property(LSSS LinkSearchEndStaticSet2 + LINK_SEARCH_END_STATIC) +if(NOT LSSS) + message(FATAL_ERROR "Failed to correctly set LINK_SEARCH_END_STATIC") +endif() diff --git a/Tests/RunCMake/set_property/LinkStatic.c b/Tests/RunCMake/set_property/LinkStatic.c new file mode 100644 index 0000000..3600977 --- /dev/null +++ b/Tests/RunCMake/set_property/LinkStatic.c @@ -0,0 +1,5 @@ +#include <math.h> +int main(void) +{ + return (int)sin(0); +} diff --git a/Tests/RunCMake/set_property/RunCMakeTest.cmake b/Tests/RunCMake/set_property/RunCMakeTest.cmake index 54e63f7..ada8804 100644 --- a/Tests/RunCMake/set_property/RunCMakeTest.cmake +++ b/Tests/RunCMake/set_property/RunCMakeTest.cmake @@ -1,3 +1,4 @@ include(RunCMake) run_cmake(LINK_LIBRARIES) +run_cmake(LINK_SEARCH_STATIC) diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake index 533c6a1..8307607 100644 --- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake @@ -7,3 +7,4 @@ run_cmake(CMP0023-NEW-2) run_cmake(MixedSignature) run_cmake(Separate-PRIVATE-LINK_PRIVATE-uses) run_cmake(SubDirTarget) +run_cmake(SharedDepNotTarget) diff --git a/Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake b/Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake new file mode 100644 index 0000000..bab537e --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/SharedDepNotTarget.cmake @@ -0,0 +1,10 @@ +enable_language(C) +set(CMAKE_LINK_DEPENDENT_LIBRARY_DIRS 1) +set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") +add_library(imported SHARED IMPORTED) +set_target_properties(imported PROPERTIES + IMPORTED_LOCATION "imported" + IMPORTED_LINK_DEPENDENT_LIBRARIES "/path/to/libSharedDep.so" + ) +add_executable(empty empty.c) +target_link_libraries(empty imported) |