diff options
34 files changed, 248 insertions, 26 deletions
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 52fdc91..bf5b5bc 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -637,7 +637,7 @@ if(CPACK_RPM_CHANGELOG_FILE) message(SEND_ERROR "CPackRPM:Warning: CPACK_RPM_CHANGELOG_FILE <${CPACK_RPM_CHANGELOG_FILE}> does not exists - ignoring") endif() else() - set(CPACK_RPM_SPEC_CHANGELOG "* Sun Jul 4 2010 Erk <eric.noulard@gmail.com>\n Generated by CPack RPM (no Changelog file were provided)") + set(CPACK_RPM_SPEC_CHANGELOG "* Sun Jul 4 2010 Eric Noulard <eric.noulard@gmail.com> - ${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}\n Generated by CPack RPM (no Changelog file were provided)") endif() # CPACK_RPM_SPEC_MORE_DEFINE @@ -876,6 +876,13 @@ if(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}") endif() +# protect @ in pathname in order to avoid their +# interpretation during the configure_file step +set(CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES}") +set(PROTECTED_AT "@") +string(REPLACE "@" "\@PROTECTED_AT\@" CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES_LIST}") +set(CPACK_RPM_INSTALL_FILES_LIST "") + # # USER generated/provided spec file handling. # @@ -982,6 +989,9 @@ else() configure_file(${CPACK_RPM_BINARY_SPECFILE}.in ${CPACK_RPM_BINARY_SPECFILE} @ONLY) endif() +# remove AT protection +unset(PROTECTED_AT) + if(RPMBUILD_EXECUTABLE) # Now call rpmbuild using the SPECFILE execute_process( diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 6afdb97..3acb4f9 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -114,6 +114,15 @@ # and <TMP_DIR> # with corresponding property values. # +# Any builtin step that specifies a "<step>_COMMAND cmd..." or custom +# step that specifies a "COMMAND cmd..." may specify additional command +# lines using the form "COMMAND cmd...". At build time the commands will +# be executed in order and aborted if any one fails. For example: +# ... BUILD_COMMAND make COMMAND echo done ... +# specifies to run "make" and then "echo done" during the build step. +# Whether the current working directory is preserved between commands +# is not defined. Behavior of shell operators like "&&" is not defined. +# # The 'ExternalProject_Get_Property' function retrieves external project # target properties: # ExternalProject_Get_Property(<name> [prop1 [prop2 [...]]]) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c63d2ba..80d424e 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 11) -set(CMake_VERSION_TWEAK 20130707) +set(CMake_VERSION_TWEAK 20130715) #set(CMake_VERSION_RC 1) diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 8fd95b9..0829add 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -282,6 +282,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, if(emitted.insert(*lib).second) { this->AddTargetDepend(depender_index, lib->c_str(), true); + this->AddInterfaceDepends(depender_index, lib->c_str(), + true, emitted); } } } diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 860417f..086f27a 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -12,6 +12,7 @@ #include "cmCoreTryCompile.h" #include "cmake.h" #include "cmCacheManager.h" +#include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" #include "cmExportTryCompileFileGenerator.h" #include <cmsys/Directory.hxx> @@ -32,18 +33,20 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) std::vector<std::string> compileDefs; std::string outputVariable; std::string copyFile; + std::string copyFileError; std::vector<cmTarget*> targets; std::string libsToLink = " "; bool useOldLinkLibs = true; char targetNameBuf[64]; bool didOutputVariable = false; bool didCopyFile = false; + bool didCopyFileError = false; bool useSources = argv[2] == "SOURCES"; std::vector<std::string> sources; enum Doing { DoingNone, DoingCMakeFlags, DoingCompileDefinitions, DoingLinkLibraries, DoingOutputVariable, DoingCopyFile, - DoingSources }; + DoingCopyFileError, DoingSources }; Doing doing = useSources? DoingSources : DoingNone; for(size_t i=3; i < argv.size(); ++i) { @@ -74,6 +77,11 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) doing = DoingCopyFile; didCopyFile = true; } + else if(argv[i] == "COPY_FILE_ERROR") + { + doing = DoingCopyFileError; + didCopyFileError = true; + } else if(doing == DoingCMakeFlags) { cmakeFlags.push_back(argv[i]); @@ -121,6 +129,11 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) copyFile = argv[i].c_str(); doing = DoingNone; } + else if(doing == DoingCopyFileError) + { + copyFileError = argv[i].c_str(); + doing = DoingNone; + } else if(doing == DoingSources) { sources.push_back(argv[i]); @@ -149,6 +162,20 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) return -1; } + if(didCopyFileError && copyFileError.empty()) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, + "COPY_FILE_ERROR must be followed by a variable name"); + return -1; + } + + if(didCopyFileError && !didCopyFile) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, + "COPY_FILE_ERROR may be used only with COPY_FILE"); + return -1; + } + if(didOutputVariable && outputVariable.empty()) { this->Makefile->IssueMessage(cmake::FATAL_ERROR, @@ -214,8 +241,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) } // Detect languages to enable. - cmGlobalGenerator* gg = - this->Makefile->GetCMakeInstance()->GetGlobalGenerator(); + cmLocalGenerator* lg = this->Makefile->GetLocalGenerator(); + cmGlobalGenerator* gg = lg->GetGlobalGenerator(); std::set<std::string> testLangs; for(std::vector<std::string>::iterator si = sources.begin(); si != sources.end(); ++si) @@ -295,13 +322,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) for(std::set<std::string>::iterator li = testLangs.begin(); li != testLangs.end(); ++li) { - fprintf(fout, "SET(CMAKE_%s_FLAGS \"", li->c_str()); std::string langFlags = "CMAKE_" + *li + "_FLAGS"; - if(const char* flags = this->Makefile->GetDefinition(langFlags.c_str())) - { - fprintf(fout, " %s ", flags); - } - fprintf(fout, " ${COMPILE_DEFINITIONS}\")\n"); + const char* flags = this->Makefile->GetDefinition(langFlags.c_str()); + fprintf(fout, "SET(CMAKE_%s_FLAGS %s)\n", li->c_str(), + lg->EscapeForCMake(flags?flags:"").c_str()); + fprintf(fout, "SET(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}" + " ${COMPILE_DEFINITIONS}\")\n", li->c_str(), li->c_str()); } fprintf(fout, "INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES})\n"); fprintf(fout, "SET(CMAKE_SUPPRESS_REGENERATION 1)\n"); @@ -444,6 +470,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) if (this->SrcFileSignature) { + std::string copyFileErrorMessage; this->FindOutputFile(targetName); if ((res==0) && (copyFile.size())) @@ -461,10 +488,23 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) { emsg << this->FindErrorMessage.c_str(); } - this->Makefile->IssueMessage(cmake::FATAL_ERROR, emsg.str()); - return -1; + if(copyFileError.empty()) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, emsg.str()); + return -1; + } + else + { + copyFileErrorMessage = emsg.str(); + } } } + + if(!copyFileError.empty()) + { + this->Makefile->AddDefinition(copyFileError.c_str(), + copyFileErrorMessage.c_str()); + } } return res; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index ad74767..19b9110 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -892,12 +892,28 @@ void cmGlobalGenerator::Configure() if ( this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE) { - const char* msg = "Configuring done"; + cmOStringStream msg; if(cmSystemTools::GetErrorOccuredFlag()) { - msg = "Configuring incomplete, errors occurred!"; + msg << "Configuring incomplete, errors occurred!"; + const char* logs[] = {"CMakeOutput.log", "CMakeError.log", 0}; + for(const char** log = logs; *log; ++log) + { + std::string f = this->CMakeInstance->GetHomeOutputDirectory(); + f += this->CMakeInstance->GetCMakeFilesDirectory(); + f += "/"; + f += *log; + if(cmSystemTools::FileExists(f.c_str())) + { + msg << "\nSee also \"" << f << "\"."; + } + } + } + else + { + msg << "Configuring done"; } - this->CMakeInstance->UpdateProgress(msg, -1); + this->CMakeInstance->UpdateProgress(msg.str().c_str(), -1); } } diff --git a/Source/cmIncludeCommand.h b/Source/cmIncludeCommand.h index c46c02d..d97b7c3 100644 --- a/Source/cmIncludeCommand.h +++ b/Source/cmIncludeCommand.h @@ -55,7 +55,7 @@ public: */ virtual const char* GetTerseDocumentation() const { - return "Read CMake listfile code from the given file."; + return "Load and run CMake code from a file or module."; } /** @@ -66,9 +66,10 @@ public: return " include(<file|module> [OPTIONAL] [RESULT_VARIABLE <VAR>]\n" " [NO_POLICY_SCOPE])\n" - "Reads CMake listfile code from the given file. Commands in the file " - "are processed immediately as if they were written in place of the " - "include command. If OPTIONAL is present, then no error " + "Load and run CMake code from the file given. " + "Variable reads and writes access the scope of the caller " + "(dynamic scoping). " + "If OPTIONAL is present, then no error " "is raised if the file does not exist. If RESULT_VARIABLE is given " "the variable will be set to the full filename which " "has been included or NOTFOUND if it failed.\n" diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h index a53cb3f..9547c4c 100644 --- a/Source/cmProjectCommand.h +++ b/Source/cmProjectCommand.h @@ -71,7 +71,13 @@ public: "language \"NONE\" all checks for any language can be disabled. " "If a variable exists called CMAKE_PROJECT_<projectName>_INCLUDE, " "the file pointed to by that variable will be included as the last step " - "of the project command."; + "of the project command." + "\n" + "The top-level CMakeLists.txt file for a project must contain a " + "literal, direct call to the project() command; loading one through " + "the include() command is not sufficient. " + "If no such call exists CMake will implicitly add one to the top that " + "enables the default languages (C and CXX)."; } cmTypeMacro(cmProjectCommand, cmCommand); diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index 163756d..a20594c 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -69,14 +69,14 @@ public: " [COMPILE_DEFINITIONS flags...]\n" " [LINK_LIBRARIES libs...]\n" " [OUTPUT_VARIABLE <var>]\n" - " [COPY_FILE <fileName>])\n" + " [COPY_FILE <fileName> [COPY_FILE_ERROR <var>]])\n" "Try building an executable from one or more source files. " "In this form the user need only supply one or more source files " "that include a definition for 'main'. " "CMake will create a CMakeLists.txt file to build the source(s) " "as an executable. " "Specify COPY_FILE to get a copy of the linked executable at the " - "given fileName." + "given fileName and optionally COPY_FILE_ERROR to capture any error." "\n" "In this version all files in bindir/CMakeFiles/CMakeTmp " "will be cleaned automatically. For debugging, --debug-trycompile can " diff --git a/Source/cmVS10LinkFlagTable.h b/Source/cmVS10LinkFlagTable.h index 64febbb..5d15620 100644 --- a/Source/cmVS10LinkFlagTable.h +++ b/Source/cmVS10LinkFlagTable.h @@ -201,7 +201,7 @@ static cmVS7FlagTable cmVS10LinkFlagTable[] = cmVS7FlagTable::UserValueRequired}, {"GenerateMapFile", "MAP", "", "true", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, - {"MapFileName", "MAP", "Generate Map File", "", + {"MapFileName", "MAP:", "Generate Map File", "", cmVS7FlagTable::UserValueRequired}, //String List Properties diff --git a/Source/cmVS11LinkFlagTable.h b/Source/cmVS11LinkFlagTable.h index ea0d0f0..b4587a8 100644 --- a/Source/cmVS11LinkFlagTable.h +++ b/Source/cmVS11LinkFlagTable.h @@ -227,7 +227,7 @@ static cmVS7FlagTable cmVS11LinkFlagTable[] = cmVS7FlagTable::UserValueRequired}, {"GenerateMapFile", "MAP", "", "true", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, - {"MapFileName", "MAP", "Generate Map File", "", + {"MapFileName", "MAP:", "Generate Map File", "", cmVS7FlagTable::UserValueRequired}, //String List Properties diff --git a/Source/cmVS12LinkFlagTable.h b/Source/cmVS12LinkFlagTable.h index ce32e38..73d450a 100644 --- a/Source/cmVS12LinkFlagTable.h +++ b/Source/cmVS12LinkFlagTable.h @@ -227,7 +227,7 @@ static cmVS7FlagTable cmVS12LinkFlagTable[] = cmVS7FlagTable::UserValueRequired}, {"GenerateMapFile", "MAP", "", "true", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, - {"MapFileName", "MAP", "Generate Map File", "", + {"MapFileName", "MAP:", "Generate Map File", "", cmVS7FlagTable::UserValueRequired}, //String List Properties diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index da15d62..370dffe 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -184,6 +184,9 @@ set_property(TARGET testSharedLibRequired APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/testSharedLibRequired>" "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}>" ) +set_property(TARGET testSharedLibRequired APPEND PROPERTY + INTERFACE_COMPILE_DEFINITIONS USING_TESTSHAREDLIBREQUIRED +) set_property(TARGET testSharedLibRequired APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL CUSTOM_PROP diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 376abac..aa8847b 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -228,3 +228,36 @@ target_compile_definitions(deps_shared_iface2 $<$<BOOL:$<TARGET_PROPERTY:CUSTOM_PROP>>:CUSTOM_PROPERTY_IS_ON> $<$<STREQUAL:$<TARGET_PROPERTY:CUSTOM_STRING>,testcontent>:CUSTOM_STRING_IS_MATCH> ) + +add_subdirectory(excludedFromAll) + +add_executable(iface_test_bld iface_test.cpp) +target_link_libraries(iface_test_bld bld_testSharedLibDepends) + +set_property(TARGET bld_testSharedLibRequired APPEND PROPERTY + LINK_INTERFACE_LIBRARIES + excludedFromAll +) +get_target_property(_configs bld_testSharedLibRequired IMPORTED_CONFIGURATIONS) +foreach(_config ${_configs}) + set_property(TARGET bld_testSharedLibRequired APPEND PROPERTY + IMPORTED_LINK_INTERFACE_LIBRARIES_${_config} + excludedFromAll + ) +endforeach() +unset(_configs) +add_executable(iface_test_exp iface_test.cpp) +target_link_libraries(iface_test_exp testSharedLibDepends) + +set_property(TARGET testSharedLibDepends APPEND PROPERTY + LINK_INTERFACE_LIBRARIES + excludedFromAll +) +get_target_property(_configs testSharedLibDepends IMPORTED_CONFIGURATIONS) +foreach(_config ${_configs}) + set_property(TARGET testSharedLibDepends APPEND PROPERTY + IMPORTED_LINK_INTERFACE_LIBRARIES_${_config} + excludedFromAll + ) +endforeach() +unset(_configs) diff --git a/Tests/ExportImport/Import/A/excludedFromAll/CMakeLists.txt b/Tests/ExportImport/Import/A/excludedFromAll/CMakeLists.txt new file mode 100644 index 0000000..cd5a59b --- /dev/null +++ b/Tests/ExportImport/Import/A/excludedFromAll/CMakeLists.txt @@ -0,0 +1,7 @@ + +set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +include(GenerateExportHeader) +add_library(excludedFromAll SHARED EXCLUDE_FROM_ALL excludedFromAll.cpp) +generate_export_header(excludedFromAll) diff --git a/Tests/ExportImport/Import/A/excludedFromAll/excludedFromAll.cpp b/Tests/ExportImport/Import/A/excludedFromAll/excludedFromAll.cpp new file mode 100644 index 0000000..2269a04 --- /dev/null +++ b/Tests/ExportImport/Import/A/excludedFromAll/excludedFromAll.cpp @@ -0,0 +1,7 @@ + +#include "excludedFromAll.h" + +int excludedFromAll() +{ + return 0; +} diff --git a/Tests/ExportImport/Import/A/excludedFromAll/excludedFromAll.h b/Tests/ExportImport/Import/A/excludedFromAll/excludedFromAll.h new file mode 100644 index 0000000..4820c76 --- /dev/null +++ b/Tests/ExportImport/Import/A/excludedFromAll/excludedFromAll.h @@ -0,0 +1,4 @@ + +#include "excludedfromall_export.h" + +int EXCLUDEDFROMALL_EXPORT excludedFromAll(); diff --git a/Tests/ExportImport/Import/A/iface_test.cpp b/Tests/ExportImport/Import/A/iface_test.cpp new file mode 100644 index 0000000..fa4474b --- /dev/null +++ b/Tests/ExportImport/Import/A/iface_test.cpp @@ -0,0 +1,11 @@ + +#ifndef USING_TESTSHAREDLIBREQUIRED +#error Expected USING_TESTSHAREDLIBREQUIRED +#endif + +#include "excludedFromAll.h" + +int main(void) +{ + return excludedFromAll(); +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index e07c42f..75e0e28 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -57,6 +57,7 @@ add_RunCMake_test(CTest) if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles") add_RunCMake_test(CompilerChange) endif() +add_RunCMake_test(Configure) add_RunCMake_test(ExternalData) add_RunCMake_test(FPHSA) add_RunCMake_test(GeneratorExpression) diff --git a/Tests/RunCMake/Configure/CMakeLists.txt b/Tests/RunCMake/Configure/CMakeLists.txt new file mode 100644 index 0000000..e8db6b0 --- /dev/null +++ b/Tests/RunCMake/Configure/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Configure/ErrorLogs-result.txt b/Tests/RunCMake/Configure/ErrorLogs-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Configure/ErrorLogs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Configure/ErrorLogs-stderr.txt b/Tests/RunCMake/Configure/ErrorLogs-stderr.txt new file mode 100644 index 0000000..4eee45d --- /dev/null +++ b/Tests/RunCMake/Configure/ErrorLogs-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at ErrorLogs.cmake:3 \(message\): + Some error! +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Configure/ErrorLogs-stdout.txt b/Tests/RunCMake/Configure/ErrorLogs-stdout.txt new file mode 100644 index 0000000..c467b62 --- /dev/null +++ b/Tests/RunCMake/Configure/ErrorLogs-stdout.txt @@ -0,0 +1,3 @@ +-- Configuring incomplete, errors occurred! +See also ".*/Tests/RunCMake/Configure/ErrorLogs-build/CMakeFiles/CMakeOutput\.log"\. +See also ".*/Tests/RunCMake/Configure/ErrorLogs-build/CMakeFiles/CMakeError\.log"\. diff --git a/Tests/RunCMake/Configure/ErrorLogs.cmake b/Tests/RunCMake/Configure/ErrorLogs.cmake new file mode 100644 index 0000000..e8cf062 --- /dev/null +++ b/Tests/RunCMake/Configure/ErrorLogs.cmake @@ -0,0 +1,3 @@ +file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Some detailed error information!\n") +message(SEND_ERROR "Some error!") diff --git a/Tests/RunCMake/Configure/RunCMakeTest.cmake b/Tests/RunCMake/Configure/RunCMakeTest.cmake new file mode 100644 index 0000000..46f9184 --- /dev/null +++ b/Tests/RunCMake/Configure/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(ErrorLogs) diff --git a/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile-result.txt b/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile-stderr.txt b/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile-stderr.txt new file mode 100644 index 0000000..5d09c0c --- /dev/null +++ b/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CopyFileErrorNoCopyFile.cmake:1 \(try_compile\): + COPY_FILE_ERROR may be used only with COPY_FILE +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile.cmake b/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile.cmake new file mode 100644 index 0000000..8d7cb0e --- /dev/null +++ b/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile.cmake @@ -0,0 +1,2 @@ +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c + COPY_FILE_ERROR _copied) diff --git a/Tests/RunCMake/try_compile/NoCopyFileError-result.txt b/Tests/RunCMake/try_compile/NoCopyFileError-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/NoCopyFileError-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/NoCopyFileError-stderr.txt b/Tests/RunCMake/try_compile/NoCopyFileError-stderr.txt new file mode 100644 index 0000000..ed552fd --- /dev/null +++ b/Tests/RunCMake/try_compile/NoCopyFileError-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at NoCopyFileError.cmake:1 \(try_compile\): + COPY_FILE_ERROR must be followed by a variable name +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/NoCopyFileError.cmake b/Tests/RunCMake/try_compile/NoCopyFileError.cmake new file mode 100644 index 0000000..d4d69ee --- /dev/null +++ b/Tests/RunCMake/try_compile/NoCopyFileError.cmake @@ -0,0 +1,2 @@ +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c + COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/copied.bin COPY_FILE_ERROR) diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 3494695..c934458 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -1,10 +1,12 @@ include(RunCMake) +run_cmake(CopyFileErrorNoCopyFile) run_cmake(NoArgs) run_cmake(OneArg) run_cmake(TwoArgs) run_cmake(NoCopyFile) run_cmake(NoCopyFile2) +run_cmake(NoCopyFileError) run_cmake(NoOutputVariable) run_cmake(NoOutputVariable2) run_cmake(NoSources) diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index 4540fd0..a4d9490 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -44,6 +44,23 @@ else() file(REMOVE "${TryCompile_BINARY_DIR}/CopyOfPass") endif() +# try to compile a file that should compile +# also check that COPY_FILE_ERROR works +file(WRITE ${TryCompile_BINARY_DIR}/invalid "") +try_compile(SHOULD_PASS + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/pass.c + OUTPUT_VARIABLE TRY_OUT + COPY_FILE ${TryCompile_BINARY_DIR}/invalid/path + COPY_FILE_ERROR _captured + ) +if(NOT SHOULD_PASS) + message(SEND_ERROR "should pass failed ${TRY_OUT}") +endif() +if(NOT _captured MATCHES "Cannot copy output executable.*/invalid/path") + message(SEND_ERROR "COPY_FILE_ERROR did not capture expected message") +endif() + # try to compile a file that should not compile try_compile(SHOULD_FAIL ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp @@ -89,6 +106,24 @@ if(SHOULD_FAIL) message(SEND_ERROR "Should fail passed ${TRY_OUT}") endif() +# try to compile a file that should compile +set(_c_flags "${CMAKE_C_FLAGS}") +if(CMAKE_GENERATOR STREQUAL "Visual Studio 6") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D \"TESTDEF\"") +elseif(WATCOM) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -dTESTDEF") +else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \"-DTESTDEF\"") +endif() +try_compile(SHOULD_PASS + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/testdef.c + OUTPUT_VARIABLE TRY_OUT) +if(NOT SHOULD_PASS) + message(SEND_ERROR "should pass failed ${TRY_OUT}") +endif() +set(CMAKE_C_FLAGS "${_c_flags}") + if(NOT SHOULD_FAIL) if(SHOULD_PASS) message("All Tests passed, ignore all previous output.") diff --git a/Tests/TryCompile/testdef.c b/Tests/TryCompile/testdef.c new file mode 100644 index 0000000..5401e71 --- /dev/null +++ b/Tests/TryCompile/testdef.c @@ -0,0 +1,4 @@ +#ifndef TESTDEF +# error "TESTDEF should be defined!" +#endif +int main(void) { return 0; } |