diff options
125 files changed, 1361 insertions, 534 deletions
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 88b39d4..00a932f 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -370,10 +370,12 @@ Properties on Source Files /prop_sf/AUTORCC_OPTIONS /prop_sf/COMPILE_DEFINITIONS /prop_sf/COMPILE_FLAGS + /prop_sf/COMPILE_OPTIONS /prop_sf/EXTERNAL_OBJECT /prop_sf/Fortran_FORMAT /prop_sf/GENERATED /prop_sf/HEADER_FILE_ONLY + /prop_sf/INCLUDE_DIRECTORIES /prop_sf/KEEP_EXTENSION /prop_sf/LABELS /prop_sf/LANGUAGE diff --git a/Help/manual/cpack.1.rst b/Help/manual/cpack.1.rst index 4f9f28d..105bb67 100644 --- a/Help/manual/cpack.1.rst +++ b/Help/manual/cpack.1.rst @@ -62,6 +62,12 @@ Options Run cpack with debug output (for CPack developers). +``--trace`` + Put underlying cmake scripts in trace mode. + +``--trace-expand`` + Put underlying cmake scripts in expanded trace mode. + ``-P <package name>`` override/define CPACK_PACKAGE_NAME diff --git a/Help/prop_sf/COMPILE_OPTIONS.rst b/Help/prop_sf/COMPILE_OPTIONS.rst new file mode 100644 index 0000000..157c0b0 --- /dev/null +++ b/Help/prop_sf/COMPILE_OPTIONS.rst @@ -0,0 +1,17 @@ +COMPILE_OPTIONS +--------------- + +List of additional options to pass to the compiler. + +This property holds a :ref:`;-list <CMake Language Lists>` of options +and will be added to the list of compile flags when this +source file builds. Use :prop_sf:`COMPILE_DEFINITIONS` to pass +additional preprocessor definitions and :prop_sf:`INCLUDE_DIRECTORIES` to pass +additional include directories. + +Contents of ``COMPILE_OPTIONS`` may use "generator expressions" with the +syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual +for available expressions. However, :generator:`Xcode` +does not support per-config per-source settings, so expressions +that depend on the build configuration are not allowed with that +generator. diff --git a/Help/prop_sf/INCLUDE_DIRECTORIES.rst b/Help/prop_sf/INCLUDE_DIRECTORIES.rst new file mode 100644 index 0000000..55780e5 --- /dev/null +++ b/Help/prop_sf/INCLUDE_DIRECTORIES.rst @@ -0,0 +1,18 @@ +INCLUDE_DIRECTORIES +------------------- + +List of preprocessor include file search directories. + +This property holds a :ref:`;-list <CMake Language Lists>` of paths +and will be added to the list of include directories when this +source file builds. These directories will take precedence over directories +defined at target level except for :generator:`Xcode` generator due to technical +limitations. + +Relative paths should not be added to this property directly. + +Contents of ``INCLUDE_DIRECTORIES`` may use "generator expressions" with +the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual +for available expressions. However, :generator:`Xcode` does not support +per-config per-source settings, so expressions that depend on the build +configuration are not allowed with that generator. diff --git a/Help/release/dev/GenerateExportHeader-include-guard.rst b/Help/release/dev/GenerateExportHeader-include-guard.rst new file mode 100644 index 0000000..fa2be42 --- /dev/null +++ b/Help/release/dev/GenerateExportHeader-include-guard.rst @@ -0,0 +1,8 @@ +GenerateExportHeader-include-guard +---------------------------------- + +* The :module:`GenerateExportHeader` module learned an optional + ``INCLUDE_GUARD_NAME`` parameter to change the name of the include guard + symbol written to the generated export header. + Additionally, it now adds a comment after the closing ``#endif`` on the + generated export header's include guard. diff --git a/Help/release/dev/UseJava-add_jar-native-headers.rst b/Help/release/dev/UseJava-add_jar-native-headers.rst new file mode 100644 index 0000000..0370a672 --- /dev/null +++ b/Help/release/dev/UseJava-add_jar-native-headers.rst @@ -0,0 +1,9 @@ +UseJava-add_jar-native-headers +------------------------------ + +* | The command add_jar from :module:`UseJava` module learns how to generate native + headers files using option -h of javac tool. + | This capability requires, at least, version 1.8 of Javac tool. + | Command create_javah will no longer be supported due to the + `suppression of javah tool <http://openjdk.java.net/jeps/313>`_ in the version 1.10 + of the JDK, so ``add_jar(GENERATE_NATIVE_HEADERS)`` must be used instead. diff --git a/Help/release/dev/cpack_trace.rst b/Help/release/dev/cpack_trace.rst new file mode 100644 index 0000000..1152385 --- /dev/null +++ b/Help/release/dev/cpack_trace.rst @@ -0,0 +1,4 @@ +cpack_trace +----------- + +* :manual:`cpack(1)` gained ``--trace`` and ``--trace-expand`` options. diff --git a/Help/release/dev/src-new-properties-COMPILE_OPTIONS-and-INCLUDE_DIRECTORIES.rst b/Help/release/dev/src-new-properties-COMPILE_OPTIONS-and-INCLUDE_DIRECTORIES.rst new file mode 100644 index 0000000..d06c109 --- /dev/null +++ b/Help/release/dev/src-new-properties-COMPILE_OPTIONS-and-INCLUDE_DIRECTORIES.rst @@ -0,0 +1,10 @@ +src-new-properties-COMPILE_OPTIONS-and-INCLUDE_DIRECTORIES +---------------------------------------------------------- + +* Source file learns new properties: + + * A :prop_sf:`COMPILE_OPTIONS` source file property was added to manage list + of options to pass to the compiler. + + * An :prop_sf:`INCLUDE_DIRECTORIES` source file property was added to specify + list of preprocessor include file search directories. diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index 31ccef7..9ac9560 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -158,10 +158,6 @@ if(NOT CMAKE_INCLUDE_FLAG_CXX) set(CMAKE_INCLUDE_FLAG_CXX ${CMAKE_INCLUDE_FLAG_C}) endif() -if(NOT CMAKE_INCLUDE_FLAG_SEP_CXX) - set(CMAKE_INCLUDE_FLAG_SEP_CXX ${CMAKE_INCLUDE_FLAG_SEP_C}) -endif() - # for most systems a module is the same as a shared library # so unless the variable CMAKE_MODULE_EXISTS is set just # copy the values from the LIBRARY variables diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index 8e5c027..5f028e4 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -151,10 +151,6 @@ if(NOT CMAKE_INCLUDE_FLAG_Fortran) set(CMAKE_INCLUDE_FLAG_Fortran ${CMAKE_INCLUDE_FLAG_C}) endif() -if(NOT CMAKE_INCLUDE_FLAG_SEP_Fortran) - set(CMAKE_INCLUDE_FLAG_SEP_Fortran ${CMAKE_INCLUDE_FLAG_SEP_C}) -endif() - set(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.") set(CMAKE_Fortran_FLAGS_INIT "$ENV{FFLAGS} ${CMAKE_Fortran_FLAGS_INIT}") diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index 3eb86f9..02cb464 100644 --- a/Modules/CMakeGenericSystem.cmake +++ b/Modules/CMakeGenericSystem.cmake @@ -9,7 +9,6 @@ set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") # -rpath set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty set(CMAKE_INCLUDE_FLAG_C "-I") # -I -set(CMAKE_INCLUDE_FLAG_C_SEP "") # , or empty set(CMAKE_LIBRARY_PATH_FLAG "-L") set(CMAKE_LIBRARY_PATH_TERMINATOR "") # for the Digital Mars D compiler the link paths have to be terminated with a "/" set(CMAKE_LINK_LIBRARY_FLAG "-l") diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 4573c2e..17a3357 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -19,6 +19,7 @@ # [EXPORT_FILE_NAME <export_file_name>] # [DEPRECATED_MACRO_NAME <deprecated_macro_name>] # [NO_EXPORT_MACRO_NAME <no_export_macro_name>] +# [INCLUDE_GUARD_NAME <include_guard_name>] # [STATIC_DEFINE <static_define>] # [NO_DEPRECATED_MACRO_NAME <no_deprecated_macro_name>] # [DEFINE_NO_DEPRECATED] @@ -277,7 +278,7 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) set(options DEFINE_NO_DEPRECATED) set(oneValueArgs PREFIX_NAME BASE_NAME EXPORT_MACRO_NAME EXPORT_FILE_NAME DEPRECATED_MACRO_NAME NO_EXPORT_MACRO_NAME STATIC_DEFINE - NO_DEPRECATED_MACRO_NAME CUSTOM_CONTENT_FROM_VARIABLE) + NO_DEPRECATED_MACRO_NAME CUSTOM_CONTENT_FROM_VARIABLE INCLUDE_GUARD_NAME) set(multiValueArgs) cmake_parse_arguments(_GEH "${options}" "${oneValueArgs}" "${multiValueArgs}" @@ -341,7 +342,11 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) endif() string(MAKE_C_IDENTIFIER ${NO_DEPRECATED_MACRO_NAME} NO_DEPRECATED_MACRO_NAME) - set(INCLUDE_GUARD_NAME "${EXPORT_MACRO_NAME}_H") + if(_GEH_INCLUDE_GUARD_NAME) + set(INCLUDE_GUARD_NAME ${_GEH_INCLUDE_GUARD_NAME}) + else() + set(INCLUDE_GUARD_NAME "${EXPORT_MACRO_NAME}_H") + endif() get_target_property(EXPORT_IMPORT_CONDITION ${TARGET_LIBRARY} DEFINE_SYMBOL) diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index b5fc236..939bd7b 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -20,6 +20,7 @@ # [VERSION version] # [OUTPUT_NAME name] # [OUTPUT_DIR dir] +# [GENERATE_NATIVE_HEADERS target [DESTINATION dir]] # ) # # This command creates a <target_name>.jar. It compiles the given @@ -35,6 +36,14 @@ # The default OUTPUT_DIR can also be changed by setting the variable # CMAKE_JAVA_TARGET_OUTPUT_DIR. # +# Optionaly, using option GENERATE_NATIVE_HEADERS, native header files can be generated +# for methods declared as native. These files provide the connective glue that allow your +# Java and C code to interact. An INTERFACE target will be created for an easy usage +# of generated files. Sub-option DESTINATION can be used to specify output directory for +# generated header files. +# +# GENERATE_NATIVE_HEADERS option requires, at least, version 1.8 of the JDK. +# # Additional instructions: # # :: @@ -168,6 +177,22 @@ # # # +# :: +# +# For an optimum usage of option GENERATE_NATIVE_HEADERS, it is recommended to +# include module JNI before any call to add_jar. The produced target for native +# headers can then be used to compile C/C++ sources with command +# target_link_libraries. +# +# +# :: +# +# find_package(JNI) +# add_jar(foo foo.java GENERATE_NATIVE_HEADERS foo-native) +# add_library(bar bar.cpp) +# target_link_libraries(bar PRIVATE foo-native) +# +# # Target Properties: # # :: @@ -359,6 +384,10 @@ # Create C header files from java classes. These files provide the connective glue # that allow your Java and C code to interact. # +# This command will no longer be supported starting with version 1.10 of the JDK due +# to the `suppression of javah tool <http://openjdk.java.net/jeps/313>`_. +# Command ``add_jar(GENERATE_NATIVE_HEADERS)`` must be used instead. +# # There are two main signatures for create_javah. The first signature # returns generated files through variable specified by GENERATED_FILES option: # @@ -448,7 +477,7 @@ function(add_jar _TARGET_NAME) cmake_parse_arguments(_add_jar "" "VERSION;OUTPUT_DIR;OUTPUT_NAME;ENTRY_POINT;MANIFEST" - "SOURCES;INCLUDE_JARS" + "SOURCES;INCLUDE_JARS;GENERATE_NATIVE_HEADERS" ${ARGN} ) @@ -494,6 +523,31 @@ function(add_jar _TARGET_NAME) get_filename_component (_MANIFEST_VALUE "${_add_jar_MANIFEST}" ABSOLUTE) endif () + unset (_GENERATE_NATIVE_HEADERS) + if (_add_jar_GENERATE_NATIVE_HEADERS) + # Raise an error if JDK version is less than 1.8 because javac -h is not supported + # by earlier versions. + if ("${Java_VERSION}" VERSION_LESS 1.8) + message (FATAL_ERROR "ADD_JAR: GENERATE_NATIVE_HEADERS is not supported with this version of Java.") + endif() + cmake_parse_arguments (_add_jar_GENERATE_NATIVE_HEADERS "" "DESTINATION" "" ${_add_jar_GENERATE_NATIVE_HEADERS}) + if (NOT _add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS) + message (FATAL_ERROR "ADD_JAR: GENERATE_NATIVE_HEADERS: missing required argument.") + endif() + list (LENGTH _add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS length) + if (length GREATER 1) + list (REMOVE_AT _add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS 0) + message (FATAL_ERROR "ADD_JAR: GENERATE_NATIVE_HEADERS: ${_add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS}: unexpected argument(s).") + endif() + if (NOT _add_jar_GENERATE_NATIVE_HEADERS_DESTINATION) + set (_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir/native_headers") + endif() + + set (_GENERATE_NATIVE_HEADERS_TARGET ${_add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS}) + set (_GENERATE_NATIVE_HEADERS_OUTPUT_DIR "${_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION}") + set (_GENERATE_NATIVE_HEADERS -h "${_GENERATE_NATIVE_HEADERS_OUTPUT_DIR}") + endif() + if (LIBRARY_OUTPUT_PATH) set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH}) else () @@ -625,6 +679,7 @@ function(add_jar _TARGET_NAME) ${CMAKE_JAVA_COMPILE_FLAGS} -classpath "${CMAKE_JAVA_INCLUDE_PATH_FINAL}" -d ${CMAKE_JAVA_CLASS_OUTPUT_PATH} + ${_GENERATE_NATIVE_HEADERS} ${_JAVA_SOURCES_FILELISTS} COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME} DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_FILELISTS} ${_JAVA_COMPILE_DEPENDS} @@ -735,6 +790,17 @@ function(add_jar _TARGET_NAME) ${CMAKE_JAVA_CLASS_OUTPUT_PATH} ) + if (_GENERATE_NATIVE_HEADERS) + # create an INTERFACE library encapsulating include directory for generated headers + add_library (${_GENERATE_NATIVE_HEADERS_TARGET} INTERFACE) + target_include_directories (${_GENERATE_NATIVE_HEADERS_TARGET} INTERFACE + "${_GENERATE_NATIVE_HEADERS_OUTPUT_DIR}" + ${JNI_INCLUDE_DIRS}) + # this INTERFACE library depends on jar generation + add_dependencies (${_GENERATE_NATIVE_HEADERS_TARGET} ${_TARGET_NAME}) + + set_property (DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${_GENERATE_NATIVE_HEADERS_OUTPUT_DIR}") + endif() endfunction() function(INSTALL_JAR _TARGET_NAME) @@ -1246,6 +1312,12 @@ function(create_javadoc _target) endfunction() function (create_javah) + if ("${Java_VERSION}" VERSION_GREATER_EQUAL 1.10) + message (FATAL_ERROR "create_javah: not supported with this Java version. Use add_jar(GENERATE_NATIVE_HEADERS) instead.") + elseif ("${Java_VERSION}" VERSION_GREATER_EQUAL 1.8) + message (DEPRECATION "create_javah: this command will no longer be supported starting with version 1.10 of JDK. Update your project by using command add_jar(GENERATE_NATIVE_HEADERS) instead.") + endif() + cmake_parse_arguments(_create_javah "" "TARGET;GENERATED_FILES;OUTPUT_NAME;OUTPUT_DIR" diff --git a/Modules/exportheader.cmake.in b/Modules/exportheader.cmake.in index 9dd75bf..c518b3d 100644 --- a/Modules/exportheader.cmake.in +++ b/Modules/exportheader.cmake.in @@ -39,4 +39,4 @@ # endif #endif @CUSTOM_CONTENT@ -#endif +#endif /* @INCLUDE_GUARD_NAME@ */ diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index bab642b..27b7cd3 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 10) -set(CMake_VERSION_PATCH 20180124) +set(CMake_VERSION_PATCH 20180125) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index ea0e899..69e53e1 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -637,6 +637,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cm.GetCurrentSnapshot().SetDefaultDefinitions(); cm.AddCMakePaths(); cm.SetProgressCallback(cmCPackGeneratorProgress, this); + cm.SetTrace(this->Trace); + cm.SetTraceExpand(this->TraceExpand); cmGlobalGenerator gg(&cm); cmMakefile mf(&gg, cm.GetCurrentSnapshot()); if (!installSubDirectory.empty() && installSubDirectory != "/" && diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 8100b66..c22f36b 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -36,6 +36,16 @@ public: } /** + * Put underlying cmake scripts in trace mode. + */ + void SetTrace(bool val) { this->Trace = val; } + + /** + * Put underlying cmake scripts in expanded trace mode. + */ + void SetTraceExpand(bool val) { this->TraceExpand = val; } + + /** * Returns true if the generator may work on this system. * Rational: * Some CPack generator may run on some host and may not on others @@ -295,6 +305,8 @@ protected: ComponentPackageMethod componentPackageMethod; cmCPackLog* Logger; + bool Trace; + bool TraceExpand; private: cmMakefile* MakefileMap; diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index addb54e..2b2152c 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -43,6 +43,8 @@ static const char* cmDocumentationOptions[][2] = { { "-D <var>=<value>", "Set a CPack variable." }, { "--config <config file>", "Specify the config file." }, { "--verbose,-V", "enable verbose output" }, + { "--trace", "Put underlying cmake scripts in trace mode." }, + { "--trace-expand", "Put underlying cmake scripts in expanded trace mode." }, { "--debug", "enable debug output (for CPack developers)" }, { "-P <package name>", "override/define CPACK_PACKAGE_NAME" }, { "-R <package version>", "override/define CPACK_PACKAGE_VERSION" }, @@ -98,6 +100,8 @@ int main(int argc, char const* const* argv) argc = args.argc(); argv = args.argv(); + cmSystemTools::EnableMSVCDebugHook(); + cmSystemTools::InitializeLibUV(); cmSystemTools::FindCMakeResources(argv[0]); cmCPackLog log; @@ -106,8 +110,6 @@ int main(int argc, char const* const* argv) log.SetOutputPrefix("CPack: "); log.SetVerbosePrefix("CPack Verbose: "); - cmSystemTools::EnableMSVCDebugHook(); - if (cmSystemTools::GetCurrentWorkingDirectory().empty()) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Current working directory cannot be established." @@ -119,6 +121,8 @@ int main(int argc, char const* const* argv) bool help = false; bool helpVersion = false; bool verbose = false; + bool trace = false; + bool traceExpand = false; bool debug = false; std::string helpFull; std::string helpMAN; @@ -154,6 +158,10 @@ int main(int argc, char const* const* argv) arg.AddArgument("--debug", argT::NO_ARGUMENT, &debug, "-V"); arg.AddArgument("--config", argT::SPACE_ARGUMENT, &cpackConfigFile, "CPack configuration file"); + arg.AddArgument("--trace", argT::NO_ARGUMENT, &trace, + "Put underlying cmake scripts in trace mode."); + arg.AddArgument("--trace-expand", argT::NO_ARGUMENT, &traceExpand, + "Put underlying cmake scripts in expanded trace mode."); arg.AddArgument("-C", argT::SPACE_ARGUMENT, &cpackBuildConfig, "CPack build configuration"); arg.AddArgument("-G", argT::SPACE_ARGUMENT, &generator, "CPack generator"); @@ -197,6 +205,14 @@ int main(int argc, char const* const* argv) globalMF.AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); #endif + if (trace) { + cminst.SetTrace(true); + } + if (traceExpand) { + cminst.SetTrace(true); + cminst.SetTraceExpand(true); + } + bool cpackConfigFileSpecified = true; if (cpackConfigFile.empty()) { cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory(); @@ -340,6 +356,10 @@ int main(int argc, char const* const* argv) << std::endl); parsed = 0; } + + cpackGenerator->SetTrace(trace); + cpackGenerator->SetTraceExpand(traceExpand); + if (parsed && !cpackGenerator->Initialize(gen, mf)) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Cannot initialize the generator " << gen diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index 97d5579..17cf628 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -75,6 +75,7 @@ int main(int argc, char const* const* argv) argc = encoding_args.argc(); argv = encoding_args.argv(); + cmSystemTools::InitializeLibUV(); cmSystemTools::FindCMakeResources(argv[0]); cmDocumentation doc; doc.addCMakeStandardDocSections(); diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index bfd43cf..193f4d3 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -55,6 +55,7 @@ int main(int argc, char** argv) int argc2 = encoding_args.argc(); char const* const* argv2 = encoding_args.argv(); + cmSystemTools::InitializeLibUV(); cmSystemTools::FindCMakeResources(argv2[0]); // check docs first so that X is not need to get docs // do docs, if args were given diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index b9e200a..2e95032 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -164,7 +164,7 @@ bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args, std::vector<std::string> srclists(s, args.end()); cmTarget* tgt = - this->Makefile->AddExecutable(exename.c_str(), srclists, excludeFromAll); + this->Makefile->AddExecutable(exename, srclists, excludeFromAll); if (use_win32) { tgt->SetProperty("WIN32_EXECUTABLE", "ON"); } diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index a200385..1fc0828 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -498,7 +498,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(cmXMLWriter& xml) // Add the file to the list of sources. std::string const& source = sf->GetFullPath(); cmSourceGroup* sourceGroup = - makefile->FindSourceGroup(source.c_str(), sourceGroups); + makefile->FindSourceGroup(source, sourceGroups); sourceGroup->AssignSource(sf); } diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index c7197f2..a89c187 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -257,6 +257,8 @@ void cmExtraSublimeTextGenerator::AppendTarget( std::string flagsString = this->ComputeFlagsForObject(sourceFile, lg, target); std::string definesString = this->ComputeDefines(sourceFile, lg, target); + std::string includesString = + this->ComputeIncludes(sourceFile, lg, target); flags.clear(); cmsys::RegularExpression flagRegex; // Regular expression to extract compiler flags from a string @@ -264,7 +266,8 @@ void cmExtraSublimeTextGenerator::AppendTarget( const char* regexString = "(^|[ ])-[DIOUWfgs][^= ]+(=\\\"[^\"]+\\\"|=[^\"][^ ]+)?"; flagRegex.compile(regexString); - std::string workString = flagsString + " " + definesString; + std::string workString = + flagsString + " " + definesString + " " + includesString; while (flagRegex.find(workString)) { std::string::size_type start = flagRegex.start(); if (workString[start] == ' ') { @@ -351,23 +354,21 @@ std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject( lg->GetTargetCompileFlags(gtgt, config, language, flags); - // Add include directory flags. - { - std::vector<std::string> includes; - lg->GetIncludeDirectories(includes, gtgt, language, config); - std::string includeFlags = lg->GetIncludeFlags(includes, gtgt, language, - true); // full include paths - lg->AppendFlags(flags, includeFlags); - } - // Add source file specific flags. + cmGeneratorExpressionInterpreter genexInterpreter(lg, gtgt, config, + gtgt->GetName(), language); + const std::string COMPILE_FLAGS("COMPILE_FLAGS"); if (const char* cflags = source->GetProperty(COMPILE_FLAGS)) { - cmGeneratorExpressionInterpreter genexInterpreter( - lg, gtgt, config, gtgt->GetName(), language); lg->AppendFlags(flags, genexInterpreter.Evaluate(cflags, COMPILE_FLAGS)); } + const std::string COMPILE_OPTIONS("COMPILE_OPTIONS"); + if (const char* coptions = source->GetProperty(COMPILE_OPTIONS)) { + lg->AppendCompileOptions( + flags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS)); + } + return flags; } @@ -410,6 +411,34 @@ std::string cmExtraSublimeTextGenerator::ComputeDefines( return definesString; } +std::string cmExtraSublimeTextGenerator::ComputeIncludes( + cmSourceFile* source, cmLocalGenerator* lg, cmGeneratorTarget* target) + +{ + std::vector<std::string> includes; + cmMakefile* makefile = lg->GetMakefile(); + const std::string& language = source->GetLanguage(); + const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); + cmGeneratorExpressionInterpreter genexInterpreter( + lg, target, config, target->GetName(), language); + + // Add include directories for this source file + const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); + if (const char* cincludes = source->GetProperty(INCLUDE_DIRECTORIES)) { + lg->AppendIncludeDirectories( + includes, genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES), + *source); + } + + // Add include directory flags. + lg->GetIncludeDirectories(includes, target, language, config); + + std::string includesString = + lg->GetIncludeFlags(includes, target, language, true, false, config); + + return includesString; +} + bool cmExtraSublimeTextGenerator::Open(const std::string& bindir, const std::string& projectName, bool dryRun) diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h index 57ba1cf..bc158f6 100644 --- a/Source/cmExtraSublimeTextGenerator.h +++ b/Source/cmExtraSublimeTextGenerator.h @@ -65,6 +65,9 @@ private: std::string ComputeDefines(cmSourceFile* source, cmLocalGenerator* lg, cmGeneratorTarget* gtgt); + std::string ComputeIncludes(cmSourceFile* source, cmLocalGenerator* lg, + cmGeneratorTarget* gtgt); + bool Open(const std::string& bindir, const std::string& projectName, bool dryRun) override; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index b3e3393..d459436 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -486,7 +486,7 @@ void cmGhsMultiTargetGenerator::WriteSources( for (std::vector<cmSourceFile*>::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { std::vector<cmSourceGroup> sourceGroups(this->Makefile->GetSourceGroups()); - char const* sourceFullPath = (*si)->GetFullPath().c_str(); + std::string const& sourceFullPath = (*si)->GetFullPath(); cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(sourceFullPath, sourceGroups); std::string sgPath = sourceGroup->GetFullName(); @@ -604,7 +604,7 @@ std::string cmGhsMultiTargetGenerator::ComputeLongestObjectDirectory( dir_max += "/"; std::vector<cmSourceGroup> sourceGroups( localGhsMultiGenerator->GetMakefile()->GetSourceGroups()); - char const* const sourceFullPath = sourceFile->GetFullPath().c_str(); + std::string const& sourceFullPath = sourceFile->GetFullPath(); cmSourceGroup* sourceGroup = localGhsMultiGenerator->GetMakefile()->FindSourceGroup(sourceFullPath, sourceGroups); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index bd51f60..9db21d8 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -743,6 +743,11 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( if (const char* cflags = sf->GetProperty(COMPILE_FLAGS)) { lg->AppendFlags(flags, genexInterpreter.Evaluate(cflags, COMPILE_FLAGS)); } + const std::string COMPILE_OPTIONS("COMPILE_OPTIONS"); + if (const char* coptions = sf->GetProperty(COMPILE_OPTIONS)) { + lg->AppendCompileOptions( + flags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS)); + } // Add per-source definitions. BuildObjectListOrString flagsBuild(this, false); @@ -759,6 +764,16 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( flags += flagsBuild.GetString(); } + // Add per-source include directories. + std::vector<std::string> includes; + const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); + if (const char* cincludes = sf->GetProperty(INCLUDE_DIRECTORIES)) { + lg->AppendIncludeDirectories( + includes, genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES), + *sf); + } + lg->AppendFlags(flags, lg->GetIncludeFlags(includes, gtgt, lang, true)); + cmXCodeObject* buildFile = this->CreateXCodeSourceFileFromPath(sf->GetFullPath(), gtgt, lang, sf); @@ -3521,7 +3536,7 @@ void cmGlobalXCodeGenerator::AppendDefines( } void cmGlobalXCodeGenerator::AppendFlag(std::string& flags, - std::string const& flag) + std::string const& flag) const { // Short-circuit for an empty flag. if (flag.empty()) { diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 2269b25..d173f7a 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -104,7 +104,7 @@ public: bool ShouldStripResourcePath(cmMakefile*) const override; bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf) override; - void AppendFlag(std::string& flags, std::string const& flag); + void AppendFlag(std::string& flags, std::string const& flag) const; protected: void AddExtraIDETargets() override; diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index 4b59f44..354b757 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -13,6 +13,7 @@ cmIDEOptions::cmIDEOptions() { this->DoingDefine = false; this->AllowDefine = true; + this->DoingInclude = false; this->AllowSlash = false; this->DoingFollowing = 0; for (int i = 0; i < FlagTableCount; ++i) { @@ -33,6 +34,13 @@ void cmIDEOptions::HandleFlag(const char* flag) return; } + // If the last option was -I then this option is the include directory. + if (this->DoingInclude) { + this->DoingInclude = false; + this->Includes.push_back(flag); + return; + } + // If the last option expected a following value, this is it. if (this->DoingFollowing) { this->FlagMapUpdate(this->DoingFollowing, flag); @@ -53,6 +61,17 @@ void cmIDEOptions::HandleFlag(const char* flag) } return; } + // Look for include directory. + if (this->AllowInclude && flag[1] == 'I') { + if (flag[2] == '\0') { + // The next argument will have the include directory. + this->DoingInclude = true; + } else { + // Store this include directory. + this->Includes.push_back(flag + 2); + } + return; + } // Look through the available flag tables. bool flag_handled = false; @@ -155,6 +174,29 @@ std::vector<std::string> const& cmIDEOptions::GetDefines() const return this->Defines; } +void cmIDEOptions::AddInclude(const std::string& include) +{ + this->Includes.push_back(include); +} + +void cmIDEOptions::AddIncludes(const char* includes) +{ + if (includes) { + // Expand the list of includes. + cmSystemTools::ExpandListArgument(includes, this->Includes); + } +} +void cmIDEOptions::AddIncludes(const std::vector<std::string>& includes) +{ + this->Includes.insert(this->Includes.end(), includes.begin(), + includes.end()); +} + +std::vector<std::string> const& cmIDEOptions::GetIncludes() const +{ + return this->Includes; +} + void cmIDEOptions::AddFlag(std::string const& flag, std::string const& value) { this->FlagMap[flag] = value; diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index ded92ca..54cb524 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -20,12 +20,17 @@ public: cmIDEOptions(); virtual ~cmIDEOptions(); - // Store definitions and flags. + // Store definitions, includes and flags. void AddDefine(const std::string& define); void AddDefines(const char* defines); void AddDefines(const std::vector<std::string>& defines); std::vector<std::string> const& GetDefines() const; + void AddInclude(const std::string& includes); + void AddIncludes(const char* includes); + void AddIncludes(const std::vector<std::string>& includes); + std::vector<std::string> const& GetIncludes() const; + void AddFlag(std::string const& flag, std::string const& value); void AddFlag(std::string const& flag, std::vector<std::string> const& value); void AppendFlag(std::string const& flag, std::string const& value); @@ -76,8 +81,13 @@ protected: // Preprocessor definitions. std::vector<std::string> Defines; + // Include directories. + std::vector<std::string> Includes; + bool DoingDefine; bool AllowDefine; + bool DoingInclude; + bool AllowInclude; bool AllowSlash; cmIDEFlagTable const* DoingFollowing; enum diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c8d94c0..86b16f8 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -16,6 +16,7 @@ #include "cmMakefile.h" #include "cmRulePlaceholderExpander.h" #include "cmSourceFile.h" +#include "cmSourceFileLocation.h" #include "cmState.h" #include "cmStateDirectory.h" #include "cmStateTypes.h" @@ -37,6 +38,7 @@ #include <sstream> #include <stdio.h> #include <string.h> +#include <unordered_set> #include <utility> #if defined(__HAIKU__) @@ -792,19 +794,14 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags, if (const char* langFlagRegexStr = this->Makefile->GetDefinition(langFlagRegexVar)) { // Filter flags acceptable to this language. - cmsys::RegularExpression r(langFlagRegexStr); std::vector<std::string> opts; if (const char* targetFlags = target->GetProperty("COMPILE_FLAGS")) { cmSystemTools::ParseWindowsCommandLine(targetFlags, opts); } target->GetCompileOptions(opts, config, lang); - for (std::string const& opt : opts) { - if (r.find(opt.c_str())) { - // (Re-)Escape this flag. COMPILE_FLAGS were already parsed - // as a command line above, and COMPILE_OPTIONS are escaped. - this->AppendFlagEscape(flags, opt); - } - } + // (Re-)Escape these flags. COMPILE_FLAGS were already parsed + // as a command line above, and COMPILE_OPTIONS are escaped. + this->AppendCompileOptions(flags, opts, langFlagRegexStr); } else { // Use all flags. if (const char* targetFlags = target->GetProperty("COMPILE_FLAGS")) { @@ -813,10 +810,8 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags, } std::vector<std::string> opts; target->GetCompileOptions(opts, config, lang); - for (std::string const& opt : opts) { - // COMPILE_OPTIONS are escaped. - this->AppendFlagEscape(flags, opt); - } + // COMPILE_OPTIONS are escaped. + this->AppendCompileOptions(flags, opts); } for (auto const& it : target->GetMaxLanguageStandards()) { @@ -1876,7 +1871,7 @@ void cmLocalGenerator::AddConfigVariableFlags(std::string& flags, } void cmLocalGenerator::AppendFlags(std::string& flags, - const std::string& newFlags) + const std::string& newFlags) const { if (!newFlags.empty()) { if (!flags.empty()) { @@ -1886,7 +1881,8 @@ void cmLocalGenerator::AppendFlags(std::string& flags, } } -void cmLocalGenerator::AppendFlags(std::string& flags, const char* newFlags) +void cmLocalGenerator::AppendFlags(std::string& flags, + const char* newFlags) const { if (newFlags && *newFlags) { this->AppendFlags(flags, std::string(newFlags)); @@ -1894,7 +1890,7 @@ void cmLocalGenerator::AppendFlags(std::string& flags, const char* newFlags) } void cmLocalGenerator::AppendFlagEscape(std::string& flags, - const std::string& rawFlag) + const std::string& rawFlag) const { this->AppendFlags(flags, this->EscapeForShell(rawFlag)); } @@ -1930,6 +1926,87 @@ void cmLocalGenerator::AppendIPOLinkerFlags(std::string& flags, } } +void cmLocalGenerator::AppendCompileOptions(std::string& options, + const char* options_list, + const char* regex) const +{ + // Short-circuit if there are no options. + if (!options_list) { + return; + } + + // Expand the list of options. + std::vector<std::string> options_vec; + cmSystemTools::ExpandListArgument(options_list, options_vec); + this->AppendCompileOptions(options, options_vec, regex); +} + +void cmLocalGenerator::AppendCompileOptions( + std::string& options, const std::vector<std::string>& options_vec, + const char* regex) const +{ + if (regex != nullptr) { + // Filter flags upon specified reges. + cmsys::RegularExpression r(regex); + + for (std::string const& opt : options_vec) { + if (r.find(opt.c_str())) { + this->AppendFlagEscape(options, opt); + } + } + } else { + for (std::string const& opt : options_vec) { + this->AppendFlagEscape(options, opt); + } + } +} + +void cmLocalGenerator::AppendIncludeDirectories( + std::vector<std::string>& includes, const char* includes_list, + const cmSourceFile& sourceFile) const +{ + // Short-circuit if there are no includes. + if (!includes_list) { + return; + } + + // Expand the list of includes. + std::vector<std::string> includes_vec; + cmSystemTools::ExpandListArgument(includes_list, includes_vec); + this->AppendIncludeDirectories(includes, includes_vec, sourceFile); +} + +void cmLocalGenerator::AppendIncludeDirectories( + std::vector<std::string>& includes, + const std::vector<std::string>& includes_vec, + const cmSourceFile& sourceFile) const +{ + std::unordered_set<std::string> uniqueIncludes; + + for (const std::string& include : includes_vec) { + if (!cmSystemTools::FileIsFullPath(include.c_str())) { + std::ostringstream e; + e << "Found relative path while evaluating include directories of " + "\"" + << sourceFile.GetLocation().GetName() << "\":\n \"" << include + << "\"\n"; + + this->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + + std::string inc = include; + + if (!cmSystemTools::IsOff(inc.c_str())) { + cmSystemTools::ConvertToUnixSlashes(inc); + } + + if (uniqueIncludes.insert(inc).second) { + includes.push_back(inc); + } + } +} + void cmLocalGenerator::AppendDefines(std::set<std::string>& defines, const char* defines_list) const { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 4a7d2ca..a66fa6e 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -118,10 +118,11 @@ public: cmGeneratorTarget const* target, const std::string& lang); ///! Append flags to a string. - virtual void AppendFlags(std::string& flags, const std::string& newFlags); - virtual void AppendFlags(std::string& flags, const char* newFlags); + virtual void AppendFlags(std::string& flags, + const std::string& newFlags) const; + virtual void AppendFlags(std::string& flags, const char* newFlags) const; virtual void AppendFlagEscape(std::string& flags, - const std::string& rawFlag); + const std::string& rawFlag) const; void AppendIPOLinkerFlags(std::string& flags, cmGeneratorTarget* target, const std::string& config, const std::string& lang); @@ -152,6 +153,23 @@ public: cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const; /** + * Process a list of include directories + */ + void AppendIncludeDirectories(std::vector<std::string>& includes, + const char* includes_list, + const cmSourceFile& sourceFile) const; + void AppendIncludeDirectories(std::vector<std::string>& includes, + std::string const& includes_list, + const cmSourceFile& sourceFile) const + { + this->AppendIncludeDirectories(includes, includes_list.c_str(), + sourceFile); + } + void AppendIncludeDirectories(std::vector<std::string>& includes, + const std::vector<std::string>& includes_vec, + const cmSourceFile& sourceFile) const; + + /** * Encode a list of preprocessor definitions for the compiler * command line. */ @@ -166,6 +184,22 @@ public: const std::vector<std::string>& defines_vec) const; /** + * Encode a list of compile options for the compiler + * command line. + */ + void AppendCompileOptions(std::string& options, const char* options_list, + const char* regex = nullptr) const; + void AppendCompileOptions(std::string& options, + std::string const& options_list, + const char* regex = nullptr) const + { + this->AppendCompileOptions(options, options_list.c_str(), regex); + } + void AppendCompileOptions(std::string& options, + const std::vector<std::string>& options_vec, + const char* regex = nullptr) const; + + /** * Join a set of defines into a definesString with a space separator. */ void JoinDefines(const std::set<std::string>& defines, diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 28890f0..e2d5322 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -830,8 +830,8 @@ std::string cmLocalUnixMakefileGenerator3::GetRelativeTargetDirectory( return dir; } -void cmLocalUnixMakefileGenerator3::AppendFlags(std::string& flags, - const std::string& newFlags) +void cmLocalUnixMakefileGenerator3::AppendFlags( + std::string& flags, const std::string& newFlags) const { if (this->IsWatcomWMake() && !newFlags.empty()) { std::string newf = newFlags; @@ -845,7 +845,7 @@ void cmLocalUnixMakefileGenerator3::AppendFlags(std::string& flags, } void cmLocalUnixMakefileGenerator3::AppendFlags(std::string& flags, - const char* newFlags) + const char* newFlags) const { this->cmLocalGenerator::AppendFlags(flags, newFlags); } diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index b149524..86c5aab 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -88,8 +88,9 @@ public: const std::string& tgt); // append flags to a string - void AppendFlags(std::string& flags, const std::string& newFlags) override; - void AppendFlags(std::string& flags, const char* newFlags) override; + void AppendFlags(std::string& flags, + const std::string& newFlags) const override; + void AppendFlags(std::string& flags, const char* newFlags) const override; // append an echo command enum EchoColor diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 59c20a9..f38cd79 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -45,15 +45,6 @@ public: extern cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[]; -static void cmConvertToWindowsSlash(std::string& s) -{ - std::string::size_type pos = 0; - while ((pos = s.find('/', pos)) != std::string::npos) { - s[pos] = '\\'; - pos++; - } -} - cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator( cmGlobalGenerator* gg, cmMakefile* mf) : cmLocalVisualStudioGenerator(gg, mf) @@ -704,11 +695,16 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( targetOptions.Parse(flags.c_str()); targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); - std::vector<std::string> targetDefines; if (!langForClCompile.empty()) { + std::vector<std::string> targetDefines; target->GetCompileDefinitions(targetDefines, configName, langForClCompile); + targetOptions.AddDefines(targetDefines); + + std::vector<std::string> targetIncludes; + this->GetIncludeDirectories(targetIncludes, target, langForClCompile, + configName); + targetOptions.AddIncludes(targetIncludes); } - targetOptions.AddDefines(targetDefines); targetOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); @@ -795,27 +791,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( << this->ConvertToXMLOutputPath(modDir.c_str()) << "\\$(ConfigurationName)\"\n"; } - fout << "\t\t\t\tAdditionalIncludeDirectories=\""; - std::vector<std::string> includes_cl; - if (!langForClCompile.empty()) { - this->GetIncludeDirectories(includes_cl, target, langForClCompile, - configName); - } - std::vector<std::string>::iterator i = includes_cl.begin(); - for (; i != includes_cl.end(); ++i) { - // output the include path - std::string ipath = this->ConvertToXMLOutputPath(i->c_str()); - fout << ipath << ";"; - // if this is fortran then output the include with - // a ConfigurationName on the end of it. - if (this->FortranProject) { - ipath = i->c_str(); - ipath += "/$(ConfigurationName)"; - ipath = this->ConvertToXMLOutputPath(ipath.c_str()); - fout << ipath << ";"; - } - } - fout << "\"\n"; + targetOptions.OutputAdditionalIncludeDirectories( + fout, "\t\t\t\t", "\n", + this->FortranProject ? "Fortran" : langForClCompile); targetOptions.OutputFlagMap(fout, "\t\t\t\t"); targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", langForClCompile); @@ -835,20 +813,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( fout << "\t\t\t<Tool\n" "\t\t\t\tName=\"MASM\"\n" - "\t\t\t\tIncludePaths=\"" ; - std::vector<std::string> includes_masm; - this->GetIncludeDirectories(includes_masm, target, "ASM_MASM", - configName); /* clang-format on */ - const char* sep = ""; - for (i = includes_masm.begin(); i != includes_masm.end(); ++i) { - std::string inc = *i; - cmConvertToWindowsSlash(inc); - fout << sep << this->EscapeForXML(inc); - sep = ";"; - } - fout << "\"\n"; + targetOptions.OutputAdditionalIncludeDirectories(fout, "\t\t\t\t", "\n", + "ASM_MASM"); // Use same preprocessor definitions as VCCLCompilerTool. targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "ASM_MASM"); @@ -868,16 +836,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( if (this->FortranProject) { tool = "VFResourceCompilerTool"; } - fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n" - << "\t\t\t\tAdditionalIncludeDirectories=\""; - std::vector<std::string> includes_rc; - this->GetIncludeDirectories(includes_rc, target, "RC", configName); - for (i = includes_rc.begin(); i != includes_rc.end(); ++i) { - std::string ipath = this->ConvertToXMLOutputPath(i->c_str()); - fout << ipath << ";"; - } + fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n"; + targetOptions.OutputAdditionalIncludeDirectories(fout, "\n\t\t\t\t", "", + "RC"); // add the -D flags to the RC tool - fout << "\""; targetOptions.OutputPreprocessorDefinitions(fout, "\n\t\t\t\t", "", "RC"); fout << "/>\n"; tool = "VCMIDLTool"; @@ -885,14 +847,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( tool = "VFMIDLTool"; } fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n"; - fout << "\t\t\t\tAdditionalIncludeDirectories=\""; - std::vector<std::string> includes_midl; - this->GetIncludeDirectories(includes_midl, target, "MIDL", configName); - for (i = includes_midl.begin(); i != includes_midl.end(); ++i) { - std::string ipath = this->ConvertToXMLOutputPath(i->c_str()); - fout << ipath << ";"; - } - fout << "\"\n"; + targetOptions.OutputAdditionalIncludeDirectories(fout, "\n\t\t\t\t", "", + "MIDL"); fout << "\t\t\t\tMkTypLibCompatible=\"false\"\n"; if (gg->GetPlatformName() == "x64") { fout << "\t\t\t\tTargetEnvironment=\"3\"\n"; @@ -1410,7 +1366,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, // Add the file to the list of sources. std::string const source = sf->GetFullPath(); cmSourceGroup* sourceGroup = - this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); + this->Makefile->FindSourceGroup(source, sourceGroups); sourceGroup->AssignSource(sf); } @@ -1440,6 +1396,7 @@ struct cmLVS7GFileConfig std::string CompileDefs; std::string CompileDefsConfig; std::string AdditionalDeps; + std::string IncludeDirs; bool ExcludedFromBuild; }; @@ -1494,6 +1451,12 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo( fc.CompileFlags = genexInterpreter.Evaluate(cflags, COMPILE_FLAGS); needfc = true; } + const std::string COMPILE_OPTIONS("COMPILE_OPTIONS"); + if (const char* coptions = sf.GetProperty(COMPILE_OPTIONS)) { + lg->AppendCompileOptions( + fc.CompileFlags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS)); + needfc = true; + } if (lg->FortranProject) { switch (cmOutputConverter::GetFortranFormat( sf.GetProperty("Fortran_FORMAT"))) { @@ -1522,6 +1485,12 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo( needfc = true; } + const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); + if (const char* cincs = sf.GetProperty(INCLUDE_DIRECTORIES)) { + fc.IncludeDirs = genexInterpreter.Evaluate(cincs, INCLUDE_DIRECTORIES); + needfc = true; + } + // Check for extra object-file dependencies. if (const char* deps = sf.GetProperty("OBJECT_DEPENDS")) { std::vector<std::string> depends; @@ -1652,7 +1621,7 @@ bool cmLocalVisualStudio7Generator::WriteGroup( this->WriteCustomRule(fout, configs, source.c_str(), *command, fcinfo); } else if (!fcinfo.FileConfigMap.empty()) { const char* aCompilerTool = "VCCLCompilerTool"; - const char* ppLang = "CXX"; + std::string ppLang = "CXX"; if (this->FortranProject) { aCompilerTool = "VFFortranCompilerTool"; } @@ -1699,7 +1668,7 @@ bool cmLocalVisualStudio7Generator::WriteGroup( fout << "\t\t\t\t\t<Tool\n" << "\t\t\t\t\tName=\"" << aCompilerTool << "\"\n"; if (!fc.CompileFlags.empty() || !fc.CompileDefs.empty() || - !fc.CompileDefsConfig.empty()) { + !fc.CompileDefsConfig.empty() || !fc.IncludeDirs.empty()) { Options::Tool tool = Options::Compiler; cmVS7FlagTable const* table = cmLocalVisualStudio7GeneratorFlagTable; @@ -1711,7 +1680,14 @@ bool cmLocalVisualStudio7Generator::WriteGroup( fileOptions.Parse(fc.CompileFlags.c_str()); fileOptions.AddDefines(fc.CompileDefs.c_str()); fileOptions.AddDefines(fc.CompileDefsConfig.c_str()); + // validate source level include directories + std::vector<std::string> includes; + this->AppendIncludeDirectories(includes, fc.IncludeDirs, **sf); + fileOptions.AddIncludes(includes); fileOptions.OutputFlagMap(fout, "\t\t\t\t\t"); + fileOptions.OutputAdditionalIncludeDirectories( + fout, "\t\t\t\t\t", "\n", + ppLang == "CXX" && this->FortranProject ? "Fortran" : ppLang); fileOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t\t", "\n", ppLang); } diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index 457d1fd..92c958d 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -31,10 +31,10 @@ std::string cmLocalXCodeGenerator::GetTargetDirectory( } void cmLocalXCodeGenerator::AppendFlagEscape(std::string& flags, - const std::string& rawFlag) + const std::string& rawFlag) const { - cmGlobalXCodeGenerator* gg = - static_cast<cmGlobalXCodeGenerator*>(this->GlobalGenerator); + const cmGlobalXCodeGenerator* gg = + static_cast<const cmGlobalXCodeGenerator*>(this->GlobalGenerator); gg->AppendFlag(flags, rawFlag); } diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index 8c9596f..5c22dcf 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -31,7 +31,7 @@ public: std::string GetTargetDirectory( cmGeneratorTarget const* target) const override; void AppendFlagEscape(std::string& flags, - const std::string& rawFlag) override; + const std::string& rawFlag) const override; void Generate() override; virtual void GenerateInstallRules(); void ComputeObjectFilenames( diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index eeeb54f..c12cd9e 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -664,7 +664,7 @@ struct file_not_persistent bool operator()(const std::string& path) const { return !(path.find("CMakeTmp") == std::string::npos && - cmSystemTools::FileExists(path.c_str())); + cmSystemTools::FileExists(path)); } }; } @@ -755,8 +755,9 @@ void cmMakefile::AddCustomCommandToTarget( return; } + cmTarget& t = ti->second; if (objLibraryCommands == RejectObjectLibraryCommands && - ti->second.GetType() == cmStateEnums::OBJECT_LIBRARY) { + t.GetType() == cmStateEnums::OBJECT_LIBRARY) { std::ostringstream e; e << "Target \"" << target << "\" is an OBJECT library " @@ -764,7 +765,7 @@ void cmMakefile::AddCustomCommandToTarget( this->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - if (ti->second.GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (t.GetType() == cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "Target \"" << target << "\" is an INTERFACE library " @@ -791,13 +792,13 @@ void cmMakefile::AddCustomCommandToTarget( cc.SetDepfile(depfile); switch (type) { case cmTarget::PRE_BUILD: - ti->second.AddPreBuildCommand(cc); + t.AddPreBuildCommand(cc); break; case cmTarget::PRE_LINK: - ti->second.AddPreLinkCommand(cc); + t.AddPreLinkCommand(cc); break; case cmTarget::POST_BUILD: - ti->second.AddPostBuildCommand(cc); + t.AddPostBuildCommand(cc); break; } } @@ -1180,14 +1181,14 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove) static cmsys::RegularExpression valid("^[-/]D[A-Za-z_][A-Za-z0-9_]*(=.*)?$"); // Make sure the definition matches. - if (!valid.find(def.c_str())) { + if (!valid.find(def)) { return false; } // Definitions with non-trivial values require a policy check. static cmsys::RegularExpression trivial( "^[-/]D[A-Za-z_][A-Za-z0-9_]*(=[A-Za-z0-9_.]+)?$"); - if (!trivial.find(def.c_str())) { + if (!trivial.find(def)) { // This definition has a non-trivial value. switch (this->GetPolicyStatus(cmPolicies::CMP0005)) { case cmPolicies::WARN: @@ -1409,9 +1410,9 @@ void cmMakefile::Configure() // make sure the CMakeFiles dir is there std::string filesDir = this->StateSnapshot.GetDirectory().GetCurrentBinary(); filesDir += cmake::GetCMakeFilesDirectory(); - cmSystemTools::MakeDirectory(filesDir.c_str()); + cmSystemTools::MakeDirectory(filesDir); - assert(cmSystemTools::FileExists(currentStart.c_str(), true)); + assert(cmSystemTools::FileExists(currentStart, true)); this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentStart.c_str()); cmListFile listFile; @@ -1572,7 +1573,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, newSnapshot.GetDirectory().SetCurrentSource(srcPath); newSnapshot.GetDirectory().SetCurrentBinary(binPath); - cmSystemTools::MakeDirectory(binPath.c_str()); + cmSystemTools::MakeDirectory(binPath); cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot); this->GetGlobalGenerator()->AddMakefile(subMf); @@ -1876,7 +1877,7 @@ cmTarget* cmMakefile::AddLibrary(const std::string& lname, return target; } -cmTarget* cmMakefile::AddExecutable(const char* exeName, +cmTarget* cmMakefile::AddExecutable(const std::string& exeName, const std::vector<std::string>& srcs, bool excludeFromAll) { @@ -1936,7 +1937,7 @@ cmSourceFile* cmMakefile::GetSourceFileWithOutput( { // If the queried path is not absolute we use the backward compatible // linear-time search for an output with a matching suffix. - if (!cmSystemTools::FileIsFullPath(name.c_str())) { + if (!cmSystemTools::FileIsFullPath(name)) { return this->LinearGetSourceFileWithOutput(name); } // Otherwise we use an efficient lookup map. @@ -2055,7 +2056,7 @@ cmSourceGroup* cmMakefile::GetOrCreateSourceGroup(const std::string& name) * inherited ones. */ cmSourceGroup* cmMakefile::FindSourceGroup( - const char* source, std::vector<cmSourceGroup>& groups) const + const std::string& source, std::vector<cmSourceGroup>& groups) const { // First search for a group that lists the file explicitly. for (std::vector<cmSourceGroup>::reverse_iterator sg = groups.rbegin(); @@ -3232,7 +3233,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, this->IsSourceFileTryCompile = fast; // does the binary directory exist ? If not create it... if (!cmSystemTools::FileIsDirectory(bindir)) { - cmSystemTools::MakeDirectory(bindir.c_str()); + cmSystemTools::MakeDirectory(bindir); } // change to the tests directory and run cmake @@ -3410,7 +3411,7 @@ std::string cmMakefile::GetModulesFile(const char* filename) const cmSystemTools::ConvertToUnixSlashes(itempl); itempl += "/"; itempl += filename; - if (cmSystemTools::FileExists(itempl.c_str())) { + if (cmSystemTools::FileExists(itempl)) { moduleInCMakeModulePath = itempl; break; } @@ -3422,7 +3423,7 @@ std::string cmMakefile::GetModulesFile(const char* filename) const moduleInCMakeRoot += "/Modules/"; moduleInCMakeRoot += filename; cmSystemTools::ConvertToUnixSlashes(moduleInCMakeRoot); - if (!cmSystemTools::FileExists(moduleInCMakeRoot.c_str())) { + if (!cmSystemTools::FileExists(moduleInCMakeRoot)) { moduleInCMakeRoot.clear(); } @@ -3554,11 +3555,11 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, this->AddCMakeOutputFile(soutfile); mode_t perm = 0; - cmSystemTools::GetPermissions(sinfile.c_str(), perm); + cmSystemTools::GetPermissions(sinfile, perm); std::string::size_type pos = soutfile.rfind('/'); if (pos != std::string::npos) { std::string path = soutfile.substr(0, pos); - cmSystemTools::MakeDirectory(path.c_str()); + cmSystemTools::MakeDirectory(path); } if (copyonly) { @@ -3618,7 +3619,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, soutfile.c_str())) { res = 0; } else { - cmSystemTools::SetPermissions(soutfile.c_str(), perm); + cmSystemTools::SetPermissions(soutfile, perm); } cmSystemTools::RemoveFile(tempOutputFile); } @@ -3707,7 +3708,7 @@ void cmMakefile::AddCMakeDependFilesFromUser() cmSystemTools::ExpandListArgument(deps_str, deps); } for (std::string const& dep : deps) { - if (cmSystemTools::FileIsFullPath(dep.c_str())) { + if (cmSystemTools::FileIsFullPath(dep)) { this->AddCMakeDependFile(dep); } else { std::string f = this->GetCurrentSourceDirectory(); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index f06e2ff..2721277 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -180,7 +180,7 @@ public: /** * Add an executable to the build. */ - cmTarget* AddExecutable(const char* exename, + cmTarget* AddExecutable(const std::string& exename, const std::vector<std::string>& srcs, bool excludeFromAll = false); @@ -516,7 +516,7 @@ public: /** * find what source group this source is in */ - cmSourceGroup* FindSourceGroup(const char* source, + cmSourceGroup* FindSourceGroup(const std::string& source, std::vector<cmSourceGroup>& groups) const; #endif diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 002cc0f..1543536 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -445,10 +445,35 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( << "\n"; } + const std::string COMPILE_OPTIONS("COMPILE_OPTIONS"); + if (const char* coptions = source.GetProperty(COMPILE_OPTIONS)) { + const char* evaluatedOptions = + genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS); + this->LocalGenerator->AppendCompileOptions(flags, evaluatedOptions); + *this->FlagFileStream << "# Custom options: " << relativeObj + << "_OPTIONS = " << evaluatedOptions << "\n" + << "\n"; + } + + // Add include directories from source file properties. + std::vector<std::string> includes; + + const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); + if (const char* cincludes = source.GetProperty(INCLUDE_DIRECTORIES)) { + const char* evaluatedIncludes = + genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES); + this->LocalGenerator->AppendIncludeDirectories(includes, evaluatedIncludes, + source); + *this->FlagFileStream << "# Custom include directories: " << relativeObj + << "_INCLUDE_DIRECTORIES = " << evaluatedIncludes + << "\n" + << "\n"; + } + // Add language-specific defines. std::set<std::string> defines; - // Add source-sepcific preprocessor definitions. + // Add source-specific preprocessor definitions. const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS"); if (const char* compile_defs = source.GetProperty(COMPILE_DEFINITIONS)) { const char* evaluatedDefs = @@ -565,7 +590,10 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( vars.Defines = definesString.c_str(); - std::string const includesString = "$(" + lang + "_INCLUDES)"; + std::string includesString = this->LocalGenerator->GetIncludeFlags( + includes, this->GeneratorTarget, lang, true, false, config); + this->LocalGenerator->AppendFlags(includesString, + "$(" + lang + "_INCLUDES)"); vars.Includes = includesString.c_str(); // At the moment, it is assumed that C, C++, Fortran, and CUDA have both diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index f967168..4f37882 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -135,16 +135,23 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject( } // Add source file specific flags. + cmGeneratorExpressionInterpreter genexInterpreter( + this->LocalGenerator, this->GeneratorTarget, + this->LocalGenerator->GetConfigName(), this->GeneratorTarget->GetName(), + language); + const std::string COMPILE_FLAGS("COMPILE_FLAGS"); if (const char* cflags = source->GetProperty(COMPILE_FLAGS)) { - cmGeneratorExpressionInterpreter genexInterpreter( - this->LocalGenerator, this->GeneratorTarget, - this->LocalGenerator->GetConfigName(), this->GeneratorTarget->GetName(), - language); this->LocalGenerator->AppendFlags( flags, genexInterpreter.Evaluate(cflags, COMPILE_FLAGS)); } + const std::string COMPILE_OPTIONS("COMPILE_OPTIONS"); + if (const char* coptions = source->GetProperty(COMPILE_OPTIONS)) { + this->LocalGenerator->AppendCompileOptions( + flags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS)); + } + return flags; } @@ -204,6 +211,30 @@ std::string cmNinjaTargetGenerator::ComputeDefines(cmSourceFile const* source, return definesString; } +std::string cmNinjaTargetGenerator::ComputeIncludes( + cmSourceFile const* source, const std::string& language) +{ + std::vector<std::string> includes; + const std::string config = this->LocalGenerator->GetConfigName(); + cmGeneratorExpressionInterpreter genexInterpreter( + this->LocalGenerator, this->GeneratorTarget, config, + this->GeneratorTarget->GetName(), language); + + const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); + if (const char* cincludes = source->GetProperty(INCLUDE_DIRECTORIES)) { + this->LocalGenerator->AppendIncludeDirectories( + includes, genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES), + *source); + } + + std::string includesString = this->LocalGenerator->GetIncludeFlags( + includes, this->GeneratorTarget, language, true, false, config); + this->LocalGenerator->AppendFlags(includesString, + this->GetIncludes(language)); + + return includesString; +} + cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const { // Static libraries never depend on other targets for linking. @@ -818,7 +849,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( cmNinjaVars vars; vars["FLAGS"] = this->ComputeFlagsForObject(source, language); vars["DEFINES"] = this->ComputeDefines(source, language); - vars["INCLUDES"] = this->GetIncludes(language); + vars["INCLUDES"] = this->ComputeIncludes(source, language); if (!this->NeedDepTypeMSVC(language)) { vars["DEP_FILE"] = this->GetLocalGenerator()->ConvertToOutputFormat( objectFileName + ".d", cmOutputConverter::SHELL); diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 770a99d..4660a3a 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -82,6 +82,9 @@ protected: std::string ComputeDefines(cmSourceFile const* source, const std::string& language); + std::string ComputeIncludes(cmSourceFile const* source, + const std::string& language); + std::string ConvertToNinjaPath(const std::string& path) const { return this->GetGlobalGenerator()->ConvertToNinjaPath(path); diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index 4c0a354..c2dee8f 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -708,9 +708,31 @@ static Json::Value DumpSourceFilesList( lg->AppendFlags(compileFlags, genexInterpreter.Evaluate(cflags, COMPILE_FLAGS)); } + const std::string COMPILE_OPTIONS("COMPILE_OPTIONS"); + if (const char* coptions = file->GetProperty(COMPILE_OPTIONS)) { + lg->AppendCompileOptions( + compileFlags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS)); + } fileData.Flags = compileFlags; - fileData.IncludePathList = ld.IncludePathList; + // Add include directories from source file properties. + std::vector<std::string> includes; + + const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); + if (const char* cincludes = file->GetProperty(INCLUDE_DIRECTORIES)) { + const char* evaluatedIncludes = + genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES); + lg->AppendIncludeDirectories(includes, evaluatedIncludes, *file); + + for (const auto& include : includes) { + fileData.IncludePathList.push_back(std::make_pair( + include, target->IsSystemIncludeDirectory(include, config))); + } + } + + fileData.IncludePathList.insert(fileData.IncludePathList.end(), + ld.IncludePathList.begin(), + ld.IncludePathList.end()); const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS"); std::set<std::string> defines; diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index bdef3e5..479ecd2 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -386,6 +386,12 @@ void cmStateSnapshot::InitializeFromParent() parent->BuildSystemDirectory->CompileOptionsBacktraces, this->Position->BuildSystemDirectory->CompileOptionsBacktraces, this->Position->CompileOptionsPosition); + + const char* include_regex = + parent->BuildSystemDirectory->Properties.GetPropertyValue( + "INCLUDE_REGULAR_EXPRESSION"); + this->Position->BuildSystemDirectory->Properties.SetProperty( + "INCLUDE_REGULAR_EXPRESSION", include_regex); } cmState* cmStateSnapshot::GetState() const diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index c321236..ce08465 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -51,6 +51,8 @@ // include wincrypt.h after windows.h #include <wincrypt.h> +#include <fcntl.h> /* _O_TEXT */ + #include "cm_uv.h" #else #include <sys/time.h> @@ -980,6 +982,21 @@ std::string cmSystemTools::GetRealPath(const std::string& path, } #endif +void cmSystemTools::InitializeLibUV() +{ +#if defined(_WIN32) + // Perform libuv one-time initialization now, and then un-do its + // global _fmode setting so that using libuv does not change the + // default file text/binary mode. See libuv issue 840. + uv_loop_close(uv_default_loop()); +#ifdef _MSC_VER + _set_fmode(_O_TEXT); +#else + _fmode = _O_TEXT; +#endif +#endif +} + bool cmSystemTools::RenameFile(const char* oldname, const char* newname) { #ifdef _WIN32 @@ -2090,8 +2107,12 @@ void cmSystemTools::FindCMakeResources(const char* argv0) (void)argv0; // ignore this on windows wchar_t modulepath[_MAX_PATH]; ::GetModuleFileNameW(NULL, modulepath, sizeof(modulepath)); - exe_dir = - cmSystemTools::GetFilenamePath(cmsys::Encoding::ToNarrow(modulepath)); + std::string path = cmsys::Encoding::ToNarrow(modulepath); + std::string realPath = cmSystemTools::GetRealPath(path, NULL); + if (realPath.empty()) { + realPath = path; + } + exe_dir = cmSystemTools::GetFilenamePath(realPath); #elif defined(__APPLE__) (void)argv0; // ignore this on OS X #define CM_EXE_PATH_LOCAL_SIZE 16384 diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index d29ba56..25df1f1 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -503,6 +503,10 @@ public: static std::string GetRealPath(const std::string& path, std::string* errorMessage = 0); #endif + + /** Perform one-time initialization of libuv. */ + static void InitializeLibUV(); + private: static bool s_ForceUnixPaths; static bool s_RunCommandHideConsole; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 1b09600..4555358 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -114,22 +114,6 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator( cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator() { - for (OptionsMap::iterator i = this->ClOptions.begin(); - i != this->ClOptions.end(); ++i) { - delete i->second; - } - for (OptionsMap::iterator i = this->LinkOptions.begin(); - i != this->LinkOptions.end(); ++i) { - delete i->second; - } - for (OptionsMap::iterator i = this->CudaOptions.begin(); - i != this->CudaOptions.end(); ++i) { - delete i->second; - } - for (OptionsMap::iterator i = this->CudaLinkOptions.begin(); - i != this->CudaLinkOptions.end(); ++i) { - delete i->second; - } if (!this->BuildFileStream) { return; } @@ -1366,7 +1350,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() si != sources.end(); ++si) { std::string const& source = si->Source->GetFullPath(); cmSourceGroup* sourceGroup = - this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); + this->Makefile->FindSourceGroup(source, sourceGroups); groupsUsed.insert(sourceGroup); } @@ -1538,7 +1522,7 @@ void cmVisualStudio10TargetGenerator::WriteGroupSources( cmSourceFile const* sf = s.SourceFile; std::string const& source = sf->GetFullPath(); cmSourceGroup* sourceGroup = - this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); + this->Makefile->FindSourceGroup(source, sourceGroups); std::string const& filter = sourceGroup->GetFullName(); this->WriteString("<", 2); std::string path = this->ConvertPath(source, s.RelativePath); @@ -1992,7 +1976,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() if (si.Kind == cmGeneratorTarget::SourceKindObjectSource) { // FIXME: refactor generation to avoid tracking XML syntax state. - this->WriteSource(tool, si.Source, " "); + this->WriteSource(tool, si.Source, ""); bool have_nested = this->OutputSourceSpecificFlags(si.Source); if (!exclude_configs.empty()) { if (!have_nested) { @@ -2036,18 +2020,32 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( } std::string flags; bool configDependentFlags = false; + std::string options; + bool configDependentOptions = false; std::string defines; bool configDependentDefines = false; + std::string includes; + bool configDependentIncludes = false; if (const char* cflags = sf.GetProperty("COMPILE_FLAGS")) { configDependentFlags = cmGeneratorExpression::Find(cflags) != std::string::npos; flags += cflags; } + if (const char* coptions = sf.GetProperty("COMPILE_OPTIONS")) { + configDependentOptions = + cmGeneratorExpression::Find(coptions) != std::string::npos; + options += coptions; + } if (const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS")) { configDependentDefines = cmGeneratorExpression::Find(cdefs) != std::string::npos; defines += cdefs; } + if (const char* cincludes = sf.GetProperty("INCLUDE_DIRECTORIES")) { + configDependentIncludes = + cmGeneratorExpression::Find(cincludes) != std::string::npos; + includes += cincludes; + } std::string lang = this->GlobalGenerator->GetLanguageFromExtension(sf.GetExtension().c_str()); std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf); @@ -2099,7 +2097,8 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( } // if we have flags or defines for this config then // use them - if (!flags.empty() || !configDefines.empty() || compileAs || noWinRT) { + if (!flags.empty() || !options.empty() || !configDefines.empty() || + !includes.empty() || compileAs || noWinRT) { (*this->BuildFileStream) << firstString; firstString = ""; // only do firstString once hasFlags = true; @@ -2137,9 +2136,16 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( } else { clOptions.Parse(flags.c_str()); } - if (clOptions.HasFlag("AdditionalIncludeDirectories")) { - clOptions.AppendFlag("AdditionalIncludeDirectories", - "%(AdditionalIncludeDirectories)"); + if (!options.empty()) { + std::string expandedOptions; + if (configDependentOptions) { + this->LocalGenerator->AppendCompileOptions( + expandedOptions, + genexInterpreter.Evaluate(options, "COMPILE_OPTIONS")); + } else { + this->LocalGenerator->AppendCompileOptions(expandedOptions, options); + } + clOptions.Parse(expandedOptions.c_str()); } if (clOptions.HasFlag("DisableSpecificWarnings")) { clOptions.AppendFlag("DisableSpecificWarnings", @@ -2151,9 +2157,21 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( } else { clOptions.AddDefines(configDefines.c_str()); } + std::vector<std::string> includeList; + if (configDependentIncludes) { + this->LocalGenerator->AppendIncludeDirectories( + includeList, + genexInterpreter.Evaluate(includes, "INCLUDE_DIRECTORIES"), *source); + } else { + this->LocalGenerator->AppendIncludeDirectories(includeList, includes, + *source); + } + clOptions.AddIncludes(includeList); clOptions.SetConfiguration(config.c_str()); clOptions.PrependInheritedString("AdditionalOptions"); clOptions.OutputFlagMap(*this->BuildFileStream, " "); + clOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, + " ", "\n", lang); clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", "\n", lang); } @@ -2446,6 +2464,13 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( break; } clOptions.AddDefines(targetDefines); + + // Get includes for this target + if (!this->LangForClCompile.empty()) { + clOptions.AddIncludes( + this->GetIncludes(configName, this->LangForClCompile)); + } + if (this->MSTools) { clOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); @@ -2497,7 +2522,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( } } - this->ClOptions[configName] = pOptions.release(); + this->ClOptions[configName] = std::move(pOptions); return true; } @@ -2510,14 +2535,9 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( } this->WriteString("<ClCompile>\n", 2); clOptions.PrependInheritedString("AdditionalOptions"); - if (!this->LangForClCompile.empty()) { - std::vector<std::string> const includes = - this->GetIncludes(configName, this->LangForClCompile); - clOptions.AppendFlag("AdditionalIncludeDirectories", includes); - } - clOptions.AppendFlag("AdditionalIncludeDirectories", - "%(AdditionalIncludeDirectories)"); clOptions.OutputFlagMap(*this->BuildFileStream, " "); + clOptions.OutputAdditionalIncludeDirectories( + *this->BuildFileStream, " ", "\n", this->LangForClCompile); clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", "\n", this->LangForClCompile); @@ -2595,7 +2615,10 @@ bool cmVisualStudio10TargetGenerator::ComputeRcOptions( Options& clOptions = *(this->ClOptions[configName]); rcOptions.AddDefines(clOptions.GetDefines()); - this->RcOptions[configName] = pOptions.release(); + // Get includes for this target + rcOptions.AddIncludes(this->GetIncludes(configName, "RC")); + + this->RcOptions[configName] = std::move(pOptions); return true; } @@ -2610,11 +2633,8 @@ void cmVisualStudio10TargetGenerator::WriteRCOptions( Options& rcOptions = *(this->RcOptions[configName]); rcOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", "\n", "RC"); - std::vector<std::string> const includes = - this->GetIncludes(configName, "RC"); - rcOptions.AppendFlag("AdditionalIncludeDirectories", includes); - rcOptions.AppendFlag("AdditionalIncludeDirectories", - "%(AdditionalIncludeDirectories)"); + rcOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, + " ", "\n", "RC"); rcOptions.PrependInheritedString("AdditionalOptions"); rcOptions.OutputFlagMap(*this->BuildFileStream, " "); @@ -2728,7 +2748,10 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions( cudaOptions.AddDefine(exportMacro); } - this->CudaOptions[configName] = pOptions.release(); + // Get includes for this target + cudaOptions.AddIncludes(this->GetIncludes(configName, "CUDA")); + + this->CudaOptions[configName] = std::move(pOptions); return true; } @@ -2741,10 +2764,8 @@ void cmVisualStudio10TargetGenerator::WriteCudaOptions( this->WriteString("<CudaCompile>\n", 2); Options& cudaOptions = *(this->CudaOptions[configName]); - std::vector<std::string> const includes = - this->GetIncludes(configName, "CUDA"); - cudaOptions.AppendFlag("Include", includes); - cudaOptions.AppendFlag("Include", "%(Include)"); + cudaOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, + " ", "\n", "CUDA"); cudaOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", "\n", "CUDA"); cudaOptions.PrependInheritedString("AdditionalOptions"); @@ -2801,7 +2822,7 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions( "-Wno-deprecated-gpu-targets"); } - this->CudaLinkOptions[configName] = pOptions.release(); + this->CudaLinkOptions[configName] = std::move(pOptions); return true; } @@ -2852,7 +2873,11 @@ bool cmVisualStudio10TargetGenerator::ComputeMasmOptions( std::string(this->Makefile->GetSafeDefinition(configFlagsVar)); masmOptions.Parse(flags.c_str()); - this->MasmOptions[configName] = pOptions.release(); + + // Get includes for this target + masmOptions.AddIncludes(this->GetIncludes(configName, "ASM_MASM")); + + this->MasmOptions[configName] = std::move(pOptions); return true; } @@ -2870,10 +2895,8 @@ void cmVisualStudio10TargetGenerator::WriteMasmOptions( "\n", "ASM_MASM"); Options& masmOptions = *(this->MasmOptions[configName]); - std::vector<std::string> const includes = - this->GetIncludes(configName, "ASM_MASM"); - masmOptions.AppendFlag("IncludePaths", includes); - masmOptions.AppendFlag("IncludePaths", "%(IncludePaths)"); + masmOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, + " ", "\n", "ASM_MASM"); masmOptions.PrependInheritedString("AdditionalOptions"); masmOptions.OutputFlagMap(*this->BuildFileStream, " "); @@ -2911,7 +2934,11 @@ bool cmVisualStudio10TargetGenerator::ComputeNasmOptions( std::string(" ") + std::string(this->Makefile->GetSafeDefinition(configFlagsVar)); nasmOptions.Parse(flags.c_str()); - this->NasmOptions[configName] = pOptions.release(); + + // Get includes for this target + nasmOptions.AddIncludes(this->GetIncludes(configName, "ASM_NASM")); + + this->NasmOptions[configName] = std::move(pOptions); return true; } @@ -2926,12 +2953,8 @@ void cmVisualStudio10TargetGenerator::WriteNasmOptions( std::vector<std::string> includes = this->GetIncludes(configName, "ASM_NASM"); Options& nasmOptions = *(this->NasmOptions[configName]); - for (size_t i = 0; i < includes.size(); i++) { - includes[i] += "\\"; - } - - nasmOptions.AppendFlag("IncludePaths", includes); - nasmOptions.AppendFlag("IncludePaths", "%(IncludePaths)"); + nasmOptions.OutputAdditionalIncludeDirectories(*this->BuildFileStream, + " ", "\n", "ASM_NASM"); nasmOptions.OutputFlagMap(*this->BuildFileStream, " "); nasmOptions.PrependInheritedString("AdditionalOptions"); nasmOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", @@ -3357,7 +3380,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( } } - this->LinkOptions[config] = pOptions.release(); + this->LinkOptions[config] = std::move(pOptions); return true; } @@ -3523,7 +3546,7 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() if (this->ProjectType == csproj) { return; } - for (std::string const& i : this->Configurations) { + for (const auto& i : this->Configurations) { this->WritePlatformConfigTag("ItemDefinitionGroup", i, 1); *this->BuildFileStream << "\n"; // output cl compile flags <ClCompile></ClCompile> diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index c346164..2bc5da9 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -7,6 +7,7 @@ #include <iosfwd> #include <map> +#include <memory> #include <set> #include <string> #include <vector> @@ -24,6 +25,8 @@ class cmVisualStudioGeneratorOptions; class cmVisualStudio10TargetGenerator { + CM_DISABLE_COPY(cmVisualStudio10TargetGenerator) + public: cmVisualStudio10TargetGenerator(cmGeneratorTarget* target, cmGlobalVisualStudio10Generator* gg); @@ -169,7 +172,7 @@ private: private: typedef cmVisualStudioGeneratorOptions Options; - typedef std::map<std::string, Options*> OptionsMap; + typedef std::map<std::string, std::unique_ptr<Options>> OptionsMap; OptionsMap ClOptions; OptionsMap RcOptions; OptionsMap CudaOptions; diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 106bdff..ccbff83 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -29,23 +29,8 @@ static std::string cmVisualStudioGeneratorOptionsEscapeForXML(std::string ret) cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions( cmLocalVisualStudioGenerator* lg, Tool tool, cmVisualStudio10TargetGenerator* g) - : cmIDEOptions() - , LocalGenerator(lg) - , Version(lg->GetVersion()) - , CurrentTool(tool) - , TargetGenerator(g) + : cmVisualStudioGeneratorOptions(lg, tool, nullptr, nullptr, g) { - // Preprocessor definitions are not allowed for linker tools. - this->AllowDefine = (tool != Linker); - - // Slash options are allowed for VS. - this->AllowSlash = true; - - this->FortranRuntimeDebug = false; - this->FortranRuntimeDLL = false; - this->FortranRuntimeMT = false; - - this->UnknownFlagField = "AdditionalOptions"; } cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions( @@ -64,6 +49,9 @@ cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions( // Preprocessor definitions are not allowed for linker tools. this->AllowDefine = (tool != Linker); + // include directories are not allowed for linker tools. + this->AllowInclude = (tool != Linker); + // Slash options are allowed for VS. this->AllowSlash = true; @@ -511,6 +499,69 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions( } } +void cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories( + std::ostream& fout, const char* prefix, const char* suffix, + const std::string& lang) +{ + if (this->Includes.empty()) { + return; + } + + const char* tag = "AdditionalIncludeDirectories"; + if (lang == "CUDA") { + tag = "Include"; + } else if (lang == "ASM_MASM" || lang == "ASM_NASM") { + tag = "IncludePaths"; + } + + if (this->Version >= cmGlobalVisualStudioGenerator::VS10) { + // if there are configuration specific flags, then + // use the configuration specific tag for PreprocessorDefinitions + if (!this->Configuration.empty()) { + fout << prefix; + this->TargetGenerator->WritePlatformConfigTag( + tag, this->Configuration.c_str(), 0, 0, 0, &fout); + } else { + fout << prefix << "<" << tag << ">"; + } + } else { + fout << prefix << tag << "=\""; + } + + const char* sep = ""; + for (std::string include : this->Includes) { + // first convert all of the slashes + std::string::size_type pos = 0; + while ((pos = include.find('/', pos)) != std::string::npos) { + include[pos] = '\\'; + pos++; + } + + if (lang == "ASM_NASM") { + include += "\\"; + } + + // Escape this include for the IDE. + fout << sep << (this->Version >= cmGlobalVisualStudioGenerator::VS10 + ? cmVisualStudio10GeneratorOptionsEscapeForXML(include) + : cmVisualStudioGeneratorOptionsEscapeForXML(include)); + sep = ";"; + + if (lang == "Fortran") { + include += "/$(ConfigurationName)"; + fout << sep << (this->Version >= cmGlobalVisualStudioGenerator::VS10 + ? cmVisualStudio10GeneratorOptionsEscapeForXML(include) + : cmVisualStudioGeneratorOptionsEscapeForXML(include)); + } + } + + if (this->Version >= cmGlobalVisualStudioGenerator::VS10) { + fout << sep << "%(" << tag << ")</" << tag << ">" << suffix; + } else { + fout << "\"" << suffix; + } +} + void cmVisualStudioGeneratorOptions::OutputFlagMap(std::ostream& fout, const char* indent) { diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index 7c08a2c..2dffe9b 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -86,6 +86,10 @@ public: void OutputPreprocessorDefinitions(std::ostream& fout, const char* prefix, const char* suffix, const std::string& lang); + void OutputAdditionalIncludeDirectories(std::ostream& fout, + const char* prefix, + const char* suffix, + const std::string& lang); void OutputFlagMap(std::ostream& fout, const char* indent); void SetConfiguration(const char* config); diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 59b908a..b185a1b 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -16,10 +16,6 @@ #include "cmDynamicLoader.h" #endif -#ifdef _WIN32 -#include <fcntl.h> /* _O_TEXT */ -#include <stdlib.h> /* _set_fmode, _fmode */ -#endif #include "cm_uv.h" #include "cmsys/Encoding.hxx" @@ -170,19 +166,8 @@ int main(int ac, char const* const* av) ac = args.argc(); av = args.argv(); -#if defined(_WIN32) - // Perform libuv one-time initialization now, and then un-do its - // global _fmode setting so that using libuv does not change the - // default file text/binary mode. See libuv issue 840. - uv_loop_close(uv_default_loop()); -#ifdef _MSC_VER - _set_fmode(_O_TEXT); -#else - _fmode = _O_TEXT; -#endif -#endif - cmSystemTools::EnableMSVCDebugHook(); + cmSystemTools::InitializeLibUV(); cmSystemTools::FindCMakeResources(av[0]); if (ac > 1) { if (strcmp(av[1], "--build") == 0) { diff --git a/Source/ctest.cxx b/Source/ctest.cxx index ad5fec0..0a6d1d2 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -137,6 +137,7 @@ int main(int argc, char const* const* argv) cmSystemTools::DoNotInheritStdPipes(); cmSystemTools::EnableMSVCDebugHook(); + cmSystemTools::InitializeLibUV(); cmSystemTools::FindCMakeResources(argv[0]); // Dispatch 'ctest --launch' mode directly. diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 351e38d..2570e5b 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -83,7 +83,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR) FOREACH(p + CMP0022 # CMake 2.8, Define link interface - required by android_mk export CMP0025 # CMake 3.0, Compiler id for Apple Clang is now AppleClang. + CMP0042 # CMake 3.0, MACOSX_RPATH is enabled by default. CMP0048 # CMake 3.0, Let the project command manage version variables. CMP0056 # CMake 3.2, Honor link flags in try_compile() source-file signature. CMP0063 # CMake 3.3, Honor visibility properties for all target types. @@ -494,6 +496,14 @@ IF(KWSYS_USE_SystemTools) KWSYS_CXX_STAT_HAS_ST_MTIM=${KWSYS_CXX_STAT_HAS_ST_MTIM} KWSYS_CXX_STAT_HAS_ST_MTIMESPEC=${KWSYS_CXX_STAT_HAS_ST_MTIMESPEC} ) + + # Disable getpwnam for static linux builds since it depends on shared glibc + GET_PROPERTY(SHARED_LIBS_SUPPORTED GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) + IF(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT SHARED_LIBS_SUPPORTED) + SET_PROPERTY(SOURCE SystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS + HAVE_GETPWNAM=0 + ) + ENDIF() ENDIF() IF(KWSYS_USE_SystemInformation) @@ -576,7 +586,7 @@ IF(KWSYS_USE_SystemInformation) CHECK_INCLUDE_FILE_CXX("execinfo.h" KWSYS_CXX_HAS_EXECINFOH) IF (KWSYS_CXX_HAS_EXECINFOH) # we have the backtrace header check if it - # can be used with this compiler + # can be used with this compiler SET(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES ${EXECINFO_LIB}) KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_BACKTRACE "Checking whether backtrace works with this C++ compiler" DIRECT) @@ -1012,11 +1022,11 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) # C tests SET(KWSYS_C_TESTS - testEncode - testTerminal + testEncode.c + testTerminal.c ) IF(KWSYS_STANDALONE) - SET(KWSYS_C_TESTS ${KWSYS_C_TESTS} testFail) + SET(KWSYS_C_TESTS ${KWSYS_C_TESTS} testFail.c) ENDIF() CREATE_TEST_SOURCELIST( KWSYS_C_TEST_SRCS ${KWSYS_NAMESPACE}TestsC.c @@ -1025,7 +1035,8 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsC ${KWSYS_C_TEST_SRCS}) SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsC PROPERTY LABELS ${KWSYS_LABELS_EXE}) TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsC ${KWSYS_TARGET_C_LINK}) - FOREACH(test ${KWSYS_C_TESTS}) + FOREACH(testfile ${KWSYS_C_TESTS}) + get_filename_component(test "${testfile}" NAME_WE) ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}}) SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST}) ENDFOREACH() @@ -1033,24 +1044,24 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) # C++ tests IF(NOT WATCOM AND NOT CMake_SOURCE_DIR) SET(KWSYS_CXX_TESTS - testHashSTL + testHashSTL.cxx ) ENDIF() SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} - testConfigure - testSystemTools - testCommandLineArguments - testCommandLineArguments1 - testDirectory + testConfigure.cxx + testSystemTools.cxx + testCommandLineArguments.cxx + testCommandLineArguments1.cxx + testDirectory.cxx ) IF(KWSYS_STL_HAS_WSTRING) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} - testEncoding + testEncoding.cxx ) ENDIF() IF(KWSYS_USE_FStream) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} - testFStream + testFStream.cxx ) ENDIF() IF(KWSYS_USE_ConsoleBuf) @@ -1062,7 +1073,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET_PROPERTY(TARGET testConsoleBufChild PROPERTY LABELS ${KWSYS_LABELS_EXE}) TARGET_LINK_LIBRARIES(testConsoleBufChild ${KWSYS_TARGET_LINK}) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} - testConsoleBuf + testConsoleBuf.cxx ) IF("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "19.0.23506") @@ -1072,10 +1083,10 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE}) ENDIF() IF(KWSYS_USE_SystemInformation) - SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testSystemInformation) + SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testSystemInformation.cxx) ENDIF() IF(KWSYS_USE_DynamicLoader) - SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testDynamicLoader) + SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testDynamicLoader.cxx) # If kwsys contains the DynamicLoader, need extra library ADD_LIBRARY(${KWSYS_NAMESPACE}TestDynload MODULE testDynload.c) SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestDynload PROPERTY LABELS ${KWSYS_LABELS_LIB}) @@ -1134,7 +1145,8 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) -p some junk at the end ) - FOREACH(test ${KWSYS_CXX_TESTS}) + FOREACH(testfile ${KWSYS_CXX_TESTS}) + get_filename_component(test "${testfile}" NAME_WE) ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsCxx ${test} ${KWSYS_TEST_ARGS_${test}}) SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST}) ENDFOREACH() diff --git a/Source/kwsys/CommandLineArguments.cxx b/Source/kwsys/CommandLineArguments.cxx index 5792da9..a6387ea 100644 --- a/Source/kwsys/CommandLineArguments.cxx +++ b/Source/kwsys/CommandLineArguments.cxx @@ -68,8 +68,8 @@ class CommandLineArgumentsInternal public: CommandLineArgumentsInternal() { - this->UnknownArgumentCallback = 0; - this->ClientData = 0; + this->UnknownArgumentCallback = KWSYS_NULLPTR; + this->ClientData = KWSYS_NULLPTR; this->LastArgument = 0; } @@ -187,7 +187,7 @@ int CommandLineArguments::Parse() switch (cs->ArgumentType) { case NO_ARGUMENT: // No value - if (!this->PopulateVariable(cs, 0)) { + if (!this->PopulateVariable(cs, KWSYS_NULLPTR)) { return 0; } break; @@ -340,7 +340,7 @@ void CommandLineArguments::AddCallback(const char* argument, s.Callback = callback; s.CallData = call_data; s.VariableType = CommandLineArguments::NO_VARIABLE_TYPE; - s.Variable = 0; + s.Variable = KWSYS_NULLPTR; s.Help = help; this->Internals->Callbacks[argument] = s; @@ -355,8 +355,8 @@ void CommandLineArguments::AddArgument(const char* argument, CommandLineArgumentsCallbackStructure s; s.Argument = argument; s.ArgumentType = type; - s.Callback = 0; - s.CallData = 0; + s.Callback = KWSYS_NULLPTR; + s.CallData = KWSYS_NULLPTR; s.VariableType = vtype; s.Variable = variable; s.Help = help; @@ -427,7 +427,7 @@ const char* CommandLineArguments::GetHelp(const char* arg) CommandLineArguments::Internal::CallbacksMap::iterator it = this->Internals->Callbacks.find(arg); if (it == this->Internals->Callbacks.end()) { - return 0; + return KWSYS_NULLPTR; } // Since several arguments may point to the same argument, find the one this @@ -621,7 +621,7 @@ void CommandLineArguments::PopulateVariable(bool* variable, void CommandLineArguments::PopulateVariable(int* variable, const std::string& value) { - char* res = 0; + char* res = KWSYS_NULLPTR; *variable = static_cast<int>(strtol(value.c_str(), &res, 10)); // if ( res && *res ) // { @@ -632,7 +632,7 @@ void CommandLineArguments::PopulateVariable(int* variable, void CommandLineArguments::PopulateVariable(double* variable, const std::string& value) { - char* res = 0; + char* res = KWSYS_NULLPTR; *variable = strtod(value.c_str(), &res); // if ( res && *res ) // { @@ -669,7 +669,7 @@ void CommandLineArguments::PopulateVariable(std::vector<bool>* variable, void CommandLineArguments::PopulateVariable(std::vector<int>* variable, const std::string& value) { - char* res = 0; + char* res = KWSYS_NULLPTR; variable->push_back(static_cast<int>(strtol(value.c_str(), &res, 10))); // if ( res && *res ) // { @@ -680,7 +680,7 @@ void CommandLineArguments::PopulateVariable(std::vector<int>* variable, void CommandLineArguments::PopulateVariable(std::vector<double>* variable, const std::string& value) { - char* res = 0; + char* res = KWSYS_NULLPTR; variable->push_back(strtod(value.c_str(), &res)); // if ( res && *res ) // { diff --git a/Source/kwsys/Configure.hxx.in b/Source/kwsys/Configure.hxx.in index 1e67874..05afc7d 100644 --- a/Source/kwsys/Configure.hxx.in +++ b/Source/kwsys/Configure.hxx.in @@ -20,6 +20,12 @@ #define @KWSYS_NAMESPACE@__has_cpp_attribute(x) 0 #endif +#if __cplusplus >= 201103L +#define @KWSYS_NAMESPACE@_NULLPTR nullptr +#else +#define @KWSYS_NAMESPACE@_NULLPTR 0 +#endif + #ifndef @KWSYS_NAMESPACE@_FALLTHROUGH #if __cplusplus >= 201703L && @KWSYS_NAMESPACE@__has_cpp_attribute(fallthrough) #define @KWSYS_NAMESPACE@_FALLTHROUGH [[fallthrough]] @@ -48,6 +54,7 @@ #define KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H \ @KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H #define KWSYS_FALLTHROUGH @KWSYS_NAMESPACE@_FALLTHROUGH +#define KWSYS_NULLPTR @KWSYS_NAMESPACE@_NULLPTR #endif #endif diff --git a/Source/kwsys/Directory.cxx b/Source/kwsys/Directory.cxx index 69068aa..a84be11 100644 --- a/Source/kwsys/Directory.cxx +++ b/Source/kwsys/Directory.cxx @@ -48,7 +48,7 @@ unsigned long Directory::GetNumberOfFiles() const const char* Directory::GetFile(unsigned long dindex) const { if (dindex >= this->Internal->Files.size()) { - return 0; + return KWSYS_NULLPTR; } return this->Internal->Files[dindex].c_str(); } diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx index 664f183..9b7d9bf 100644 --- a/Source/kwsys/DynamicLoader.cxx +++ b/Source/kwsys/DynamicLoader.cxx @@ -60,7 +60,7 @@ const char* DynamicLoader::LastError() } // namespace KWSYS_NAMESPACE #elif defined(__hpux) -// Implementation for HPUX machines +// Implementation for HPUX machines #include <dl.h> #include <errno.h> diff --git a/Source/kwsys/EncodingCXX.cxx b/Source/kwsys/EncodingCXX.cxx index b1e54c9..a1fe040 100644 --- a/Source/kwsys/EncodingCXX.cxx +++ b/Source/kwsys/EncodingCXX.cxx @@ -65,7 +65,7 @@ Encoding::CommandLineArguments::CommandLineArguments(int ac, for (int i = 0; i < ac; i++) { this->argv_[i] = strdup(av[i]); } - this->argv_[ac] = 0; + this->argv_[ac] = KWSYS_NULLPTR; } Encoding::CommandLineArguments::CommandLineArguments(int ac, @@ -75,7 +75,7 @@ Encoding::CommandLineArguments::CommandLineArguments(int ac, for (int i = 0; i < ac; i++) { this->argv_[i] = kwsysEncoding_DupToNarrow(av[i]); } - this->argv_[ac] = 0; + this->argv_[ac] = KWSYS_NULLPTR; } Encoding::CommandLineArguments::~CommandLineArguments() @@ -90,7 +90,7 @@ Encoding::CommandLineArguments::CommandLineArguments( { this->argv_.resize(other.argv_.size()); for (size_t i = 0; i < this->argv_.size(); i++) { - this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0; + this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : KWSYS_NULLPTR; } } @@ -105,7 +105,7 @@ Encoding::CommandLineArguments& Encoding::CommandLineArguments::operator=( this->argv_.resize(other.argv_.size()); for (i = 0; i < this->argv_.size(); i++) { - this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0; + this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : KWSYS_NULLPTR; } } @@ -193,7 +193,7 @@ std::string Encoding::ToNarrow(const std::wstring& str) std::wstring Encoding::ToWide(const char* cstr) { std::wstring wstr; - size_t length = kwsysEncoding_mbstowcs(0, cstr, 0) + 1; + size_t length = kwsysEncoding_mbstowcs(KWSYS_NULLPTR, cstr, 0) + 1; if (length > 0) { std::vector<wchar_t> wchars(length); if (kwsysEncoding_mbstowcs(&wchars[0], cstr, length) > 0) { @@ -206,7 +206,7 @@ std::wstring Encoding::ToWide(const char* cstr) std::string Encoding::ToNarrow(const wchar_t* wcstr) { std::string str; - size_t length = kwsysEncoding_wcstombs(0, wcstr, 0) + 1; + size_t length = kwsysEncoding_wcstombs(KWSYS_NULLPTR, wcstr, 0) + 1; if (length > 0) { std::vector<char> chars(length); if (kwsysEncoding_wcstombs(&chars[0], wcstr, length) > 0) { diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx index d2f0b85..2b6db78 100644 --- a/Source/kwsys/Glob.cxx +++ b/Source/kwsys/Glob.cxx @@ -28,7 +28,7 @@ #include <string.h> namespace KWSYS_NAMESPACE { #if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__) -// On Windows and apple, no difference between lower and upper case +// On Windows and Apple, no difference between lower and upper case #define KWSYS_GLOB_CASE_INDEPENDENT #endif @@ -81,13 +81,13 @@ std::string Glob::PatternToRegex(const std::string& pattern, int c = *i; if (c == '*') { // A '*' (not between brackets) matches any string. - // We modify this to not match slashes since the orignal glob + // We modify this to not match slashes since the original glob // pattern documentation was meant for matching file name // components separated by slashes. regex += "[^/]*"; } else if (c == '?') { // A '?' (not between brackets) matches any single character. - // We modify this to not match slashes since the orignal glob + // We modify this to not match slashes since the original glob // pattern documentation was meant for matching file name // components separated by slashes. regex += "[^/]"; @@ -201,7 +201,7 @@ bool Glob::RecurseDirectory(std::string::size_type start, } #if defined(KWSYS_GLOB_CASE_INDEPENDENT) - // On Windows and apple, no difference between lower and upper case + // On Windows and Apple, no difference between lower and upper case fname = kwsys::SystemTools::LowerCase(fname); #endif @@ -430,7 +430,7 @@ void Glob::SetRelative(const char* dir) const char* Glob::GetRelative() { if (this->Relative.empty()) { - return 0; + return KWSYS_NULLPTR; } return this->Relative.c_str(); } diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index 718a1aa..1e80b39 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -231,7 +231,7 @@ struct kwsysProcess_s when reaping PIDs or modifying this array to avoid race conditions. */ volatile pid_t* volatile ForkPIDs; - /* Flag for whether the children were terminated by a faild select. */ + /* Flag for whether the children were terminated by a failed select. */ int SelectError; /* The timeout length. */ diff --git a/Source/kwsys/RegularExpression.cxx b/Source/kwsys/RegularExpression.cxx index fa3551c..78cff1a 100644 --- a/Source/kwsys/RegularExpression.cxx +++ b/Source/kwsys/RegularExpression.cxx @@ -37,18 +37,18 @@ namespace KWSYS_NAMESPACE { RegularExpression::RegularExpression(const RegularExpression& rxp) { if (!rxp.program) { - this->program = 0; + this->program = KWSYS_NULLPTR; return; } int ind; this->progsize = rxp.progsize; // Copy regular expression size this->program = new char[this->progsize]; // Allocate storage - for (ind = this->progsize; ind-- != 0;) // Copy regular expresion + for (ind = this->progsize; ind-- != 0;) // Copy regular expression this->program[ind] = rxp.program[ind]; // Copy pointers into last successful "find" operation this->regmatch = rxp.regmatch; this->regmust = rxp.regmust; // Copy field - if (rxp.regmust != 0) { + if (rxp.regmust != KWSYS_NULLPTR) { char* dum = rxp.program; ind = 0; while (dum != rxp.regmust) { @@ -69,19 +69,19 @@ RegularExpression& RegularExpression::operator=(const RegularExpression& rxp) return *this; } if (!rxp.program) { - this->program = 0; + this->program = KWSYS_NULLPTR; return *this; } int ind; this->progsize = rxp.progsize; // Copy regular expression size delete[] this->program; this->program = new char[this->progsize]; // Allocate storage - for (ind = this->progsize; ind-- != 0;) // Copy regular expresion + for (ind = this->progsize; ind-- != 0;) // Copy regular expression this->program[ind] = rxp.program[ind]; // Copy pointers into last successful "find" operation this->regmatch = rxp.regmatch; this->regmust = rxp.regmust; // Copy field - if (rxp.regmust != 0) { + if (rxp.regmust != KWSYS_NULLPTR) { char* dum = rxp.program; ind = 0; while (dum != rxp.regmust) { @@ -128,8 +128,8 @@ bool RegularExpression::deep_equal(const RegularExpression& rxp) const this->regmatch.end() == rxp.regmatch.end()); } -// The remaining code in this file is derived from the regular expression code -// whose copyright statement appears below. It has been changed to work +// The remaining code in this file is derived from the regular expression code +// whose copyright statement appears below. It has been changed to work // with the class concepts of C++ and COOL. /* @@ -335,7 +335,7 @@ bool RegularExpression::compile(const char* exp) size_t len; int flags; - if (exp == 0) { + if (exp == KWSYS_NULLPTR) { // RAISE Error, SYM(RegularExpression), SYM(No_Expr), printf("RegularExpression::compile(): No expression supplied.\n"); return false; @@ -363,13 +363,13 @@ bool RegularExpression::compile(const char* exp) // Allocate space. //#ifndef _WIN32 - if (this->program != 0) + if (this->program != KWSYS_NULLPTR) delete[] this->program; //#endif this->program = new char[comp.regsize]; this->progsize = static_cast<int>(comp.regsize); - if (this->program == 0) { + if (this->program == KWSYS_NULLPTR) { // RAISE Error, SYM(RegularExpression), SYM(Out_Of_Memory), printf("RegularExpression::compile(): Out of memory.\n"); return false; @@ -385,7 +385,7 @@ bool RegularExpression::compile(const char* exp) // Dig out information for optimizations. this->regstart = '\0'; // Worst-case defaults. this->reganch = 0; - this->regmust = 0; + this->regmust = KWSYS_NULLPTR; this->regmlen = 0; scan = this->program + 1; // First BRANCH. if (OP(regnext(scan)) == END) { // Only one top-level choice. @@ -406,9 +406,9 @@ bool RegularExpression::compile(const char* exp) // absence of others. // if (flags & SPSTART) { - longest = 0; + longest = KWSYS_NULLPTR; len = 0; - for (; scan != 0; scan = regnext(scan)) + for (; scan != KWSYS_NULLPTR; scan = regnext(scan)) if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) { longest = OPERAND(scan); len = strlen(OPERAND(scan)); @@ -444,19 +444,19 @@ char* RegExpCompile::reg(int paren, int* flagp) if (regnpar >= RegularExpressionMatch::NSUBEXP) { // RAISE Error, SYM(RegularExpression), SYM(Too_Many_Parens), printf("RegularExpression::compile(): Too many parentheses.\n"); - return 0; + return KWSYS_NULLPTR; } parno = regnpar; regnpar++; ret = regnode(static_cast<char>(OPEN + parno)); } else - ret = 0; + ret = KWSYS_NULLPTR; // Pick up the branches, linking them together. br = regbranch(&flags); - if (br == 0) - return (0); - if (ret != 0) + if (br == KWSYS_NULLPTR) + return (KWSYS_NULLPTR); + if (ret != KWSYS_NULLPTR) regtail(ret, br); // OPEN -> first. else ret = br; @@ -466,8 +466,8 @@ char* RegExpCompile::reg(int paren, int* flagp) while (*regparse == '|') { regparse++; br = regbranch(&flags); - if (br == 0) - return (0); + if (br == KWSYS_NULLPTR) + return (KWSYS_NULLPTR); regtail(ret, br); // BRANCH -> BRANCH. if (!(flags & HASWIDTH)) *flagp &= ~HASWIDTH; @@ -479,23 +479,23 @@ char* RegExpCompile::reg(int paren, int* flagp) regtail(ret, ender); // Hook the tails of the branches to the closing node. - for (br = ret; br != 0; br = regnext(br)) + for (br = ret; br != KWSYS_NULLPTR; br = regnext(br)) regoptail(br, ender); // Check for proper termination. if (paren && *regparse++ != ')') { // RAISE Error, SYM(RegularExpression), SYM(Unmatched_Parens), printf("RegularExpression::compile(): Unmatched parentheses.\n"); - return 0; + return KWSYS_NULLPTR; } else if (!paren && *regparse != '\0') { if (*regparse == ')') { // RAISE Error, SYM(RegularExpression), SYM(Unmatched_Parens), printf("RegularExpression::compile(): Unmatched parentheses.\n"); - return 0; + return KWSYS_NULLPTR; } else { // RAISE Error, SYM(RegularExpression), SYM(Internal_Error), printf("RegularExpression::compile(): Internal error.\n"); - return 0; + return KWSYS_NULLPTR; } // NOTREACHED } @@ -517,19 +517,19 @@ char* RegExpCompile::regbranch(int* flagp) *flagp = WORST; // Tentatively. ret = regnode(BRANCH); - chain = 0; + chain = KWSYS_NULLPTR; while (*regparse != '\0' && *regparse != '|' && *regparse != ')') { latest = regpiece(&flags); - if (latest == 0) - return (0); + if (latest == KWSYS_NULLPTR) + return (KWSYS_NULLPTR); *flagp |= flags & HASWIDTH; - if (chain == 0) // First piece. + if (chain == KWSYS_NULLPTR) // First piece. *flagp |= flags & SPSTART; else regtail(chain, latest); chain = latest; } - if (chain == 0) // Loop ran zero times. + if (chain == KWSYS_NULLPTR) // Loop ran zero times. regnode(NOTHING); return (ret); @@ -552,8 +552,8 @@ char* RegExpCompile::regpiece(int* flagp) int flags; ret = regatom(&flags); - if (ret == 0) - return (0); + if (ret == KWSYS_NULLPTR) + return (KWSYS_NULLPTR); op = *regparse; if (!ISMULT(op)) { @@ -564,7 +564,7 @@ char* RegExpCompile::regpiece(int* flagp) if (!(flags & HASWIDTH) && op != '?') { // RAISE Error, SYM(RegularExpression), SYM(Empty_Operand), printf("RegularExpression::compile() : *+ operand could be empty.\n"); - return 0; + return KWSYS_NULLPTR; } *flagp = (op != '+') ? (WORST | SPSTART) : (WORST | HASWIDTH); @@ -598,7 +598,7 @@ char* RegExpCompile::regpiece(int* flagp) if (ISMULT(*regparse)) { // RAISE Error, SYM(RegularExpression), SYM(Nested_Operand), printf("RegularExpression::compile(): Nested *?+.\n"); - return 0; + return KWSYS_NULLPTR; } return (ret); } @@ -651,7 +651,7 @@ char* RegExpCompile::regatom(int* flagp) if (rxpclass > rxpclassend + 1) { // RAISE Error, SYM(RegularExpression), SYM(Invalid_Range), printf("RegularExpression::compile(): Invalid range in [].\n"); - return 0; + return KWSYS_NULLPTR; } for (; rxpclass <= rxpclassend; rxpclass++) regc(static_cast<char>(rxpclass)); @@ -664,15 +664,15 @@ char* RegExpCompile::regatom(int* flagp) if (*regparse != ']') { // RAISE Error, SYM(RegularExpression), SYM(Unmatched_Bracket), printf("RegularExpression::compile(): Unmatched [].\n"); - return 0; + return KWSYS_NULLPTR; } regparse++; *flagp |= HASWIDTH | SIMPLE; } break; case '(': ret = reg(1, &flags); - if (ret == 0) - return (0); + if (ret == KWSYS_NULLPTR) + return (KWSYS_NULLPTR); *flagp |= flags & (HASWIDTH | SPSTART); break; case '\0': @@ -680,18 +680,18 @@ char* RegExpCompile::regatom(int* flagp) case ')': // RAISE Error, SYM(RegularExpression), SYM(Internal_Error), printf("RegularExpression::compile(): Internal error.\n"); // Never here - return 0; + return KWSYS_NULLPTR; case '?': case '+': case '*': // RAISE Error, SYM(RegularExpression), SYM(No_Operand), printf("RegularExpression::compile(): ?+* follows nothing.\n"); - return 0; + return KWSYS_NULLPTR; case '\\': if (*regparse == '\0') { // RAISE Error, SYM(RegularExpression), SYM(Trailing_Backslash), printf("RegularExpression::compile(): Trailing backslash.\n"); - return 0; + return KWSYS_NULLPTR; } ret = regnode(EXACTLY); regc(*regparse++); @@ -707,7 +707,7 @@ char* RegExpCompile::regatom(int* flagp) if (len <= 0) { // RAISE Error, SYM(RegularExpression), SYM(Internal_Error), printf("RegularExpression::compile(): Internal error.\n"); - return 0; + return KWSYS_NULLPTR; } ender = *(regparse + len); if (len > 1 && ISMULT(ender)) @@ -805,7 +805,7 @@ void RegExpCompile::regtail(char* p, const char* val) scan = p; for (;;) { temp = regnext(scan); - if (temp == 0) + if (temp == KWSYS_NULLPTR) break; scan = temp; } @@ -824,7 +824,7 @@ void RegExpCompile::regtail(char* p, const char* val) void RegExpCompile::regoptail(char* p, const char* val) { // "Operandless" and "op != BRANCH" are synonymous in practice. - if (p == 0 || p == regdummyptr || OP(p) != BRANCH) + if (p == KWSYS_NULLPTR || p == regdummyptr || OP(p) != BRANCH) return; regtail(OPERAND(p), val); } @@ -874,14 +874,14 @@ bool RegularExpression::find(char const* string, } // If there is a "must appear" string, look for it. - if (this->regmust != 0) { + if (this->regmust != KWSYS_NULLPTR) { s = string; - while ((s = strchr(s, this->regmust[0])) != 0) { + while ((s = strchr(s, this->regmust[0])) != KWSYS_NULLPTR) { if (strncmp(s, this->regmust, this->regmlen) == 0) break; // Found it. s++; } - if (s == 0) // Not present. + if (s == KWSYS_NULLPTR) // Not present. return false; } @@ -899,7 +899,7 @@ bool RegularExpression::find(char const* string, s = string; if (this->regstart != '\0') // We know what char it must start with. - while ((s = strchr(s, this->regstart)) != 0) { + while ((s = strchr(s, this->regstart)) != KWSYS_NULLPTR) { if (regFind.regtry(s, rmatch.startp, rmatch.endp, this->program)) return true; s++; @@ -933,8 +933,8 @@ int RegExpFind::regtry(const char* string, const char** start, sp1 = start; ep = end; for (i = RegularExpressionMatch::NSUBEXP; i > 0; i--) { - *sp1++ = 0; - *ep++ = 0; + *sp1++ = KWSYS_NULLPTR; + *ep++ = KWSYS_NULLPTR; } if (regmatch(prog + 1)) { start[0] = string; @@ -962,7 +962,7 @@ int RegExpFind::regmatch(const char* prog) scan = prog; - while (scan != 0) { + while (scan != KWSYS_NULLPTR) { next = regnext(scan); @@ -994,12 +994,14 @@ int RegExpFind::regmatch(const char* prog) reginput += len; } break; case ANYOF: - if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == 0) + if (*reginput == '\0' || + strchr(OPERAND(scan), *reginput) == KWSYS_NULLPTR) return (0); reginput++; break; case ANYBUT: - if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != 0) + if (*reginput == '\0' || + strchr(OPERAND(scan), *reginput) != KWSYS_NULLPTR) return (0); reginput++; break; @@ -1028,7 +1030,7 @@ int RegExpFind::regmatch(const char* prog) // Don't set startp if some later invocation of the // same parentheses already has. // - if (regstartp[no] == 0) + if (regstartp[no] == KWSYS_NULLPTR) regstartp[no] = save; return (1); } else @@ -1056,7 +1058,7 @@ int RegExpFind::regmatch(const char* prog) // Don't set endp if some later invocation of the // same parentheses already has. // - if (regendp[no] == 0) + if (regendp[no] == KWSYS_NULLPTR) regendp[no] = save; return (1); } else @@ -1076,7 +1078,7 @@ int RegExpFind::regmatch(const char* prog) return (1); reginput = save; scan = regnext(scan); - } while (scan != 0 && OP(scan) == BRANCH); + } while (scan != KWSYS_NULLPTR && OP(scan) == BRANCH); return (0); // NOTREACHED } @@ -1154,13 +1156,13 @@ int RegExpFind::regrepeat(const char* p) } break; case ANYOF: - while (*scan != '\0' && strchr(opnd, *scan) != 0) { + while (*scan != '\0' && strchr(opnd, *scan) != KWSYS_NULLPTR) { count++; scan++; } break; case ANYBUT: - while (*scan != '\0' && strchr(opnd, *scan) == 0) { + while (*scan != '\0' && strchr(opnd, *scan) == KWSYS_NULLPTR) { count++; scan++; } @@ -1182,11 +1184,11 @@ static const char* regnext(const char* p) int offset; if (p == regdummyptr) - return (0); + return (KWSYS_NULLPTR); offset = NEXT(p); if (offset == 0) - return (0); + return (KWSYS_NULLPTR); if (OP(p) == BACK) return (p - offset); @@ -1199,11 +1201,11 @@ static char* regnext(char* p) int offset; if (p == regdummyptr) - return (0); + return (KWSYS_NULLPTR); offset = NEXT(p); if (offset == 0) - return (0); + return (KWSYS_NULLPTR); if (OP(p) == BACK) return (p - offset); diff --git a/Source/kwsys/RegularExpression.hxx.in b/Source/kwsys/RegularExpression.hxx.in index a3fe72d..3cbbeb8 100644 --- a/Source/kwsys/RegularExpression.hxx.in +++ b/Source/kwsys/RegularExpression.hxx.in @@ -202,7 +202,7 @@ inline std::string RegularExpressionMatch::match(int n) const * * ? Matches preceding pattern zero or once only * - * () Saves a matched expression and uses it in a later match + * () Saves a matched expression and uses it in a later match * * Note that more than one of these metacharacters can be used * in a single regular expression in order to create complex diff --git a/Source/kwsys/SharedForward.h.in b/Source/kwsys/SharedForward.h.in index f638267..0caf5e7 100644 --- a/Source/kwsys/SharedForward.h.in +++ b/Source/kwsys/SharedForward.h.in @@ -225,7 +225,7 @@ static const char kwsys_shared_forward_path_slash[2] = { #define KWSYS_SHARED_FORWARD_LDD_N 1 #define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH" -/* OSX */ +/* OS X */ #elif defined(__APPLE__) #define KWSYS_SHARED_FORWARD_LDD "otool", "-L" #define KWSYS_SHARED_FORWARD_LDD_N 2 diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index ab1f40a..7503469 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -340,7 +340,7 @@ public: bool DoesCPUSupportCPUID(); - // Retrieve memory information in megabyte. + // Retrieve memory information in MiB. size_t GetTotalVirtualMemory(); size_t GetAvailableVirtualMemory(); size_t GetTotalPhysicalMemory(); @@ -348,7 +348,7 @@ public: LongLong GetProcessId(); - // Retrieve memory information in kib + // Retrieve memory information in KiB. LongLong GetHostMemoryTotal(); LongLong GetHostMemoryAvailable(const char* envVarName); LongLong GetHostMemoryUsed(); @@ -736,7 +736,7 @@ bool SystemInformation::DoesCPUSupportCPUID() return this->Implementation->DoesCPUSupportCPUID(); } -// Retrieve memory information in megabyte. +// Retrieve memory information in MiB. size_t SystemInformation::GetTotalVirtualMemory() { return this->Implementation->GetTotalVirtualMemory(); @@ -881,7 +881,7 @@ int LoadLines(FILE* file, std::vector<std::string>& lines) char buf[bufSize] = { '\0' }; while (!feof(file) && !ferror(file)) { errno = 0; - if (fgets(buf, bufSize, file) == 0) { + if (fgets(buf, bufSize, file) == KWSYS_NULLPTR) { if (ferror(file) && (errno == EINTR)) { clearerr(file); } @@ -977,7 +977,7 @@ int GetFieldsFromCommand(const char* command, const char** fieldNames, T* values) { FILE* file = popen(command, "r"); - if (file == 0) { + if (file == KWSYS_NULLPTR) { return -1; } std::vector<std::string> fields; @@ -987,7 +987,7 @@ int GetFieldsFromCommand(const char* command, const char** fieldNames, return -1; } int i = 0; - while (fieldNames[i] != NULL) { + while (fieldNames[i] != KWSYS_NULLPTR) { int ierr = NameValue(fields, fieldNames[i], values[i]); if (ierr) { return -(i + 2); @@ -1023,7 +1023,8 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo, break; case SIGFPE: - oss << "Caught SIGFPE at " << (sigInfo->si_addr == 0 ? "0x" : "") + oss << "Caught SIGFPE at " + << (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "") << sigInfo->si_addr << " "; switch (sigInfo->si_code) { #if defined(FPE_INTDIV) @@ -1071,7 +1072,8 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo, break; case SIGSEGV: - oss << "Caught SIGSEGV at " << (sigInfo->si_addr == 0 ? "0x" : "") + oss << "Caught SIGSEGV at " + << (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "") << sigInfo->si_addr << " "; switch (sigInfo->si_code) { case SEGV_MAPERR: @@ -1089,7 +1091,8 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo, break; case SIGBUS: - oss << "Caught SIGBUS at " << (sigInfo->si_addr == 0 ? "0x" : "") + oss << "Caught SIGBUS at " + << (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "") << sigInfo->si_addr << " "; switch (sigInfo->si_code) { case BUS_ADRALN: @@ -1129,7 +1132,8 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo, break; case SIGILL: - oss << "Caught SIGILL at " << (sigInfo->si_addr == 0 ? "0x" : "") + oss << "Caught SIGILL at " + << (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "") << sigInfo->si_addr << " "; switch (sigInfo->si_code) { case ILL_ILLOPC: @@ -1313,8 +1317,8 @@ SymbolProperties::SymbolProperties() // not using an initializer list // to avoid some PGI compiler warnings this->SetBinary("???"); - this->SetBinaryBaseAddress(NULL); - this->Address = NULL; + this->SetBinaryBaseAddress(KWSYS_NULLPTR); + this->Address = KWSYS_NULLPTR; this->SetSourceFile("???"); this->SetFunction("???"); this->SetLineNumber(-1); @@ -1649,7 +1653,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName( // any number of interfaces on this system we look for the // first of these that contains the name returned by gethostname // and is longer. failing that we return gethostname and indicate - // with a failure code. Return of a failure code is not necessarilly + // with a failure code. Return of a failure code is not necessarily // an indication of an error. for instance gethostname may return // the fully qualified domain name, or there may not be one if the // system lives on a private network such as in the case of a cluster @@ -1671,7 +1675,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName( return -2; } - for (ifa = ifas; ifa != NULL; ifa = ifa->ifa_next) { + for (ifa = ifas; ifa != KWSYS_NULLPTR; ifa = ifa->ifa_next) { int fam = ifa->ifa_addr ? ifa->ifa_addr->sa_family : -1; // Skip Loopback interfaces if (((fam == AF_INET) || (fam == AF_INET6)) && @@ -1682,7 +1686,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName( : sizeof(struct sockaddr_in6)); ierr = getnameinfo(ifa->ifa_addr, static_cast<socklen_t>(addrlen), host, - NI_MAXHOST, NULL, 0, NI_NAMEREQD); + NI_MAXHOST, KWSYS_NULLPTR, 0, NI_NAMEREQD); if (ierr) { // don't report the failure now since we may succeed on another // interface. If all attempts fail then return the failure code. @@ -3609,7 +3613,7 @@ SystemInformationImplementation::GetHostMemoryTotal() #elif defined(__APPLE__) uint64_t mem; size_t len = sizeof(mem); - int ierr = sysctlbyname("hw.memsize", &mem, &len, NULL, 0); + int ierr = sysctlbyname("hw.memsize", &mem, &len, KWSYS_NULLPTR, 0); if (ierr) { return -1; } @@ -3752,7 +3756,8 @@ SystemInformationImplementation::GetHostMemoryUsed() if (psz < 1) { return -1; } - const char* names[3] = { "Pages wired down:", "Pages active:", NULL }; + const char* names[3] = { "Pages wired down:", "Pages active:", + KWSYS_NULLPTR }; SystemInformation::LongLong values[2] = { SystemInformation::LongLong(0) }; int ierr = GetFieldsFromCommand("vm_stat", names, values); if (ierr) { @@ -3800,7 +3805,7 @@ SystemInformationImplementation::GetProcMemoryUsed() std::ostringstream oss; oss << "ps -o rss= -p " << pid; FILE* file = popen(oss.str().c_str(), "r"); - if (file == 0) { + if (file == KWSYS_NULLPTR) { return -1; } oss.str(""); @@ -3933,13 +3938,13 @@ void SystemInformationImplementation::SetStackTraceOnError(int enable) if (enable && !saOrigValid) { // save the current actions - sigaction(SIGABRT, 0, &saABRTOrig); - sigaction(SIGSEGV, 0, &saSEGVOrig); - sigaction(SIGTERM, 0, &saTERMOrig); - sigaction(SIGINT, 0, &saINTOrig); - sigaction(SIGILL, 0, &saILLOrig); - sigaction(SIGBUS, 0, &saBUSOrig); - sigaction(SIGFPE, 0, &saFPEOrig); + sigaction(SIGABRT, KWSYS_NULLPTR, &saABRTOrig); + sigaction(SIGSEGV, KWSYS_NULLPTR, &saSEGVOrig); + sigaction(SIGTERM, KWSYS_NULLPTR, &saTERMOrig); + sigaction(SIGINT, KWSYS_NULLPTR, &saINTOrig); + sigaction(SIGILL, KWSYS_NULLPTR, &saILLOrig); + sigaction(SIGBUS, KWSYS_NULLPTR, &saBUSOrig); + sigaction(SIGFPE, KWSYS_NULLPTR, &saFPEOrig); // enable read, disable write saOrigValid = 1; @@ -3953,22 +3958,22 @@ void SystemInformationImplementation::SetStackTraceOnError(int enable) #endif sigemptyset(&sa.sa_mask); - sigaction(SIGABRT, &sa, 0); - sigaction(SIGSEGV, &sa, 0); - sigaction(SIGTERM, &sa, 0); - sigaction(SIGINT, &sa, 0); - sigaction(SIGILL, &sa, 0); - sigaction(SIGBUS, &sa, 0); - sigaction(SIGFPE, &sa, 0); + sigaction(SIGABRT, &sa, KWSYS_NULLPTR); + sigaction(SIGSEGV, &sa, KWSYS_NULLPTR); + sigaction(SIGTERM, &sa, KWSYS_NULLPTR); + sigaction(SIGINT, &sa, KWSYS_NULLPTR); + sigaction(SIGILL, &sa, KWSYS_NULLPTR); + sigaction(SIGBUS, &sa, KWSYS_NULLPTR); + sigaction(SIGFPE, &sa, KWSYS_NULLPTR); } else if (!enable && saOrigValid) { // restore previous actions - sigaction(SIGABRT, &saABRTOrig, 0); - sigaction(SIGSEGV, &saSEGVOrig, 0); - sigaction(SIGTERM, &saTERMOrig, 0); - sigaction(SIGINT, &saINTOrig, 0); - sigaction(SIGILL, &saILLOrig, 0); - sigaction(SIGBUS, &saBUSOrig, 0); - sigaction(SIGFPE, &saFPEOrig, 0); + sigaction(SIGABRT, &saABRTOrig, KWSYS_NULLPTR); + sigaction(SIGSEGV, &saSEGVOrig, KWSYS_NULLPTR); + sigaction(SIGTERM, &saTERMOrig, KWSYS_NULLPTR); + sigaction(SIGINT, &saINTOrig, KWSYS_NULLPTR); + sigaction(SIGILL, &saILLOrig, KWSYS_NULLPTR); + sigaction(SIGBUS, &saBUSOrig, KWSYS_NULLPTR); + sigaction(SIGFPE, &saFPEOrig, KWSYS_NULLPTR); // enable write, disable read saOrigValid = 0; @@ -4404,7 +4409,7 @@ bool SystemInformationImplementation::ParseSysCtl() int err = 0; uint64_t value = 0; size_t len = sizeof(value); - sysctlbyname("hw.memsize", &value, &len, NULL, 0); + sysctlbyname("hw.memsize", &value, &len, KWSYS_NULLPTR, 0); this->TotalPhysicalMemory = static_cast<size_t>(value / 1048576); // Parse values for Mac @@ -4414,7 +4419,7 @@ bool SystemInformationImplementation::ParseSysCtl() if (host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmstat, &count) == KERN_SUCCESS) { len = sizeof(value); - err = sysctlbyname("hw.pagesize", &value, &len, NULL, 0); + err = sysctlbyname("hw.pagesize", &value, &len, KWSYS_NULLPTR, 0); int64_t available_memory = vmstat.free_count * value; this->AvailablePhysicalMemory = static_cast<size_t>(available_memory / 1048576); @@ -4426,7 +4431,7 @@ bool SystemInformationImplementation::ParseSysCtl() size_t miblen = sizeof(mib) / sizeof(mib[0]); struct xsw_usage swap; len = sizeof(swap); - err = sysctl(mib, miblen, &swap, &len, NULL, 0); + err = sysctl(mib, miblen, &swap, &len, KWSYS_NULLPTR, 0); if (err == 0) { this->AvailableVirtualMemory = static_cast<size_t>(swap.xsu_avail / 1048576); @@ -4439,71 +4444,75 @@ bool SystemInformationImplementation::ParseSysCtl() // CPU Info len = sizeof(this->NumberOfPhysicalCPU); - sysctlbyname("hw.physicalcpu", &this->NumberOfPhysicalCPU, &len, NULL, 0); + sysctlbyname("hw.physicalcpu", &this->NumberOfPhysicalCPU, &len, + KWSYS_NULLPTR, 0); len = sizeof(this->NumberOfLogicalCPU); - sysctlbyname("hw.logicalcpu", &this->NumberOfLogicalCPU, &len, NULL, 0); + sysctlbyname("hw.logicalcpu", &this->NumberOfLogicalCPU, &len, KWSYS_NULLPTR, + 0); int cores_per_package = 0; len = sizeof(cores_per_package); err = sysctlbyname("machdep.cpu.cores_per_package", &cores_per_package, &len, - NULL, 0); + KWSYS_NULLPTR, 0); // That name was not found, default to 1 this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical = err != 0 ? 1 : static_cast<unsigned char>(cores_per_package); len = sizeof(value); - sysctlbyname("hw.cpufrequency", &value, &len, NULL, 0); + sysctlbyname("hw.cpufrequency", &value, &len, KWSYS_NULLPTR, 0); this->CPUSpeedInMHz = static_cast<float>(value) / 1000000; // Chip family len = sizeof(this->ChipID.Family); // Seems only the intel chips will have this name so if this fails it is // probably a PPC machine - err = - sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len, NULL, 0); + err = sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len, + KWSYS_NULLPTR, 0); if (err != 0) // Go back to names we know but are less descriptive { this->ChipID.Family = 0; ::memset(retBuf, 0, 128); len = 32; - err = sysctlbyname("hw.machine", &retBuf, &len, NULL, 0); + err = sysctlbyname("hw.machine", &retBuf, &len, KWSYS_NULLPTR, 0); std::string machineBuf(retBuf); if (machineBuf.find_first_of("Power") != std::string::npos) { this->ChipID.Vendor = "IBM"; len = sizeof(this->ChipID.Family); - err = sysctlbyname("hw.cputype", &this->ChipID.Family, &len, NULL, 0); + err = sysctlbyname("hw.cputype", &this->ChipID.Family, &len, + KWSYS_NULLPTR, 0); len = sizeof(this->ChipID.Model); - err = sysctlbyname("hw.cpusubtype", &this->ChipID.Model, &len, NULL, 0); + err = sysctlbyname("hw.cpusubtype", &this->ChipID.Model, &len, + KWSYS_NULLPTR, 0); this->FindManufacturer(); } } else // Should be an Intel Chip. { len = sizeof(this->ChipID.Family); - err = - sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len, NULL, 0); + err = sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len, + KWSYS_NULLPTR, 0); ::memset(retBuf, 0, 128); len = 128; - err = sysctlbyname("machdep.cpu.vendor", retBuf, &len, NULL, 0); + err = sysctlbyname("machdep.cpu.vendor", retBuf, &len, KWSYS_NULLPTR, 0); // Chip Vendor this->ChipID.Vendor = retBuf; this->FindManufacturer(); // Chip Model len = sizeof(value); - err = sysctlbyname("machdep.cpu.model", &value, &len, NULL, 0); + err = sysctlbyname("machdep.cpu.model", &value, &len, KWSYS_NULLPTR, 0); this->ChipID.Model = static_cast<int>(value); // Chip Stepping len = sizeof(value); value = 0; - err = sysctlbyname("machdep.cpu.stepping", &value, &len, NULL, 0); + err = sysctlbyname("machdep.cpu.stepping", &value, &len, KWSYS_NULLPTR, 0); if (!err) { this->ChipID.Revision = static_cast<int>(value); } // feature string - char* buf = 0; + char* buf = KWSYS_NULLPTR; size_t allocSize = 128; err = 0; @@ -4520,7 +4529,8 @@ bool SystemInformationImplementation::ParseSysCtl() } buf[0] = ' '; len = allocSize - 2; // keep space for leading and trailing space - err = sysctlbyname("machdep.cpu.features", buf + 1, &len, NULL, 0); + err = + sysctlbyname("machdep.cpu.features", buf + 1, &len, KWSYS_NULLPTR, 0); } if (!err && buf && len) { // now we can match every flags as space + flag + space @@ -4561,7 +4571,8 @@ bool SystemInformationImplementation::ParseSysCtl() // brand string ::memset(retBuf, 0, sizeof(retBuf)); len = sizeof(retBuf); - err = sysctlbyname("machdep.cpu.brand_string", retBuf, &len, NULL, 0); + err = + sysctlbyname("machdep.cpu.brand_string", retBuf, &len, KWSYS_NULLPTR, 0); if (!err) { this->ChipID.ProcessorName = retBuf; this->ChipID.ModelName = retBuf; @@ -4569,10 +4580,10 @@ bool SystemInformationImplementation::ParseSysCtl() // Cache size len = sizeof(value); - err = sysctlbyname("hw.l1icachesize", &value, &len, NULL, 0); + err = sysctlbyname("hw.l1icachesize", &value, &len, KWSYS_NULLPTR, 0); this->Features.L1CacheSize = static_cast<int>(value); len = sizeof(value); - err = sysctlbyname("hw.l2cachesize", &value, &len, NULL, 0); + err = sysctlbyname("hw.l2cachesize", &value, &len, KWSYS_NULLPTR, 0); this->Features.L2CacheSize = static_cast<int>(value); return true; @@ -4609,7 +4620,7 @@ std::string SystemInformationImplementation::RunProcess( kwsysProcess_Execute(gp); - char* data = NULL; + char* data = KWSYS_NULLPTR; int length; double timeout = 255; int pipe; // pipe id as returned by kwsysProcess_WaitForData() @@ -4621,7 +4632,7 @@ std::string SystemInformationImplementation::RunProcess( { buffer.append(data, length); } - kwsysProcess_WaitForExit(gp, 0); + kwsysProcess_WaitForExit(gp, KWSYS_NULLPTR); int result = 0; switch (kwsysProcess_GetState(gp)) { @@ -4694,7 +4705,7 @@ std::string SystemInformationImplementation::ParseValueFromKStat( std::string lastArg = command.substr(start + 1, command.size() - start - 1); args.push_back(lastArg.c_str()); - args.push_back(0); + args.push_back(KWSYS_NULLPTR); std::string buffer = this->RunProcess(args); @@ -5379,7 +5390,7 @@ int SystemInformationImplementation::CallSwVers(const char* arg, std::vector<const char*> args; args.push_back("sw_vers"); args.push_back(arg); - args.push_back(0); + args.push_back(KWSYS_NULLPTR); ver = this->RunProcess(args); this->TrimNewline(ver); #else diff --git a/Source/kwsys/SystemInformation.hxx.in b/Source/kwsys/SystemInformation.hxx.in index 5678e8a..fe7e8b5 100644 --- a/Source/kwsys/SystemInformation.hxx.in +++ b/Source/kwsys/SystemInformation.hxx.in @@ -103,14 +103,14 @@ public: // Retrieve id of the current running process LongLong GetProcessId(); - // Retrieve memory information in megabyte. + // Retrieve memory information in MiB. size_t GetTotalVirtualMemory(); size_t GetAvailableVirtualMemory(); size_t GetTotalPhysicalMemory(); size_t GetAvailablePhysicalMemory(); // returns an informative general description if the installed and - // available ram on this system. See the GetHostMmeoryTotal, and + // available ram on this system. See the GetHostMemoryTotal, and // Get{Host,Proc}MemoryAvailable methods for more information. std::string GetMemoryDescription(const char* hostLimitEnvVarName = NULL, const char* procLimitEnvVarName = NULL); diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index f547362..999beb3 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -107,7 +107,8 @@ extern char** environ; // getpwnam doesn't exist on Windows and Cray Xt3/Catamount // same for TIOCGWINSZ -#if defined(_WIN32) || defined(__LIBCATAMOUNT__) +#if defined(_WIN32) || defined(__LIBCATAMOUNT__) || \ + (defined(HAVE_GETPWNAM) && HAVE_GETPWNAM == 0) #undef HAVE_GETPWNAM #undef HAVE_TTY_INFO #else @@ -306,7 +307,7 @@ inline int Chdir(const std::string& dir) return chdir(dir.c_str()); } inline void Realpath(const std::string& path, std::string& resolved_path, - std::string* errorMessage = 0) + std::string* errorMessage = KWSYS_NULLPTR) { char resolved_name[KWSYS_SYSTEMTOOLS_MAXPATH]; @@ -352,7 +353,7 @@ double SystemTools::GetTime(void) 11644473600.0); #else struct timeval t; - gettimeofday(&t, 0); + gettimeofday(&t, KWSYS_NULLPTR); return 1.0 * double(t.tv_sec) + 0.000001 * double(t.tv_usec); #endif } @@ -414,7 +415,7 @@ public: const envchar* Release(const envchar* env) { - const envchar* old = 0; + const envchar* old = KWSYS_NULLPTR; iterator i = this->find(env); if (i != this->end()) { old = *i; @@ -489,7 +490,7 @@ void SystemTools::GetPath(std::vector<std::string>& path, const char* env) const char* SystemTools::GetEnvImpl(const char* key) { - const char* v = 0; + const char* v = KWSYS_NULLPTR; #if defined(_WIN32) std::string env; if (SystemTools::GetEnv(key, env)) { @@ -545,7 +546,7 @@ bool SystemTools::HasEnv(const char* key) #else const char* v = getenv(key); #endif - return v != 0; + return v != KWSYS_NULLPTR; } bool SystemTools::HasEnv(const std::string& key) @@ -776,7 +777,7 @@ bool SystemTools::MakeDirectory(const std::string& path, const mode_t* mode) while ((pos = dir.find('/', pos)) != std::string::npos) { topdir = dir.substr(0, pos); - if (Mkdir(topdir) == 0 && mode != 0) { + if (Mkdir(topdir) == 0 && mode != KWSYS_NULLPTR) { SystemTools::SetPermissions(topdir, *mode); } @@ -795,7 +796,7 @@ bool SystemTools::MakeDirectory(const std::string& path, const mode_t* mode) ) { return false; } - } else if (mode != 0) { + } else if (mode != KWSYS_NULLPTR) { SystemTools::SetPermissions(topdir, *mode); } @@ -1072,7 +1073,7 @@ bool SystemTools::WriteRegistryValue(const std::string&, const std::string&, // HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath // => will delete the data of the "default" value of the key // HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.4;Root -// => will delete the data of the "Root" value of the key +// => will delete the data of the "Root" value of the key #if defined(_WIN32) && !defined(__CYGWIN__) bool SystemTools::DeleteRegistryValue(const std::string& key, KeyWOW64 view) @@ -1520,7 +1521,7 @@ char* SystemTools::AppendStrings(const char* str1, const char* str2) size_t len1 = strlen(str1); char* newstr = new char[len1 + strlen(str2) + 1]; if (!newstr) { - return 0; + return KWSYS_NULLPTR; } strcpy(newstr, str1); strcat(newstr + len1, str2); @@ -1543,7 +1544,7 @@ char* SystemTools::AppendStrings(const char* str1, const char* str2, size_t len1 = strlen(str1), len2 = strlen(str2); char* newstr = new char[len1 + len2 + strlen(str3) + 1]; if (!newstr) { - return 0; + return KWSYS_NULLPTR; } strcpy(newstr, str1); strcat(newstr + len1, str2); @@ -1593,7 +1594,7 @@ size_t SystemTools::CountChar(const char* str, char c) char* SystemTools::RemoveChars(const char* str, const char* toremove) { if (!str) { - return NULL; + return KWSYS_NULLPTR; } char* clean_str = new char[strlen(str) + 1]; char* ptr = clean_str; @@ -1615,7 +1616,7 @@ char* SystemTools::RemoveChars(const char* str, const char* toremove) char* SystemTools::RemoveCharsButUpperHex(const char* str) { if (!str) { - return 0; + return KWSYS_NULLPTR; } char* clean_str = new char[strlen(str) + 1]; char* ptr = clean_str; @@ -1696,7 +1697,7 @@ bool SystemTools::StringEndsWith(const std::string& str1, const char* str2) const char* SystemTools::FindLastString(const char* str1, const char* str2) { if (!str1 || !str2) { - return NULL; + return KWSYS_NULLPTR; } size_t len1 = strlen(str1), len2 = strlen(str2); @@ -1709,7 +1710,7 @@ const char* SystemTools::FindLastString(const char* str1, const char* str2) } while (ptr-- != str1); } - return NULL; + return KWSYS_NULLPTR; } // Duplicate string @@ -1719,7 +1720,7 @@ char* SystemTools::DuplicateString(const char* str) char* newstr = new char[strlen(str) + 1]; return strcpy(newstr, str); } - return NULL; + return KWSYS_NULLPTR; } // Return a cropped string @@ -3100,7 +3101,7 @@ bool SystemTools::FindProgramPath(const char* argv0, std::string& pathOut, std::string SystemTools::CollapseFullPath(const std::string& in_relative) { - return SystemTools::CollapseFullPath(in_relative, 0); + return SystemTools::CollapseFullPath(in_relative, KWSYS_NULLPTR); } void SystemTools::AddTranslationPath(const std::string& a, @@ -3326,7 +3327,7 @@ std::string SystemTools::RelativePath(const std::string& local, unsigned int sameCount = 0; while (((sameCount <= (localSplit.size() - 1)) && (sameCount <= (remoteSplit.size() - 1))) && -// for windows and apple do a case insensitive string compare +// for Windows and Apple do a case insensitive string compare #if defined(_WIN32) || defined(__APPLE__) SystemTools::Strucmp(localSplit[sameCount].c_str(), remoteSplit[sameCount].c_str()) == 0 diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index 8a02b75..719d45c 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -881,7 +881,7 @@ public: /** * Get the width of the terminal window. The code may or may not work, so - * make sure you have some resonable defaults prepared if the code returns + * make sure you have some reasonable defaults prepared if the code returns * some bogus size. */ static int GetTerminalWidth(); diff --git a/Source/kwsys/testCommandLineArguments.cxx b/Source/kwsys/testCommandLineArguments.cxx index d2215d6..78baed9 100644 --- a/Source/kwsys/testCommandLineArguments.cxx +++ b/Source/kwsys/testCommandLineArguments.cxx @@ -76,7 +76,7 @@ int testCommandLineArguments(int argc, char* argv[]) int some_int_variable = 10; double some_double_variable = 10.10; - char* some_string_variable = 0; + char* some_string_variable = KWSYS_NULLPTR; std::string some_stl_string_variable = ""; bool some_bool_variable = false; bool some_bool_variable1 = false; @@ -202,7 +202,7 @@ int testCommandLineArguments(int argc, char* argv[]) for (cc = 0; cc < strings_argument.size(); ++cc) { delete[] strings_argument[cc]; - strings_argument[cc] = 0; + strings_argument[cc] = KWSYS_NULLPTR; } return res; } diff --git a/Source/kwsys/testCommandLineArguments1.cxx b/Source/kwsys/testCommandLineArguments1.cxx index 5a03401..5dfa5e3 100644 --- a/Source/kwsys/testCommandLineArguments1.cxx +++ b/Source/kwsys/testCommandLineArguments1.cxx @@ -21,7 +21,7 @@ int testCommandLineArguments1(int argc, char* argv[]) arg.Initialize(argc, argv); int n = 0; - char* m = 0; + char* m = KWSYS_NULLPTR; std::string p; int res = 0; @@ -55,11 +55,11 @@ int testCommandLineArguments1(int argc, char* argv[]) delete[] m; } - char** newArgv = 0; + char** newArgv = KWSYS_NULLPTR; int newArgc = 0; arg.GetUnusedArguments(&newArgc, &newArgv); int cc; - const char* valid_unused_args[9] = { 0, + const char* valid_unused_args[9] = { KWSYS_NULLPTR, "--ignored", "--second-ignored", "third-ignored", diff --git a/Source/kwsys/testEncoding.cxx b/Source/kwsys/testEncoding.cxx index 2742fe4..6bf273f 100644 --- a/Source/kwsys/testEncoding.cxx +++ b/Source/kwsys/testEncoding.cxx @@ -84,7 +84,7 @@ static int testRobustEncoding() // this conversion could fail std::wstring wstr = kwsys::Encoding::ToWide(cstr); - wstr = kwsys::Encoding::ToWide(NULL); + wstr = kwsys::Encoding::ToWide(KWSYS_NULLPTR); if (wstr != L"") { const wchar_t* wcstr = wstr.c_str(); std::cout << "ToWide(NULL) returned"; @@ -112,7 +112,7 @@ static int testRobustEncoding() std::string win_str = kwsys::Encoding::ToNarrow(cwstr); #endif - std::string str = kwsys::Encoding::ToNarrow(NULL); + std::string str = kwsys::Encoding::ToNarrow(KWSYS_NULLPTR); if (str != "") { std::cout << "ToNarrow(NULL) returned " << str << std::endl; ret++; diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index a6af9cc..f1321e5 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -52,7 +52,7 @@ static const char* toUnixPaths[][2] = { { "\\\\usr\\local\\bin\\passwd", "//usr/local/bin/passwd" }, { "\\\\usr\\lo cal\\bin\\pa sswd", "//usr/lo cal/bin/pa sswd" }, { "\\\\usr\\lo\\ cal\\bin\\pa\\ sswd", "//usr/lo\\ cal/bin/pa\\ sswd" }, - { 0, 0 } + { KWSYS_NULLPTR, KWSYS_NULLPTR } }; static bool CheckConvertToUnixSlashes(std::string const& input, @@ -68,10 +68,11 @@ static bool CheckConvertToUnixSlashes(std::string const& input, return true; } -static const char* checkEscapeChars[][4] = { { "1 foo 2 bar 2", "12", "\\", - "\\1 foo \\2 bar \\2" }, - { " {} ", "{}", "#", " #{#} " }, - { 0, 0, 0, 0 } }; +static const char* checkEscapeChars[][4] = { + { "1 foo 2 bar 2", "12", "\\", "\\1 foo \\2 bar \\2" }, + { " {} ", "{}", "#", " #{#} " }, + { KWSYS_NULLPTR, KWSYS_NULLPTR, KWSYS_NULLPTR, KWSYS_NULLPTR } +}; static bool CheckEscapeChars(std::string const& input, const char* chars_to_escape, char escape_char, @@ -159,7 +160,7 @@ static bool CheckFileOperations() res = false; } // calling with 0 pointer should return false - if (kwsys::SystemTools::MakeDirectory(0)) { + if (kwsys::SystemTools::MakeDirectory(KWSYS_NULLPTR)) { std::cerr << "Problem with MakeDirectory(0)" << std::endl; res = false; } @@ -217,11 +218,11 @@ static bool CheckFileOperations() } // calling with 0 pointer should return false - if (kwsys::SystemTools::FileExists(0)) { + if (kwsys::SystemTools::FileExists(KWSYS_NULLPTR)) { std::cerr << "Problem with FileExists(0)" << std::endl; res = false; } - if (kwsys::SystemTools::FileExists(0, true)) { + if (kwsys::SystemTools::FileExists(KWSYS_NULLPTR, true)) { std::cerr << "Problem with FileExists(0) as file" << std::endl; res = false; } diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 8b38a70..08bfebe 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -390,6 +390,9 @@ if(BUILD_TESTING) endif() ADD_TEST_MACRO(SourcesProperty SourcesProperty) ADD_TEST_MACRO(SourceFileProperty SourceFileProperty) + if (NOT CMAKE_GENERATOR STREQUAL "Xcode") + ADD_TEST_MACRO(SourceFileIncludeDirProperty SourceFileIncludeDirProperty) + endif() if(CMAKE_CXX_COMPILER_ID STREQUAL GNU AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) set(runCxxDialectTest 1) @@ -3194,29 +3197,51 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --test-command ${JAVA_RUNTIME} -classpath hello3.jar HelloWorld) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceListAndOutput") - # For next test, java tool must have same architecture as toolchain + # For next tests, java tool must have same architecture as toolchain math(EXPR _object_mode "${CMAKE_SIZEOF_VOID_P} * 8") execute_process( COMMAND "${Java_JAVA_EXECUTABLE}" -d${_object_mode} -version OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE _result ) if(_result EQUAL 0) - if(_isMultiConfig) - set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$<CONFIGURATION>) - else() - set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah) + ## next test is valid only if Java version is less than 1.10 + if ("${Java_VERSION}" VERSION_LESS 1.10) + if(_isMultiConfig) + set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$<CONFIGURATION>) + else() + set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah) + endif() + add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/JavaJavah" + "${CMake_BINARY_DIR}/Tests/JavaJavah" + ${build_generator_args} + --build-project helloJavah + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJavah/" + --build-options ${build_options} + --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVAH_LIBRARY_PATH} -classpath hello3.jar HelloWorld2) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah") + endif() + ## next test is valid only if Java is, at least, version 1.8 + if (NOT "${Java_VERSION}" VERSION_LESS 1.8) + if(_isMultiConfig) + set (JAVANATIVEHEADERS_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaNativeHeaders/$<CONFIGURATION>) + else() + set (JAVANATIVEHEADERS_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaNativeHeaders) + endif() + add_test(NAME Java.NativeHeaders COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/JavaNativeHeaders" + "${CMake_BINARY_DIR}/Tests/JavaNativeHeaders" + ${build_generator_args} + --build-project helloJavaNativeHeaders + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaNativeHeaders/" + --build-options ${build_options} + --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVANATIVEHEADERS_LIBRARY_PATH} -classpath hello4.jar HelloWorld3) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaNativeHeaders") endif() - add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/JavaJavah" - "${CMake_BINARY_DIR}/Tests/JavaJavah" - ${build_generator_args} - --build-project helloJavah - --build-two-config - --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJavah/" - --build-options ${build_options} - --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVAH_LIBRARY_PATH} -classpath hello3.jar HelloWorld2) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah") endif() endif() endif() diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 4586357..19d12e5 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -260,17 +260,49 @@ add_custom_target(check-part4 ALL #----------------------------------------------------------------------------- # Cover source file properties with generator expressions. -add_executable(srcgenex_flags srcgenex_flags.c) -set_property(SOURCE srcgenex_flags.c PROPERTY COMPILE_FLAGS "-DNAME=$<TARGET_PROPERTY:NAME>") - -add_executable(srcgenex_flags_COMPILE_LANGUAGE srcgenex_flags_COMPILE_LANGUAGE.c) -set_property(SOURCE srcgenex_flags_COMPILE_LANGUAGE.c PROPERTY COMPILE_FLAGS "$<$<COMPILE_LANGUAGE:C>:-DNAME=$<TARGET_PROPERTY:NAME>>") - -add_executable(srcgenex_defs srcgenex_defs.c) -set_property(SOURCE srcgenex_defs.c PROPERTY COMPILE_DEFINITIONS NAME=$<TARGET_PROPERTY:NAME>) - -add_executable(srcgenex_defs_COMPILE_LANGUAGE srcgenex_defs_COMPILE_LANGUAGE.c) -set_property(SOURCE srcgenex_defs_COMPILE_LANGUAGE.c PROPERTY COMPILE_DEFINITIONS $<$<COMPILE_LANGUAGE:C>:NAME=$<TARGET_PROPERTY:NAME>>) +## generate various source files +foreach (item IN ITEMS flags flags_COMPILE_LANGUAGE + options options_COMPILE_LANGUAGE + defs defs_COMPILE_LANGUAGE) + set(TARGET_NAME srcgenex_${item}) + configure_file(srcgenex.c.in ${TARGET_NAME}.c @ONLY) +endforeach() +add_executable(srcgenex_flags "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_flags.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_flags.c" + PROPERTY COMPILE_FLAGS "-DNAME=$<TARGET_PROPERTY:NAME>") +add_executable(srcgenex_flags_COMPILE_LANGUAGE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_flags_COMPILE_LANGUAGE.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_flags_COMPILE_LANGUAGE.c" + PROPERTY COMPILE_FLAGS "$<$<COMPILE_LANGUAGE:C>:-DNAME=$<TARGET_PROPERTY:NAME>>") + +add_executable(srcgenex_options "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_options.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_options.c" + PROPERTY COMPILE_OPTIONS -DUNUSED -DNAME=$<TARGET_PROPERTY:NAME>) +add_executable(srcgenex_options_COMPILE_LANGUAGE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_options_COMPILE_LANGUAGE.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_options_COMPILE_LANGUAGE.c" + PROPERTY COMPILE_OPTIONS $<$<COMPILE_LANGUAGE:C>:-DNAME=$<TARGET_PROPERTY:NAME>>) + +add_executable(srcgenex_defs "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_defs.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_defs.c" + PROPERTY COMPILE_DEFINITIONS UNUSED NAME=$<TARGET_PROPERTY:NAME>) +add_executable(srcgenex_defs_COMPILE_LANGUAGE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_defs_COMPILE_LANGUAGE.c") +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_defs_COMPILE_LANGUAGE.c" + PROPERTY COMPILE_DEFINITIONS $<$<COMPILE_LANGUAGE:C>:NAME=$<TARGET_PROPERTY:NAME>>) + +foreach (item IN ITEMS basic COMPILE_LANGUAGE) + set(TARGET_NAME srcgenex_includes_${item}) + configure_file(srcgenex_includes.h.in "sf_includes_${item}/${TARGET_NAME}.h" @ONLY) + configure_file(srcgenex_includes.c.in ${TARGET_NAME}.c @ONLY) +endforeach() +add_executable(srcgenex_includes_basic "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_includes_basic.c") +# first include directory is useless but ensure list aspect is tested +set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_includes_basic.c" + PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/sf_includes_basic") +if (CMAKE_GENERATOR MATCHES "Makefiles|Ninja|Watcom WMake") + add_executable(srcgenex_includes_COMPILE_LANGUAGE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_includes_COMPILE_LANGUAGE.c") + # first include directory is useless but ensure list aspect is tested + set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_includes_COMPILE_LANGUAGE.c" + PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}" $<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_BINARY_DIR}/sf_includes_COMPILE_LANGUAGE>) +endif() #----------------------------------------------------------------------------- # Cover test properties with generator expressions. diff --git a/Tests/GeneratorExpression/srcgenex_defs.c b/Tests/GeneratorExpression/srcgenex.c.in index 883e631..4a43bd1 100644 --- a/Tests/GeneratorExpression/srcgenex_defs.c +++ b/Tests/GeneratorExpression/srcgenex.c.in @@ -1,4 +1,4 @@ -int srcgenex_defs(void) +int @TARGET_NAME@(void) { return 0; } diff --git a/Tests/GeneratorExpression/srcgenex_defs_COMPILE_LANGUAGE.c b/Tests/GeneratorExpression/srcgenex_defs_COMPILE_LANGUAGE.c deleted file mode 100644 index 421b55b..0000000 --- a/Tests/GeneratorExpression/srcgenex_defs_COMPILE_LANGUAGE.c +++ /dev/null @@ -1,12 +0,0 @@ -int srcgenex_defs_COMPILE_LANGUAGE(void) -{ - return 0; -} - -int main(int argc, char* argv[]) -{ -#ifndef NAME -#error NAME not defined -#endif - return NAME(); -} diff --git a/Tests/GeneratorExpression/srcgenex_flags.c b/Tests/GeneratorExpression/srcgenex_flags.c deleted file mode 100644 index 3de2b12..0000000 --- a/Tests/GeneratorExpression/srcgenex_flags.c +++ /dev/null @@ -1,12 +0,0 @@ -int srcgenex_flags(void) -{ - return 0; -} - -int main(int argc, char* argv[]) -{ -#ifndef NAME -#error NAME not defined -#endif - return NAME(); -} diff --git a/Tests/GeneratorExpression/srcgenex_flags_COMPILE_LANGUAGE.c b/Tests/GeneratorExpression/srcgenex_flags_COMPILE_LANGUAGE.c deleted file mode 100644 index 4e80d6e..0000000 --- a/Tests/GeneratorExpression/srcgenex_flags_COMPILE_LANGUAGE.c +++ /dev/null @@ -1,12 +0,0 @@ -int srcgenex_flags_COMPILE_LANGUAGE(void) -{ - return 0; -} - -int main(int argc, char* argv[]) -{ -#ifndef NAME -#error NAME not defined -#endif - return NAME(); -} diff --git a/Tests/GeneratorExpression/srcgenex_includes.c.in b/Tests/GeneratorExpression/srcgenex_includes.c.in new file mode 100644 index 0000000..b48d7df --- /dev/null +++ b/Tests/GeneratorExpression/srcgenex_includes.c.in @@ -0,0 +1,12 @@ + +#include "@TARGET_NAME@.h" + +int @TARGET_NAME@(void) +{ + return 0; +} + +int main(int argc, char* argv[]) +{ + return @TARGET_NAME@(); +} diff --git a/Tests/GeneratorExpression/srcgenex_includes.h.in b/Tests/GeneratorExpression/srcgenex_includes.h.in new file mode 100644 index 0000000..2259ca6 --- /dev/null +++ b/Tests/GeneratorExpression/srcgenex_includes.h.in @@ -0,0 +1,7 @@ + +#if !defined @TARGET_NAME@_H +#define @TARGET_NAME@_H + +int @TARGET_NAME@(void); + +#endif diff --git a/Tests/JavaNativeHeaders/CMakeLists.txt b/Tests/JavaNativeHeaders/CMakeLists.txt new file mode 100644 index 0000000..7dc2679 --- /dev/null +++ b/Tests/JavaNativeHeaders/CMakeLists.txt @@ -0,0 +1,18 @@ +project(helloJavaNativeHeaders Java CXX) + +cmake_minimum_required (VERSION 2.6) +set(CMAKE_VERBOSE_MAKEFILE 1) + +find_package(Java COMPONENTS Development) +include (UseJava) + +# JNI support +find_package(JNI) + +add_jar(B1 D.java GENERATE_NATIVE_HEADERS D1-native) +add_jar(E1 E.java GENERATE_NATIVE_HEADERS E1-native) + +add_jar(hello4 HelloWorld3.java) + +add_library(D SHARED D.cpp E.cpp) +target_link_libraries (D PRIVATE D1-native E1-native) diff --git a/Tests/JavaNativeHeaders/D.cpp b/Tests/JavaNativeHeaders/D.cpp new file mode 100644 index 0000000..2a90a08 --- /dev/null +++ b/Tests/JavaNativeHeaders/D.cpp @@ -0,0 +1,10 @@ + +#include <jni.h> +#include <stdio.h> + +#include "D.h" + +JNIEXPORT void JNICALL Java_D_printName(JNIEnv*, jobject) +{ + printf("D\n"); +} diff --git a/Tests/JavaNativeHeaders/D.java b/Tests/JavaNativeHeaders/D.java new file mode 100644 index 0000000..449c0df --- /dev/null +++ b/Tests/JavaNativeHeaders/D.java @@ -0,0 +1,19 @@ +class D +{ + public D() + { + } + + public native void printName(); + + static { + try { + + System.loadLibrary("D"); + + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load.\n" + e); + System.exit(1); + } + } +} diff --git a/Tests/JavaNativeHeaders/E.cpp b/Tests/JavaNativeHeaders/E.cpp new file mode 100644 index 0000000..fb98946 --- /dev/null +++ b/Tests/JavaNativeHeaders/E.cpp @@ -0,0 +1,10 @@ + +#include <jni.h> +#include <stdio.h> + +#include "E.h" + +JNIEXPORT void JNICALL Java_E_printName(JNIEnv*, jobject) +{ + printf("E\n"); +} diff --git a/Tests/JavaNativeHeaders/E.java b/Tests/JavaNativeHeaders/E.java new file mode 100644 index 0000000..30fd95a --- /dev/null +++ b/Tests/JavaNativeHeaders/E.java @@ -0,0 +1,19 @@ +class E +{ + public E() + { + } + + public native void printName(); + + static { + try { + + System.loadLibrary("D"); + + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load.\n" + e); + System.exit(1); + } + } +} diff --git a/Tests/JavaNativeHeaders/HelloWorld3.java b/Tests/JavaNativeHeaders/HelloWorld3.java new file mode 100644 index 0000000..77f1fed --- /dev/null +++ b/Tests/JavaNativeHeaders/HelloWorld3.java @@ -0,0 +1,15 @@ +class HelloWorld3 +{ + public static void main(String args[]) + { + D d; + d = new D(); + d.printName(); + + E e; + e = new E(); + e.printName(); + + System.out.println("Hello World!"); + } +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index e440b7f..d5bd297 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -176,6 +176,7 @@ add_RunCMake_test(CompileDefinitions) add_RunCMake_test(CompileFeatures) add_RunCMake_test(PolicyScope) add_RunCMake_test(WriteCompilerDetectionHeader) +add_RunCMake_test(SourceProperties) if(NOT WIN32) add_RunCMake_test(PositionIndependentCode) endif() diff --git a/Tests/RunCMake/GenerateExportHeader/GEH.cmake b/Tests/RunCMake/GenerateExportHeader/GEH.cmake index cf81f36..ae9a84c 100644 --- a/Tests/RunCMake/GenerateExportHeader/GEH.cmake +++ b/Tests/RunCMake/GenerateExportHeader/GEH.cmake @@ -85,6 +85,7 @@ macro_add_test_library(libshared) macro_add_test_library(libstatic) add_subdirectory(nodeprecated) +add_subdirectory(includeguard) if(NOT BORLAND) add_subdirectory(c_identifier) endif() diff --git a/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake b/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake index 55625a8..18c3340 100644 --- a/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake @@ -12,6 +12,8 @@ function(run_GEH) run_cmake(GEH) run_cmake_command(GEH-build ${CMAKE_COMMAND} --build . --config Debug) run_cmake_command(GEH-run ${RunCMake_TEST_BINARY_DIR}/GenerateExportHeader) + run_cmake_command(GEH-incguard-macro-run ${RunCMake_TEST_BINARY_DIR}/test_includeguard_macro) + run_cmake_command(GEH-incguard-custom-run ${RunCMake_TEST_BINARY_DIR}/test_includeguard_custom) file(STRINGS "${RunCMake_TEST_BINARY_DIR}/failure_test_targets" failure_test_targets) diff --git a/Tests/RunCMake/GenerateExportHeader/includeguard/CMakeLists.txt b/Tests/RunCMake/GenerateExportHeader/includeguard/CMakeLists.txt new file mode 100644 index 0000000..514d27b --- /dev/null +++ b/Tests/RunCMake/GenerateExportHeader/includeguard/CMakeLists.txt @@ -0,0 +1,19 @@ +set(libincludeguard_SRC libincludeguard.cpp) + +add_library(includeguard_macro ${libincludeguard_SRC}) +generate_export_header(includeguard_macro) + +set(EXPORT_HEADER includeguard_macro_export.h) +set(DEF_SYMBOL INCLUDEGUARD_MACRO_EXPORT_H) +set(NDEF_SYMBOL CUSTOM_GUARD) +configure_file(main.cpp.in main_macro.cpp) +add_executable(test_includeguard_macro ${CMAKE_CURRENT_BINARY_DIR}/main_macro.cpp) + +add_library(includeguard_custom ${libincludeguard_SRC}) +generate_export_header(includeguard_custom INCLUDE_GUARD_NAME CUSTOM_GUARD) + +set(EXPORT_HEADER includeguard_custom_export.h) +set(DEF_SYMBOL CUSTOM_GUARD) +set(NDEF_SYMBOL INCLUDEGUARD_CUSTOM_EXPORT_H) +configure_file(main.cpp.in main_custom.cpp) +add_executable(test_includeguard_custom ${CMAKE_CURRENT_BINARY_DIR}/main_custom.cpp) diff --git a/Tests/RunCMake/GenerateExportHeader/includeguard/libincludeguard.cpp b/Tests/RunCMake/GenerateExportHeader/includeguard/libincludeguard.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/GenerateExportHeader/includeguard/libincludeguard.cpp diff --git a/Tests/RunCMake/GenerateExportHeader/includeguard/main.cpp.in b/Tests/RunCMake/GenerateExportHeader/includeguard/main.cpp.in new file mode 100644 index 0000000..51bd5d9 --- /dev/null +++ b/Tests/RunCMake/GenerateExportHeader/includeguard/main.cpp.in @@ -0,0 +1,10 @@ +#include "@EXPORT_HEADER@" + +int main() +{ +#if defined(@DEF_SYMBOL@) && !defined(@NDEF_SYMBOL@) + return 0; +#else + return 1; +#endif +} diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h index e8af0a5..0b1dcba 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSHARED_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h index 598bd71..5e3ac9f 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSTATIC_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h index cc20e09..dac4fda 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSHARED_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h index 4aaa848..b6e2a4a 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSTATIC_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h index 053ad18..11f8042 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSHARED_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h index 4aaa848..b6e2a4a 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSTATIC_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h index 808ff01..1481acd 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSHARED_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h index 4aaa848..b6e2a4a 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSTATIC_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h index cc20e09..dac4fda 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSHARED_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h index 4aaa848..b6e2a4a 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSTATIC_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h index 4e675af..3ba2d2e 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSHARED_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h index 4d5ed4e..3c7e093 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSTATIC_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h index 84340e3..bf9163e 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSHARED_EXPORT_H */ diff --git a/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h index 598bd71..5e3ac9f 100644 --- a/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h +++ b/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h @@ -39,4 +39,4 @@ # endif #endif -#endif +#endif /* LIBSTATIC_EXPORT_H */ diff --git a/Tests/RunCMake/Make/IncludeRegexSubdir-check.cmake b/Tests/RunCMake/Make/IncludeRegexSubdir-check.cmake new file mode 100644 index 0000000..dbdf7be --- /dev/null +++ b/Tests/RunCMake/Make/IncludeRegexSubdir-check.cmake @@ -0,0 +1,4 @@ +include("${RunCMake_TEST_BINARY_DIR}/IncludeRegexSubdir/CMakeFiles/CMakeDirectoryInformation.cmake" OPTIONAL) +if(NOT CMAKE_C_INCLUDE_REGEX_SCAN STREQUAL "^custom_include_regex$") + set(RunCMake_TEST_FAILED "CMAKE_C_INCLUDE_REGEX_SCAN has unexpected value:\n \"${CMAKE_C_INCLUDE_REGEX_SCAN}\"") +endif() diff --git a/Tests/RunCMake/Make/IncludeRegexSubdir.cmake b/Tests/RunCMake/Make/IncludeRegexSubdir.cmake new file mode 100644 index 0000000..a7a93a0 --- /dev/null +++ b/Tests/RunCMake/Make/IncludeRegexSubdir.cmake @@ -0,0 +1,3 @@ +enable_language(C) +include_regular_expression("^custom_include_regex$") +add_subdirectory(IncludeRegexSubdir) diff --git a/Tests/RunCMake/Make/IncludeRegexSubdir/CMakeLists.txt b/Tests/RunCMake/Make/IncludeRegexSubdir/CMakeLists.txt new file mode 100644 index 0000000..e712aea --- /dev/null +++ b/Tests/RunCMake/Make/IncludeRegexSubdir/CMakeLists.txt @@ -0,0 +1 @@ +# We only need this directory to be processed. No targets needed. diff --git a/Tests/RunCMake/Make/RunCMakeTest.cmake b/Tests/RunCMake/Make/RunCMakeTest.cmake index 869d11e..3b2b8f5 100644 --- a/Tests/RunCMake/Make/RunCMakeTest.cmake +++ b/Tests/RunCMake/Make/RunCMakeTest.cmake @@ -17,3 +17,4 @@ run_TargetMessages(VAR-ON -DCMAKE_TARGET_MESSAGES=ON) run_TargetMessages(VAR-OFF -DCMAKE_TARGET_MESSAGES=OFF) run_cmake(CustomCommandDepfile-ERROR) +run_cmake(IncludeRegexSubdir) diff --git a/Tests/RunCMake/SourceProperties/CMakeLists.txt b/Tests/RunCMake/SourceProperties/CMakeLists.txt new file mode 100644 index 0000000..a17c8cd --- /dev/null +++ b/Tests/RunCMake/SourceProperties/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.4) +project(${RunCMake_TEST} C) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/SourceProperties/RelativeIncludeDir-result.txt b/Tests/RunCMake/SourceProperties/RelativeIncludeDir-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/SourceProperties/RelativeIncludeDir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/SourceProperties/RelativeIncludeDir-stderr.txt b/Tests/RunCMake/SourceProperties/RelativeIncludeDir-stderr.txt new file mode 100644 index 0000000..cf146c2 --- /dev/null +++ b/Tests/RunCMake/SourceProperties/RelativeIncludeDir-stderr.txt @@ -0,0 +1,4 @@ +CMake Error in CMakeLists.txt: + Found relative path while evaluating include directories of "empty.c": + + "relative" diff --git a/Tests/RunCMake/SourceProperties/RelativeIncludeDir.cmake b/Tests/RunCMake/SourceProperties/RelativeIncludeDir.cmake new file mode 100644 index 0000000..08dffa8 --- /dev/null +++ b/Tests/RunCMake/SourceProperties/RelativeIncludeDir.cmake @@ -0,0 +1,4 @@ + +set_property (SOURCE empty.c PROPERTY INCLUDE_DIRECTORIES "relative") + +add_library (somelib empty.c) diff --git a/Tests/RunCMake/SourceProperties/RunCMakeTest.cmake b/Tests/RunCMake/SourceProperties/RunCMakeTest.cmake new file mode 100644 index 0000000..0982153 --- /dev/null +++ b/Tests/RunCMake/SourceProperties/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(RelativeIncludeDir) diff --git a/Tests/RunCMake/SourceProperties/empty.c b/Tests/RunCMake/SourceProperties/empty.c new file mode 100644 index 0000000..a9ec102 --- /dev/null +++ b/Tests/RunCMake/SourceProperties/empty.c @@ -0,0 +1,5 @@ + +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-result.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-stderr.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-stderr.txt new file mode 100644 index 0000000..f9b8ee7 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-stderr.txt @@ -0,0 +1,8 @@ +^CMake Error in CMakeLists.txt: + Xcode does not support per-config per-source INCLUDE_DIRECTORIES: + + \$<\$<CONFIG:Debug>:MYDEBUG> + + specified for source: + + .*/Tests/RunCMake/XcodeProject/main.c$ diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs.cmake b/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs.cmake new file mode 100644 index 0000000..4476c39 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs.cmake @@ -0,0 +1,3 @@ +enable_language(C) +add_executable(main main.c) +set_property(SOURCE main.c PROPERTY INCLUDE_DIRECTORIES "$<$<CONFIG:Debug>:MYDEBUG>") diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-result.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-stderr.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-stderr.txt new file mode 100644 index 0000000..bfca020 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-stderr.txt @@ -0,0 +1,8 @@ +^CMake Error in CMakeLists.txt: + Xcode does not support per-config per-source COMPILE_OPTIONS: + + \$<\$<CONFIG:Debug>:-DMYDEBUG> + + specified for source: + + .*/Tests/RunCMake/XcodeProject/main.c$ diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions.cmake b/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions.cmake new file mode 100644 index 0000000..f8e8030 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions.cmake @@ -0,0 +1,3 @@ +enable_language(C) +add_executable(main main.c) +set_property(SOURCE main.c PROPERTY COMPILE_OPTIONS $<$<CONFIG:Debug>:-DMYDEBUG>) diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 1313cb5..64a07f0 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -19,7 +19,9 @@ if (NOT XCODE_VERSION VERSION_LESS 6) endif() run_cmake(PerConfigPerSourceFlags) +run_cmake(PerConfigPerSourceOptions) run_cmake(PerConfigPerSourceDefinitions) +run_cmake(PerConfigPerSourceIncludeDirs) # Use a single build tree for a few tests without cleaning. diff --git a/Tests/SourceFileIncludeDirProperty/CMakeLists.txt b/Tests/SourceFileIncludeDirProperty/CMakeLists.txt new file mode 100644 index 0000000..786d5b6 --- /dev/null +++ b/Tests/SourceFileIncludeDirProperty/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.0) + +project(SourceFileIncludeDirProperty C) + +# +# Check that source level include directory take +# precedence over target one + +add_executable(SourceFileIncludeDirProperty main.c) + +set_property (TARGET SourceFileIncludeDirProperty + PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/target") + +set_property (SOURCE main.c + PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/source") diff --git a/Tests/SourceFileIncludeDirProperty/main.c b/Tests/SourceFileIncludeDirProperty/main.c new file mode 100644 index 0000000..36144ca --- /dev/null +++ b/Tests/SourceFileIncludeDirProperty/main.c @@ -0,0 +1,7 @@ + +#include "header.h" + +int main() +{ + return 0; +} diff --git a/Tests/SourceFileIncludeDirProperty/source/header.h b/Tests/SourceFileIncludeDirProperty/source/header.h new file mode 100644 index 0000000..0c6f241 --- /dev/null +++ b/Tests/SourceFileIncludeDirProperty/source/header.h @@ -0,0 +1,2 @@ + +/* used header file */ diff --git a/Tests/SourceFileIncludeDirProperty/target/header.h b/Tests/SourceFileIncludeDirProperty/target/header.h new file mode 100644 index 0000000..71c1521 --- /dev/null +++ b/Tests/SourceFileIncludeDirProperty/target/header.h @@ -0,0 +1,2 @@ + +#error "wrong header file" |