diff options
-rw-r--r-- | Help/generator/Ninja.rst | 4 | ||||
-rw-r--r-- | Help/release/dev/add-bruce-c.rst | 4 | ||||
-rw-r--r-- | Help/release/dev/ninja-directory-targets.rst | 7 | ||||
-rw-r--r-- | Help/variable/CMAKE_LANG_COMPILER_ID.rst | 1 | ||||
-rw-r--r-- | Modules/CMakeCCompilerId.c.in | 22 | ||||
-rw-r--r-- | Modules/CMakeCompilerIdDetection.cmake | 1 | ||||
-rw-r--r-- | Modules/CMakeDetermineCCompiler.cmake | 3 | ||||
-rw-r--r-- | Modules/CMakePlatformId.h.in | 6 | ||||
-rw-r--r-- | Modules/Compiler/Bruce-C-DetermineCompiler.cmake | 1 | ||||
-rw-r--r-- | Modules/Compiler/Bruce-C.cmake | 7 | ||||
-rw-r--r-- | Modules/FindPkgConfig.cmake | 2 | ||||
-rw-r--r-- | Modules/TestBigEndian.cmake | 2 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 82 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.h | 3 | ||||
-rw-r--r-- | Tests/RunCMake/FindPkgConfig/FindPkgConfig_cache_variables.cmake | 11 | ||||
-rw-r--r-- | Tests/RunCMake/Ninja/RunCMakeTest.cmake | 16 | ||||
-rw-r--r-- | Tests/RunCMake/Ninja/SubDir-build-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/Ninja/SubDir.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/Ninja/SubDir/CMakeLists.txt | 2 |
20 files changed, 162 insertions, 17 deletions
diff --git a/Help/generator/Ninja.rst b/Help/generator/Ninja.rst index 920abcb..d94e5f6 100644 --- a/Help/generator/Ninja.rst +++ b/Help/generator/Ninja.rst @@ -6,3 +6,7 @@ Generates build.ninja files. A build.ninja file is generated into the build tree. Recent versions of the ninja program can build the project through the "all" target. An "install" target is also provided. + +For each subdirectory ``sub/dir`` of the project an additional target +named ``sub/dir/all`` is generated that depends on all targets required +by that subdirectory. diff --git a/Help/release/dev/add-bruce-c.rst b/Help/release/dev/add-bruce-c.rst new file mode 100644 index 0000000..9e47900 --- /dev/null +++ b/Help/release/dev/add-bruce-c.rst @@ -0,0 +1,4 @@ +add-bruce-c +----------- + +* Support was added for the Bruce C Compiler with compiler id ``Bruce``. diff --git a/Help/release/dev/ninja-directory-targets.rst b/Help/release/dev/ninja-directory-targets.rst new file mode 100644 index 0000000..4826228 --- /dev/null +++ b/Help/release/dev/ninja-directory-targets.rst @@ -0,0 +1,7 @@ +ninja-directory-targets +----------------------- + +* The :generator:`Ninja` generator learned to produce phony targets + of the form ``sub/dir/all`` to drive the build of a subdirectory. + This is equivalent to ``cd sub/dir; make all`` with + :ref:`Makefile Generators`. diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst index 81976a9..ebd616e 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst @@ -12,6 +12,7 @@ include: ADSP = Analog VisualDSP++ (analog.com) AppleClang = Apple Clang (apple.com) ARMCC = ARM Compiler (arm.com) + Bruce = Bruce C Compiler CCur = Concurrent Fortran (ccur.com) Clang = LLVM Clang (clang.llvm.org) Cray = Cray Compiler (cray.com) diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index 5bfe0fd..c107dfd 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -5,6 +5,11 @@ #if defined(__18CXX) # define ID_VOID_MAIN #endif +#if defined(__CLASSIC_C__) +/* cv-qualifiers did not exist in K&R C */ +# define const +# define volatile +#endif @CMAKE_C_COMPILER_ID_CONTENT@ @@ -28,23 +33,28 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; @CMAKE_C_COMPILER_ID_PLATFORM_CONTENT@ @CMAKE_C_COMPILER_ID_ERROR_FOR_TEST@ -const char* info_language_dialect_default = "INFO" ":" "dialect_default[" -#if !defined(__STDC_VERSION__) - "90" +#if !defined(__STDC__) +# define C_DIALECT #elif __STDC_VERSION__ >= 201000L - "11" +# define C_DIALECT "11" #elif __STDC_VERSION__ >= 199901L - "99" +# define C_DIALECT "99" #else +# define C_DIALECT "90" #endif -"]"; +const char* info_language_dialect_default = + "INFO" ":" "dialect_default[" C_DIALECT "]"; /*--------------------------------------------------------------------------*/ #ifdef ID_VOID_MAIN void main() {} #else +# if defined(__CLASSIC_C__) +int main(argc, argv) int argc; char *argv[]; +# else int main(int argc, char* argv[]) +# endif { int require = 0; require += info_compiler[argc]; diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index cbc0055..1d341e5 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -79,6 +79,7 @@ function(compiler_id_detection outvar lang) if (lang STREQUAL C) list(APPEND ordered_compilers TinyCC + Bruce ) endif() list(APPEND ordered_compilers diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index e0b5468..f8c6303 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -87,6 +87,9 @@ else() # Try enabling ANSI mode on HP. "-Aa" + + # Try compiling K&R-compatible code (needed by Bruce C Compiler). + "-D__CLASSIC_C__" ) endif() diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index da99b9e..47eb00a 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -91,11 +91,11 @@ # define PLATFORM_ID "Windows3x" # else /* unknown platform */ -# define PLATFORM_ID "" +# define PLATFORM_ID # endif #else /* unknown platform */ -# define PLATFORM_ID "" +# define PLATFORM_ID #endif @@ -145,7 +145,7 @@ # endif #else -# define ARCHITECTURE_ID "" +# define ARCHITECTURE_ID #endif /* Convert integer to decimal digit literals. */ diff --git a/Modules/Compiler/Bruce-C-DetermineCompiler.cmake b/Modules/Compiler/Bruce-C-DetermineCompiler.cmake new file mode 100644 index 0000000..bb9f4b9 --- /dev/null +++ b/Modules/Compiler/Bruce-C-DetermineCompiler.cmake @@ -0,0 +1 @@ +set(_compiler_id_pp_test "defined(__BCC__)") diff --git a/Modules/Compiler/Bruce-C.cmake b/Modules/Compiler/Bruce-C.cmake new file mode 100644 index 0000000..23676ec --- /dev/null +++ b/Modules/Compiler/Bruce-C.cmake @@ -0,0 +1,7 @@ +# Bruce C Compiler ignores "-g" flag and optimization cannot be +# enabled here (it is implemented only for 8086 target). +set (CMAKE_C_FLAGS_INIT "-D__CLASSIC_C__") +set (CMAKE_C_FLAGS_DEBUG_INIT "-g") +set (CMAKE_C_FLAGS_MINSIZEREL_INIT "-DNDEBUG") +set (CMAKE_C_FLAGS_RELEASE_INIT "-DNDEBUG") +set (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g -DNDEBUG") diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 4f50e38..447c526 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -383,7 +383,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma pkg_get_variable("${_pkg_check_prefix}_INCLUDEDIR" ${_pkg_check_modules_pkg} "includedir") pkg_get_variable("${_pkg_check_prefix}_LIBDIR" ${_pkg_check_modules_pkg} "libdir") foreach (variable IN ITEMS PREFIX INCLUDEDIR LIBDIR) - _pkgconfig_set("${_pkg_check_modules_pkg}_${variable}" "${${_pkg_check_modules_pkg}_${variable}}") + _pkgconfig_set("${_pkg_check_prefix}_${variable}" "${${_pkg_check_prefix}_${variable}}") endforeach () if (NOT ${_is_silent}) diff --git a/Modules/TestBigEndian.cmake b/Modules/TestBigEndian.cmake index fcb41ab..fdc3adb 100644 --- a/Modules/TestBigEndian.cmake +++ b/Modules/TestBigEndian.cmake @@ -104,7 +104,7 @@ macro(TEST_BIG_ENDIAN VARIABLE) message(SEND_ERROR "TEST_BIG_ENDIAN found no result!") endif() - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the system is big endian passed with the following output:\n${OUTPUT}\nTestEndianess.c:\n${TEST_ENDIANESS_FILE_CONTENT}\n\n") else() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 11dff2b..f61e30e 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 20160321) +set(CMake_VERSION_PATCH 20160322) #set(CMake_VERSION_RC 1) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 83422b7..f12396f 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -577,6 +577,7 @@ void cmGlobalNinjaGenerator::Generate() this->WriteAssumedSourceDependencies(); this->WriteTargetAliases(*this->BuildFileStream); + this->WriteFolderTargets(*this->BuildFileStream); this->WriteUnknownExplicitDependencies(*this->BuildFileStream); this->WriteBuiltinTargets(*this->BuildFileStream); @@ -848,6 +849,18 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaPath(const std::string& path) return convPath; } +std::string +cmGlobalNinjaGenerator::ConvertToNinjaFolderRule(const std::string& path) +{ + cmLocalNinjaGenerator *ng = + static_cast<cmLocalNinjaGenerator *>(this->LocalGenerators[0]); + std::string convPath = ng->Convert(path+"/all", cmOutputConverter::HOME); +#ifdef _WIN32 + cmSystemTools::ReplaceString(convPath, "/", "\\"); +#endif + return convPath; +} + void cmGlobalNinjaGenerator::AddCXXCompileCommand( const std::string &commandLine, const std::string &sourceFile) @@ -1044,6 +1057,75 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os) } } +void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os) +{ + cmGlobalNinjaGenerator::WriteDivider(os); + os << "# Folder targets.\n\n"; + + std::map<std::string, cmNinjaDeps> targetsPerFolder; + for (std::vector<cmLocalGenerator *>::const_iterator + lgi = this->LocalGenerators.begin(); + lgi != this->LocalGenerators.end(); ++lgi) + { + cmLocalGenerator const* lg = *lgi; + const std::string currentSourceFolder( + lg->GetStateSnapshot().GetDirectory().GetCurrentSource()); + // The directory-level rule should depend on the target-level rules + // for all targets in the directory. + targetsPerFolder[currentSourceFolder] = cmNinjaDeps(); + for (std::vector<cmGeneratorTarget*>::const_iterator + ti = lg->GetGeneratorTargets().begin(); + ti != lg->GetGeneratorTargets().end(); ++ti) + { + cmGeneratorTarget const* gt = *ti; + cmState::TargetType const type = gt->GetType(); + if((type == cmState::EXECUTABLE || + type == cmState::STATIC_LIBRARY || + type == cmState::SHARED_LIBRARY || + type == cmState::MODULE_LIBRARY || + type == cmState::OBJECT_LIBRARY || + type == cmState::UTILITY) && + !gt->GetPropertyAsBool("EXCLUDE_FROM_ALL")) + { + targetsPerFolder[currentSourceFolder].push_back(gt->GetName()); + } + } + + // The directory-level rule should depend on the directory-level + // rules of the subdirectories. + std::vector<cmState::Snapshot> const& children = + lg->GetStateSnapshot().GetChildren(); + for(std::vector<cmState::Snapshot>::const_iterator + stateIt = children.begin(); stateIt != children.end(); ++stateIt) + { + targetsPerFolder[currentSourceFolder].push_back( + this->ConvertToNinjaFolderRule( + stateIt->GetDirectory().GetCurrentSource())); + } + } + + std::string const rootSourceDir = + this->LocalGenerators[0]->GetSourceDirectory(); + for (std::map<std::string, cmNinjaDeps >::const_iterator it = + targetsPerFolder.begin(); it != targetsPerFolder.end(); ++it) + { + cmGlobalNinjaGenerator::WriteDivider( os ); + std::string const& currentSourceDir = it->first; + + // Do not generate a rule for the root source dir. + if (rootSourceDir.length() >= currentSourceDir.length()) + { + continue; + } + + std::string const comment = "Folder: " + currentSourceDir; + cmNinjaDeps output(1); + output.push_back(this->ConvertToNinjaFolderRule(currentSourceDir)); + + this->WritePhonyBuild(os, comment, output, it->second); + } +} + void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) { if (!this->ComputingUnknownDependencies) diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 8656590..3023a95 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -228,6 +228,8 @@ public: return this->RulesFileStream; } std::string ConvertToNinjaPath(const std::string& path); + std::string ConvertToNinjaFolderRule(const std::string& path); + struct MapToNinjaPathImpl { cmGlobalNinjaGenerator* GG; @@ -342,6 +344,7 @@ private: void WriteAssumedSourceDependencies(); void WriteTargetAliases(std::ostream& os); + void WriteFolderTargets(std::ostream& os); void WriteUnknownExplicitDependencies(std::ostream& os); void WriteBuiltinTargets(std::ostream& os); diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_cache_variables.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_cache_variables.cmake index 8d8d000..d0046ca 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_cache_variables.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_cache_variables.cmake @@ -1,14 +1,15 @@ +cmake_minimum_required(VERSION 3.3) + find_package(PkgConfig REQUIRED) pkg_check_modules(NCURSES QUIET ncurses) if (NCURSES_FOUND) foreach (variable IN ITEMS PREFIX INCLUDEDIR LIBDIR) - get_property("${variable}" + get_property(value CACHE "NCURSES_${variable}" - PROPERTY TYPE - SET) - if (NOT ${variable}) - message(FATAL_ERROR "Failed to set cache entry for NCURSES_${variable}") + PROPERTY VALUE) + if (NOT value STREQUAL NCURSES_${variable}) + message(FATAL_ERROR "Failed to set cache entry for NCURSES_${variable}:\nexpected -->${value}<--\nreceived -->${NCURSES_${variable}}<--") endif () endforeach () else () diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 64f97bc..4e06888 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -16,3 +16,19 @@ run_CMP0058(WARN-no) run_CMP0058(WARN-by) run_CMP0058(NEW-no) run_CMP0058(NEW-by) + +function(run_SubDir) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SubDir-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(SubDir) + if(WIN32) + set(SubDir_all [[SubDir\all]]) + else() + set(SubDir_all [[SubDir/all]]) + endif() + run_cmake_command(SubDir-build ${CMAKE_COMMAND} --build . --target ${SubDir_all}) +endfunction() +run_SubDir() diff --git a/Tests/RunCMake/Ninja/SubDir-build-stdout.txt b/Tests/RunCMake/Ninja/SubDir-build-stdout.txt new file mode 100644 index 0000000..e4b4662 --- /dev/null +++ b/Tests/RunCMake/Ninja/SubDir-build-stdout.txt @@ -0,0 +1 @@ +Building InAll diff --git a/Tests/RunCMake/Ninja/SubDir.cmake b/Tests/RunCMake/Ninja/SubDir.cmake new file mode 100644 index 0000000..7224ec3 --- /dev/null +++ b/Tests/RunCMake/Ninja/SubDir.cmake @@ -0,0 +1,2 @@ +add_subdirectory(SubDir) +add_custom_target(TopFail ALL COMMAND does_not_exist) diff --git a/Tests/RunCMake/Ninja/SubDir/CMakeLists.txt b/Tests/RunCMake/Ninja/SubDir/CMakeLists.txt new file mode 100644 index 0000000..73ae431 --- /dev/null +++ b/Tests/RunCMake/Ninja/SubDir/CMakeLists.txt @@ -0,0 +1,2 @@ +add_custom_target(SubFail COMMAND does_not_exist) +add_custom_target(InAll ALL COMMAND ${CMAKE_COMMAND} -E echo "Building InAll") |