diff options
35 files changed, 310 insertions, 57 deletions
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index 10f05df..62910cf 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -135,6 +135,7 @@ All Modules /module/FindLibLZMA /module/FindLibXml2 /module/FindLibXslt + /module/FindLTTngUST /module/FindLua50 /module/FindLua51 /module/FindLua diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst index 7b294a8..390220c 100644 --- a/Help/manual/cmake-toolchains.7.rst +++ b/Help/manual/cmake-toolchains.7.rst @@ -138,9 +138,10 @@ a path on the host to install to. The :variable:`CMAKE_INSTALL_PREFIX` is always the runtime installation location, even when cross-compiling. The :variable:`CMAKE_<LANG>_COMPILER` variables may be set to full paths, or to -names of compilers to search for in standard locations. In cases where CMake does -not have enough information to extract information from the compiler, the -:module:`CMakeForceCompiler` module can be used to bypass some of the checks. +names of compilers to search for in standard locations. For toolchains that +do not support linking binaries without custom flags or scripts one may set +the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable to ``STATIC_LIBRARY`` +to tell CMake not to try to link executables during its checks. CMake ``find_*`` commands will look in the sysroot, and the :variable:`CMAKE_FIND_ROOT_PATH` entries by default in all cases, as well as looking in the host system root prefix. diff --git a/Help/module/FindLTTngUST.rst b/Help/module/FindLTTngUST.rst new file mode 100644 index 0000000..a775462 --- /dev/null +++ b/Help/module/FindLTTngUST.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/FindLTTngUST.cmake diff --git a/Help/release/dev/add-FindLTTngUST.rst b/Help/release/dev/add-FindLTTngUST.rst new file mode 100644 index 0000000..a156cc8 --- /dev/null +++ b/Help/release/dev/add-FindLTTngUST.rst @@ -0,0 +1,5 @@ +add-FindLTTngUST +---------------- + +* The :module:`FindLTTngUST` module was introduced to find the LTTng-UST + library. diff --git a/Help/release/dev/deprecate-CMakeForceCompiler.rst b/Help/release/dev/deprecate-CMakeForceCompiler.rst new file mode 100644 index 0000000..dc6e817 --- /dev/null +++ b/Help/release/dev/deprecate-CMakeForceCompiler.rst @@ -0,0 +1,5 @@ +deprecate-CMakeForceCompiler +---------------------------- + +* The :module:`CMakeForceCompiler` module and its macros are now deprecated. + See module documentation for an explanation. diff --git a/Modules/CMakeForceCompiler.cmake b/Modules/CMakeForceCompiler.cmake index faa0dc5..d16d184 100644 --- a/Modules/CMakeForceCompiler.cmake +++ b/Modules/CMakeForceCompiler.cmake @@ -2,9 +2,7 @@ # CMakeForceCompiler # ------------------ # -# Discouraged. Avoid using this module if possible. It will be deprecated -# by a future version of CMake once alternatives have been provided for all -# toolchain file use cases. +# Deprecated. Do not use. # # The macros provided by this module were once intended for use by # cross-compiling toolchain files when CMake was not able to automatically @@ -14,11 +12,11 @@ # CMake detects from a compiler is now too extensive to be provided by # toolchain files using these macros. # -# The only known remaining use case for these macros is to write toolchain -# files for cross-compilers that cannot link binaries without special flags or -# custom linker scripts. These macros cause CMake to skip checks it normally -# performs as part of enabling a language and introspecting the toolchain. -# However, skipping these checks may limit some generation functionality. +# One common use case for this module was to skip CMake's checks for a +# working compiler when using a cross-compiler that cannot link binaries +# without special flags or custom linker scripts. This case is now supported +# by setting the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable in the +# toolchain file instead. # # ------------------------------------------------------------------------- # @@ -78,6 +76,8 @@ # License text for the above reference.) macro(CMAKE_FORCE_C_COMPILER compiler id) + message(DEPRECATION "The CMAKE_FORCE_C_COMPILER macro is deprecated. " + "Instead just set CMAKE_C_COMPILER and allow CMake to identify the compiler.") set(CMAKE_C_COMPILER "${compiler}") set(CMAKE_C_COMPILER_ID_RUN TRUE) set(CMAKE_C_COMPILER_ID ${id}) @@ -90,6 +90,8 @@ macro(CMAKE_FORCE_C_COMPILER compiler id) endmacro() macro(CMAKE_FORCE_CXX_COMPILER compiler id) + message(DEPRECATION "The CMAKE_FORCE_CXX_COMPILER macro is deprecated. " + "Instead just set CMAKE_CXX_COMPILER and allow CMake to identify the compiler.") set(CMAKE_CXX_COMPILER "${compiler}") set(CMAKE_CXX_COMPILER_ID_RUN TRUE) set(CMAKE_CXX_COMPILER_ID ${id}) @@ -102,6 +104,8 @@ macro(CMAKE_FORCE_CXX_COMPILER compiler id) endmacro() macro(CMAKE_FORCE_Fortran_COMPILER compiler id) + message(DEPRECATION "The CMAKE_FORCE_Fortran_COMPILER macro is deprecated. " + "Instead just set CMAKE_Fortran_COMPILER and allow CMake to identify the compiler.") set(CMAKE_Fortran_COMPILER "${compiler}") set(CMAKE_Fortran_COMPILER_ID_RUN TRUE) set(CMAKE_Fortran_COMPILER_ID ${id}) diff --git a/Modules/FindLTTngUST.cmake b/Modules/FindLTTngUST.cmake new file mode 100644 index 0000000..e3220ac --- /dev/null +++ b/Modules/FindLTTngUST.cmake @@ -0,0 +1,111 @@ +#.rst: +# FindLTTngUST +# ------------ +# +# This module finds the `LTTng-UST <http://lttng.org/>`__ library. +# +# Imported target +# ^^^^^^^^^^^^^^^ +# +# This module defines the following :prop_tgt:`IMPORTED` target: +# +# ``LTTng::UST`` +# The LTTng-UST library, if found +# +# Result variables +# ^^^^^^^^^^^^^^^^ +# +# This module sets the following +# +# ``LTTNGUST_FOUND`` +# ``TRUE`` if system has LTTng-UST +# ``LTTNGUST_INCLUDE_DIRS`` +# The LTTng-UST include directories +# ``LTTNGUST_LIBRARIES`` +# The libraries needed to use LTTng-UST +# ``LTTNGUST_VERSION_STRING`` +# The LTTng-UST version +# ``LTTNGUST_HAS_TRACEF`` +# ``TRUE`` if the ``tracef()`` API is available in the system's LTTng-UST +# ``LTTNGUST_HAS_TRACELOG`` +# ``TRUE`` if the ``tracelog()`` API is available in the system's LTTng-UST + +#============================================================================= +# Copyright 2016 Kitware, Inc. +# Copyright 2016 Philippe Proulx <pproulx@efficios.com> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +find_path(LTTNGUST_INCLUDE_DIRS NAMES lttng/tracepoint.h) +find_library(LTTNGUST_LIBRARIES NAMES lttng-ust) + +if(LTTNGUST_INCLUDE_DIRS AND LTTNGUST_LIBRARIES) + # find tracef() and tracelog() support + set(LTTNGUST_HAS_TRACEF 0) + set(LTTNGUST_HAS_TRACELOG 0) + + if(EXISTS "${LTTNGUST_INCLUDE_DIRS}/lttng/tracef.h") + set(LTTNGUST_HAS_TRACEF TRUE) + endif() + + if(EXISTS "${LTTNGUST_INCLUDE_DIRS}/lttng/tracelog.h") + set(LTTNGUST_HAS_TRACELOG TRUE) + endif() + + # get version + set(lttngust_version_file "${LTTNGUST_INCLUDE_DIRS}/lttng/ust-version.h") + + if(EXISTS "${lttngust_version_file}") + file(STRINGS "${lttngust_version_file}" lttngust_version_major_string + REGEX "^[\t ]*#define[\t ]+LTTNG_UST_MAJOR_VERSION[\t ]+[0-9]+[\t ]*$") + file(STRINGS "${lttngust_version_file}" lttngust_version_minor_string + REGEX "^[\t ]*#define[\t ]+LTTNG_UST_MINOR_VERSION[\t ]+[0-9]+[\t ]*$") + file(STRINGS "${lttngust_version_file}" lttngust_version_patch_string + REGEX "^[\t ]*#define[\t ]+LTTNG_UST_PATCHLEVEL_VERSION[\t ]+[0-9]+[\t ]*$") + string(REGEX REPLACE ".*([0-9]+).*" "\\1" + lttngust_v_major "${lttngust_version_major_string}") + string(REGEX REPLACE ".*([0-9]+).*" "\\1" + lttngust_v_minor "${lttngust_version_minor_string}") + string(REGEX REPLACE ".*([0-9]+).*" "\\1" + lttngust_v_patch "${lttngust_version_patch_string}") + set(LTTNGUST_VERSION_STRING + "${lttngust_v_major}.${lttngust_v_minor}.${lttngust_v_patch}") + unset(lttngust_version_major_string) + unset(lttngust_version_minor_string) + unset(lttngust_version_patch_string) + unset(lttngust_v_major) + unset(lttngust_v_minor) + unset(lttngust_v_patch) + endif() + + unset(lttngust_version_file) + + if(NOT TARGET LTTng::UST) + add_library(LTTng::UST UNKNOWN IMPORTED) + set_target_properties(LTTng::UST PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${LTTNGUST_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS} + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${LTTNGUST_LIBRARIES}") + endif() + + # add libdl to required libraries + set(LTTNGUST_LIBRARIES ${LTTNGUST_LIBRARIES} ${CMAKE_DL_LIBS}) +endif() + +# handle the QUIETLY and REQUIRED arguments and set LTTNGUST_FOUND to +# TRUE if all listed variables are TRUE +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(LTTngUST FOUND_VAR LTTNGUST_FOUND + REQUIRED_VARS LTTNGUST_LIBRARIES + LTTNGUST_INCLUDE_DIRS + VERSION_VAR LTTNGUST_VERSION_STRING) +mark_as_advanced(LTTNGUST_LIBRARIES LTTNGUST_INCLUDE_DIRS) diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 879192e..e194185 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -28,9 +28,10 @@ # for Python. You need to set this variable before calling # find_package(PythonInterp). # -# If also calling find_package(PythonLibs), call find_package(PythonInterp) -# first to get the currently active Python version by default with a consistent -# version of PYTHON_LIBRARIES. +# If calling both ``find_package(PythonInterp)`` and +# ``find_package(PythonLibs)``, call ``find_package(PythonInterp)`` first to +# get the currently active Python version by default with a consistent version +# of PYTHON_LIBRARIES. #============================================================================= # Copyright 2005-2010 Kitware, Inc. diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 68e1228..ab92f86 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -32,9 +32,10 @@ # PYTHON_LIBRARY - path to the python library # PYTHON_INCLUDE_DIR - path to where Python.h is found # -# If also calling find_package(PythonInterp), call find_package(PythonInterp) -# first to get the currently active Python version by default with a consistent -# version of PYTHON_LIBRARIES. +# If calling both ``find_package(PythonInterp)`` and +# ``find_package(PythonLibs)``, call ``find_package(PythonInterp)`` first to +# get the currently active Python version by default with a consistent version +# of PYTHON_LIBRARIES. #============================================================================= # Copyright 2001-2009 Kitware, Inc. diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 391e7f8..9ea1281 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -500,6 +500,7 @@ function(gp_resolved_file_type original_file file exepath dirs type_var) if(NOT IS_ABSOLUTE "${original_file}") message(STATUS "warning: gp_resolved_file_type expects absolute full path for first arg original_file") endif() + get_filename_component(original_file "${original_file}" ABSOLUTE) # canonicalize path set(is_embedded 0) set(is_local 0) @@ -515,6 +516,7 @@ function(gp_resolved_file_type original_file file exepath dirs type_var) if(NOT IS_ABSOLUTE "${file}") gp_resolve_item("${original_file}" "${file}" "${exepath}" "${dirs}" resolved_file "${rpaths}") endif() + get_filename_component(resolved_file "${resolved_file}" ABSOLUTE) # canonicalize path string(TOLOWER "${original_file}" original_lower) string(TOLOWER "${resolved_file}" lower) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 2a369b2..b65f25d 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 5) -set(CMake_VERSION_PATCH 20160307) +set(CMake_VERSION_PATCH 20160309) #set(CMake_VERSION_RC 1) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 76ed038..b5688a8 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -426,3 +426,35 @@ std::string cmCommonTargetGenerator::GetManifests() return cmJoin(manifests, " "); } + +void cmCommonTargetGenerator +::AppendOSXVerFlag(std::string& flags, const std::string& lang, + const char* name, bool so) +{ + // Lookup the flag to specify the version. + std::string fvar = "CMAKE_"; + fvar += lang; + fvar += "_OSX_"; + fvar += name; + fvar += "_VERSION_FLAG"; + const char* flag = this->Makefile->GetDefinition(fvar); + + // Skip if no such flag. + if(!flag) + { + return; + } + + // Lookup the target version information. + int major; + int minor; + int patch; + this->GeneratorTarget->GetTargetVersion(so, major, minor, patch); + if(major > 0 || minor > 0 || patch > 0) + { + // Append the flag since a non-zero version is specified. + std::ostringstream vflag; + vflag << flag << major << "." << minor << "." << patch; + this->LocalGenerator->AppendFlags(flags, vflag.str()); + } +} diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index 0c17500..bfb6b79 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -79,6 +79,9 @@ protected: virtual void AddIncludeFlags(std::string& flags, std::string const& lang) = 0; + void AppendOSXVerFlag(std::string& flags, const std::string& lang, + const char* name, bool so); + typedef std::map<std::string, std::string> ByLanguageMap; std::string GetFlags(const std::string &l); ByLanguageMap FlagsByLanguage; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 848028f..c628406 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -398,6 +398,21 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, return; } + std::set<std::string> cur_languages(languages.begin(), languages.end()); + for (std::set<std::string>::iterator li = cur_languages.begin(); + li != cur_languages.end(); ++li) + { + if (!this->LanguagesInProgress.insert(*li).second) + { + std::ostringstream e; + e << "Language '" << *li << "' is currently being enabled. " + "Recursive call not allowed."; + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + cmSystemTools::SetFatalErrorOccured(); + return; + } + } + if(this->TryCompileOuterMakefile) { // In a try-compile we can only enable languages provided by caller. @@ -823,6 +838,12 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, { cmSystemTools::SetFatalErrorOccured(); } + + for (std::set<std::string>::iterator li = cur_languages.begin(); + li != cur_languages.end(); ++li) + { + this->LanguagesInProgress.erase(*li); + } } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 48fa704..6e819d3 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -457,6 +457,7 @@ private: // in EnableLanguagesFromGenerator std::map<std::string, bool> IgnoreExtensions; std::set<std::string> LanguagesReady; // Ready for try_compile + std::set<std::string> LanguagesInProgress; std::map<std::string, std::string> OutputExtensions; std::map<std::string, std::string> LanguageToOutputExtension; std::map<std::string, std::string> ExtensionToLanguage; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 1923ea4..435844e 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -841,37 +841,3 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules this->CleanFiles.insert(this->CleanFiles.end(), libCleanFiles.begin(),libCleanFiles.end()); } - -//---------------------------------------------------------------------------- -void -cmMakefileLibraryTargetGenerator -::AppendOSXVerFlag(std::string& flags, const std::string& lang, - const char* name, bool so) -{ - // Lookup the flag to specify the version. - std::string fvar = "CMAKE_"; - fvar += lang; - fvar += "_OSX_"; - fvar += name; - fvar += "_VERSION_FLAG"; - const char* flag = this->Makefile->GetDefinition(fvar); - - // Skip if no such flag. - if(!flag) - { - return; - } - - // Lookup the target version information. - int major; - int minor; - int patch; - this->GeneratorTarget->GetTargetVersion(so, major, minor, patch); - if(major > 0 || minor > 0 || patch > 0) - { - // Append the flag since a non-zero version is specified. - std::ostringstream vflag; - vflag << flag << major << "." << minor << "." << patch; - this->LocalGenerator->AppendFlags(flags, vflag.str()); - } -} diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h index 68980c3..009f15d 100644 --- a/Source/cmMakefileLibraryTargetGenerator.h +++ b/Source/cmMakefileLibraryTargetGenerator.h @@ -38,9 +38,6 @@ protected: // Store the computd framework version for OS X Frameworks. std::string FrameworkVersion; - - void AppendOSXVerFlag(std::string& flags, const std::string& lang, - const char* name, bool so); }; #endif diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 17561b5..c34df3c 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -504,6 +504,16 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } } + // Add OS X version flags, if any. + if(this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY || + this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) + { + this->AppendOSXVerFlag(vars["LINK_FLAGS"], this->TargetLinkLanguage, + "COMPATIBILITY", true); + this->AppendOSXVerFlag(vars["LINK_FLAGS"], this->TargetLinkLanguage, + "CURRENT", false); + } + this->addPoolNinjaVariable("JOB_POOL_LINK", >, vars); this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 61d7855..27a01a3 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2715,7 +2715,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator); const char* toolset = gg->GetPlatformToolset(); if (toolset && - (cmHasLiteralPrefix(toolset, "v110") || + (cmHasLiteralPrefix(toolset, "v100") || + cmHasLiteralPrefix(toolset, "v110") || cmHasLiteralPrefix(toolset, "v120"))) { if (const char* debug = linkOptions.GetFlag("GenerateDebugInformation")) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index ba493cb..c7d2138 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1371,6 +1371,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindJsonCpp) endif() + if(CMake_TEST_FindLTTngUST) + add_subdirectory(FindLTTngUST) + endif() + if(CMake_TEST_FindOpenSSL) add_subdirectory(FindOpenSSL) endif() diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt index 0aad161..1f39052 100644 --- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt +++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt @@ -81,7 +81,7 @@ endmacro() # reported. foreach(VTEST ALSA ARMADILLO BZIP2 CUPS CURL EXPAT FREETYPE GETTEXT GIT HG - HSPELL ICOTOOL JASPER LIBLZMA LIBXML2 LIBXSLT PERL PKG_CONFIG + HSPELL ICOTOOL JASPER LIBLZMA LIBXML2 LIBXSLT LTTNGUST PERL PKG_CONFIG PostgreSQL TIFF ZLIB) check_version_string(${VTEST} ${VTEST}_VERSION_STRING) endforeach() diff --git a/Tests/FindLTTngUST/CMakeLists.txt b/Tests/FindLTTngUST/CMakeLists.txt new file mode 100644 index 0000000..c9c471d --- /dev/null +++ b/Tests/FindLTTngUST/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindLTTngUST.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindLTTngUST/Test" + "${CMake_BINARY_DIR}/Tests/FindLTTngUST/Test" + ${build_generator_args} + --build-project TestFindLTTngUST + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindLTTngUST/Test/CMakeLists.txt b/Tests/FindLTTngUST/Test/CMakeLists.txt new file mode 100644 index 0000000..e5bd9f3 --- /dev/null +++ b/Tests/FindLTTngUST/Test/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.5) +project(TestFindLTTngUST C) +include(CTest) + +find_package(LTTngUST REQUIRED) + +add_definitions(-DCMAKE_EXPECTED_LTTNGUST_VERSION="${LTTNGUST_VERSION_STRING}") +add_definitions(-DCMAKE_LTTNGUST_HAS_TRACEF="${LTTNGUST_HAS_TRACEF}") +add_definitions(-DCMAKE_LTTNGUST_HAS_TRACELOG="${LTTNGUST_HAS_TRACELOG}") + +add_executable(test_tgt main.c) +target_link_libraries(test_tgt LTTng::UST) +add_test(NAME test_tgt COMMAND test_tgt) + +add_executable(test_var main.c) +target_include_directories(test_var PRIVATE ${LTTNGUST_INCLUDE_DIRS}) +target_link_libraries(test_var PRIVATE ${LTTNGUST_LIBRARIES}) +add_test(NAME test_var COMMAND test_var) diff --git a/Tests/FindLTTngUST/Test/main.c b/Tests/FindLTTngUST/Test/main.c new file mode 100644 index 0000000..ac775a0 --- /dev/null +++ b/Tests/FindLTTngUST/Test/main.c @@ -0,0 +1,31 @@ +#include <assert.h> +#include <string.h> +#include <stdio.h> +#include <lttng/ust-version.h> + +#ifdef CMAKE_LTTNGUST_HAS_TRACEF +#include <lttng/tracef.h> +#endif + +#ifdef CMAKE_LTTNGUST_HAS_TRACELOG +#include <lttng/tracelog.h> +#endif + +int main(void) +{ + char lttng_version_string[16]; + + snprintf(lttng_version_string, 16, "%u.%u.%u", LTTNG_UST_MAJOR_VERSION, + LTTNG_UST_MINOR_VERSION, LTTNG_UST_PATCHLEVEL_VERSION); + assert(!strcmp(lttng_version_string, CMAKE_EXPECTED_LTTNGUST_VERSION)); + +#ifdef CMAKE_LTTNGUST_HAS_TRACEF + tracef("calling tracef()! %d %s", -23, CMAKE_EXPECTED_LTTNGUST_VERSION); +#endif + +#ifdef CMAKE_LTTNGUST_HAS_TRACELOG + tracelog(TRACE_WARNING, "calling tracelog()! %d", 17); +#endif + + return 0; +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 5bef629..23b9b42 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -152,6 +152,7 @@ add_RunCMake_test(ObjectLibrary) add_RunCMake_test(Swift) add_RunCMake_test(TargetObjects) add_RunCMake_test(TargetSources) +add_RunCMake_test(ToolchainFile) add_RunCMake_test(find_dependency) add_RunCMake_test(CompileDefinitions) add_RunCMake_test(CompileFeatures) diff --git a/Tests/RunCMake/ToolchainFile/CMakeLists.txt b/Tests/RunCMake/ToolchainFile/CMakeLists.txt new file mode 100644 index 0000000..93ee9df --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.5) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ToolchainFile/CallEnableLanguage-result.txt b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ToolchainFile/CallEnableLanguage-stderr.txt b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-stderr.txt new file mode 100644 index 0000000..0de51c6 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at CallEnableLanguage-toolchain.cmake:[0-9]+ \(enable_language\): + Language 'NONE' is currently being enabled. Recursive call not allowed. +Call Stack \(most recent call first\): + .*/Modules/CMakeDetermineSystem.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(project\)$ diff --git a/Tests/RunCMake/ToolchainFile/CallEnableLanguage-toolchain.cmake b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-toolchain.cmake new file mode 100644 index 0000000..8145101 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-toolchain.cmake @@ -0,0 +1 @@ +enable_language(NONE) diff --git a/Tests/RunCMake/ToolchainFile/CallEnableLanguage.cmake b/Tests/RunCMake/ToolchainFile/CallEnableLanguage.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CallEnableLanguage.cmake diff --git a/Tests/RunCMake/ToolchainFile/CallProject-result.txt b/Tests/RunCMake/ToolchainFile/CallProject-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CallProject-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ToolchainFile/CallProject-stderr.txt b/Tests/RunCMake/ToolchainFile/CallProject-stderr.txt new file mode 100644 index 0000000..e2b9f1b --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CallProject-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at CallProject-toolchain.cmake:[0-9]+ \(project\): + Language 'NONE' is currently being enabled. Recursive call not allowed. +Call Stack \(most recent call first\): + .*/Modules/CMakeDetermineSystem.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(project\)$ diff --git a/Tests/RunCMake/ToolchainFile/CallProject-toolchain.cmake b/Tests/RunCMake/ToolchainFile/CallProject-toolchain.cmake new file mode 100644 index 0000000..b113c13 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CallProject-toolchain.cmake @@ -0,0 +1 @@ +project(Bad NONE) diff --git a/Tests/RunCMake/ToolchainFile/CallProject.cmake b/Tests/RunCMake/ToolchainFile/CallProject.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CallProject.cmake diff --git a/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake new file mode 100644 index 0000000..75293e7 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake @@ -0,0 +1,9 @@ +include(RunCMake) + +function(run_cmake_toolchain t) + set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/${t}-toolchain.cmake) + run_cmake(${t}) +endfunction() + +run_cmake_toolchain(CallEnableLanguage) +run_cmake_toolchain(CallProject) |