diff options
26 files changed, 324 insertions, 47 deletions
diff --git a/Modules/CPackNSIS.cmake b/Modules/CPackNSIS.cmake index 7d9f29b..5e2ba17 100644 --- a/Modules/CPackNSIS.cmake +++ b/Modules/CPackNSIS.cmake @@ -15,16 +15,22 @@ ##end # ##variable -# CPACK_NSIS_MUI_ICON - The icon file (.ico) for the generated +# CPACK_NSIS_MUI_ICON - An icon filename. +# The name of a *.ico file used as the main icon for the generated # install program. ##end # ##variable -# CPACK_NSIS_MUI_UNIICON - The icon file (.ico) for the generated +# CPACK_NSIS_MUI_UNIICON - An icon filename. +# The name of a *.ico file used as the main icon for the generated # uninstall program. ##end # ##variable +# CPACK_NSIS_INSTALLER_MUI_ICON_CODE - undocumented. +##end +# +##variable # CPACK_NSIS_EXTRA_INSTALL_COMMANDS - Extra NSIS commands that will # be added to the install Section. ##end @@ -40,7 +46,8 @@ ##end # ##variable -# CPACK_NSIS_MODIFY_PATH - If this is set to "ON", then an extra page +# CPACK_NSIS_MODIFY_PATH - Modify PATH toggle. +# If this is set to "ON", then an extra page # will appear in the installer that will allow the user to choose # whether the program directory should be added to the system PATH # variable. diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake index 642d962..a94644e 100644 --- a/Modules/CheckIncludeFiles.cmake +++ b/Modules/CheckIncludeFiles.cmake @@ -13,7 +13,7 @@ # CMAKE_REQUIRED_INCLUDES = list of include directories #============================================================================= -# Copyright 2003-2009 Kitware, Inc. +# Copyright 2003-2012 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -44,7 +44,17 @@ MACRO(CHECK_INCLUDE_FILES INCLUDE VARIABLE) CONFIGURE_FILE("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFiles.c" @ONLY IMMEDIATE) - MESSAGE(STATUS "Looking for include files ${INCLUDE}") + SET(_INCLUDE ${INCLUDE}) # remove empty elements + IF("${_INCLUDE}" MATCHES "^([^;]+);.+;([^;]+)$") + LIST(LENGTH _INCLUDE _INCLUDE_LEN) + SET(_description "${_INCLUDE_LEN} include files ${CMAKE_MATCH_1}, ..., ${CMAKE_MATCH_2}") + ELSEIF("${_INCLUDE}" MATCHES "^([^;]+);([^;]+)$") + SET(_description "include files ${CMAKE_MATCH_1}, ${CMAKE_MATCH_2}") + ELSE() + SET(_description "include file ${_INCLUDE}") + ENDIF() + + MESSAGE(STATUS "Looking for ${_description}") TRY_COMPILE(${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFiles.c @@ -54,14 +64,14 @@ MACRO(CHECK_INCLUDE_FILES INCLUDE VARIABLE) "${CHECK_INCLUDE_FILES_INCLUDE_DIRS}" OUTPUT_VARIABLE OUTPUT) IF(${VARIABLE}) - MESSAGE(STATUS "Looking for include files ${INCLUDE} - found") + MESSAGE(STATUS "Looking for ${_description} - found") SET(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}") FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if files ${INCLUDE} " "exist passed with the following output:\n" "${OUTPUT}\n\n") ELSE(${VARIABLE}) - MESSAGE(STATUS "Looking for include files ${INCLUDE} - not found.") + MESSAGE(STATUS "Looking for ${_description} - not found.") SET(${VARIABLE} "" CACHE INTERNAL "Have includes ${INCLUDE}") FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if files ${INCLUDE} " diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 9c03b3d..7504ea4 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -65,7 +65,8 @@ # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1, # 1.36, 1.36.0, 1.36.1, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0, # 1.40, 1.40.0, 1.41, 1.41.0, 1.42, 1.42.0, 1.43, 1.43.0, 1.44, 1.44.0, -# 1.45, 1.45.0, 1.46, 1.46.0, 1.46.1, 1.47, 1.47.0, 1.48, 1.48.0 +# 1.45, 1.45.0, 1.46, 1.46.0, 1.46.1, 1.47, 1.47.0, 1.48, 1.48.0, +# 1.49, 1.49.0, 1.50, 1.50.0 # # NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should # add both 1.x and 1.x.0 as shown above. Official Boost include directories @@ -449,7 +450,7 @@ else(Boost_FIND_VERSION_EXACT) # The user has not requested an exact version. Among known # versions, find those that are acceptable to the user request. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS} - "1.48.0" "1.48" "1.47.0" "1.47" "1.46.1" + "1.50.0" "1.50" "1.49.0" "1.49" "1.48.0" "1.48" "1.47.0" "1.47" "1.46.1" "1.46.0" "1.46" "1.45.0" "1.45" "1.44.0" "1.44" "1.43.0" "1.43" "1.42.0" "1.42" "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37" "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0" diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index c4b5635..f9d37c3 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -56,6 +56,7 @@ SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a") # hardcode CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did before, Alex IF(NOT DEFINED CMAKE_INSTALL_NAME_TOOL) FIND_PROGRAM(CMAKE_INSTALL_NAME_TOOL install_name_tool) + MARK_AS_ADVANCED(CMAKE_INSTALL_NAME_TOOL) ENDIF(NOT DEFINED CMAKE_INSTALL_NAME_TOOL) # Set the assumed (Pre 10.5 or Default) location of the developer tools @@ -63,6 +64,7 @@ SET(OSX_DEVELOPER_ROOT "/Developer") # Use the xcode-select tool if it's available (Xcode >= 3.0 installations) FIND_PROGRAM(CMAKE_XCODE_SELECT xcode-select) +MARK_AS_ADVANCED(CMAKE_XCODE_SELECT) IF(CMAKE_XCODE_SELECT) EXECUTE_PROCESS(COMMAND ${CMAKE_XCODE_SELECT} "-print-path" OUTPUT_VARIABLE OSX_DEVELOPER_ROOT @@ -239,10 +241,22 @@ SET(CMAKE_SYSTEM_FRAMEWORK_PATH # default to searching for application bundles first SET(CMAKE_FIND_APPBUNDLE FIRST) # set up the default search directories for application bundles +SET(_apps_paths) +FOREACH(_path + "~/Applications" + "/Applications" + "${OSX_DEVELOPER_ROOT}/../Applications" # Xcode 4.3+ + "${OSX_DEVELOPER_ROOT}/Applications" # pre-4.3 + ) + GET_FILENAME_COMPONENT(_apps "${_path}" ABSOLUTE) + IF(EXISTS "${_apps}") + LIST(APPEND _apps_paths "${_apps}") + ENDIF() +ENDFOREACH() +LIST(REMOVE_DUPLICATES _apps_paths) SET(CMAKE_SYSTEM_APPBUNDLE_PATH - ~/Applications - /Applications - /Developer/Applications) + ${_apps_paths}) +UNSET(_apps_paths) INCLUDE(Platform/UnixPaths) LIST(APPEND CMAKE_SYSTEM_PREFIX_PATH diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index a5feaca..11bccde 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -241,9 +241,12 @@ void cmGlobalVisualStudio71Generator ::WriteExternalProject(std::ostream& fout, const char* name, const char* location, + const char* typeGuid, const std::set<cmStdString>& depends) { - fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" + fout << "Project(\"{" + << (typeGuid ? typeGuid : "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942") + << "}\") = \"" << name << "\", \"" << this->ConvertToSolutionPath(location) << "\", \"{" << this->GetGUID(name) @@ -279,18 +282,20 @@ void cmGlobalVisualStudio71Generator // executables to the libraries it uses are also done here void cmGlobalVisualStudio71Generator ::WriteProjectConfigurations(std::ostream& fout, const char* name, - bool partOfDefaultBuild) + bool partOfDefaultBuild, const char* platformMapping) { std::string guid = this->GetGUID(name); for(std::vector<std::string>::iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { fout << "\t\t{" << guid << "}." << *i - << ".ActiveCfg = " << *i << "|Win32\n"; + << ".ActiveCfg = " << *i << "|" + << (platformMapping ? platformMapping : "Win32") << std::endl; if(partOfDefaultBuild) { fout << "\t\t{" << guid << "}." << *i - << ".Build.0 = " << *i << "|Win32\n"; + << ".Build.0 = " << *i << "|" + << (platformMapping ? platformMapping : "Win32") << std::endl; } } } diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index 81c2087..503b708 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -64,10 +64,12 @@ protected: const char* name, const char* path, cmTarget &t); virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, - bool partOfDefaultBuild); + bool partOfDefaultBuild, + const char* platformMapping = NULL); virtual void WriteExternalProject(std::ostream& fout, const char* name, const char* path, + const char* typeGuid, const std::set<cmStdString>& depends); virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index a68e6d8..09b200f 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -251,7 +251,8 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( if(expath) { this->WriteProjectConfigurations(fout, target->GetName(), - true); + true, + target->GetProperty("VS_PLATFORM_MAPPING")); } else { @@ -286,8 +287,12 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( { std::string project = target->GetName(); std::string location = expath; - this->WriteExternalProject(fout, project.c_str(), - location.c_str(), target->GetUtilities()); + + this->WriteExternalProject(fout, + project.c_str(), + location.c_str(), + target->GetProperty("VS_PROJECT_TYPE"), + target->GetUtilities()); written = true; } else @@ -580,18 +585,20 @@ cmGlobalVisualStudio7Generator // executables to the libraries it uses are also done here void cmGlobalVisualStudio7Generator ::WriteProjectConfigurations(std::ostream& fout, const char* name, - bool partOfDefaultBuild) + bool partOfDefaultBuild, const char* platformMapping) { std::string guid = this->GetGUID(name); for(std::vector<std::string>::iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { fout << "\t\t{" << guid << "}." << *i - << ".ActiveCfg = " << *i << "|Win32\n"; + << ".ActiveCfg = " << *i << "|" + << (platformMapping ? platformMapping : "Win32") << "\n"; if(partOfDefaultBuild) { fout << "\t\t{" << guid << "}." << *i - << ".Build.0 = " << *i << "|Win32\n"; + << ".Build.0 = " << *i << "|" + << (platformMapping ? platformMapping : "Win32") << "\n"; } } } @@ -604,10 +611,14 @@ void cmGlobalVisualStudio7Generator void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout, const char* name, const char* location, + const char* typeGuid, const std::set<cmStdString>&) { std::string d = cmSystemTools::ConvertToOutputPath(location); - fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" + fout << "Project(" + << "\"{" + << (typeGuid ? typeGuid : "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942") + << "}\") = \"" << name << "\", \"" << this->ConvertToSolutionPath(location) << "\", \"{" << this->GetGUID(name) diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index c92998e..9b9107d 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -107,7 +107,8 @@ protected: const char* name, const char* path, cmTarget &t); virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, - bool partOfDefaultBuild); + bool partOfDefaultBuild, + const char* platformMapping = NULL); virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout); virtual std::string WriteUtilityDepend(cmTarget* target); @@ -130,6 +131,7 @@ protected: virtual void WriteExternalProject(std::ostream& fout, const char* name, const char* path, + const char* typeGuid, const std::set<cmStdString>& dependencies); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index a723109..72eb48d 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -270,20 +270,20 @@ cmGlobalVisualStudio8Generator void cmGlobalVisualStudio8Generator ::WriteProjectConfigurations(std::ostream& fout, const char* name, - bool partOfDefaultBuild) + bool partOfDefaultBuild, const char* platformMapping) { std::string guid = this->GetGUID(name); for(std::vector<std::string>::iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { fout << "\t\t{" << guid << "}." << *i - << "|" << this->GetPlatformName() << ".ActiveCfg = " - << *i << "|" << this->GetPlatformName() << "\n"; + << "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|" + << (platformMapping ? platformMapping : this->GetPlatformName()) << "\n"; if(partOfDefaultBuild) { fout << "\t\t{" << guid << "}." << *i - << "|" << this->GetPlatformName() << ".Build.0 = " - << *i << "|" << this->GetPlatformName() << "\n"; + << "|" << this->GetPlatformName() << ".Build.0 = " << *i << "|" + << (platformMapping ? platformMapping : this->GetPlatformName()) << "\n"; } } } diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index e0913ed..7dae429 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -77,7 +77,8 @@ protected: virtual void WriteSolutionConfigurations(std::ostream& fout); virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, - bool partOfDefaultBuild); + bool partOfDefaultBuild, + const char* platformMapping = NULL); virtual bool ComputeTargetDepends(); virtual void WriteProjectDepends(std::ostream& fout, const char* name, const char* path, cmTarget &t); diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx index a4369a3..bcec45e 100644 --- a/Source/cmIncludeExternalMSProjectCommand.cxx +++ b/Source/cmIncludeExternalMSProjectCommand.cxx @@ -25,18 +25,76 @@ bool cmIncludeExternalMSProjectCommand #ifdef _WIN32 if(this->Makefile->GetDefinition("WIN32")) { + enum Doing { DoingNone, DoingType, DoingGuid, DoingPlatform }; + + Doing doing = DoingNone; + + std::string customType; + std::string customGuid; + std::string platformMapping; + + std::vector<std::string> depends; + for (unsigned int i=2; i<args.size(); ++i) + { + if (args[i] == "TYPE") + { + doing = DoingType; + } + else if (args[i] == "GUID") + { + doing = DoingGuid; + } + else if (args[i] == "PLATFORM") + { + doing = DoingPlatform; + } + else + { + switch (doing) + { + case DoingNone: depends.push_back(args[i]); break; + case DoingType: customType = args[i]; break; + case DoingGuid: customGuid = args[i]; break; + case DoingPlatform: platformMapping = args[i]; break; + } + doing = DoingNone; + } + } + + // Hack together a utility target storing enough information + // to reproduce the target inclusion. + std::string utility_name = args[0]; + std::string path = args[1]; cmSystemTools::ConvertToUnixSlashes(path); + if (!customGuid.empty()) + { + std::string guidVariable = utility_name + "_GUID_CMAKE"; + this->Makefile->GetCMakeInstance()->AddCacheEntry(guidVariable.c_str(), + customGuid.c_str(), + "Stored GUID", + cmCacheManager::INTERNAL); + } + // Create a target instance for this utility. cmTarget* target=this->Makefile->AddNewTarget(cmTarget::UTILITY, - args[0].c_str()); + utility_name.c_str()); + + target->SetProperty("GENERATOR_FILE_NAME", utility_name.c_str()); target->SetProperty("EXTERNAL_MSPROJECT", path.c_str()); - target->SetProperty("EXCLUDE_FROM_ALL","FALSE"); - target->SetProperty("GENERATOR_FILE_NAME", args[0].c_str()); - for (unsigned int i=2; i<args.size(); ++i) + target->SetProperty("EXCLUDE_FROM_ALL", "FALSE"); + + if (!customType.empty()) + target->SetProperty("VS_PROJECT_TYPE",customType.c_str()); + if (!platformMapping.empty()) + target->SetProperty("VS_PLATFORM_MAPPING",platformMapping.c_str()); + + for (std::vector<std::string>::const_iterator it = depends.begin(); + it != depends.end(); + ++it) { - target->AddUtility(args[i].c_str()); + target->AddUtility(it->c_str()); } } #endif diff --git a/Source/cmIncludeExternalMSProjectCommand.h b/Source/cmIncludeExternalMSProjectCommand.h index 911a772..2b2ed0d 100644 --- a/Source/cmIncludeExternalMSProjectCommand.h +++ b/Source/cmIncludeExternalMSProjectCommand.h @@ -59,11 +59,21 @@ public: { return " include_external_msproject(projectname location\n" + " [TYPE projectTypeGUID]\n" + " [GUID projectGUID]\n" + " [PLATFORM platformName]\n" " dep1 dep2 ...)\n" "Includes an external Microsoft project in the generated workspace " "file. Currently does nothing on UNIX. This will create a " "target named [projectname]. This can be used in the add_dependencies " - "command to make things depend on the external project."; + "command to make things depend on the external project." + "\n" + "TYPE, GUID and PLATFORM are optional parameters that allow one " + "to specify the type of project, id (GUID) of the project and " + "the name of the target platform. " + "This is useful for projects requiring values other than the default " + "(e.g. WIX projects). " + "These options are not supported by the Visual Studio 6 generator."; } cmTypeMacro(cmIncludeExternalMSProjectCommand, cmCommand); diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index bf0e997..ace7adf 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -99,6 +99,14 @@ void cmLocalVisualStudio10Generator { cmVS10XMLParser parser; parser.ParseFile(path); + + // if we can not find a GUID then create one + if(parser.GUID.empty()) + { + this->GlobalGenerator->CreateGUID(name); + return; + } + std::string guidStoreName = name; guidStoreName += "_GUID_CMAKE"; // save the GUID in the cache diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 8b87ed4..475b84c 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2012) SET(KWSYS_DATE_STAMP_MONTH 04) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 05) +SET(KWSYS_DATE_STAMP_DAY 16) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 865a409..1c6db39 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -24,11 +24,16 @@ # 4.) Create a <SubTest>.cmake file for each sub-test named above # containing the actual test code. Optionally create files # containing expected test results: -# <SubTest>-result.txt = Process result expected if not "0" -# <SubTest>-stdout.txt = Regex matching expected stdout content -# <SubTest>-stderr.txt = Regex matching expected stderr content +# <SubTest>-result.txt = Process result expected if not "0" +# <SubTest>-stdout.txt = Regex matching expected stdout content +# <SubTest>-stderr.txt = Regex matching expected stderr content +# <SubTest>-check.cmake = Custom result check # Note that trailing newlines will be stripped from actual test # output before matching against the stdout and stderr expressions. +# The code in <SubTest>-check.cmake may use variables +# RunCMake_TEST_SOURCE_DIR = Top of test source tree +# RunCMake_TEST_BINARY_DIR = Top of test binary tree +# and an failure must store a message in RunCMake_TEST_FAILED. macro(add_RunCMake_test test) add_test(RunCMake.${test} ${CMAKE_CMAKE_COMMAND} @@ -45,3 +50,7 @@ add_RunCMake_test(ObjectLibrary) add_RunCMake_test(build_command) add_RunCMake_test(find_package) add_RunCMake_test(list) + +if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]") + add_RunCMake_test(include_external_msproject) +endif() diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 2639463..c3c161a 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -25,14 +25,14 @@ function(run_cmake test) unset(expect_std${o}) endif() endforeach() - set(source_dir "${top_src}") - set(binary_dir "${top_bin}/${test}-build") - file(REMOVE_RECURSE "${binary_dir}") - file(MAKE_DIRECTORY "${binary_dir}") + set(RunCMake_TEST_SOURCE_DIR "${top_src}") + set(RunCMake_TEST_BINARY_DIR "${top_bin}/${test}-build") + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") execute_process( - COMMAND ${CMAKE_COMMAND} "${source_dir}" + COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}" -G "${RunCMake_GENERATOR}" -DRunCMake_TEST=${test} - WORKING_DIRECTORY "${binary_dir}" + WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" OUTPUT_VARIABLE actual_stdout ERROR_VARIABLE actual_stderr RESULT_VARIABLE actual_result @@ -53,6 +53,11 @@ function(run_cmake test) endif() endif() endforeach() + unset(RunCMake_TEST_FAILED) + include(${top_src}/${test}-check.cmake OPTIONAL) + if(RunCMake_TEST_FAILED) + set(msg "${RunCMake_TEST_FAILED}\n${msg}") + endif() if(msg) string(REGEX REPLACE "\n" "\n actual-out> " actual_out " actual-out> ${actual_stdout}") string(REGEX REPLACE "\n" "\n actual-err> " actual_err " actual-err> ${actual_stderr}") diff --git a/Tests/RunCMake/include_external_msproject/CMakeLists.txt b/Tests/RunCMake/include_external_msproject/CMakeLists.txt new file mode 100644 index 0000000..e8db6b0 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/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/include_external_msproject/CustomGuid-check.cmake b/Tests/RunCMake/include_external_msproject/CustomGuid-check.cmake new file mode 100644 index 0000000..68dec4c --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomGuid-check.cmake @@ -0,0 +1 @@ +check_project(CustomGuid external "aaa-bbb-ccc-000" "" "") diff --git a/Tests/RunCMake/include_external_msproject/CustomGuid.cmake b/Tests/RunCMake/include_external_msproject/CustomGuid.cmake new file mode 100644 index 0000000..1dbe7da --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomGuid.cmake @@ -0,0 +1,2 @@ +include_external_msproject(external external.project + GUID aaa-bbb-ccc-000) diff --git a/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform-check.cmake b/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform-check.cmake new file mode 100644 index 0000000..614712e --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform-check.cmake @@ -0,0 +1 @@ +check_project(CustomGuidTypePlatform external "aaa-bbb-ccc-111" "aaa-bbb-ccc-ddd-eee" "Custom Platform") diff --git a/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform.cmake b/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform.cmake new file mode 100644 index 0000000..ee4db65 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomGuidTypePlatform.cmake @@ -0,0 +1,5 @@ +# Test all optional parameters are set. +include_external_msproject(external external.project + GUID aaa-bbb-ccc-111 + TYPE aaa-bbb-ccc-ddd-eee + PLATFORM "Custom Platform") diff --git a/Tests/RunCMake/include_external_msproject/CustomTypePlatform-check.cmake b/Tests/RunCMake/include_external_msproject/CustomTypePlatform-check.cmake new file mode 100644 index 0000000..054eeb0 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomTypePlatform-check.cmake @@ -0,0 +1 @@ +check_project(CustomTypePlatform external "" "aaa-bbb-ccc-ddd-eee" "Custom Platform") diff --git a/Tests/RunCMake/include_external_msproject/CustomTypePlatform.cmake b/Tests/RunCMake/include_external_msproject/CustomTypePlatform.cmake new file mode 100644 index 0000000..8c76adb --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/CustomTypePlatform.cmake @@ -0,0 +1,3 @@ +include_external_msproject(external external.project + TYPE aaa-bbb-ccc-ddd-eee + PLATFORM "Custom Platform") diff --git a/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake b/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake new file mode 100644 index 0000000..90710f9 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake @@ -0,0 +1,6 @@ +include(RunCMake) +include(${CMAKE_CURRENT_LIST_DIR}/check_utils.cmake) + +run_cmake(CustomGuid) +run_cmake(CustomTypePlatform) +run_cmake(CustomGuidTypePlatform) diff --git a/Tests/RunCMake/include_external_msproject/check_utils.cmake b/Tests/RunCMake/include_external_msproject/check_utils.cmake new file mode 100644 index 0000000..7d6b8f8 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/check_utils.cmake @@ -0,0 +1,109 @@ +# Check that file contains line that matches regular expression. +# Sets IS_FOUND variable to TRUE if found and to FALSE otherwise. +macro(check_line_exists TARGET_FILE REG_EXP_REF) + set(IS_FOUND "FALSE") + + file(STRINGS ${TARGET_FILE} FOUND_LINE LIMIT_COUNT 1 REGEX "${${REG_EXP_REF}}") + list(LENGTH FOUND_LINE _VAR_LEN) + + if(_VAR_LEN GREATER 0) + set(IS_FOUND "TRUE") + endif(_VAR_LEN GREATER 0) +endmacro(check_line_exists TARGET_FILE REG_EXP_REF) + +# Search and parse project section line by project name. +# If search was successful stores found type and guid into FOUND_TYPE and FOUND_GUID variables respectively. +# Sets IS_FOUND variable to TRUE if found and to FALSE otherwise. +macro(parse_project_section TARGET_FILE PROJECT_NAME) + set(REG_EXP "^Project\\(\\\"{(.+)}\\\"\\) = \\\"${PROJECT_NAME}\\\", \\\".+\\..+\\\", \\\"{(.+)}\\\"$") + + check_line_exists(${TARGET_FILE} REG_EXP) + if(NOT IS_FOUND) + return() + endif(NOT IS_FOUND) + + string(REGEX REPLACE "${REG_EXP}" "\\1;\\2" _GUIDS "${FOUND_LINE}") + + list(GET _GUIDS 0 FOUND_TYPE) + list(GET _GUIDS 1 FOUND_GUID) +endmacro(parse_project_section TARGET_FILE PROJECT_NAME) + +# Search project section line by project name and type. +# Returns TRUE if found and FALSE otherwise +function(check_project_type TARGET_FILE PROJECT_NAME PROJECT_TYPE RESULT) + set(${RESULT} "FALSE" PARENT_SCOPE) + + parse_project_section(${TARGET_FILE} ${PROJECT_NAME}) + if(IS_FOUND AND FOUND_TYPE STREQUAL PROJECT_TYPE) + set(${RESULT} "TRUE" PARENT_SCOPE) + endif(IS_FOUND AND FOUND_TYPE STREQUAL PROJECT_TYPE) +endfunction(check_project_type TARGET_FILE PROJECT_NAME PROJECT_TYPE RESULT) + + +# Search project section line by project name and id. +# Returns TRUE if found and FALSE otherwise +function(check_project_guid TARGET_FILE PROJECT_NAME PROJECT_GUID RESULT) + set(${RESULT} "FALSE" PARENT_SCOPE) + + parse_project_section(${TARGET_FILE} ${PROJECT_NAME}) + if(IS_FOUND AND FOUND_GUID STREQUAL PROJECT_GUID) + set(${RESULT} "TRUE" PARENT_SCOPE) + endif(IS_FOUND AND FOUND_GUID STREQUAL PROJECT_GUID) +endfunction(check_project_guid TARGET_FILE PROJECT_NAME PROJECT_GUID RESULT) + + +# Search project's build configuration line by project name and target platform name. +# Returns TRUE if found and FALSE otherwise +function(check_custom_platform TARGET_FILE PROJECT_NAME PLATFORM_NAME RESULT) + set(${RESULT} "FALSE" PARENT_SCOPE) + + # extract project guid + parse_project_section(${TARGET_FILE} ${PROJECT_NAME}) + if(NOT IS_FOUND) + return() + endif(NOT IS_FOUND) + + # probably whould be better to use configuration name + # extracted from CMAKE_CONFIGURATION_TYPES than just hardcoded "Debug" instead + set(REG_EXP "^(\t)*\\{${FOUND_GUID}\\}\\.Debug[^ ]*\\.ActiveCfg = Debug\\|${PLATFORM_NAME}$") + check_line_exists(${TARGET_FILE} REG_EXP) + + set(${RESULT} ${IS_FOUND} PARENT_SCOPE) +endfunction(check_custom_platform TARGET_FILE PLATFORM_NAME RESULT) + +# RunCMake test check helper +function(check_project test name guid type platform) + set(sln "${RunCMake_TEST_BINARY_DIR}/${test}.sln") + set(sep "") + set(failed "") + if(NOT type) + set(type 8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942) + endif() + if(NOT platform) + if("${RunCMake_GENERATOR}" MATCHES "Win64") + set(platform "x64") + else() + set(platform "Win32") + endif() + endif() + if(guid) + check_project_guid("${sln}" "${name}" "${guid}" passed_guid) + if(NOT passed_guid) + set(failed "${failed}${sep}${name} solution has no project with expected GUID=${guid}") + set(sep "\n") + endif() + else() + set(passed_guid 1) + endif() + check_project_type("${sln}" "${name}" "${type}" passed_type) + if(NOT passed_type) + set(failed "${failed}${sep}${name} solution has no project with expected TYPE=${type}") + set(sep "\n") + endif() + check_custom_platform("${sln}" "${name}" "${platform}" passed_platform) + if(NOT passed_platform) + set(failed "${failed}${sep}${name} solution has no project with expected PLATFORM=${platform}") + set(sep "\n") + endif() + set(RunCMake_TEST_FAILED "${failed}" PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/include_external_msproject/main.cpp b/Tests/RunCMake/include_external_msproject/main.cpp new file mode 100644 index 0000000..9198103 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/main.cpp @@ -0,0 +1,3 @@ +void main() +{ +} |