From 28dcccfaced3c3f0a8a751cf31ae108bf6c8dda7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 19 Feb 2014 09:30:37 -0500 Subject: Begin post-3.0 development --- Help/release/dev/0-sample-topic.rst | 7 +++++++ Help/release/index.rst | 2 ++ Source/CMakeVersion.cmake | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 Help/release/dev/0-sample-topic.rst diff --git a/Help/release/dev/0-sample-topic.rst b/Help/release/dev/0-sample-topic.rst new file mode 100644 index 0000000..e4cc01e --- /dev/null +++ b/Help/release/dev/0-sample-topic.rst @@ -0,0 +1,7 @@ +0-sample-topic +-------------- + +* This is a sample release note for the change in a topic. + Developers should add similar notes for each topic branch + making a noteworthy change. Each document should be named + and titled to match the topic name to avoid merge conflicts. diff --git a/Help/release/index.rst b/Help/release/index.rst index 752c568..15ce065 100644 --- a/Help/release/index.rst +++ b/Help/release/index.rst @@ -5,6 +5,8 @@ CMake Release Notes This file should include the adjacent "dev.txt" file in development versions but not in release versions. +.. include:: dev.txt + Releases ======== diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 5ce43f5..abe9a66 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 0) -set(CMake_VERSION_PATCH 0) -set(CMake_VERSION_RC 1) +set(CMake_VERSION_PATCH 20140219) +#set(CMake_VERSION_RC 1) -- cgit v0.12 From 44e784342d34d63db79214203108e3f968992d15 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 20 Feb 2014 00:01:10 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index abe9a66..7db0587 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 0) -set(CMake_VERSION_PATCH 20140219) +set(CMake_VERSION_PATCH 20140220) #set(CMake_VERSION_RC 1) -- cgit v0.12 From c0bbefbfe7209e849c04f57e79908401ba825fe0 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 21 Feb 2014 00:01:11 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 7db0587..0c481ad 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 0) -set(CMake_VERSION_PATCH 20140220) +set(CMake_VERSION_PATCH 20140221) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 73e5c6aead4d2c748ced061a7de27f2ffc7e2d31 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 21 Feb 2014 10:59:06 -0500 Subject: ExternalProject: Add option to always run the build step Teach ExternalProject_Add a new BUILD_ALWAYS option to skip using the build step stamp file and execute the step on every build. Extend the BuildDepends test with a case to cover this option. --- Modules/ExternalProject.cmake | 9 +++++++ Tests/BuildDepends/CMakeLists.txt | 30 ++++++++++++++++++++++ Tests/BuildDepends/Project/CMakeLists.txt | 12 +++++++++ Tests/BuildDepends/Project/External/CMakeLists.txt | 14 ++++++++++ 4 files changed, 65 insertions(+) create mode 100644 Tests/BuildDepends/Project/External/CMakeLists.txt diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 0df51a8..1e83163 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -54,6 +54,7 @@ # [BINARY_DIR dir] # Specify build dir location # [BUILD_COMMAND cmd...] # Command to drive the native build # [BUILD_IN_SOURCE 1] # Use source dir for build dir +# [BUILD_ALWAYS 1] # No stamp file, build step always runs # #--Install step--------------- # [INSTALL_DIR dir] # Installation prefix # [INSTALL_COMMAND cmd...] # Command to drive install after build @@ -1716,10 +1717,18 @@ function(_ep_add_build_command name) set(log "") endif() + get_property(build_always TARGET ${name} PROPERTY _EP_BUILD_ALWAYS) + if(build_always) + set(always 1) + else() + set(always 0) + endif() + ExternalProject_Add_Step(${name} build COMMAND ${cmd} WORKING_DIRECTORY ${binary_dir} DEPENDEES configure + ALWAYS ${always} ${log} ) endfunction() diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt index 9727930..a875f07 100644 --- a/Tests/BuildDepends/CMakeLists.txt +++ b/Tests/BuildDepends/CMakeLists.txt @@ -68,6 +68,8 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_exe.h "#define link_depends_no_shared_exe_value 0\n") set(link_depends_no_shared_check_txt ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_check.txt) +file(WRITE ${BuildDepends_BINARY_DIR}/Project/external.in "external original\n") + help_xcode_depends() message("Building project first time") @@ -166,6 +168,19 @@ else() "Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.") endif() +if(EXISTS ${BuildDepends_BINARY_DIR}/Project/external.out) + file(STRINGS ${BuildDepends_BINARY_DIR}/Project/external.out external_out) + if("${external_out}" STREQUAL "external original") + message(STATUS "external.out contains '${external_out}'") + else() + message(SEND_ERROR "Project did not initially build properly: " + "external.out contains '${external_out}'") + endif() +else() + message(SEND_ERROR "Project did not initially build properly: " + "external.out is missing") +endif() + message("Waiting 3 seconds...") # any additional argument will cause ${bar} to wait forever execute_process(COMMAND ${bar} -infinite TIMEOUT 3 OUTPUT_VARIABLE out) @@ -191,6 +206,8 @@ if(TEST_LINK_DEPENDS) file(WRITE ${TEST_LINK_DEPENDS} "2") endif() +file(WRITE ${BuildDepends_BINARY_DIR}/Project/external.in "external changed\n") + help_xcode_depends() message("Building project second time") @@ -294,3 +311,16 @@ else() message(SEND_ERROR "Project did not rebuild properly. " "Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.") endif() + +if(EXISTS ${BuildDepends_BINARY_DIR}/Project/external.out) + file(STRINGS ${BuildDepends_BINARY_DIR}/Project/external.out external_out) + if("${external_out}" STREQUAL "external changed") + message(STATUS "external.out contains '${external_out}'") + else() + message(SEND_ERROR "Project did not rebuild properly: " + "external.out contains '${external_out}'") + endif() +else() + message(SEND_ERROR "Project did not rebuild properly: " + "external.out is missing") +endif() diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index 8806ecd..9ee4a43 100644 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -139,3 +139,15 @@ add_custom_target(header_tgt DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dir/header.h) include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_executable(ninjadep ninjadep.cpp) add_dependencies(ninjadep header_tgt) + +include(ExternalProject) +ExternalProject_Add(ExternalBuild + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/External + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/External + STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/External/Stamp + BUILD_ALWAYS 1 + CMAKE_ARGS + -Dexternal_in=${CMAKE_CURRENT_BINARY_DIR}/external.in + -Dexternal_out=${CMAKE_CURRENT_BINARY_DIR}/external.out + INSTALL_COMMAND "" + ) diff --git a/Tests/BuildDepends/Project/External/CMakeLists.txt b/Tests/BuildDepends/Project/External/CMakeLists.txt new file mode 100644 index 0000000..c6015b6 --- /dev/null +++ b/Tests/BuildDepends/Project/External/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.0) +project(BuildDependsExternal NONE) +if(NOT DEFINED external_in) + message(FATAL_ERROR "Define external_in") +endif() +if(NOT DEFINED external_out) + message(FATAL_ERROR "Define external_out") +endif() +add_custom_command( + OUTPUT ${external_out} + COMMAND ${CMAKE_COMMAND} -E copy ${external_in} ${external_out} + DEPENDS ${external_in} + ) +add_custom_target(drive ALL DEPENDS ${external_out}) -- cgit v0.12 From a9bdef2dda7985762e2eae7e6ae323606d917b4e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 7 Feb 2014 17:53:31 -0500 Subject: tests: Add variable expansion tests There are some corner cases in variable expansion which would be nice to capture before going and rewriting the variable expansion code. The majority of these are related to configuring files and strings with '@' in them in conjunction with @ONLY being specified. Another is testing for '(' usage inside of ENV variable references based on whether it is quoted or not. --- Tests/RunCMake/Syntax/AtWithVariable-stderr.txt | 1 + Tests/RunCMake/Syntax/AtWithVariable.cmake | 9 +++++++++ .../RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt | 1 + Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake | 8 ++++++++ .../Syntax/AtWithVariableAtOnlyFile-stderr.txt | 5 +++++ Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake | 9 +++++++++ .../Syntax/AtWithVariableEmptyExpansion-stderr.txt | 1 + .../Syntax/AtWithVariableEmptyExpansion.cmake | 8 ++++++++ .../AtWithVariableEmptyExpansionAtOnly-stderr.txt | 1 + .../Syntax/AtWithVariableEmptyExpansionAtOnly.cmake | 8 ++++++++ Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt | 5 +++++ Tests/RunCMake/Syntax/AtWithVariableFile.cmake | 8 ++++++++ Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt | 1 + Tests/RunCMake/Syntax/EscapeQuotes.cmake | 9 +++++++++ Tests/RunCMake/Syntax/EscapedAt-stderr.txt | 1 + Tests/RunCMake/Syntax/EscapedAt.cmake | 5 +++++ Tests/RunCMake/Syntax/ExpandInAt-stderr.txt | 1 + Tests/RunCMake/Syntax/ExpandInAt.cmake | 6 ++++++ Tests/RunCMake/Syntax/ParenInENV-result.txt | 1 + Tests/RunCMake/Syntax/ParenInENV-stderr.txt | 20 ++++++++++++++++++++ Tests/RunCMake/Syntax/ParenInENV.cmake | 2 ++ Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt | 1 + Tests/RunCMake/Syntax/ParenInQuotedENV.cmake | 2 ++ Tests/RunCMake/Syntax/RunCMakeTest.cmake | 13 +++++++++++++ Tests/RunCMake/Syntax/atfile.txt.in | 4 ++++ 25 files changed, 130 insertions(+) create mode 100644 Tests/RunCMake/Syntax/AtWithVariable-stderr.txt create mode 100644 Tests/RunCMake/Syntax/AtWithVariable.cmake create mode 100644 Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt create mode 100644 Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake create mode 100644 Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt create mode 100644 Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake create mode 100644 Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt create mode 100644 Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake create mode 100644 Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt create mode 100644 Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake create mode 100644 Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt create mode 100644 Tests/RunCMake/Syntax/AtWithVariableFile.cmake create mode 100644 Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt create mode 100644 Tests/RunCMake/Syntax/EscapeQuotes.cmake create mode 100644 Tests/RunCMake/Syntax/EscapedAt-stderr.txt create mode 100644 Tests/RunCMake/Syntax/EscapedAt.cmake create mode 100644 Tests/RunCMake/Syntax/ExpandInAt-stderr.txt create mode 100644 Tests/RunCMake/Syntax/ExpandInAt.cmake create mode 100644 Tests/RunCMake/Syntax/ParenInENV-result.txt create mode 100644 Tests/RunCMake/Syntax/ParenInENV-stderr.txt create mode 100644 Tests/RunCMake/Syntax/ParenInENV.cmake create mode 100644 Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt create mode 100644 Tests/RunCMake/Syntax/ParenInQuotedENV.cmake create mode 100644 Tests/RunCMake/Syntax/atfile.txt.in diff --git a/Tests/RunCMake/Syntax/AtWithVariable-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariable-stderr.txt new file mode 100644 index 0000000..5dcd4d7 --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariable-stderr.txt @@ -0,0 +1 @@ +-->wrong<-- diff --git a/Tests/RunCMake/Syntax/AtWithVariable.cmake b/Tests/RunCMake/Syntax/AtWithVariable.cmake new file mode 100644 index 0000000..2bbf61d --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariable.cmake @@ -0,0 +1,9 @@ +set(right "wrong") +set(var "\${right}") +# Expanded here. +set(ref "@var@") + +# 'right' is dereferenced because 'var' was dereferenced when +# assigning to 'ref' above. +string(CONFIGURE "${ref}" output) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt new file mode 100644 index 0000000..cbd1be4 --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt @@ -0,0 +1 @@ +-->\${right}<-- diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake b/Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake new file mode 100644 index 0000000..e06484c --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake @@ -0,0 +1,8 @@ +set(right "wrong") +set(var "\${right}") +# Expanded here. +set(ref "@var@") + +# No dereference done at all. +string(CONFIGURE "${ref}" output @ONLY) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt new file mode 100644 index 0000000..90bffb6 --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt @@ -0,0 +1,5 @@ +-->==>\${right}<== +==><== +==>\${var}<== +==>\${empty}<== +<-- diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake new file mode 100644 index 0000000..bdd7bcd --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake @@ -0,0 +1,9 @@ +set(right "wrong") +set(var "\${right}") + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/atfile.txt.in" + "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt" + @ONLY) +file(READ "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt" output) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt new file mode 100644 index 0000000..cbd1be4 --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt @@ -0,0 +1 @@ +-->\${right}<-- diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake new file mode 100644 index 0000000..840c7f0 --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake @@ -0,0 +1,8 @@ +# Literal since 'var' is not defined. +set(ref "@var@") +set(right "wrong") +set(var "\${right}") + +# 'var' is dereferenced here. +string(CONFIGURE "${ref}" output) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt new file mode 100644 index 0000000..cbd1be4 --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt @@ -0,0 +1 @@ +-->\${right}<-- diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake new file mode 100644 index 0000000..b657506 --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake @@ -0,0 +1,8 @@ +# Literal since 'var' is not defined. +set(ref "@var@") +set(right "wrong") +set(var "\${right}") + +# 'var' is dereferenced, but now 'right' +string(CONFIGURE "${ref}" output @ONLY) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt new file mode 100644 index 0000000..43f029f --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt @@ -0,0 +1,5 @@ +-->==>\${right}<== +==><== +==>\${right}<== +==><== +<-- diff --git a/Tests/RunCMake/Syntax/AtWithVariableFile.cmake b/Tests/RunCMake/Syntax/AtWithVariableFile.cmake new file mode 100644 index 0000000..c709099 --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableFile.cmake @@ -0,0 +1,8 @@ +set(right "wrong") +set(var "\${right}") + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/atfile.txt.in" + "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt") +file(READ "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt" output) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt b/Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt new file mode 100644 index 0000000..077272d --- /dev/null +++ b/Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt @@ -0,0 +1 @@ +-->"<-- diff --git a/Tests/RunCMake/Syntax/EscapeQuotes.cmake b/Tests/RunCMake/Syntax/EscapeQuotes.cmake new file mode 100644 index 0000000..46d2b6f --- /dev/null +++ b/Tests/RunCMake/Syntax/EscapeQuotes.cmake @@ -0,0 +1,9 @@ +set(var "\"") +set(ref "@var@") +set(rref "\${var}") + +string(CONFIGURE "${ref}" output ESCAPE_QUOTES) +message("-->${output}<--") + +string(CONFIGURE "${rref}" output ESCAPE_QUOTES) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/EscapedAt-stderr.txt b/Tests/RunCMake/Syntax/EscapedAt-stderr.txt new file mode 100644 index 0000000..a51c0d3 --- /dev/null +++ b/Tests/RunCMake/Syntax/EscapedAt-stderr.txt @@ -0,0 +1 @@ +-->\\n<-- diff --git a/Tests/RunCMake/Syntax/EscapedAt.cmake b/Tests/RunCMake/Syntax/EscapedAt.cmake new file mode 100644 index 0000000..1ced620 --- /dev/null +++ b/Tests/RunCMake/Syntax/EscapedAt.cmake @@ -0,0 +1,5 @@ +set(var "n") +set(ref "\\@var@") + +string(CONFIGURE "${ref}" output) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/ExpandInAt-stderr.txt b/Tests/RunCMake/Syntax/ExpandInAt-stderr.txt new file mode 100644 index 0000000..5da8b60 --- /dev/null +++ b/Tests/RunCMake/Syntax/ExpandInAt-stderr.txt @@ -0,0 +1 @@ +-->@foo@<-- diff --git a/Tests/RunCMake/Syntax/ExpandInAt.cmake b/Tests/RunCMake/Syntax/ExpandInAt.cmake new file mode 100644 index 0000000..98f0277 --- /dev/null +++ b/Tests/RunCMake/Syntax/ExpandInAt.cmake @@ -0,0 +1,6 @@ +set("\${varname}" bar) +set(var foo) +set(ref "@\${var}@") + +string(CONFIGURE "${ref}" output) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/ParenInENV-result.txt b/Tests/RunCMake/Syntax/ParenInENV-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Syntax/ParenInENV-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Syntax/ParenInENV-stderr.txt b/Tests/RunCMake/Syntax/ParenInENV-stderr.txt new file mode 100644 index 0000000..7ecfe11 --- /dev/null +++ b/Tests/RunCMake/Syntax/ParenInENV-stderr.txt @@ -0,0 +1,20 @@ +CMake Warning \(dev\) at CMakeLists.txt:3 \(include\): + Syntax Warning in cmake code at + + .*/Tests/RunCMake/Syntax/ParenInENV.cmake:2:21 + + Argument not separated from preceding token by whitespace. +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Error at ParenInENV.cmake:2 \(message\): + Syntax error in cmake code at + + .*/Tests/RunCMake/Syntax/ParenInENV.cmake:2 + + when parsing string + + -->\$ENV{e + + syntax error, unexpected \$end, expecting } \(9\) +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/ParenInENV.cmake b/Tests/RunCMake/Syntax/ParenInENV.cmake new file mode 100644 index 0000000..148f726 --- /dev/null +++ b/Tests/RunCMake/Syntax/ParenInENV.cmake @@ -0,0 +1,2 @@ +set("ENV{e(x)}" value) +message(-->$ENV{e(x)}<--) diff --git a/Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt b/Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt new file mode 100644 index 0000000..7020c7e --- /dev/null +++ b/Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt @@ -0,0 +1 @@ +-->value<-- diff --git a/Tests/RunCMake/Syntax/ParenInQuotedENV.cmake b/Tests/RunCMake/Syntax/ParenInQuotedENV.cmake new file mode 100644 index 0000000..6333717 --- /dev/null +++ b/Tests/RunCMake/Syntax/ParenInQuotedENV.cmake @@ -0,0 +1,2 @@ +set("ENV{e(x)}" value) +message("-->$ENV{e(x)}<--") diff --git a/Tests/RunCMake/Syntax/RunCMakeTest.cmake b/Tests/RunCMake/Syntax/RunCMakeTest.cmake index 5f05cfc..dcabd8a 100644 --- a/Tests/RunCMake/Syntax/RunCMakeTest.cmake +++ b/Tests/RunCMake/Syntax/RunCMakeTest.cmake @@ -52,3 +52,16 @@ run_cmake(UnterminatedString) run_cmake(UnterminatedBracket0) run_cmake(UnterminatedBracket1) run_cmake(UnterminatedBracketComment) + +# Variable expansion tests +run_cmake(ExpandInAt) +run_cmake(EscapedAt) +run_cmake(EscapeQuotes) +run_cmake(AtWithVariable) +run_cmake(AtWithVariableEmptyExpansion) +run_cmake(AtWithVariableAtOnly) +run_cmake(AtWithVariableEmptyExpansionAtOnly) +run_cmake(AtWithVariableFile) +run_cmake(AtWithVariableAtOnlyFile) +run_cmake(ParenInENV) +run_cmake(ParenInQuotedENV) diff --git a/Tests/RunCMake/Syntax/atfile.txt.in b/Tests/RunCMake/Syntax/atfile.txt.in new file mode 100644 index 0000000..3775919 --- /dev/null +++ b/Tests/RunCMake/Syntax/atfile.txt.in @@ -0,0 +1,4 @@ +==>@var@<== +==>@empty@<== +==>${var}<== +==>${empty}<== -- cgit v0.12 From 67253133f8ca99034a1eabe326a51c74f5e95c87 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 8 Feb 2014 11:35:52 -0500 Subject: ExpandListArguments: Optimize the parser Optimize cmSystemTools::ExpandListArguments so as not to build a string character-by-character. This avoids excess reallocations of the result string. --- Source/cmSystemTools.cxx | 51 +++++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index ff05975..7cc63bb 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1044,7 +1044,7 @@ void cmSystemTools::ExpandListArgument(const std::string& arg, bool emptyArgs) { // If argument is empty, it is an empty list. - if(arg.length() == 0 && !emptyArgs) + if(!emptyArgs && arg.empty()) { return; } @@ -1054,10 +1054,11 @@ void cmSystemTools::ExpandListArgument(const std::string& arg, newargs.push_back(arg); return; } - std::vector newArgVec; + std::string newArg; + const char *last = arg.c_str(); // Break the string at non-escaped semicolons not nested in []. int squareNesting = 0; - for(const char* c = arg.c_str(); *c; ++c) + for(const char* c = last; *c; ++c) { switch(*c) { @@ -1065,34 +1066,21 @@ void cmSystemTools::ExpandListArgument(const std::string& arg, { // We only want to allow escaping of semicolons. Other // escapes should not be processed here. - ++c; - if(*c == ';') - { - newArgVec.push_back(*c); - } - else + const char* next = c + 1; + if(*next == ';') { - newArgVec.push_back('\\'); - if(*c) - { - newArgVec.push_back(*c); - } - else - { - // Terminate the loop properly. - --c; - } + newArg.append(last, c - last); + // Skip over the escape character + last = c = next; } } break; case '[': { ++squareNesting; - newArgVec.push_back(*c); } break; case ']': { --squareNesting; - newArgVec.push_back(*c); } break; case ';': { @@ -1100,31 +1088,28 @@ void cmSystemTools::ExpandListArgument(const std::string& arg, // brackets. if(squareNesting == 0) { - if ( newArgVec.size() || emptyArgs ) + newArg.append(last, c - last); + // Skip over the semicolon + last = c + 1; + if ( !newArg.empty() || emptyArgs ) { // Add the last argument if the string is not empty. - newArgVec.push_back(0); - newargs.push_back(&*newArgVec.begin()); - newArgVec.clear(); + newargs.push_back(newArg); + newArg = ""; } } - else - { - newArgVec.push_back(*c); - } } break; default: { // Just append this character. - newArgVec.push_back(*c); } break; } } - if ( newArgVec.size() || emptyArgs ) + newArg.append(last); + if ( !newArg.empty() || emptyArgs ) { // Add the last argument if the string is not empty. - newArgVec.push_back(0); - newargs.push_back(&*newArgVec.begin()); + newargs.push_back(newArg); } } -- cgit v0.12 From 68eb1757445dd1bb6537e32be8c9a72360112978 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 8 Feb 2014 12:01:30 -0500 Subject: cmGeneratorExpressionLexer: Use a switch statement to parse Optimize cmGeneratorExpressionLexer::Tokenize to use a switch statement. The many dereferences of the input pointer were expensive. Also remove excess pointer arithmetic. --- Source/cmGeneratorExpressionLexer.cxx | 70 +++++++++++++++++------------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/Source/cmGeneratorExpressionLexer.cxx b/Source/cmGeneratorExpressionLexer.cxx index cd71ec0..117a24e 100644 --- a/Source/cmGeneratorExpressionLexer.cxx +++ b/Source/cmGeneratorExpressionLexer.cxx @@ -42,42 +42,42 @@ cmGeneratorExpressionLexer::Tokenize(const char *input) const char *upto = c; for ( ; *c; ++c) - { - if(c[0] == '$' && c[1] == '<') { - InsertText(upto, c, result); - upto = c; - result.push_back(cmGeneratorExpressionToken( - cmGeneratorExpressionToken::BeginExpression, upto, 2)); - upto = c + 2; - ++c; - SawBeginExpression = true; - } - else if(c[0] == '>') - { - InsertText(upto, c, result); - upto = c; - result.push_back(cmGeneratorExpressionToken( - cmGeneratorExpressionToken::EndExpression, upto, 1)); - upto = c + 1; - SawGeneratorExpression = SawBeginExpression; - } - else if(c[0] == ':') - { - InsertText(upto, c, result); - upto = c; - result.push_back(cmGeneratorExpressionToken( - cmGeneratorExpressionToken::ColonSeparator, upto, 1)); - upto = c + 1; - } - else if(c[0] == ',') - { - InsertText(upto, c, result); - upto = c; - result.push_back(cmGeneratorExpressionToken( - cmGeneratorExpressionToken::CommaSeparator, upto, 1)); - upto = c + 1; - } + switch(*c) + { + case '$': + if(c[1] == '<') + { + InsertText(upto, c, result); + result.push_back(cmGeneratorExpressionToken( + cmGeneratorExpressionToken::BeginExpression, c, 2)); + upto = c + 2; + ++c; + SawBeginExpression = true; + } + break; + case '>': + InsertText(upto, c, result); + result.push_back(cmGeneratorExpressionToken( + cmGeneratorExpressionToken::EndExpression, c, 1)); + upto = c + 1; + SawGeneratorExpression = SawBeginExpression; + break; + case ':': + InsertText(upto, c, result); + result.push_back(cmGeneratorExpressionToken( + cmGeneratorExpressionToken::ColonSeparator, c, 1)); + upto = c + 1; + break; + case ',': + InsertText(upto, c, result); + result.push_back(cmGeneratorExpressionToken( + cmGeneratorExpressionToken::CommaSeparator, c, 1)); + upto = c + 1; + break; + default: + break; + } } InsertText(upto, c, result); -- cgit v0.12 From 7c565d2fd5e86d420ea83eb724ad5380ca5c2e97 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 9 Feb 2014 05:09:52 -0500 Subject: cmGeneratorExpression: Improve parsing in StripEmptyListElements The char-by-char parsing causes lots of reallocations which shouldn't be necessary. To improve this, fast-path strings without a semicolon, reserve space in the result, and insert into the result in chunks. --- Source/cmGeneratorExpression.cxx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 2e66d78..cd30546 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -157,17 +157,24 @@ cmCompiledGeneratorExpression::~cmCompiledGeneratorExpression() std::string cmGeneratorExpression::StripEmptyListElements( const std::string &input) { + if (input.find(';') == input.npos) + { + return input; + } std::string result; + result.reserve(input.size()); const char *c = input.c_str(); + const char *last = c; bool skipSemiColons = true; for ( ; *c; ++c) { - if(c[0] == ';') + if(*c == ';') { if(skipSemiColons) { - continue; + result.append(last, c - last); + last = c + 1; } skipSemiColons = true; } @@ -175,8 +182,8 @@ std::string cmGeneratorExpression::StripEmptyListElements( { skipSemiColons = false; } - result += *c; } + result.append(last); if (!result.empty() && *(result.end() - 1) == ';') { -- cgit v0.12 From 4e647cf6b5114307ff0e4bc985b53a0c04661623 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 22 Feb 2014 00:01:06 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 0c481ad..ef128e1 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 0) -set(CMake_VERSION_PATCH 20140221) +set(CMake_VERSION_PATCH 20140222) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 01981d8e45a60a66f3140a981c0bc1e7fe2ea804 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 23 Feb 2014 00:01:05 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index ef128e1..693144a 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 0) -set(CMake_VERSION_PATCH 20140222) +set(CMake_VERSION_PATCH 20140223) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 2f2bb105d5eb27920518e144959cb706a619f2ce Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 24 Feb 2014 00:01:04 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 693144a..e9a1721 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 0) -set(CMake_VERSION_PATCH 20140223) +set(CMake_VERSION_PATCH 20140224) #set(CMake_VERSION_RC 1) -- cgit v0.12 From f0111deb1ea21f667b2fbf57f55d5ee2a80f5ccc Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Sun, 23 Feb 2014 19:58:43 +0100 Subject: UseSWIG: Name extra generated files after module name (#10080) --- Modules/UseSWIG.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 11ca205..4ae6f81 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -85,9 +85,6 @@ macro(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile) set(${outfiles} "") get_source_file_property(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename ${infile} SWIG_MODULE_NAME) - if(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND") - get_filename_component(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${infile}" NAME_WE) - endif() foreach(it ${SWIG_${language}_EXTRA_FILE_EXTENSION}) set(${outfiles} ${${outfiles}} "${generatedpath}/${SWIG_GET_EXTRA_OUTPUT_FILES_module_basename}.${it}") @@ -103,6 +100,10 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) get_source_file_property(swig_source_file_generated ${infile} GENERATED) get_source_file_property(swig_source_file_cplusplus ${infile} CPLUSPLUS) get_source_file_property(swig_source_file_flags ${infile} SWIG_FLAGS) + get_source_file_property(_SWIG_MODULE_NAME ${infile} SWIG_MODULE_NAME) + if ( NOT _SWIG_MODULE_NAME ) + set_source_files_properties(${infile} PROPERTIES SWIG_MODULE_NAME ${name}) + endif () if("${swig_source_file_flags}" STREQUAL "NOTFOUND") set(swig_source_file_flags "") endif() -- cgit v0.12 From 84e5f5a004fc4659504f25a2d23984b2bceb1a9f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 6 Feb 2014 11:24:37 +0100 Subject: cmTarget: Move SourceFileFlags to cmGeneratorTarget. --- Source/cmGeneratorTarget.cxx | 106 ++++++++++++++++++++++++++++++++++++- Source/cmGeneratorTarget.h | 29 ++++++++++ Source/cmGlobalXCodeGenerator.cxx | 28 +++++----- Source/cmOSXBundleGenerator.cxx | 32 +++++------ Source/cmOSXBundleGenerator.h | 2 +- Source/cmTarget.cxx | 108 -------------------------------------- Source/cmTarget.h | 29 ---------- 7 files changed, 166 insertions(+), 168 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 175bb0e..4db27ca 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -25,7 +25,8 @@ #include "assert.h" //---------------------------------------------------------------------------- -cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t) +cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t), + SourceFileFlagsConstructed(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = this->Makefile->GetLocalGenerator(); @@ -876,3 +877,106 @@ bool cmStrictTargetComparison::operator()(cmTarget const* t1, } return nameResult < 0; } + +//---------------------------------------------------------------------------- +struct cmGeneratorTarget::SourceFileFlags +cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const +{ + struct SourceFileFlags flags; + this->ConstructSourceFileFlags(); + std::map::iterator si = + this->SourceFlagsMap.find(sf); + if(si != this->SourceFlagsMap.end()) + { + flags = si->second; + } + return flags; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ConstructSourceFileFlags() const +{ + if(this->SourceFileFlagsConstructed) + { + return; + } + this->SourceFileFlagsConstructed = true; + + // Process public headers to mark the source files. + if(const char* files = this->Target->GetProperty("PUBLIC_HEADER")) + { + std::vector relFiles; + cmSystemTools::ExpandListArgument(files, relFiles); + for(std::vector::iterator it = relFiles.begin(); + it != relFiles.end(); ++it) + { + if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str())) + { + SourceFileFlags& flags = this->SourceFlagsMap[sf]; + flags.MacFolder = "Headers"; + flags.Type = cmGeneratorTarget::SourceFileTypePublicHeader; + } + } + } + + // Process private headers after public headers so that they take + // precedence if a file is listed in both. + if(const char* files = this->Target->GetProperty("PRIVATE_HEADER")) + { + std::vector relFiles; + cmSystemTools::ExpandListArgument(files, relFiles); + for(std::vector::iterator it = relFiles.begin(); + it != relFiles.end(); ++it) + { + if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str())) + { + SourceFileFlags& flags = this->SourceFlagsMap[sf]; + flags.MacFolder = "PrivateHeaders"; + flags.Type = cmGeneratorTarget::SourceFileTypePrivateHeader; + } + } + } + + // Mark sources listed as resources. + if(const char* files = this->Target->GetProperty("RESOURCE")) + { + std::vector relFiles; + cmSystemTools::ExpandListArgument(files, relFiles); + for(std::vector::iterator it = relFiles.begin(); + it != relFiles.end(); ++it) + { + if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str())) + { + SourceFileFlags& flags = this->SourceFlagsMap[sf]; + flags.MacFolder = "Resources"; + flags.Type = cmGeneratorTarget::SourceFileTypeResource; + } + } + } + + // Handle the MACOSX_PACKAGE_LOCATION property on source files that + // were not listed in one of the other lists. + std::vector sources; + this->GetSourceFiles(sources); + for(std::vector::const_iterator si = sources.begin(); + si != sources.end(); ++si) + { + cmSourceFile* sf = *si; + if(const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION")) + { + SourceFileFlags& flags = this->SourceFlagsMap[sf]; + if(flags.Type == cmGeneratorTarget::SourceFileTypeNormal) + { + flags.MacFolder = location; + if(strcmp(location, "Resources") == 0) + { + flags.Type = cmGeneratorTarget::SourceFileTypeResource; + } + else + { + flags.Type = cmGeneratorTarget::SourceFileTypeMacContent; + } + } + } + } +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a4caba1..9a3339d 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -88,6 +88,31 @@ public: /** Get sources that must be built before the given source. */ std::vector const* GetSourceDepends(cmSourceFile* sf) const; + /** + * Flags for a given source file as used in this target. Typically assigned + * via SET_TARGET_PROPERTIES when the property is a list of source files. + */ + enum SourceFileType + { + SourceFileTypeNormal, + SourceFileTypePrivateHeader, // is in "PRIVATE_HEADER" target property + SourceFileTypePublicHeader, // is in "PUBLIC_HEADER" target property + SourceFileTypeResource, // is in "RESOURCE" target property *or* + // has MACOSX_PACKAGE_LOCATION=="Resources" + SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources" + }; + struct SourceFileFlags + { + SourceFileFlags(): Type(SourceFileTypeNormal), MacFolder(0) {} + SourceFileFlags(SourceFileFlags const& r): + Type(r.Type), MacFolder(r.MacFolder) {} + SourceFileType Type; + const char* MacFolder; // location inside Mac content folders + }; + + struct SourceFileFlags + GetTargetSourceFileFlags(const cmSourceFile* sf) const; + private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; @@ -107,6 +132,10 @@ private: std::vector ObjectLibraries; mutable std::map > SystemIncludesCache; + void ConstructSourceFileFlags() const; + mutable bool SourceFileFlagsConstructed; + mutable std::map SourceFlagsMap; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 484b28f..004f7ac 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -713,22 +713,23 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, // Is this a resource file in this target? Add it to the resources group... // - cmTarget::SourceFileFlags tsFlags = cmtarget.GetTargetSourceFileFlags(sf); - bool isResource = (tsFlags.Type == cmTarget::SourceFileTypeResource); + cmGeneratorTarget::SourceFileFlags tsFlags = + this->GetGeneratorTarget(&cmtarget)->GetTargetSourceFileFlags(sf); + bool isResource = tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource; // Is this a "private" or "public" framework header file? // Set the ATTRIBUTES attribute appropriately... // if(cmtarget.IsFrameworkOnApple()) { - if(tsFlags.Type == cmTarget::SourceFileTypePrivateHeader) + if(tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader) { cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST); attrs->AddObject(this->CreateString("Private")); settings->AddAttribute("ATTRIBUTES", attrs); isResource = true; } - else if(tsFlags.Type == cmTarget::SourceFileTypePublicHeader) + else if(tsFlags.Type == cmGeneratorTarget::SourceFileTypePublicHeader) { cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST); attrs->AddObject(this->CreateString("Public")); @@ -973,6 +974,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { cmTarget& cmtarget = l->second; + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); // make sure ALL_BUILD, INSTALL, etc are only done once if(this->SpecialTargetEmitted(l->first.c_str())) @@ -1011,8 +1013,8 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, cmXCodeObject* filetype = fr->GetObject()->GetObject("explicitFileType"); - cmTarget::SourceFileFlags tsFlags = - cmtarget.GetTargetSourceFileFlags(*i); + cmGeneratorTarget::SourceFileFlags tsFlags = + gtgt->GetTargetSourceFileFlags(*i); if(filetype && strcmp(filetype->GetString(), "compiled.mach-o.objfile") == 0) @@ -1020,12 +1022,12 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, externalObjFiles.push_back(xsf); } else if(this->IsHeaderFile(*i) || - (tsFlags.Type == cmTarget::SourceFileTypePrivateHeader) || - (tsFlags.Type == cmTarget::SourceFileTypePublicHeader)) + (tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader) || + (tsFlags.Type == cmGeneratorTarget::SourceFileTypePublicHeader)) { headerFiles.push_back(xsf); } - else if(tsFlags.Type == cmTarget::SourceFileTypeResource) + else if(tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource) { resourceFiles.push_back(xsf); } @@ -1048,7 +1050,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // the externalObjFiles above, except each one is not a cmSourceFile // within the target.) std::vector objs; - this->GetGeneratorTarget(&cmtarget)->UseObjectLibraries(objs); + gtgt->UseObjectLibraries(objs); for(std::vector::const_iterator oi = objs.begin(); oi != objs.end(); ++oi) { @@ -1138,9 +1140,9 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, for(std::vector::const_iterator i = classes.begin(); i != classes.end(); ++i) { - cmTarget::SourceFileFlags tsFlags = - cmtarget.GetTargetSourceFileFlags(*i); - if(tsFlags.Type == cmTarget::SourceFileTypeMacContent) + cmGeneratorTarget::SourceFileFlags tsFlags = + gtgt->GetTargetSourceFileFlags(*i); + if(tsFlags.Type == cmGeneratorTarget::SourceFileTypeMacContent) { bundleFiles[tsFlags.MacFolder].push_back(*i); } diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 9a340dc..78b59b3 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -20,7 +20,7 @@ cmOSXBundleGenerator:: cmOSXBundleGenerator(cmGeneratorTarget* target, const char* configName) - : Target(target->Target) + : GT(target) , Makefile(target->Target->GetMakefile()) , LocalGenerator(Makefile->GetLocalGenerator()) , ConfigName(configName) @@ -34,7 +34,7 @@ cmOSXBundleGenerator(cmGeneratorTarget* target, //---------------------------------------------------------------------------- bool cmOSXBundleGenerator::MustSkip() { - return !this->Target->HaveWellDefinedOutputFiles(); + return !this->GT->Target->HaveWellDefinedOutputFiles(); } //---------------------------------------------------------------------------- @@ -47,7 +47,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // Compute bundle directory names. std::string out = outpath; out += "/"; - out += this->Target->GetAppBundleDirectory(this->ConfigName, false); + out += this->GT->Target->GetAppBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); @@ -57,9 +57,9 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // to be set. std::string plist = outpath; plist += "/"; - plist += this->Target->GetAppBundleDirectory(this->ConfigName, true); + plist += this->GT->Target->GetAppBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; - this->LocalGenerator->GenerateAppleInfoPList(this->Target, + this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, targetName.c_str(), plist.c_str()); this->Makefile->AddCMakeOutputFile(plist); @@ -77,20 +77,20 @@ void cmOSXBundleGenerator::CreateFramework( // Compute the location of the top-level foo.framework directory. std::string contentdir = outpath + "/" + - this->Target->GetFrameworkDirectory(this->ConfigName, true); + this->GT->Target->GetFrameworkDirectory(this->ConfigName, true); contentdir += "/"; std::string newoutpath = outpath + "/" + - this->Target->GetFrameworkDirectory(this->ConfigName, false); + this->GT->Target->GetFrameworkDirectory(this->ConfigName, false); - std::string frameworkVersion = this->Target->GetFrameworkVersion(); + std::string frameworkVersion = this->GT->Target->GetFrameworkVersion(); // Configure the Info.plist file into the Resources directory. this->MacContentFolders->insert("Resources"); std::string plist = newoutpath; plist += "/Resources/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); - this->LocalGenerator->GenerateFrameworkInfoPList(this->Target, + this->LocalGenerator->GenerateFrameworkInfoPList(this->GT->Target, name.c_str(), plist.c_str()); @@ -172,16 +172,16 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, // Compute bundle directory names. std::string out = root; out += "/"; - out += this->Target->GetCFBundleDirectory(this->ConfigName, false); + out += this->GT->Target->GetCFBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); // Configure the Info.plist file. Note that it needs the executable name // to be set. std::string plist = - this->Target->GetCFBundleDirectory(this->ConfigName, true); + this->GT->Target->GetCFBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; - this->LocalGenerator->GenerateAppleInfoPList(this->Target, + this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, targetName.c_str(), plist.c_str()); this->Makefile->AddCMakeOutputFile(plist); @@ -199,9 +199,9 @@ GenerateMacOSXContentStatements(std::vector const& sources, for(std::vector::const_iterator si = sources.begin(); si != sources.end(); ++si) { - cmTarget::SourceFileFlags tsFlags = - this->Target->GetTargetSourceFileFlags(*si); - if(tsFlags.Type != cmTarget::SourceFileTypeNormal) + cmGeneratorTarget::SourceFileFlags tsFlags = + this->GT->GetTargetSourceFileFlags(*si); + if(tsFlags.Type != cmGeneratorTarget::SourceFileTypeNormal) { (*generator)(**si, tsFlags.MacFolder); } @@ -215,7 +215,7 @@ cmOSXBundleGenerator::InitMacOSXContentDirectory(const char* pkgloc) // Construct the full path to the content subdirectory. std::string macdir = - this->Target->GetMacContentDirectory(this->ConfigName, + this->GT->Target->GetMacContentDirectory(this->ConfigName, /*implib*/ false); macdir += "/"; macdir += pkgloc; diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h index 29b7611..2f36394 100644 --- a/Source/cmOSXBundleGenerator.h +++ b/Source/cmOSXBundleGenerator.h @@ -59,7 +59,7 @@ private: bool MustSkip(); private: - cmTarget* Target; + cmGeneratorTarget* GT; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; const char* ConfigName; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index db34bd8..61f05a1 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -83,17 +83,12 @@ public: cmTargetInternals() { this->PolicyWarnedCMP0022 = false; - this->SourceFileFlagsConstructed = false; } cmTargetInternals(cmTargetInternals const&) { this->PolicyWarnedCMP0022 = false; - this->SourceFileFlagsConstructed = false; } ~cmTargetInternals(); - typedef cmTarget::SourceFileFlags SourceFileFlags; - mutable std::map SourceFlagsMap; - mutable bool SourceFileFlagsConstructed; // The backtrace when the target was created. cmListFileBacktrace Backtrace; @@ -648,109 +643,6 @@ void cmTarget::ProcessSourceExpression(std::string const& expr) } //---------------------------------------------------------------------------- -struct cmTarget::SourceFileFlags -cmTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const -{ - struct SourceFileFlags flags; - this->ConstructSourceFileFlags(); - std::map::iterator si = - this->Internal->SourceFlagsMap.find(sf); - if(si != this->Internal->SourceFlagsMap.end()) - { - flags = si->second; - } - return flags; -} - -//---------------------------------------------------------------------------- -void cmTarget::ConstructSourceFileFlags() const -{ - if(this->Internal->SourceFileFlagsConstructed) - { - return; - } - this->Internal->SourceFileFlagsConstructed = true; - - // Process public headers to mark the source files. - if(const char* files = this->GetProperty("PUBLIC_HEADER")) - { - std::vector relFiles; - cmSystemTools::ExpandListArgument(files, relFiles); - for(std::vector::iterator it = relFiles.begin(); - it != relFiles.end(); ++it) - { - if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str())) - { - SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf]; - flags.MacFolder = "Headers"; - flags.Type = cmTarget::SourceFileTypePublicHeader; - } - } - } - - // Process private headers after public headers so that they take - // precedence if a file is listed in both. - if(const char* files = this->GetProperty("PRIVATE_HEADER")) - { - std::vector relFiles; - cmSystemTools::ExpandListArgument(files, relFiles); - for(std::vector::iterator it = relFiles.begin(); - it != relFiles.end(); ++it) - { - if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str())) - { - SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf]; - flags.MacFolder = "PrivateHeaders"; - flags.Type = cmTarget::SourceFileTypePrivateHeader; - } - } - } - - // Mark sources listed as resources. - if(const char* files = this->GetProperty("RESOURCE")) - { - std::vector relFiles; - cmSystemTools::ExpandListArgument(files, relFiles); - for(std::vector::iterator it = relFiles.begin(); - it != relFiles.end(); ++it) - { - if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str())) - { - SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf]; - flags.MacFolder = "Resources"; - flags.Type = cmTarget::SourceFileTypeResource; - } - } - } - - // Handle the MACOSX_PACKAGE_LOCATION property on source files that - // were not listed in one of the other lists. - std::vector sources; - this->GetSourceFiles(sources); - for(std::vector::const_iterator si = sources.begin(); - si != sources.end(); ++si) - { - cmSourceFile* sf = *si; - if(const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION")) - { - SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf]; - if(flags.Type == cmTarget::SourceFileTypeNormal) - { - flags.MacFolder = location; - if(strcmp(location, "Resources") == 0) - { - flags.Type = cmTarget::SourceFileTypeResource; - } - else - { - flags.Type = cmTarget::SourceFileTypeMacContent; - } - } - } - } -} - -//---------------------------------------------------------------------------- void cmTarget::MergeLinkLibraries( cmMakefile& mf, const char *selfname, const LinkLibraryVectorType& libs ) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 271824b..a02ed09 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -140,34 +140,6 @@ public: } /** - * Flags for a given source file as used in this target. Typically assigned - * via SET_TARGET_PROPERTIES when the property is a list of source files. - */ - enum SourceFileType - { - SourceFileTypeNormal, - SourceFileTypePrivateHeader, // is in "PRIVATE_HEADER" target property - SourceFileTypePublicHeader, // is in "PUBLIC_HEADER" target property - SourceFileTypeResource, // is in "RESOURCE" target property *or* - // has MACOSX_PACKAGE_LOCATION=="Resources" - SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources" - }; - struct SourceFileFlags - { - SourceFileFlags(): Type(SourceFileTypeNormal), MacFolder(0) {} - SourceFileFlags(SourceFileFlags const& r): - Type(r.Type), MacFolder(r.MacFolder) {} - SourceFileType Type; - const char* MacFolder; // location inside Mac content folders - }; - - /** - * Get the flags for a given source file as used in this target - */ - struct SourceFileFlags - GetTargetSourceFileFlags(const cmSourceFile* sf) const; - - /** * Add sources to the target. */ void AddSources(std::vector const& srcs); @@ -756,7 +728,6 @@ private: friend class cmTargetTraceDependencies; cmTargetInternalPointer Internal; - void ConstructSourceFileFlags() const; void ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, -- cgit v0.12 From f81eb49e8be851cef5e75a5074ff46435c941301 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 14 Feb 2014 12:07:34 +0100 Subject: cmTarget: Find source files on request. In a follow-up, the list of sources will become dependent on the config, so check for existence in cmTarget::GetSourceFiles instead of up-front with cmGlobalGenerator::CheckTargets(). --- Source/cmGlobalGenerator.cxx | 35 ----------------------------------- Source/cmGlobalGenerator.h | 1 - Source/cmTarget.cxx | 14 ++++---------- Source/cmTarget.h | 5 ----- 4 files changed, 4 insertions(+), 51 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 4f3328d..e143eba 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1148,12 +1148,6 @@ void cmGlobalGenerator::Generate() return; } - // Check that all targets are valid. - if(!this->CheckTargets()) - { - return; - } - this->FinalizeTargetCompileInfo(); #ifdef CMAKE_BUILD_WITH_CMAKE @@ -1306,35 +1300,6 @@ bool cmGlobalGenerator::ComputeTargetDepends() } //---------------------------------------------------------------------------- -bool cmGlobalGenerator::CheckTargets() -{ - // Make sure all targets can find their source files. - for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) - { - cmTargets& targets = - this->LocalGenerators[i]->GetMakefile()->GetTargets(); - for(cmTargets::iterator ti = targets.begin(); - ti != targets.end(); ++ti) - { - cmTarget& target = ti->second; - if(target.GetType() == cmTarget::EXECUTABLE || - target.GetType() == cmTarget::STATIC_LIBRARY || - target.GetType() == cmTarget::SHARED_LIBRARY || - target.GetType() == cmTarget::MODULE_LIBRARY || - target.GetType() == cmTarget::OBJECT_LIBRARY || - target.GetType() == cmTarget::UTILITY) - { - if(!target.FindSourceFiles()) - { - return false; - } - } - } - } - return true; -} - -//---------------------------------------------------------------------------- void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens) { #ifdef CMAKE_BUILD_WITH_CMAKE diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 753eebf..b66f01e 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -340,7 +340,6 @@ protected: virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const; - bool CheckTargets(); typedef std::vector > AutogensType; void CreateQtAutoGeneratorsTargets(AutogensType& autogens); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 61f05a1..5fa9276 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -522,10 +522,11 @@ bool cmTarget::IsBundleOnApple() const } //---------------------------------------------------------------------------- -bool cmTarget::FindSourceFiles() +void cmTarget::GetSourceFiles(std::vector &files) const { + assert(this->GetType() != INTERFACE_LIBRARY); for(std::vector::const_iterator - si = this->SourceFiles.begin(); + si = this->SourceFiles.begin(); si != this->SourceFiles.end(); ++si) { std::string e; @@ -537,16 +538,9 @@ bool cmTarget::FindSourceFiles() cm->IssueMessage(cmake::FATAL_ERROR, e, this->GetBacktrace()); } - return false; + return; } } - return true; -} - -//---------------------------------------------------------------------------- -void cmTarget::GetSourceFiles(std::vector &files) const -{ - assert(this->GetType() != INTERFACE_LIBRARY); files = this->SourceFiles; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a02ed09..4d487f7 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -330,11 +330,6 @@ public: void GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - /** - * Make sure the full path to all source files is known. - */ - bool FindSourceFiles(); - ///! Return the preferred linker language for this target const char* GetLinkerLanguage(const char* config = 0, cmTarget const* head = 0) const; -- cgit v0.12 From 21e91350b06b562ac2668c6ff2a3b220e41d4bc1 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 13 Feb 2014 09:53:27 +0100 Subject: cmTarget: Change GetTransitivePropertyLinkLibraries to output targets. The callers already skip non-targets, so unify the target search. Change supporting functions to accept a container of targets instead of strings where possible. --- Source/cmGeneratorExpressionEvaluator.cxx | 51 +++++++++++++++++++++---------- Source/cmGeneratorTarget.cxx | 32 ++++++++----------- Source/cmTarget.cxx | 26 +++++++++++++--- Source/cmTarget.h | 4 +-- 4 files changed, 71 insertions(+), 42 deletions(-) diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 7036992..ebedf65 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -800,7 +800,7 @@ static const char* targetPropertyTransitiveWhitelist[] = { #undef TRANSITIVE_PROPERTY_NAME -std::string getLinkedTargetsContent(const std::vector &libraries, +std::string getLinkedTargetsContent(const std::vector &targets, cmTarget const* target, cmTarget const* headTarget, cmGeneratorExpressionContext *context, @@ -811,23 +811,21 @@ std::string getLinkedTargetsContent(const std::vector &libraries, std::string sep; std::string depString; - for (std::vector::const_iterator - it = libraries.begin(); - it != libraries.end(); ++it) + for (std::vector::const_iterator + it = targets.begin(); + it != targets.end(); ++it) { - if (*it == target->GetName()) + if (*it == target) { // Broken code can have a target in its own link interface. // Don't follow such link interface entries so as not to create a // self-referencing loop. continue; } - if (context->Makefile->FindTargetToUse(*it)) - { - depString += - sep + "$"; - sep = ";"; - } + depString += + sep + "$GetName() + "," + interfacePropertyName + ">"; + sep = ";"; } cmsys::auto_ptr cge = ge.Parse(depString); std::string linkedTargetsContent = cge->Evaluate(context->Makefile, @@ -843,6 +841,27 @@ std::string getLinkedTargetsContent(const std::vector &libraries, return linkedTargetsContent; } +std::string getLinkedTargetsContent(const std::vector &libraries, + cmTarget const* target, + cmTarget const* headTarget, + cmGeneratorExpressionContext *context, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string &interfacePropertyName) +{ + std::vector tgts; + for (std::vector::const_iterator + it = libraries.begin(); + it != libraries.end(); ++it) + { + if (cmTarget *tgt = context->Makefile->FindTargetToUse(*it)) + { + tgts.push_back(tgt); + } + } + return getLinkedTargetsContent(tgts, target, headTarget, context, + dagChecker, interfacePropertyName); +} + //---------------------------------------------------------------------------- static const struct TargetPropertyNode : public cmGeneratorExpressionNode { @@ -1065,13 +1084,13 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode cmStrCmp(propertyName)) != transEnd) { - std::vector libs; - target->GetTransitivePropertyLinkLibraries(context->Config, - headTarget, libs); - if (!libs.empty()) + std::vector tgts; + target->GetTransitivePropertyTargets(context->Config, + headTarget, tgts); + if (!tgts.empty()) { linkedTargetsContent = - getLinkedTargetsContent(libs, target, + getLinkedTargetsContent(tgts, target, headTarget, context, &dagChecker, interfacePropertyName); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4db27ca..6223ed1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -63,19 +63,12 @@ cmGeneratorTarget::GetSourceDepends(cmSourceFile* sf) const return 0; } -static void handleSystemIncludesDep(cmMakefile *mf, const std::string &name, +static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt, const char *config, cmTarget *headTarget, cmGeneratorExpressionDAGChecker *dagChecker, std::vector& result, bool excludeImported) { - cmTarget* depTgt = mf->FindTargetToUse(name); - - if (!depTgt) - { - return; - } - cmListFileBacktrace lfbt; if (const char* dirs = @@ -225,26 +218,25 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, &dagChecker), result); } - std::set uniqueDeps; + std::set uniqueDeps; for(std::vector::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { - if (uniqueDeps.insert(*li).second) + cmTarget* tgt = this->Makefile->FindTargetToUse(*li); + if (!tgt) { - cmTarget* tgt = this->Makefile->FindTargetToUse(*li); - - if (!tgt) - { - continue; - } + continue; + } - handleSystemIncludesDep(this->Makefile, *li, config, this->Target, + if (uniqueDeps.insert(tgt).second) + { + handleSystemIncludesDep(this->Makefile, tgt, config, this->Target, &dagChecker, result, excludeImported); - std::vector deps; - tgt->GetTransitivePropertyLinkLibraries(config, this->Target, deps); + std::vector deps; + tgt->GetTransitivePropertyTargets(config, this->Target, deps); - for(std::vector::const_iterator di = deps.begin(); + for(std::vector::const_iterator di = deps.begin(); di != deps.end(); ++di) { if (uniqueDeps.insert(*di).second) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 5fa9276..faf53c1 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5213,10 +5213,9 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config, } //---------------------------------------------------------------------------- -void cmTarget::GetTransitivePropertyLinkLibraries( - const char* config, +void cmTarget::GetTransitivePropertyTargets(const char* config, cmTarget const* headTarget, - std::vector &libs) const + std::vector &tgts) const { cmTarget::LinkInterface const* iface = this->GetLinkInterface(config, headTarget); @@ -5228,7 +5227,15 @@ void cmTarget::GetTransitivePropertyLinkLibraries( || this->GetPolicyStatusCMP0022() == cmPolicies::WARN || this->GetPolicyStatusCMP0022() == cmPolicies::OLD) { - libs = iface->Libraries; + for(std::vector::const_iterator it = iface->Libraries.begin(); + it != iface->Libraries.end(); ++it) + { + if (cmTarget* tgt = headTarget->GetMakefile() + ->FindTargetToUse(it->c_str())) + { + tgts.push_back(tgt); + } + } return; } @@ -5246,12 +5253,23 @@ void cmTarget::GetTransitivePropertyLinkLibraries( cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(), linkIfaceProp, 0, 0); dagChecker.SetTransitivePropertiesOnly(); + std::vector libs; cmSystemTools::ExpandListArgument(ge.Parse(interfaceLibs)->Evaluate( this->Makefile, config, false, headTarget, this, &dagChecker), libs); + + for(std::vector::const_iterator it = libs.begin(); + it != libs.end(); ++it) + { + if (cmTarget* tgt = headTarget->GetMakefile() + ->FindTargetToUse(it->c_str())) + { + tgts.push_back(tgt); + } + } } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 4d487f7..0d85259 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -264,9 +264,9 @@ public: if the target cannot be linked. */ LinkInterface const* GetLinkInterface(const char* config, cmTarget const* headTarget) const; - void GetTransitivePropertyLinkLibraries(const char* config, + void GetTransitivePropertyTargets(const char* config, cmTarget const* headTarget, - std::vector &libs) const; + std::vector &libs) const; /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ -- cgit v0.12 From 326d07d27ec173d3e67a314010764ebbe7b2aa9c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 13 Feb 2014 11:26:08 +0100 Subject: cmTarget: Extract a ComputeLinkImplementationLanguages method. --- Source/cmTarget.cxx | 6 ++++++ Source/cmTarget.h | 1 + 2 files changed, 7 insertions(+) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index faf53c1..bc57c51 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5537,6 +5537,7 @@ cmTarget::GetLinkImplementation(const char* config, cmTarget const* head) const // Compute the link implementation for this configuration. LinkImplementation impl; this->ComputeLinkImplementation(config, impl, head); + this->ComputeLinkImplementationLanguages(impl); // Store the information for this configuration. cmTargetInternals::LinkImplMapType::value_type entry(key, impl); @@ -5619,7 +5620,12 @@ void cmTarget::ComputeLinkImplementation(const char* config, impl.WrongConfigLibraries.push_back(item); } } +} +//---------------------------------------------------------------------------- +void +cmTarget::ComputeLinkImplementationLanguages(LinkImplementation& impl) const +{ // This target needs runtime libraries for its source languages. std::set languages; // Get languages used in our source files. diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 0d85259..234adba 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -696,6 +696,7 @@ private: void ComputeLinkImplementation(const char* config, LinkImplementation& impl, cmTarget const* head) const; + void ComputeLinkImplementationLanguages(LinkImplementation& impl) const; void ComputeLinkClosure(const char* config, LinkClosure& lc, cmTarget const* head) const; -- cgit v0.12 From 3bcb197c11be54445db3282e9811dc29f2321c70 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 13 Feb 2014 15:11:07 +0100 Subject: cmTarget: Re-arrange the ComputeLinkInterface method. Arrange the logic so that the part which deals with libraries only is at the top. In a follow-up commit, this will be split into two methods. Ensure that the explanatory CMP0022 comment is only present in one location. --- Source/cmTarget.cxx | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index bc57c51..edef7a0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5366,7 +5366,22 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, false, headTarget, this, &dagChecker), iface.Libraries); + } + else if (this->PolicyStatusCMP0022 == cmPolicies::WARN + || this->PolicyStatusCMP0022 == cmPolicies::OLD) + // If CMP0022 is NEW then the plain tll signature sets the + // INTERFACE_LINK_LIBRARIES, so if we get here then the project + // cleared the property explicitly and we should not fall back + // to the link implementation. + { + // The link implementation is the default link interface. + LinkImplementation const* impl = this->GetLinkImplementation(config, + headTarget); + iface.Libraries = impl->Libraries; + } + if(explicitLibraries) + { if(this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::STATIC_LIBRARY || this->GetType() == cmTarget::INTERFACE_LIBRARY) @@ -5415,16 +5430,11 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, } else if (this->PolicyStatusCMP0022 == cmPolicies::WARN || this->PolicyStatusCMP0022 == cmPolicies::OLD) - // If CMP0022 is NEW then the plain tll signature sets the - // INTERFACE_LINK_LIBRARIES, so if we get here then the project - // cleared the property explicitly and we should not fall back - // to the link implementation. { // The link implementation is the default link interface. LinkImplementation const* impl = this->GetLinkImplementation(config, headTarget); iface.ImplementationIsInterface = true; - iface.Libraries = impl->Libraries; iface.WrongConfigLibraries = impl->WrongConfigLibraries; if(this->LinkLanguagePropagatesToDependents()) { -- cgit v0.12 From d93e1af2928cbb06a66ad67d56c3a5cb217f3963 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 13 Feb 2014 11:07:22 +0100 Subject: cmTarget: Extract a ComputeLinkInterfaceLibraries method. When evaluating the SOURCES property, we will need to be able to access the link libraries without accessing the link languages, as the languages depend on the SOURCES. --- Source/cmTarget.cxx | 161 +++++++++++++++++++++++++++++----------------------- Source/cmTarget.h | 10 +++- 2 files changed, 99 insertions(+), 72 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index edef7a0..f203312 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5202,7 +5202,9 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config, { // Compute the link interface for this configuration. cmTargetInternals::OptionalLinkInterface iface; - iface.Exists = this->ComputeLinkInterface(config, iface, head); + const char* explicitLibraries = + this->ComputeLinkInterfaceLibraries(config, iface, head, iface.Exists); + this->ComputeLinkInterface(config, iface, head, explicitLibraries); // Store the information for this configuration. cmTargetInternals::LinkInterfaceMapType::value_type entry(key, iface); @@ -5273,8 +5275,10 @@ void cmTarget::GetTransitivePropertyTargets(const char* config, } //---------------------------------------------------------------------------- -bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, - cmTarget const* headTarget) const +const char* cmTarget::ComputeLinkInterfaceLibraries(const char* config, + LinkInterface& iface, + cmTarget const* headTarget, + bool &exists) const { // Construct the property name suffix for this configuration. std::string suffix = "_"; @@ -5350,8 +5354,10 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, (this->GetType() == cmTarget::EXECUTABLE || (this->GetType() == cmTarget::MODULE_LIBRARY))) { - return false; + exists = false; + return 0; } + exists = true; if(explicitLibraries) { @@ -5378,70 +5384,6 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, LinkImplementation const* impl = this->GetLinkImplementation(config, headTarget); iface.Libraries = impl->Libraries; - } - - if(explicitLibraries) - { - if(this->GetType() == cmTarget::SHARED_LIBRARY - || this->GetType() == cmTarget::STATIC_LIBRARY - || this->GetType() == cmTarget::INTERFACE_LIBRARY) - { - // Shared libraries may have runtime implementation dependencies - // on other shared libraries that are not in the interface. - std::set emitted; - for(std::vector::const_iterator - li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) - { - emitted.insert(*li); - } - if (this->GetType() != cmTarget::INTERFACE_LIBRARY) - { - LinkImplementation const* impl = this->GetLinkImplementation(config, - headTarget); - for(std::vector::const_iterator - li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) - { - if(emitted.insert(*li).second) - { - if(cmTarget* tgt = this->Makefile->FindTargetToUse(*li)) - { - // This is a runtime dependency on another shared library. - if(tgt->GetType() == cmTarget::SHARED_LIBRARY) - { - iface.SharedDeps.push_back(*li); - } - } - else - { - // TODO: Recognize shared library file names. Perhaps this - // should be moved to cmComputeLinkInformation, but that creates - // a chicken-and-egg problem since this list is needed for its - // construction. - } - } - } - if(this->LinkLanguagePropagatesToDependents()) - { - // Targets using this archive need its language runtime libraries. - iface.Languages = impl->Languages; - } - } - } - } - else if (this->PolicyStatusCMP0022 == cmPolicies::WARN - || this->PolicyStatusCMP0022 == cmPolicies::OLD) - { - // The link implementation is the default link interface. - LinkImplementation const* impl = this->GetLinkImplementation(config, - headTarget); - iface.ImplementationIsInterface = true; - iface.WrongConfigLibraries = impl->WrongConfigLibraries; - if(this->LinkLanguagePropagatesToDependents()) - { - // Targets using this archive need its language runtime libraries. - iface.Languages = impl->Languages; - } - if(this->PolicyStatusCMP0022 == cmPolicies::WARN && !this->Internal->PolicyWarnedCMP0022) { @@ -5506,9 +5448,90 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, } } } + return explicitLibraries; +} + +//---------------------------------------------------------------------------- +void cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, + cmTarget const* headTarget, + const char* explicitLibraries) const +{ + if(explicitLibraries) + { + if(this->GetType() == cmTarget::SHARED_LIBRARY + || this->GetType() == cmTarget::STATIC_LIBRARY + || this->GetType() == cmTarget::INTERFACE_LIBRARY) + { + // Shared libraries may have runtime implementation dependencies + // on other shared libraries that are not in the interface. + std::set emitted; + for(std::vector::const_iterator + li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) + { + emitted.insert(*li); + } + if (this->GetType() != cmTarget::INTERFACE_LIBRARY) + { + LinkImplementation const* impl = this->GetLinkImplementation(config, + headTarget); + for(std::vector::const_iterator + li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) + { + if(emitted.insert(*li).second) + { + if(cmTarget* tgt = this->Makefile->FindTargetToUse(*li)) + { + // This is a runtime dependency on another shared library. + if(tgt->GetType() == cmTarget::SHARED_LIBRARY) + { + iface.SharedDeps.push_back(*li); + } + } + else + { + // TODO: Recognize shared library file names. Perhaps this + // should be moved to cmComputeLinkInformation, but that creates + // a chicken-and-egg problem since this list is needed for its + // construction. + } + } + } + if(this->LinkLanguagePropagatesToDependents()) + { + // Targets using this archive need its language runtime libraries. + iface.Languages = impl->Languages; + } + } + } + } + else if (this->PolicyStatusCMP0022 == cmPolicies::WARN + || this->PolicyStatusCMP0022 == cmPolicies::OLD) + { + // The link implementation is the default link interface. + LinkImplementation const* impl = this->GetLinkImplementation(config, + headTarget); + iface.ImplementationIsInterface = true; + iface.WrongConfigLibraries = impl->WrongConfigLibraries; + if(this->LinkLanguagePropagatesToDependents()) + { + // Targets using this archive need its language runtime libraries. + iface.Languages = impl->Languages; + } + } if(this->GetType() == cmTarget::STATIC_LIBRARY) { + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(config && *config) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + // How many repetitions are needed if this library has cyclic // dependencies? std::string propName = "LINK_INTERFACE_MULTIPLICITY"; @@ -5523,8 +5546,6 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, sscanf(reps, "%u", &iface.Multiplicity); } } - - return true; } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 234adba..09c6f74 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -690,8 +690,14 @@ private: void CheckPropertyCompatibility(cmComputeLinkInformation *info, const char* config) const; - bool ComputeLinkInterface(const char* config, LinkInterface& iface, - cmTarget const* head) const; + void ComputeLinkInterface(const char* config, LinkInterface& iface, + cmTarget const* head, + const char *explicitLibraries) const; + + const char* ComputeLinkInterfaceLibraries(const char* config, + LinkInterface& iface, + cmTarget const* head, + bool &exists) const; void ComputeLinkImplementation(const char* config, LinkImplementation& impl, -- cgit v0.12 From 01bca553b83cd8c3a4a4d0348bd317d118a98995 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 13 Feb 2014 16:00:55 +0100 Subject: cmTarget: Move ComputeLinkInterface to the internal class. In a follow-up, this will use the OptionalLinkInterface in its API. That class is in the cmTargetInternals class. --- Source/cmTarget.cxx | 48 ++++++++++++++++++++++++++++-------------------- Source/cmTarget.h | 4 ---- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f203312..0a192e6 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -99,6 +99,11 @@ public: OptionalLinkInterface(): Exists(false) {} bool Exists; }; + void ComputeLinkInterface(cmTarget const* thisTarget, + const char* config, OptionalLinkInterface& iface, + cmTarget const* head, + const char *explicitLibraries) const; + typedef std::map LinkInterfaceMapType; LinkInterfaceMapType LinkInterfaceMap; @@ -5204,7 +5209,8 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config, cmTargetInternals::OptionalLinkInterface iface; const char* explicitLibraries = this->ComputeLinkInterfaceLibraries(config, iface, head, iface.Exists); - this->ComputeLinkInterface(config, iface, head, explicitLibraries); + this->Internal->ComputeLinkInterface(this, config, iface, + head, explicitLibraries); // Store the information for this configuration. cmTargetInternals::LinkInterfaceMapType::value_type entry(key, iface); @@ -5452,15 +5458,17 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const char* config, } //---------------------------------------------------------------------------- -void cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, - cmTarget const* headTarget, - const char* explicitLibraries) const +void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, + const char* config, + OptionalLinkInterface& iface, + cmTarget const* headTarget, + const char* explicitLibraries) const { if(explicitLibraries) { - if(this->GetType() == cmTarget::SHARED_LIBRARY - || this->GetType() == cmTarget::STATIC_LIBRARY - || this->GetType() == cmTarget::INTERFACE_LIBRARY) + if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY + || thisTarget->GetType() == cmTarget::STATIC_LIBRARY + || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY) { // Shared libraries may have runtime implementation dependencies // on other shared libraries that are not in the interface. @@ -5470,16 +5478,16 @@ void cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, { emitted.insert(*li); } - if (this->GetType() != cmTarget::INTERFACE_LIBRARY) + if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) { - LinkImplementation const* impl = this->GetLinkImplementation(config, - headTarget); + cmTarget::LinkImplementation const* impl = + thisTarget->GetLinkImplementation(config, headTarget); for(std::vector::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { if(emitted.insert(*li).second) { - if(cmTarget* tgt = this->Makefile->FindTargetToUse(*li)) + if(cmTarget* tgt = thisTarget->Makefile->FindTargetToUse(*li)) { // This is a runtime dependency on another shared library. if(tgt->GetType() == cmTarget::SHARED_LIBRARY) @@ -5496,7 +5504,7 @@ void cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, } } } - if(this->LinkLanguagePropagatesToDependents()) + if(thisTarget->LinkLanguagePropagatesToDependents()) { // Targets using this archive need its language runtime libraries. iface.Languages = impl->Languages; @@ -5504,22 +5512,22 @@ void cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, } } } - else if (this->PolicyStatusCMP0022 == cmPolicies::WARN - || this->PolicyStatusCMP0022 == cmPolicies::OLD) + else if (thisTarget->PolicyStatusCMP0022 == cmPolicies::WARN + || thisTarget->PolicyStatusCMP0022 == cmPolicies::OLD) { // The link implementation is the default link interface. - LinkImplementation const* impl = this->GetLinkImplementation(config, - headTarget); + cmTarget::LinkImplementation const* + impl = thisTarget->GetLinkImplementation(config, headTarget); iface.ImplementationIsInterface = true; iface.WrongConfigLibraries = impl->WrongConfigLibraries; - if(this->LinkLanguagePropagatesToDependents()) + if(thisTarget->LinkLanguagePropagatesToDependents()) { // Targets using this archive need its language runtime libraries. iface.Languages = impl->Languages; } } - if(this->GetType() == cmTarget::STATIC_LIBRARY) + if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY) { // Construct the property name suffix for this configuration. std::string suffix = "_"; @@ -5536,12 +5544,12 @@ void cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, // dependencies? std::string propName = "LINK_INTERFACE_MULTIPLICITY"; propName += suffix; - if(const char* config_reps = this->GetProperty(propName.c_str())) + if(const char* config_reps = thisTarget->GetProperty(propName.c_str())) { sscanf(config_reps, "%u", &iface.Multiplicity); } else if(const char* reps = - this->GetProperty("LINK_INTERFACE_MULTIPLICITY")) + thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY")) { sscanf(reps, "%u", &iface.Multiplicity); } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 09c6f74..8bc5af4 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -690,10 +690,6 @@ private: void CheckPropertyCompatibility(cmComputeLinkInformation *info, const char* config) const; - void ComputeLinkInterface(const char* config, LinkInterface& iface, - cmTarget const* head, - const char *explicitLibraries) const; - const char* ComputeLinkInterfaceLibraries(const char* config, LinkInterface& iface, cmTarget const* head, -- cgit v0.12 From b8b99cc1e5efa8f1513ceb3025c66f3b28fc5bab Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 13 Feb 2014 15:02:09 +0100 Subject: cmTarget: Avoid computing languages when computing transitive targets. For the OLD CMP0022 behavior, we need to treat the implementation as the interface when computing the interface libraries. Make it possible to do that without computing the link languages by adding a new GetLinkImplementationLibraries method. Extend the existing GetLinkImplementation method to populate the languages if the libraries have already been computed and cached. Change GetTransitivePropertyTargets to invoke GetLinkInterfaceLibraries instead of GetLinkInterface. This is key, as it is a method called by cmGeneratorExpressionEvaluator. Change the cmGeneratorExpressionEvaluator to invoke GetLinkImplementationLibraries instead of GetLinkImplementation. --- Source/cmGeneratorExpressionEvaluator.cxx | 6 +- Source/cmTarget.cxx | 109 +++++++++++++++++++++++++++--- Source/cmTarget.h | 5 ++ 3 files changed, 108 insertions(+), 12 deletions(-) diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index ebedf65..bdefcfb 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -1099,9 +1099,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode else if (std::find_if(transBegin, transEnd, cmStrCmp(interfacePropertyName)) != transEnd) { - const cmTarget::LinkImplementation *impl = target->GetLinkImplementation( - context->Config, - headTarget); + const cmTarget::LinkImplementation *impl + = target->GetLinkImplementationLibraries(context->Config, + headTarget); if(impl) { linkedTargetsContent = diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0a192e6..ea031cd 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -96,8 +96,11 @@ public: // Cache link interface computation from each configuration. struct OptionalLinkInterface: public cmTarget::LinkInterface { - OptionalLinkInterface(): Exists(false) {} + OptionalLinkInterface(): + Exists(false), Complete(false), ExplicitLibraries(0) {} bool Exists; + bool Complete; + const char* ExplicitLibraries; }; void ComputeLinkInterface(cmTarget const* thisTarget, const char* config, OptionalLinkInterface& iface, @@ -5207,17 +5210,70 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config, { // Compute the link interface for this configuration. cmTargetInternals::OptionalLinkInterface iface; - const char* explicitLibraries = + iface.ExplicitLibraries = this->ComputeLinkInterfaceLibraries(config, iface, head, iface.Exists); - this->Internal->ComputeLinkInterface(this, config, iface, - head, explicitLibraries); + if (iface.Exists) + { + this->Internal->ComputeLinkInterface(this, config, iface, + head, iface.ExplicitLibraries); + } + + // Store the information for this configuration. + cmTargetInternals::LinkInterfaceMapType::value_type entry(key, iface); + i = this->Internal->LinkInterfaceMap.insert(entry).first; + } + else if(!i->second.Complete && i->second.Exists) + { + this->Internal->ComputeLinkInterface(this, config, i->second, head, + i->second.ExplicitLibraries); + } + + return i->second.Exists ? &i->second : 0; +} + +//---------------------------------------------------------------------------- +cmTarget::LinkInterface const* +cmTarget::GetLinkInterfaceLibraries(const char* config, + cmTarget const* head) const +{ + // Imported targets have their own link interface. + if(this->IsImported()) + { + if(cmTarget::ImportInfo const* info = this->GetImportInfo(config, head)) + { + return &info->LinkInterface; + } + return 0; + } + + // Link interfaces are not supported for executables that do not + // export symbols. + if(this->GetType() == cmTarget::EXECUTABLE && + !this->IsExecutableWithExports()) + { + return 0; + } + + // Lookup any existing link interface for this configuration. + TargetConfigPair key(head, cmSystemTools::UpperCase(config? config : "")); + + cmTargetInternals::LinkInterfaceMapType::iterator + i = this->Internal->LinkInterfaceMap.find(key); + if(i == this->Internal->LinkInterfaceMap.end()) + { + // Compute the link interface for this configuration. + cmTargetInternals::OptionalLinkInterface iface; + iface.ExplicitLibraries = this->ComputeLinkInterfaceLibraries(config, + iface, + head, + iface.Exists); // Store the information for this configuration. cmTargetInternals::LinkInterfaceMapType::value_type entry(key, iface); i = this->Internal->LinkInterfaceMap.insert(entry).first; } - return i->second.Exists? &i->second : 0; + return i->second.Exists ? &i->second : 0; } //---------------------------------------------------------------------------- @@ -5225,8 +5281,8 @@ void cmTarget::GetTransitivePropertyTargets(const char* config, cmTarget const* headTarget, std::vector &tgts) const { - cmTarget::LinkInterface const* iface = this->GetLinkInterface(config, - headTarget); + cmTarget::LinkInterface const* iface + = this->GetLinkInterfaceLibraries(config, headTarget); if (!iface) { return; @@ -5387,8 +5443,8 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const char* config, // to the link implementation. { // The link implementation is the default link interface. - LinkImplementation const* impl = this->GetLinkImplementation(config, - headTarget); + LinkImplementation const* impl = + this->GetLinkImplementationLibraries(config, headTarget); iface.Libraries = impl->Libraries; if(this->PolicyStatusCMP0022 == cmPolicies::WARN && !this->Internal->PolicyWarnedCMP0022) @@ -5554,6 +5610,7 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, sscanf(reps, "%u", &iface.Multiplicity); } } + iface.Complete = true; } //---------------------------------------------------------------------------- @@ -5582,6 +5639,40 @@ cmTarget::GetLinkImplementation(const char* config, cmTarget const* head) const cmTargetInternals::LinkImplMapType::value_type entry(key, impl); i = this->Internal->LinkImplMap.insert(entry).first; } + else if (i->second.Languages.empty()) + { + this->ComputeLinkImplementationLanguages(i->second); + } + + return &i->second; +} + +//---------------------------------------------------------------------------- +cmTarget::LinkImplementation const* +cmTarget::GetLinkImplementationLibraries(const char* config, + cmTarget const* head) const +{ + // There is no link implementation for imported targets. + if(this->IsImported()) + { + return 0; + } + + // Lookup any existing link implementation for this configuration. + TargetConfigPair key(head, cmSystemTools::UpperCase(config? config : "")); + + cmTargetInternals::LinkImplMapType::iterator + i = this->Internal->LinkImplMap.find(key); + if(i == this->Internal->LinkImplMap.end()) + { + // Compute the link implementation for this configuration. + LinkImplementation impl; + this->ComputeLinkImplementation(config, impl, head); + + // Store the information for this configuration. + cmTargetInternals::LinkImplMapType::value_type entry(key, impl); + i = this->Internal->LinkImplMap.insert(entry).first; + } return &i->second; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8bc5af4..f3cd874 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -264,6 +264,8 @@ public: if the target cannot be linked. */ LinkInterface const* GetLinkInterface(const char* config, cmTarget const* headTarget) const; + LinkInterface const* GetLinkInterfaceLibraries(const char* config, + cmTarget const* headTarget) const; void GetTransitivePropertyTargets(const char* config, cmTarget const* headTarget, std::vector &libs) const; @@ -285,6 +287,9 @@ public: LinkImplementation const* GetLinkImplementation(const char* config, cmTarget const* head) const; + LinkImplementation const* GetLinkImplementationLibraries(const char* config, + cmTarget const* head) const; + /** Link information from the transitive closure of the link implementation and the interfaces of its dependencies. */ struct LinkClosure -- cgit v0.12 From a6dd4990dbfa1afadbaeea33250e52affa5e00d9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 12 Feb 2014 13:48:47 +0100 Subject: cmTarget: Create a temporary cmTarget in checkInterfacePropertyCompatibility This simplifies further refactoring. --- Source/cmTarget.cxx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ea031cd..eca8bb7 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4459,23 +4459,24 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, // target itself has a POSITION_INDEPENDENT_CODE which disagrees // with a dependency. - if (!li->Target) + cmTarget const* theTarget = li->Target; + if (!theTarget) { continue; } - const bool ifaceIsSet = li->Target->GetProperties() + const bool ifaceIsSet = theTarget->GetProperties() .find("INTERFACE_" + p) - != li->Target->GetProperties().end(); + != theTarget->GetProperties().end(); PropertyType ifacePropContent = - getTypedProperty(li->Target, + getTypedProperty(theTarget, ("INTERFACE_" + p).c_str(), 0); std::string reportEntry; if (ifaceIsSet) { reportEntry += " * Target \""; - reportEntry += li->Target->GetName(); + reportEntry += theTarget->GetName(); reportEntry += "\" property value \""; reportEntry += valueAsString(ifacePropContent); reportEntry += "\" "; @@ -4496,7 +4497,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, e << "Property " << p << " on target \"" << tgt->GetName() << "\" does\nnot match the " "INTERFACE_" << p << " property requirement\nof " - "dependency \"" << li->Target->GetName() << "\".\n"; + "dependency \"" << theTarget->GetName() << "\".\n"; cmSystemTools::Error(e.str().c_str()); break; } @@ -4530,7 +4531,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, << tgt->GetName() << "\" is\nimplied to be " << defaultValue << " because it was used to determine the link libraries\n" "already. The INTERFACE_" << p << " property on\ndependency \"" - << li->Target->GetName() << "\" is in conflict.\n"; + << theTarget->GetName() << "\" is in conflict.\n"; cmSystemTools::Error(e.str().c_str()); break; } @@ -4561,7 +4562,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, { cmOStringStream e; e << "The INTERFACE_" << p << " property of \"" - << li->Target->GetName() << "\" does\nnot agree with the value " + << theTarget->GetName() << "\" does\nnot agree with the value " "of " << p << " already determined\nfor \"" << tgt->GetName() << "\".\n"; cmSystemTools::Error(e.str().c_str()); -- cgit v0.12 From 5771f81d91d232a143345dc05835323f36ab7ecc Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 13 Feb 2014 18:27:31 +0100 Subject: cmTarget: Add GetTransitiveTargetClosure method. Replace calls to GetLinkInformation with calls to a method to get only the target closure, not the link languages etc. The replaced calls are used while evaluating generator expressions only. This makes transitive generator expression evaluation independent from the languages of a target. In a follow-up topic, it will be possible to make the languages depend on generator expression evaluation, via evaluation of the SOURCES and INTERFACE_SOURCES target properties. Because the order of entries is not the same as the final link line, the order of debug output is different in the RunCMake.CompatibleInterface test, because the BOOL_PROP7 target property is evaluated first. Adjust the test to account for that new order. --- Source/cmTarget.cxx | 76 ++++++++++++++++------ Source/cmTarget.h | 3 + .../CompatibleInterface/DebugProperties-stderr.txt | 14 ++-- 3 files changed, 67 insertions(+), 26 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index eca8bb7..7df2928 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4424,12 +4424,13 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet)); - cmComputeLinkInformation *info = tgt->GetLinkInformation(config); - if(!info) + std::vector deps; + tgt->GetTransitiveTargetClosure(config, tgt, deps); + + if(deps.empty()) { return propContent; } - const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); bool propInitialized = explicitlySet; std::string report = " * Target \""; @@ -4449,7 +4450,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, report += "\" property not set.\n"; } - for(cmComputeLinkInformation::ItemVector::const_iterator li = + for(std::vector::const_iterator li = deps.begin(); li != deps.end(); ++li) { @@ -4459,11 +4460,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, // target itself has a POSITION_INDEPENDENT_CODE which disagrees // with a dependency. - cmTarget const* theTarget = li->Target; - if (!theTarget) - { - continue; - } + cmTarget const* theTarget = *li; const bool ifaceIsSet = theTarget->GetProperties() .find("INTERFACE_" + p) @@ -4643,23 +4640,19 @@ bool isLinkDependentProperty(cmTarget const* tgt, const std::string &p, const char *interfaceProperty, const char *config) { - cmComputeLinkInformation *info = tgt->GetLinkInformation(config); - if(!info) + std::vector deps; + tgt->GetTransitiveTargetClosure(config, tgt, deps); + + if(deps.empty()) { return false; } - const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); - - for(cmComputeLinkInformation::ItemVector::const_iterator li = + for(std::vector::const_iterator li = deps.begin(); li != deps.end(); ++li) { - if (!li->Target) - { - continue; - } - const char *prop = li->Target->GetProperty(interfaceProperty); + const char *prop = (*li)->GetProperty(interfaceProperty); if (!prop) { continue; @@ -5278,6 +5271,51 @@ cmTarget::GetLinkInterfaceLibraries(const char* config, } //---------------------------------------------------------------------------- +void processILibs(const char* config, + cmTarget const* headTarget, + std::string const& name, + std::vector& tgts, std::set& emitted) +{ + if (cmTarget* tgt = headTarget->GetMakefile() + ->FindTargetToUse(name.c_str())) + { + if (emitted.insert(tgt).second) + { + tgts.push_back(tgt); + std::vector ilibs; + cmTarget::LinkInterface const* iface = + tgt->GetLinkInterfaceLibraries(config, headTarget); + if (iface) + { + for(std::vector::const_iterator + it = iface->Libraries.begin(); + it != iface->Libraries.end(); ++it) + { + processILibs(config, headTarget, *it, tgts, emitted); + } + } + } + } +} + +//---------------------------------------------------------------------------- +void cmTarget::GetTransitiveTargetClosure(const char* config, + cmTarget const* headTarget, + std::vector &tgts) const +{ + std::set emitted; + + cmTarget::LinkImplementation const* impl + = this->GetLinkImplementationLibraries(config, headTarget); + + for(std::vector::const_iterator it = impl->Libraries.begin(); + it != impl->Libraries.end(); ++it) + { + processILibs(config, headTarget, *it, tgts, emitted); + } +} + +//---------------------------------------------------------------------------- void cmTarget::GetTransitivePropertyTargets(const char* config, cmTarget const* headTarget, std::vector &tgts) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f3cd874..5dec9e2 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -269,6 +269,9 @@ public: void GetTransitivePropertyTargets(const char* config, cmTarget const* headTarget, std::vector &libs) const; + void GetTransitiveTargetClosure(const char* config, + cmTarget const* headTarget, + std::vector &libs) const; /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ diff --git a/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt b/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt index 17b8a5c..82a34d5 100644 --- a/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt +++ b/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt @@ -1,4 +1,11 @@ CMake Debug Log: + Boolean compatibility of property "BOOL_PROP7" for target + "CompatibleInterface" \(result: "FALSE"\): + + \* Target "CompatibleInterface" property is implied by use. + \* Target "iface1" property value "FALSE" \(Agree\) ++ +CMake Debug Log: Boolean compatibility of property "BOOL_PROP1" for target "CompatibleInterface" \(result: "TRUE"\): @@ -40,13 +47,6 @@ CMake Debug Log: \* Target "iface2" property value "FALSE" \(Agree\) + CMake Debug Log: - Boolean compatibility of property "BOOL_PROP7" for target - "CompatibleInterface" \(result: "FALSE"\): - - \* Target "CompatibleInterface" property is implied by use. - \* Target "iface1" property value "FALSE" \(Agree\) -+ -CMake Debug Log: String compatibility of property "STRING_PROP1" for target "CompatibleInterface" \(result: "prop1"\): -- cgit v0.12 From d3682d8647789db759270a2f9c96493167468e61 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 14 Feb 2014 10:23:23 +0100 Subject: cmGeneratorTarget: Use a method to access the definition file. --- Source/cmGeneratorTarget.cxx | 6 ++++++ Source/cmGeneratorTarget.h | 3 ++- Source/cmMakefileTargetGenerator.cxx | 11 ++++++----- Source/cmNinjaTargetGenerator.cxx | 6 +++--- Source/cmVisualStudio10TargetGenerator.cxx | 6 +++--- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6223ed1..e2810ac 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -431,6 +431,12 @@ void cmGeneratorTarget::LookupObjectLibraries() } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetModuleDefinitionFile() const +{ + return this->ModuleDefinitionFile; +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::UseObjectLibraries(std::vector& objs) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9a3339d..51d51f3 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -52,7 +52,7 @@ public: cmLocalGenerator* LocalGenerator; cmGlobalGenerator const* GlobalGenerator; - std::string ModuleDefinitionFile; + std::string GetModuleDefinitionFile() const; /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build @@ -118,6 +118,7 @@ private: struct SourceEntry { std::vector Depends; }; typedef std::map SourceEntriesType; SourceEntriesType SourceEntries; + std::string ModuleDefinitionFile; std::vector CustomCommands; std::vector ExtraSources; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index c3ca85d..5a841ed 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1650,9 +1650,10 @@ void cmMakefileTargetGenerator this->AppendTargetDepends(depends); // Add a dependency on the link definitions file, if any. - if(!this->GeneratorTarget->ModuleDefinitionFile.empty()) + std::string def = this->GeneratorTarget->GetModuleDefinitionFile(); + if(!def.empty()) { - depends.push_back(this->GeneratorTarget->ModuleDefinitionFile); + depends.push_back(def); } // Add user-specified dependencies. @@ -2019,7 +2020,8 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags) //---------------------------------------------------------------------------- void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags) { - if(this->GeneratorTarget->ModuleDefinitionFile.empty()) + std::string def = this->GeneratorTarget->GetModuleDefinitionFile(); + if(def.empty()) { return; } @@ -2035,8 +2037,7 @@ void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags) // Append the flag and value. Use ConvertToLinkReference to help // vs6's "cl -link" pass it to the linker. std::string flag = defFileFlag; - flag += (this->LocalGenerator->ConvertToLinkReference( - this->GeneratorTarget->ModuleDefinitionFile.c_str())); + flag += (this->LocalGenerator->ConvertToLinkReference(def.c_str())); this->LocalGenerator->AppendFlags(flags, flag.c_str()); } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 900af8d..5f6fc2d 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -498,10 +498,10 @@ cmNinjaTargetGenerator { this->WriteObjectBuildStatement(*si); } - if(!this->GeneratorTarget->ModuleDefinitionFile.empty()) + std::string def = this->GeneratorTarget->GetModuleDefinitionFile(); + if(!def.empty()) { - this->ModuleDefinitionFile = this->ConvertToNinjaPath( - this->GeneratorTarget->ModuleDefinitionFile.c_str()); + this->ModuleDefinitionFile = this->ConvertToNinjaPath(def.c_str()); } { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ed7e243..d760b3f 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1666,10 +1666,10 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) linkOptions.AddFlag("ImportLibrary", imLib.c_str()); linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str()); linkOptions.Parse(flags.c_str()); - if(!this->GeneratorTarget->ModuleDefinitionFile.empty()) + std::string def = this->GeneratorTarget->GetModuleDefinitionFile(); + if(!def.empty()) { - linkOptions.AddFlag("ModuleDefinitionFile", - this->GeneratorTarget->ModuleDefinitionFile.c_str()); + linkOptions.AddFlag("ModuleDefinitionFile", def.c_str()); } this->LinkOptions[config] = pOptions.release(); -- cgit v0.12 From 64d398416ad678c1c57fbd3a7981623e28d69bca Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 13 Feb 2014 21:07:31 +0100 Subject: cmGeneratorTarget: Classify sources on demand, not up front. Implement a Visitor to hold the sequence of source file tests for populating outputs. Use VS 6 and 7 workaround from Brad King for lack of partial template specialization and function template specialization capabilities. This will make it possible to use context dependent generator expressions to determine the sources of a target. --- Source/cmGeneratorTarget.cxx | 349 +++++++++++++++++++++++++++++-------------- Source/cmGeneratorTarget.h | 17 +-- Source/cmGlobalGenerator.cxx | 1 - 3 files changed, 241 insertions(+), 126 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e2810ac..4cb1904 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -25,6 +25,194 @@ #include "assert.h" //---------------------------------------------------------------------------- +void reportBadObjLib(std::vector const& badObjLib, + cmTarget *target, cmake *cm) +{ + if(!badObjLib.empty()) + { + cmOStringStream e; + e << "OBJECT library \"" << target->GetName() << "\" contains:\n"; + for(std::vector::const_iterator i = badObjLib.begin(); + i != badObjLib.end(); ++i) + { + e << " " << (*i)->GetLocation().GetName() << "\n"; + } + e << "but may contain only headers and sources that compile."; + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + target->GetBacktrace()); + } +} + +struct ObjectSourcesTag {}; +struct CustomCommandsTag {}; +struct ExtraSourcesTag {}; +struct HeaderSourcesTag {}; +struct ExternalObjectsTag {}; +struct IDLSourcesTag {}; +struct ResxTag {}; +struct ModuleDefinitionFileTag {}; + +#if !defined(_MSC_VER) || _MSC_VER >= 1310 +template +struct IsSameTag +{ + enum { + Result = false + }; +}; + +template +struct IsSameTag +{ + enum { + Result = true + }; +}; +#else +struct IsSameTagBase +{ + typedef char (&no_type)[1]; + typedef char (&yes_type)[2]; + template struct Check; + template static yes_type check(Check*, Check*); + static no_type check(...); +}; +template +struct IsSameTag: public IsSameTagBase +{ + enum { + Result = (sizeof(check(static_cast< Check* >(0), + static_cast< Check* >(0))) == + sizeof(yes_type)) + }; +}; +#endif + +template +struct DoAccept +{ + template static void Do(T&, cmSourceFile*) {} +}; + +template<> +struct DoAccept +{ + static void Do(std::vector& files, cmSourceFile* f) + { + files.push_back(f); + } + static void Do(cmGeneratorTarget::ResxData& data, cmSourceFile* f) + { + // Build and save the name of the corresponding .h file + // This relationship will be used later when building the project files. + // Both names would have been auto generated from Visual Studio + // where the user supplied the file name and Visual Studio + // appended the suffix. + std::string resx = f->GetFullPath(); + std::string hFileName = resx.substr(0, resx.find_last_of(".")) + ".h"; + data.ExpectedResxHeaders.insert(hFileName); + data.ResxSources.push_back(f); + } + static void Do(std::string& data, cmSourceFile* f) + { + data = f->GetFullPath(); + } +}; + +//---------------------------------------------------------------------------- +template > +struct TagVisitor +{ + DataType& Data; + std::vector BadObjLibFiles; + cmTarget *Target; + cmGlobalGenerator *GlobalGenerator; + cmsys::RegularExpression Header; + bool IsObjLib; + + TagVisitor(cmTarget *target, DataType& data) + : Data(data), Target(target), + GlobalGenerator(target->GetMakefile() + ->GetLocalGenerator()->GetGlobalGenerator()), + Header(CM_HEADER_REGEX), + IsObjLib(target->GetType() == cmTarget::OBJECT_LIBRARY) + { + } + + ~TagVisitor() + { + reportBadObjLib(this->BadObjLibFiles, this->Target, + this->GlobalGenerator->GetCMakeInstance()); + } + + void Accept(cmSourceFile *sf) + { + std::string ext = cmSystemTools::LowerCase(sf->GetExtension()); + if(sf->GetCustomCommand()) + { + DoAccept::Result>::Do(this->Data, sf); + } + else if(this->Target->GetType() == cmTarget::UTILITY) + { + DoAccept::Result>::Do(this->Data, sf); + } + else if(sf->GetPropertyAsBool("HEADER_FILE_ONLY")) + { + DoAccept::Result>::Do(this->Data, sf); + } + else if(sf->GetPropertyAsBool("EXTERNAL_OBJECT")) + { + DoAccept::Result>::Do(this->Data, sf); + if(this->IsObjLib) + { + this->BadObjLibFiles.push_back(sf); + } + } + else if(sf->GetLanguage()) + { + DoAccept::Result>::Do(this->Data, sf); + } + else if(ext == "def") + { + DoAccept::Result>::Do(this->Data, + sf); + if(this->IsObjLib) + { + this->BadObjLibFiles.push_back(sf); + } + } + else if(ext == "idl") + { + DoAccept::Result>::Do(this->Data, sf); + if(this->IsObjLib) + { + this->BadObjLibFiles.push_back(sf); + } + } + else if(ext == "resx") + { + DoAccept::Result>::Do(this->Data, sf); + } + else if(this->Header.find(sf->GetFullPath().c_str())) + { + DoAccept::Result>::Do(this->Data, sf); + } + else if(this->GlobalGenerator->IgnoreFile(sf->GetExtension().c_str())) + { + DoAccept::Result>::Do(this->Data, sf); + } + else + { + DoAccept::Result>::Do(this->Data, sf); + if(this->IsObjLib && ext != "txt") + { + this->BadObjLibFiles.push_back(sf); + } + } + } +}; + +//---------------------------------------------------------------------------- cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t), SourceFileFlagsConstructed(false) { @@ -96,11 +284,34 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt, } } +#define IMPLEMENT_VISIT_IMPL(DATA, DATATYPE) \ + { \ + std::vector sourceFiles; \ + this->Target->GetSourceFiles(sourceFiles); \ + TagVisitor visitor(this->Target, data); \ + for(std::vector::const_iterator si = sourceFiles.begin(); \ + si != sourceFiles.end(); ++si) \ + { \ + visitor.Accept(*si); \ + } \ + } \ + + +#define IMPLEMENT_VISIT(DATA) \ + IMPLEMENT_VISIT_IMPL(DATA, EMPTY) \ + +#define EMPTY +#define COMMA , + //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetObjectSources(std::vector &objs) const +cmGeneratorTarget::GetObjectSources(std::vector &data) const { - objs = this->ObjectSources; + IMPLEMENT_VISIT(ObjectSources); + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY) + { + this->ObjectSources = data; + } } //---------------------------------------------------------------------------- @@ -129,49 +340,53 @@ bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetResxSources(std::vector& srcs) const +void cmGeneratorTarget::GetIDLSources(std::vector& data) const { - srcs = this->ResxSources; + IMPLEMENT_VISIT(IDLSources); } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetIDLSources(std::vector& srcs) const +void +cmGeneratorTarget::GetHeaderSources(std::vector& data) const { - srcs = this->IDLSources; + IMPLEMENT_VISIT(HeaderSources); } //---------------------------------------------------------------------------- -void -cmGeneratorTarget::GetHeaderSources(std::vector& srcs) const +void cmGeneratorTarget::GetExtraSources(std::vector& data) const { - srcs = this->HeaderSources; + IMPLEMENT_VISIT(ExtraSources); } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetExtraSources(std::vector& srcs) const +void +cmGeneratorTarget::GetCustomCommands(std::vector& data) const { - srcs = this->ExtraSources; + IMPLEMENT_VISIT(CustomCommands); } //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetCustomCommands(std::vector& srcs) const +cmGeneratorTarget::GetExternalObjects(std::vector& data) const { - srcs = this->CustomCommands; + IMPLEMENT_VISIT(ExternalObjects); } //---------------------------------------------------------------------------- void cmGeneratorTarget::GetExpectedResxHeaders(std::set& srcs) const { - srcs = this->ExpectedResxHeaders; + ResxData data; + IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData) + srcs = data.ExpectedResxHeaders; } //---------------------------------------------------------------------------- -void -cmGeneratorTarget::GetExternalObjects(std::vector& srcs) const +void cmGeneratorTarget::GetResxSources(std::vector& srcs) const { - srcs = this->ExternalObjects; + ResxData data; + IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData) + srcs = data.ResxSources; } //---------------------------------------------------------------------------- @@ -283,102 +498,6 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files) const } //---------------------------------------------------------------------------- -void cmGeneratorTarget::ClassifySources() -{ - cmsys::RegularExpression header(CM_HEADER_REGEX); - - cmTarget::TargetType targetType = this->Target->GetType(); - bool isObjLib = targetType == cmTarget::OBJECT_LIBRARY; - - std::vector badObjLib; - std::vector sources; - this->Target->GetSourceFiles(sources); - for(std::vector::const_iterator si = sources.begin(); - si != sources.end(); ++si) - { - cmSourceFile* sf = *si; - std::string ext = cmSystemTools::LowerCase(sf->GetExtension()); - if(sf->GetCustomCommand()) - { - this->CustomCommands.push_back(sf); - } - else if(targetType == cmTarget::UTILITY) - { - this->ExtraSources.push_back(sf); - } - else if(sf->GetPropertyAsBool("HEADER_FILE_ONLY")) - { - this->HeaderSources.push_back(sf); - } - else if(sf->GetPropertyAsBool("EXTERNAL_OBJECT")) - { - this->ExternalObjects.push_back(sf); - if(isObjLib) { badObjLib.push_back(sf); } - } - else if(sf->GetLanguage()) - { - this->ObjectSources.push_back(sf); - } - else if(ext == "def") - { - this->ModuleDefinitionFile = sf->GetFullPath(); - if(isObjLib) { badObjLib.push_back(sf); } - } - else if(ext == "idl") - { - this->IDLSources.push_back(sf); - if(isObjLib) { badObjLib.push_back(sf); } - } - else if(ext == "resx") - { - // Build and save the name of the corresponding .h file - // This relationship will be used later when building the project files. - // Both names would have been auto generated from Visual Studio - // where the user supplied the file name and Visual Studio - // appended the suffix. - std::string resx = sf->GetFullPath(); - std::string hFileName = resx.substr(0, resx.find_last_of(".")) + ".h"; - this->ExpectedResxHeaders.insert(hFileName); - this->ResxSources.push_back(sf); - } - else if(header.find(sf->GetFullPath().c_str())) - { - this->HeaderSources.push_back(sf); - } - else if(this->GlobalGenerator->IgnoreFile(sf->GetExtension().c_str())) - { - // We only get here if a source file is not an external object - // and has an extension that is listed as an ignored file type. - // No message or diagnosis should be given. - this->ExtraSources.push_back(sf); - } - else - { - this->ExtraSources.push_back(sf); - if(isObjLib && ext != "txt") - { - badObjLib.push_back(sf); - } - } - } - - if(!badObjLib.empty()) - { - cmOStringStream e; - e << "OBJECT library \"" << this->Target->GetName() << "\" contains:\n"; - for(std::vector::iterator i = badObjLib.begin(); - i != badObjLib.end(); ++i) - { - e << " " << (*i)->GetLocation().GetName() << "\n"; - } - e << "but may contain only headers and sources that compile."; - this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); - } -} - -//---------------------------------------------------------------------------- void cmGeneratorTarget::LookupObjectLibraries() { std::vector const& objLibs = @@ -433,7 +552,9 @@ void cmGeneratorTarget::LookupObjectLibraries() //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile() const { - return this->ModuleDefinitionFile; + std::string data; + IMPLEMENT_VISIT_IMPL(ModuleDefinitionFile, COMMA std::string) + return data; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 51d51f3..1e6ce64 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -82,7 +82,6 @@ public: */ void TraceDependencies(); - void ClassifySources(); void LookupObjectLibraries(); /** Get sources that must be built before the given source. */ @@ -113,23 +112,19 @@ public: struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; + struct ResxData { + mutable std::set ExpectedResxHeaders; + mutable std::vector ResxSources; + }; private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; typedef std::map SourceEntriesType; SourceEntriesType SourceEntries; - std::string ModuleDefinitionFile; - - std::vector CustomCommands; - std::vector ExtraSources; - std::vector HeaderSources; - std::vector ExternalObjects; - std::vector IDLSources; - std::vector ResxSources; + std::map Objects; std::set ExplicitObjectName; - std::set ExpectedResxHeaders; - std::vector ObjectSources; + mutable std::vector ObjectSources; std::vector ObjectLibraries; mutable std::map > SystemIncludesCache; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index e143eba..f76c6d1 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1439,7 +1439,6 @@ void cmGlobalGenerator::ComputeGeneratorTargetObjects() continue; } cmGeneratorTarget* gt = ti->second; - gt->ClassifySources(); gt->LookupObjectLibraries(); this->ComputeTargetObjects(gt); } -- cgit v0.12 From f9d5b1fd0fe1e1c5a0083c6518c7da6c36776042 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 14 Feb 2014 12:24:13 +0100 Subject: Handle Mac OSX source flags for individual files lazily. The actual list of files will become config dependent in a follow-up commit. --- Source/cmGeneratorTarget.cxx | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4cb1904..a7b2fb6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1009,6 +1009,23 @@ cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const { flags = si->second; } + else + { + // Handle the MACOSX_PACKAGE_LOCATION property on source files that + // were not listed in one of the other lists. + if(const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION")) + { + flags.MacFolder = location; + if(strcmp(location, "Resources") == 0) + { + flags.Type = cmGeneratorTarget::SourceFileTypeResource; + } + else + { + flags.Type = cmGeneratorTarget::SourceFileTypeMacContent; + } + } + } return flags; } @@ -1072,30 +1089,4 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const } } } - - // Handle the MACOSX_PACKAGE_LOCATION property on source files that - // were not listed in one of the other lists. - std::vector sources; - this->GetSourceFiles(sources); - for(std::vector::const_iterator si = sources.begin(); - si != sources.end(); ++si) - { - cmSourceFile* sf = *si; - if(const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION")) - { - SourceFileFlags& flags = this->SourceFlagsMap[sf]; - if(flags.Type == cmGeneratorTarget::SourceFileTypeNormal) - { - flags.MacFolder = location; - if(strcmp(location, "Resources") == 0) - { - flags.Type = cmGeneratorTarget::SourceFileTypeResource; - } - else - { - flags.Type = cmGeneratorTarget::SourceFileTypeMacContent; - } - } - } - } } -- cgit v0.12 From b4aac0caca76c7d2041556785799b5ea1bbf1ce7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 21 Feb 2014 09:25:30 -0500 Subject: Makefile: Fix per-config linker PDB output directory Also, now that all call sites of cmTarget::GetPDBName and cmTarget::GetPDBDirectory pass the configuration, make the argument non-optional. --- Source/cmMakefileExecutableTargetGenerator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 2 +- Source/cmTarget.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 69b8092..664d73e 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -129,7 +129,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } } - std::string pdbOutputPath = this->Target->GetPDBDirectory(); + std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(pdbOutputPath.c_str()); pdbOutputPath += "/"; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index d6a0cd4..b9af638 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -321,7 +321,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } } - std::string pdbOutputPath = this->Target->GetPDBDirectory(); + std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(pdbOutputPath.c_str()); pdbOutputPath += "/"; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 271824b..599e85d 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -340,7 +340,7 @@ public: If the configuration name is given then the generator will add its subdirectory for that configuration. Otherwise just the canonical pdb output directory is given. */ - std::string GetPDBDirectory(const char* config = 0) const; + std::string GetPDBDirectory(const char* config) const; /** Get the location of the target in the build tree for the given configuration. This location is suitable for use as the LOCATION @@ -375,7 +375,7 @@ public: const char* config=0, bool implib = false) const; /** Get the name of the pdb file for the target. */ - std::string GetPDBName(const char* config=0) const; + std::string GetPDBName(const char* config) const; /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const char* config) const; -- cgit v0.12 From aae5184c169b037c027d4ede5ba42c37395ba7b4 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 24 Feb 2014 11:45:49 -0500 Subject: Help: Refactor PDB_NAME and PDB_OUTPUT_DIRECTORY docs Move the note about VS 6 into the PDB_NOTE.txt common include file and include it from the per-config properties too. Also re-word the note to clarify the separate compiler and linker flags involved and state explicitly that compiler flags are not affected. --- Help/prop_tgt/PDB_NAME.rst | 3 --- Help/prop_tgt/PDB_NAME_CONFIG.rst | 3 +-- Help/prop_tgt/PDB_NOTE.txt | 10 +++++++--- Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst | 3 --- Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst | 3 +-- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Help/prop_tgt/PDB_NAME.rst b/Help/prop_tgt/PDB_NAME.rst index e8fc3be..333c865 100644 --- a/Help/prop_tgt/PDB_NAME.rst +++ b/Help/prop_tgt/PDB_NAME.rst @@ -8,6 +8,3 @@ This property specifies the base name for the debug symbols file. If not set, the logical target name is used by default. .. include:: PDB_NOTE.txt - -This property is not implemented by the :generator:`Visual Studio 6` -generator. diff --git a/Help/prop_tgt/PDB_NAME_CONFIG.rst b/Help/prop_tgt/PDB_NAME_CONFIG.rst index c846b57..7bf9e43 100644 --- a/Help/prop_tgt/PDB_NAME_CONFIG.rst +++ b/Help/prop_tgt/PDB_NAME_CONFIG.rst @@ -6,5 +6,4 @@ generated by the linker for an executable or shared library target. This is the configuration-specific version of :prop_tgt:`PDB_NAME`. -This property is not implemented by the :generator:`Visual Studio 6` -generator. +.. include:: PDB_NOTE.txt diff --git a/Help/prop_tgt/PDB_NOTE.txt b/Help/prop_tgt/PDB_NOTE.txt index e55aba2..c03bd3a 100644 --- a/Help/prop_tgt/PDB_NOTE.txt +++ b/Help/prop_tgt/PDB_NOTE.txt @@ -3,6 +3,10 @@ is invoked to produce them so they have no linker-generated ``.pdb`` file containing debug symbols. - The compiler-generated program database files specified by the MSVC - ``/Fd`` flag are not the same as linker-generated program database - files and so are not influenced by this property. + The linker-generated program database files are specified by the + ``/pdb`` linker flag and are not the same as compiler-generated + program database files specified by the ``/Fd`` compiler flag. + This property does not influence the latter. + + This property is not implemented by the :generator:`Visual Studio 6` + generator. diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst index 9a863a1..4877368 100644 --- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst +++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst @@ -10,6 +10,3 @@ value of the :variable:`CMAKE_PDB_OUTPUT_DIRECTORY` variable if it is set when a target is created. .. include:: PDB_NOTE.txt - -This property is not implemented by the :generator:`Visual Studio 6` -generator. diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst index caec2de..7bbc237 100644 --- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst @@ -11,5 +11,4 @@ property is initialized by the value of the :variable:`CMAKE_PDB_OUTPUT_DIRECTORY_` variable if it is set when a target is created. -This property is not implemented by the :generator:`Visual Studio 6` -generator. +.. include:: PDB_NOTE.txt -- cgit v0.12 From 718a9532c6bfa8c68864dd5dadba9f55e0f1bcf3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 24 Feb 2014 14:09:05 -0500 Subject: cmTarget: Refactor ComputePDBOutputDir interface Add a runtime parameter to specify the property name prefix. Update the call site to pass "PDB" to preserve the existing name for that call path. --- Source/cmTarget.cxx | 10 +++++----- Source/cmTarget.h | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index db34bd8..cf09269 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2467,7 +2467,7 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const OutputInfo info; this->ComputeOutputDir(config, false, info.OutDir); this->ComputeOutputDir(config, true, info.ImpDir); - if(!this->ComputePDBOutputDir(config, info.PdbDir)) + if(!this->ComputePDBOutputDir("PDB", config, info.PdbDir)) { info.PdbDir = info.OutDir; } @@ -4111,13 +4111,13 @@ bool cmTarget::ComputeOutputDir(const char* config, } //---------------------------------------------------------------------------- -bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) const +bool cmTarget::ComputePDBOutputDir(const char* kind, const char* config, + std::string& out) const { // Look for a target property defining the target output directory // based on the target type. - std::string targetTypeName = "PDB"; const char* propertyName = 0; - std::string propertyNameStr = targetTypeName; + std::string propertyNameStr = kind; if(!propertyNameStr.empty()) { propertyNameStr += "_OUTPUT_DIRECTORY"; @@ -4127,7 +4127,7 @@ bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) const // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(config? config : ""); const char* configProp = 0; - std::string configPropStr = targetTypeName; + std::string configPropStr = kind; if(!configPropStr.empty()) { configPropStr += "_OUTPUT_DIRECTORY_"; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 599e85d..7683253 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -710,7 +710,8 @@ private: OutputInfo const* GetOutputInfo(const char* config) const; bool ComputeOutputDir(const char* config, bool implib, std::string& out) const; - bool ComputePDBOutputDir(const char* config, std::string& out) const; + bool ComputePDBOutputDir(const char* kind, const char* config, + std::string& out) const; // Cache import information from properties for each configuration. struct ImportInfo; -- cgit v0.12 From 3737860a383b1020f44a31be9ac5536e9913fc71 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 24 Feb 2014 14:09:30 -0500 Subject: cmTarget: Add per-config compilation info Add a cmTarget::CompileInfo struct to hold per-configuration information about the compilation settings in a target. This is different than cmTarget::OutputInfo because it applies to any targets that can compile sources even if they do not link or archive. --- Source/cmTarget.cxx | 46 ++++++++++++++++++++++++++++++++++++++++++++++ Source/cmTarget.h | 4 ++++ 2 files changed, 50 insertions(+) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index cf09269..a50d6ad 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -71,6 +71,11 @@ struct cmTarget::ImportInfo cmTarget::LinkInterface LinkInterface; }; +//---------------------------------------------------------------------------- +struct cmTarget::CompileInfo +{ +}; + struct TargetConfigPair : public std::pair { TargetConfigPair(cmTarget const* tgt, const std::string &config) : std::pair(tgt, config) {} @@ -116,6 +121,9 @@ public: ImportInfoMapType; ImportInfoMapType ImportInfoMap; + typedef std::map CompileInfoMapType; + CompileInfoMapType CompileInfoMap; + // Cache link implementation computation from each configuration. typedef std::map LinkImplMapType; @@ -2478,6 +2486,44 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const } //---------------------------------------------------------------------------- +cmTarget::CompileInfo const* cmTarget::GetCompileInfo(const char* config) const +{ + // There is no compile information for imported targets. + if(this->IsImported()) + { + return 0; + } + + if(this->GetType() > cmTarget::OBJECT_LIBRARY) + { + std::string msg = "cmTarget::GetCompileInfo called for "; + msg += this->GetName(); + msg += " which has type "; + msg += cmTarget::GetTargetTypeName(this->GetType()); + this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); + abort(); + return 0; + } + + // Lookup/compute/cache the compile information for this configuration. + std::string config_upper; + if(config && *config) + { + config_upper = cmSystemTools::UpperCase(config); + } + typedef cmTargetInternals::CompileInfoMapType CompileInfoMapType; + CompileInfoMapType::const_iterator i = + this->Internal->CompileInfoMap.find(config_upper); + if(i == this->Internal->CompileInfoMap.end()) + { + CompileInfo info; + CompileInfoMapType::value_type entry(config_upper, info); + i = this->Internal->CompileInfoMap.insert(entry).first; + } + return &i->second; +} + +//---------------------------------------------------------------------------- std::string cmTarget::GetDirectory(const char* config, bool implib) const { if (this->IsImported()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 7683253..6787706 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -720,6 +720,10 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info, cmTarget const* head) const; + // Cache target compile paths for each configuration. + struct CompileInfo; + CompileInfo const* GetCompileInfo(const char* config) const; + mutable cmTargetLinkInformationMap LinkInformation; void CheckPropertyCompatibility(cmComputeLinkInformation *info, const char* config) const; -- cgit v0.12 From cd8c797a8592cfae1894c5b81c70e011c1dd9490 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 25 Feb 2014 00:01:14 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index e9a1721..56e5b81 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 0) -set(CMake_VERSION_PATCH 20140224) +set(CMake_VERSION_PATCH 20140225) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 048be20536b6960e3a4a5001ba3d642e2e5cdad1 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 11 Feb 2014 13:54:07 -0500 Subject: Help: Add release notes for the 'faster-parsers' topic --- Help/release/dev/faster-parsers.rst | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Help/release/dev/faster-parsers.rst diff --git a/Help/release/dev/faster-parsers.rst b/Help/release/dev/faster-parsers.rst new file mode 100644 index 0000000..c2a8bfb --- /dev/null +++ b/Help/release/dev/faster-parsers.rst @@ -0,0 +1,6 @@ +faster-parsers +-------------- + +* The :manual:`cmake-language(7)` internal implementation of generator + expression and list expansion parsers have been optimized and shows + non-trivial speedup on large projects. -- cgit v0.12 From 8993df6c3db7a105f146f07b7ff5585698b1c29c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matth=C3=A4us=20G=2E=20Chajdas?= Date: Sat, 22 Feb 2014 19:46:48 +0100 Subject: FindHg: Search for TortoiseHg Use the TortoiseHg registry entry as a search path. --- Modules/FindHg.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/FindHg.cmake b/Modules/FindHg.cmake index a1fb33f..8dea652 100644 --- a/Modules/FindHg.cmake +++ b/Modules/FindHg.cmake @@ -37,6 +37,8 @@ find_program(HG_EXECUTABLE NAMES hg + PATHS + [HKEY_LOCAL_MACHINE\\Software\\TortoiseHG] PATH_SUFFIXES Mercurial DOC "hg command line client" ) -- cgit v0.12 From bcefbe737dee16c58bc578d4d483727ff859f8de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matth=C3=A4us=20G=2E=20Chajdas?= Date: Sat, 22 Feb 2014 19:46:48 +0100 Subject: FindHg: Add Hg_WC_INFO macro Add a macro to extract information from a Hg work tree much like the Subversion_WC_INFO macro does for Subversion work tree. --- Modules/FindHg.cmake | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/Modules/FindHg.cmake b/Modules/FindHg.cmake index 8dea652..c418afd 100644 --- a/Modules/FindHg.cmake +++ b/Modules/FindHg.cmake @@ -2,7 +2,7 @@ # FindHg # ------ # -# +# Extract information from a mercurial working copy. # # The module defines the following variables: # @@ -12,6 +12,20 @@ # HG_FOUND - true if the command line client was found # HG_VERSION_STRING - the version of mercurial found # +# If the command line client executable is found the following macro is defined: +# +# :: +# +# HG_WC_INFO( ) +# +# Hg_WC_INFO extracts information of a mercurial working copy +# at a given location. This macro defines the following variables: +# +# :: +# +# _WC_CHANGESET - current changeset +# _WC_REVISION - current revision +# # Example usage: # # :: @@ -19,11 +33,15 @@ # find_package(Hg) # if(HG_FOUND) # message("hg found: ${HG_EXECUTABLE}") +# HG_WC_INFO(${PROJECT_SOURCE_DIR} Project) +# message("Current revision is ${Project_WC_REVISION}") +# message("Current changeset is ${Project_WC_CHANGESET}") # endif() #============================================================================= # Copyright 2010-2012 Kitware, Inc. # Copyright 2012 Rolf Eike Beer +# Copyright 2014 Matthaeus G. Chajdas # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -53,6 +71,21 @@ if(HG_EXECUTABLE) set(HG_VERSION_STRING "${CMAKE_MATCH_1}") endif() unset(hg_version) + + macro(HG_WC_INFO dir prefix) + execute_process(COMMAND ${HG_EXECUTABLE} id -i -n + WORKING_DIRECTORY ${dir} + RESULT_VARIABLE hg_id_result + ERROR_VARIABLE hg_id_error + OUTPUT_VARIABLE ${prefix}_WC_DATA + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT ${hg_id_result} EQUAL 0) + message(SEND_ERROR "Command \"${HG_EXECUTBALE} id -n\" in directory ${dir} failed with output:\n${hg_id_error}") + endif() + + string(REGEX REPLACE "([0-9a-f]+)\\+? [0-9]+\\+?" "\\1" ${prefix}_WC_CHANGESET ${${prefix}_WC_DATA}) + string(REGEX REPLACE "[0-9a-f]+\\+? ([0-9]+)\\+?" "\\1" ${prefix}_WC_REVISION ${${prefix}_WC_DATA}) + endmacro(HG_WC_INFO) endif() # Handle the QUIETLY and REQUIRED arguments and set HG_FOUND to TRUE if -- cgit v0.12 From 4c0f8dfb0aecd1eb7b567d627f4c312b2d0d5f68 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 25 Feb 2014 11:48:00 -0500 Subject: Utilities/Release: Update default binary distribution dir to v3.0 --- Utilities/Release/upload_release.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/Release/upload_release.cmake b/Utilities/Release/upload_release.cmake index 9bf3523..0d928ba 100644 --- a/Utilities/Release/upload_release.cmake +++ b/Utilities/Release/upload_release.cmake @@ -3,7 +3,7 @@ if(NOT DEFINED PROJECT_PREFIX) set(PROJECT_PREFIX cmake-) endif() if(NOT VERSION) - set(VERSION 2.8) + set(VERSION 3.0) endif() set(dir "v${VERSION}") if("${VERSION}" MATCHES "master") -- cgit v0.12 From b3d85113a63e360e7552ec5332ef7b6c3162abcc Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 25 Feb 2014 13:11:04 -0500 Subject: Utilities/Release: Copy pre-built docs tarball to unique name Name the pre-built docs tarball on the remote machine according to the release script name so that multiple tarballs going to a single remote machine do not clobber one another. --- Utilities/Release/release_cmake.cmake | 9 +++++---- Utilities/Release/release_cmake.sh.in | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Utilities/Release/release_cmake.cmake b/Utilities/Release/release_cmake.cmake index 630f54f..a8772ee 100644 --- a/Utilities/Release/release_cmake.cmake +++ b/Utilities/Release/release_cmake.cmake @@ -67,14 +67,15 @@ macro(remote_command comment command) endmacro() if(CMAKE_DOC_TARBALL) - message("scp '${CMAKE_DOC_TARBALL}' '${HOST}:'") + get_filename_component(CMAKE_DOC_TARBALL_NAME "${CMAKE_DOC_TARBALL}" NAME) + string(REPLACE ".tar.gz" "-${SCRIPT_NAME}.tar.gz" CMAKE_DOC_TARBALL_STAGED "${CMAKE_DOC_TARBALL_NAME}") + message("scp '${CMAKE_DOC_TARBALL}' '${HOST}:${CMAKE_DOC_TARBALL_STAGED}'") execute_process(COMMAND - scp ${CMAKE_DOC_TARBALL} ${HOST}: + scp ${CMAKE_DOC_TARBALL} ${HOST}:${CMAKE_DOC_TARBALL_STAGED} RESULT_VARIABLE result) if(${result} GREATER 0) - message("error sending doc tarball with scp '${CMAKE_DOC_TARBALL}' '${HOST}:'") + message("error sending doc tarball with scp '${CMAKE_DOC_TARBALL}' '${HOST}:${CMAKE_DOC_TARBALL_STAGED}'") endif() - get_filename_component(CMAKE_DOC_TARBALL_NAME "${CMAKE_DOC_TARBALL}" NAME) endif() # set this so configure file will work from script mode diff --git a/Utilities/Release/release_cmake.sh.in b/Utilities/Release/release_cmake.sh.in index f41bda8..1f57c28 100755 --- a/Utilities/Release/release_cmake.sh.in +++ b/Utilities/Release/release_cmake.sh.in @@ -18,7 +18,7 @@ check_exit_value() CMAKE_DOC_TARBALL="" if [ ! -z "@CMAKE_DOC_TARBALL_NAME@" ] ; then CMAKE_DOC_TARBALL=@CMAKE_RELEASE_DIRECTORY@/@CMAKE_DOC_TARBALL_NAME@ - mv "$HOME/@CMAKE_DOC_TARBALL_NAME@" "$CMAKE_DOC_TARBALL" + mv "$HOME/@CMAKE_DOC_TARBALL_STAGED@" "$CMAKE_DOC_TARBALL" check_exit_value $? "mv doc tarball" || exit 1 fi -- cgit v0.12 From c859d176a15326cd1ef7b5c35908f28313d1be19 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 26 Feb 2014 00:01:06 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 56e5b81..a1ae3b3 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 0) -set(CMake_VERSION_PATCH 20140225) +set(CMake_VERSION_PATCH 20140226) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 6fcd835c0786182c4981f9f640849c5c91100845 Mon Sep 17 00:00:00 2001 From: Nils Gladitz Date: Mon, 24 Feb 2014 23:21:12 +0100 Subject: CPackWIX: refactor and cleanup Extract addtional classes and functions which are getting unsightly large. Use some of the coding conventions more consistently. --- Source/CMakeLists.txt | 4 + Source/CPack/WiX/cmCPackWIXGenerator.cxx | 577 +++++----------------- Source/CPack/WiX/cmCPackWIXGenerator.h | 103 ++-- Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx | 87 ++++ Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h | 42 ++ Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx | 102 ++++ Source/CPack/WiX/cmWIXFeaturesSourceWriter.h | 39 ++ Source/CPack/WiX/cmWIXFilesSourceWriter.cxx | 149 ++++++ Source/CPack/WiX/cmWIXFilesSourceWriter.h | 62 +++ Source/CPack/WiX/cmWIXPatch.cxx | 91 ++++ Source/CPack/WiX/cmWIXPatch.h | 45 ++ Source/CPack/WiX/cmWIXPatchParser.cxx | 2 +- Source/CPack/WiX/cmWIXPatchParser.h | 2 +- Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx | 8 +- Source/CPack/WiX/cmWIXRichTextFormatWriter.h | 8 +- Source/CPack/WiX/cmWIXShortcut.h | 29 ++ Source/CPack/WiX/cmWIXSourceWriter.cxx | 14 +- Source/CPack/WiX/cmWIXSourceWriter.h | 16 +- 18 files changed, 846 insertions(+), 534 deletions(-) create mode 100644 Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx create mode 100644 Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h create mode 100644 Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx create mode 100644 Source/CPack/WiX/cmWIXFeaturesSourceWriter.h create mode 100644 Source/CPack/WiX/cmWIXFilesSourceWriter.cxx create mode 100644 Source/CPack/WiX/cmWIXFilesSourceWriter.h create mode 100644 Source/CPack/WiX/cmWIXPatch.cxx create mode 100644 Source/CPack/WiX/cmWIXPatch.h create mode 100644 Source/CPack/WiX/cmWIXShortcut.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 175a034..966e0f6 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -562,7 +562,11 @@ if(WIN32) set(CPACK_SRCS ${CPACK_SRCS} CPack/WiX/cmCPackWIXGenerator.cxx CPack/WiX/cmWIXSourceWriter.cxx + CPack/WiX/cmWIXDirectoriesSourceWriter.cxx + CPack/WiX/cmWIXFeaturesSourceWriter.cxx + CPack/WiX/cmWIXFilesSourceWriter.cxx CPack/WiX/cmWIXRichTextFormatWriter.cxx + CPack/WiX/cmWIXPatch.cxx CPack/WiX/cmWIXPatchParser.cxx ) endif() diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 43119d6..8e671cc 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -1,6 +1,6 @@ /*============================================================================ CMake - Cross Platform Makefile Generator - Copyright 2000-2013 Kitware, Inc., Insight Software Consortium + Copyright 2000-2014 Kitware, Inc., Insight Software Consortium Distributed under the OSI-approved BSD License (the "License"); see accompanying file Copyright.txt for details. @@ -19,6 +19,9 @@ #include #include "cmWIXSourceWriter.h" +#include "cmWIXDirectoriesSourceWriter.h" +#include "cmWIXFeaturesSourceWriter.h" +#include "cmWIXFilesSourceWriter.h" #include "cmWIXRichTextFormatWriter.h" #include @@ -28,11 +31,9 @@ #include // for GUID generation -#include -#include - cmCPackWIXGenerator::cmCPackWIXGenerator(): - HasDesktopShortcuts(false) + HasDesktopShortcuts(false), + Patch(Logger) { } @@ -44,15 +45,9 @@ int cmCPackWIXGenerator::InitializeInternal() return this->Superclass::InitializeInternal(); } -bool cmCPackWIXGenerator::RunWiXCommand(const std::string& command) +bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command) { - std::string cpackTopLevel; - if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel)) - { - return false; - } - - std::string logFileName = cpackTopLevel + "/wix.log"; + std::string logFileName = this->CPackTopLevel + "/wix.log"; cmCPackLogger(cmCPackLog::LOG_DEBUG, "Running WiX command: " << command << std::endl); @@ -81,7 +76,7 @@ bool cmCPackWIXGenerator::RunWiXCommand(const std::string& command) } bool cmCPackWIXGenerator::RunCandleCommand( - const std::string& sourceFile, const std::string& objectFile) + std::string const& sourceFile, std::string const& objectFile) { std::string executable; if(!RequireOption("CPACK_WIX_CANDLE_EXECUTABLE", executable)) @@ -108,7 +103,7 @@ bool cmCPackWIXGenerator::RunCandleCommand( return RunWiXCommand(command.str()); } -bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles) +bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles) { std::string executable; if(!RequireOption("CPACK_WIX_LIGHT_EXECUTABLE", executable)) @@ -121,8 +116,8 @@ bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles) command << " -nologo"; command << " -out " << QuotePath(packageFileNames.at(0)); - for(extension_set_t::const_iterator i = LightExtensions.begin(); - i != LightExtensions.end(); ++i) + for(extension_set_t::const_iterator i = this->LightExtensions.begin(); + i != this->LightExtensions.end(); ++i) { command << " -ext " << QuotePath(*i); } @@ -182,15 +177,14 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() "you might want to set this explicitly." << std::endl); } - std::string cpackTopLevel; - if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel)) + if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", this->CPackTopLevel)) { return false; } if(GetOption("CPACK_WIX_LICENSE_RTF") == 0) { - std::string licenseFilename = cpackTopLevel + "/License.rtf"; + std::string licenseFilename = this->CPackTopLevel + "/License.rtf"; SetOption("CPACK_WIX_LICENSE_RTF", licenseFilename.c_str()); if(!CreateLicenseFile()) @@ -213,7 +207,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() { std::string defaultRef = "WixUI_InstallDir"; - if(Components.size()) + if(this->Components.size()) { defaultRef = "WixUI_FeatureTree"; } @@ -221,17 +215,17 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() SetOption("CPACK_WIX_UI_REF", defaultRef.c_str()); } - CollectExtensions("CPACK_WIX_EXTENSIONS", CandleExtensions); - CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", CandleExtensions); + CollectExtensions("CPACK_WIX_EXTENSIONS", this->CandleExtensions); + CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", this->CandleExtensions); - LightExtensions.insert("WixUIExtension"); - CollectExtensions("CPACK_WIX_EXTENSIONS", LightExtensions); - CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", LightExtensions); + this->LightExtensions.insert("WixUIExtension"); + CollectExtensions("CPACK_WIX_EXTENSIONS", this->LightExtensions); + CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", this->LightExtensions); const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE"); if(patchFilePath) { - LoadPatchFragments(patchFilePath); + this->Patch.LoadFragments(patchFilePath); } return true; @@ -244,10 +238,7 @@ bool cmCPackWIXGenerator::PackageFilesImpl() return false; } - if(!CreateWiXVariablesIncludeFile()) - { - return false; - } + CreateWiXVariablesIncludeFile(); if(!CreateWiXSourceFiles()) { @@ -257,9 +248,9 @@ bool cmCPackWIXGenerator::PackageFilesImpl() AppendUserSuppliedExtraSources(); std::stringstream objectFiles; - for(size_t i = 0; i < WixSources.size(); ++i) + for(size_t i = 0; i < this->WixSources.size(); ++i) { - const std::string& sourceFilename = WixSources[i]; + std::string const& sourceFilename = this->WixSources[i]; std::string objectFilename = cmSystemTools::GetFilenameWithoutExtension(sourceFilename) + ".wixobj"; @@ -282,7 +273,7 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraSources() const char *cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES"); if(!cpackWixExtraSources) return; - cmSystemTools::ExpandListArgument(cpackWixExtraSources, WixSources); + cmSystemTools::ExpandListArgument(cpackWixExtraSources, this->WixSources); } void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream) @@ -297,22 +288,18 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream) for(size_t i = 0; i < expandedExtraObjects.size(); ++i) { - stream << " " << QuotePath(expandedExtraObjects[i]); + stream << " " << QuotePath(expandedExtraObjects[i]); } } -bool cmCPackWIXGenerator::CreateWiXVariablesIncludeFile() +void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile() { - std::string cpackTopLevel; - if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel)) - { - return false; - } - std::string includeFilename = - cpackTopLevel + "/cpack_variables.wxi"; + this->CPackTopLevel + "/cpack_variables.wxi"; + + cmWIXSourceWriter includeFile( + this->Logger, includeFilename, true); - cmWIXSourceWriter includeFile(Logger, includeFilename, true); CopyDefinition(includeFile, "CPACK_WIX_PRODUCT_GUID"); CopyDefinition(includeFile, "CPACK_WIX_UPGRADE_GUID"); CopyDefinition(includeFile, "CPACK_PACKAGE_VENDOR"); @@ -326,12 +313,10 @@ bool cmCPackWIXGenerator::CreateWiXVariablesIncludeFile() GetOption("CPACK_PACKAGE_NAME")); CopyDefinition(includeFile, "CPACK_WIX_PROGRAM_MENU_FOLDER"); CopyDefinition(includeFile, "CPACK_WIX_UI_REF"); - - return true; } void cmCPackWIXGenerator::CopyDefinition( - cmWIXSourceWriter &source, const std::string &name) + cmWIXSourceWriter &source, std::string const& name) { const char* value = GetOption(name.c_str()); if(value) @@ -341,7 +326,7 @@ void cmCPackWIXGenerator::CopyDefinition( } void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source, - const std::string& name, const std::string& value) + std::string const& name, std::string const& value) { std::stringstream tmp; tmp << name << "=\"" << value << '"'; @@ -352,81 +337,47 @@ void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source, bool cmCPackWIXGenerator::CreateWiXSourceFiles() { - std::string cpackTopLevel; - if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel)) - { - return false; - } - std::string directoryDefinitionsFilename = - cpackTopLevel + "/directories.wxs"; + this->CPackTopLevel + "/directories.wxs"; - WixSources.push_back(directoryDefinitionsFilename); + this->WixSources.push_back(directoryDefinitionsFilename); - cmWIXSourceWriter directoryDefinitions(Logger, directoryDefinitionsFilename); + cmWIXDirectoriesSourceWriter directoryDefinitions( + this->Logger, directoryDefinitionsFilename); directoryDefinitions.BeginElement("Fragment"); - directoryDefinitions.BeginElement("Directory"); - directoryDefinitions.AddAttribute("Id", "TARGETDIR"); - directoryDefinitions.AddAttribute("Name", "SourceDir"); - - directoryDefinitions.BeginElement("Directory"); - if(GetArchitecture() == "x86") - { - directoryDefinitions.AddAttribute("Id", "ProgramFilesFolder"); - } - else - { - directoryDefinitions.AddAttribute("Id", "ProgramFiles64Folder"); - } - - std::vector install_root; - - std::string tmp; - if(!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY", tmp)) + std::string installRoot; + if(!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY", installRoot)) { return false; } - cmSystemTools::SplitPath(tmp.c_str(), install_root); - - if(!install_root.empty() && install_root.back().empty()) - { - install_root.pop_back(); - } - - for(size_t i = 1; i < install_root.size(); ++i) - { - directoryDefinitions.BeginElement("Directory"); - - if(i == install_root.size() - 1) - { - directoryDefinitions.AddAttribute("Id", "INSTALL_ROOT"); - } - else - { - std::stringstream ss; - ss << "INSTALL_PREFIX_" << i; - directoryDefinitions.AddAttribute("Id", ss.str()); - } + directoryDefinitions.BeginElement("Directory"); + directoryDefinitions.AddAttribute("Id", "TARGETDIR"); + directoryDefinitions.AddAttribute("Name", "SourceDir"); - directoryDefinitions.AddAttribute("Name", install_root[i]); - } + size_t installRootSize = + directoryDefinitions.BeginInstallationPrefixDirectory( + GetProgramFilesFolderId(), installRoot); std::string fileDefinitionsFilename = - cpackTopLevel + "/files.wxs"; + this->CPackTopLevel + "/files.wxs"; - WixSources.push_back(fileDefinitionsFilename); + this->WixSources.push_back(fileDefinitionsFilename); + + cmWIXFilesSourceWriter fileDefinitions( + this->Logger, fileDefinitionsFilename); - cmWIXSourceWriter fileDefinitions(Logger, fileDefinitionsFilename); fileDefinitions.BeginElement("Fragment"); std::string featureDefinitionsFilename = - cpackTopLevel +"/features.wxs"; + this->CPackTopLevel +"/features.wxs"; + + this->WixSources.push_back(featureDefinitionsFilename); - WixSources.push_back(featureDefinitionsFilename); + cmWIXFeaturesSourceWriter featureDefinitions( + this->Logger, featureDefinitionsFilename); - cmWIXSourceWriter featureDefinitions(Logger, featureDefinitionsFilename); featureDefinitions.BeginElement("Fragment"); featureDefinitions.BeginElement("Feature"); @@ -439,13 +390,15 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() { return false; } - featureDefinitions.AddAttribute("Title", cpackPackageName); + featureDefinitions.AddAttribute("Title", cpackPackageName); featureDefinitions.AddAttribute("Level", "1"); - if(!CreateCMakePackageRegistryEntry(featureDefinitions)) + const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY"); + if(package) { - return false; + featureDefinitions.CreateCMakePackageRegistryEntry( + package, GetOption("CPACK_WIX_UPGRADE_GUID")); } if(!CreateFeatureHierarchy(featureDefinitions)) @@ -471,7 +424,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() else { for(std::map::const_iterator - i = Components.begin(); i != Components.end(); ++i) + i = this->Components.begin(); i != this->Components.end(); ++i) { cmCPackComponent const& component = i->second; @@ -513,31 +466,51 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() featureDefinitions.EndElement("Fragment"); fileDefinitions.EndElement("Fragment"); - for(size_t i = 1; i < install_root.size(); ++i) - { - directoryDefinitions.EndElement("Directory"); - } - - directoryDefinitions.EndElement("Directory"); + directoryDefinitions.EndInstallationPrefixDirectory( + installRootSize); if(hasShortcuts) { - CreateStartMenuFolder(directoryDefinitions); + directoryDefinitions.EmitStartMenuFolder( + GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER")); } if(this->HasDesktopShortcuts) { - CreateDesktopFolder(directoryDefinitions); + directoryDefinitions.EmitDesktopFolder(); } directoryDefinitions.EndElement("Directory"); directoryDefinitions.EndElement("Fragment"); + if(!GenerateMainSourceFileFromTemplate()) + { + return false; + } + + return this->Patch.CheckForUnappliedFragments(); +} + +std::string cmCPackWIXGenerator::GetProgramFilesFolderId() const +{ + if(GetArchitecture() == "x86") + { + return "ProgramFilesFolder"; + } + else + { + return "ProgramFiles64Folder"; + } +} + +bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate() +{ std::string wixTemplate = FindTemplate("WIX.template.in"); if(GetOption("CPACK_WIX_TEMPLATE") != 0) { wixTemplate = GetOption("CPACK_WIX_TEMPLATE"); } + if(wixTemplate.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -545,7 +518,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() return false; } - std::string mainSourceFilePath = cpackTopLevel + "/main.wxs"; + std::string mainSourceFilePath = this->CPackTopLevel + "/main.wxs"; if(!ConfigureFile(wixTemplate.c_str(), mainSourceFilePath .c_str())) { @@ -556,68 +529,13 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() return false; } - WixSources.push_back(mainSourceFilePath); - - std::string fragmentList; - for(cmWIXPatchParser::fragment_map_t::const_iterator - i = Fragments.begin(); i != Fragments.end(); ++i) - { - if(!fragmentList.empty()) - { - fragmentList += ", "; - } - - fragmentList += "'"; - fragmentList += i->first; - fragmentList += "'"; - } - - if(fragmentList.size()) - { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Some XML patch fragments did not have matching IDs: " << - fragmentList << std::endl); - return false; - } - - return true; -} - -bool cmCPackWIXGenerator::CreateCMakePackageRegistryEntry( - cmWIXSourceWriter& featureDefinitions) -{ - const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY"); - if(!package) - { - return true; - } - - featureDefinitions.BeginElement("Component"); - featureDefinitions.AddAttribute("Id", "CM_PACKAGE_REGISTRY"); - featureDefinitions.AddAttribute("Directory", "TARGETDIR"); - featureDefinitions.AddAttribute("Guid", "*"); - - std::string registryKey = - std::string("Software\\Kitware\\CMake\\Packages\\") + package; - - std::string upgradeGuid = GetOption("CPACK_WIX_UPGRADE_GUID"); - - featureDefinitions.BeginElement("RegistryValue"); - featureDefinitions.AddAttribute("Root", "HKLM"); - featureDefinitions.AddAttribute("Key", registryKey); - featureDefinitions.AddAttribute("Name", upgradeGuid); - featureDefinitions.AddAttribute("Type", "string"); - featureDefinitions.AddAttribute("Value", "[INSTALL_ROOT]"); - featureDefinitions.AddAttribute("KeyPath", "yes"); - featureDefinitions.EndElement("RegistryValue"); - - featureDefinitions.EndElement("Component"); + this->WixSources.push_back(mainSourceFilePath); return true; } bool cmCPackWIXGenerator::CreateFeatureHierarchy( - cmWIXSourceWriter& featureDefinitions) + cmWIXFeaturesSourceWriter& featureDefinitions) { for(std::map::const_iterator i = ComponentGroups.begin(); i != ComponentGroups.end(); ++i) @@ -625,105 +543,30 @@ bool cmCPackWIXGenerator::CreateFeatureHierarchy( cmCPackComponentGroup const& group = i->second; if(group.ParentGroup == 0) { - if(!EmitFeatureForComponentGroup(featureDefinitions, group)) - { - return false; - } + featureDefinitions.EmitFeatureForComponentGroup(group); } } for(std::map::const_iterator - i = Components.begin(); i != Components.end(); ++i) + i = this->Components.begin(); i != this->Components.end(); ++i) { cmCPackComponent const& component = i->second; if(!component.Group) { - if(!EmitFeatureForComponent(featureDefinitions, component)) - { - return false; - } + featureDefinitions.EmitFeatureForComponent(component); } } return true; } -bool cmCPackWIXGenerator::EmitFeatureForComponentGroup( - cmWIXSourceWriter& featureDefinitions, - cmCPackComponentGroup const& group) -{ - featureDefinitions.BeginElement("Feature"); - featureDefinitions.AddAttribute("Id", "CM_G_" + group.Name); - - if(group.IsExpandedByDefault) - { - featureDefinitions.AddAttribute("Display", "expand"); - } - - featureDefinitions.AddAttributeUnlessEmpty( - "Title", group.DisplayName); - - featureDefinitions.AddAttributeUnlessEmpty( - "Description", group.Description); - - for(std::vector::const_iterator - i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i) - { - if(!EmitFeatureForComponentGroup(featureDefinitions, **i)) - { - return false; - } - } - - for(std::vector::const_iterator - i = group.Components.begin(); i != group.Components.end(); ++i) - { - if(!EmitFeatureForComponent(featureDefinitions, **i)) - { - return false; - } - } - - featureDefinitions.EndElement("Feature"); - - return true; -} - -bool cmCPackWIXGenerator::EmitFeatureForComponent( - cmWIXSourceWriter& featureDefinitions, - cmCPackComponent const& component) -{ - featureDefinitions.BeginElement("Feature"); - featureDefinitions.AddAttribute("Id", "CM_C_" + component.Name); - - featureDefinitions.AddAttributeUnlessEmpty( - "Title", component.DisplayName); - - featureDefinitions.AddAttributeUnlessEmpty( - "Description", component.Description); - - if(component.IsRequired) - { - featureDefinitions.AddAttribute("Absent", "disallow"); - } - - if(component.IsHidden) - { - featureDefinitions.AddAttribute("Display", "hidden"); - } - - featureDefinitions.EndElement("Feature"); - - return true; -} - bool cmCPackWIXGenerator::AddComponentsToFeature( std::string const& rootPath, std::string const& featureId, - cmWIXSourceWriter& directoryDefinitions, - cmWIXSourceWriter& fileDefinitions, - cmWIXSourceWriter& featureDefinitions, + cmWIXDirectoriesSourceWriter& directoryDefinitions, + cmWIXFilesSourceWriter& fileDefinitions, + cmWIXFeaturesSourceWriter& featureDefinitions, shortcut_map_t& shortcutMap) { featureDefinitions.BeginElement("FeatureRef"); @@ -768,8 +611,8 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( std::string const& cpackComponentName, std::string const& featureId, shortcut_map_t& shortcutMap, - cmWIXSourceWriter& fileDefinitions, - cmWIXSourceWriter& featureDefinitions) + cmWIXFilesSourceWriter& fileDefinitions, + cmWIXFeaturesSourceWriter& featureDefinitions) { bool thisHasDesktopShortcuts = false; @@ -799,6 +642,7 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( fileDefinitions.BeginElement("DirectoryRef"); fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); + fileDefinitions.BeginElement("Component"); fileDefinitions.AddAttribute("Id", componentId); fileDefinitions.AddAttribute("Guid", "*"); @@ -809,63 +653,34 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( std::string const& id = i->first; cmWIXShortcut const& shortcut = i->second; - std::string shortcutId = std::string("CM_S") + id; - std::string fileId = std::string("CM_F") + id; - - fileDefinitions.BeginElement("Shortcut"); - fileDefinitions.AddAttribute("Id", shortcutId); - fileDefinitions.AddAttribute("Name", shortcut.textLabel); - std::string target = "[#" + fileId + "]"; - fileDefinitions.AddAttribute("Target", target); - fileDefinitions.AddAttribute("WorkingDirectory", - shortcut.workingDirectoryId); - fileDefinitions.EndElement("Shortcut"); + fileDefinitions.EmitShortcut(id, shortcut, false); - if (shortcut.desktop) + if(shortcut.desktop) { - thisHasDesktopShortcuts = true; + thisHasDesktopShortcuts = true; } } if(cpackComponentName.empty()) { - CreateUninstallShortcut(cpackPackageName, fileDefinitions); + fileDefinitions.EmitUninstallShortcut(cpackPackageName); } - fileDefinitions.BeginElement("RemoveFolder"); - fileDefinitions.AddAttribute("Id", + fileDefinitions.EmitRemoveFolder( "CM_REMOVE_PROGRAM_MENU_FOLDER" + idSuffix); - fileDefinitions.AddAttribute("On", "uninstall"); - fileDefinitions.EndElement("RemoveFolder"); std::string registryKey = std::string("Software\\") + cpackVendor + "\\" + cpackPackageName; - fileDefinitions.BeginElement("RegistryValue"); - fileDefinitions.AddAttribute("Root", "HKCU"); - fileDefinitions.AddAttribute("Key", registryKey); - - std::string valueName; - if(!cpackComponentName.empty()) - { - valueName = cpackComponentName + "_"; - } - valueName += "installed"; - - fileDefinitions.AddAttribute("Name", valueName); - fileDefinitions.AddAttribute("Type", "integer"); - fileDefinitions.AddAttribute("Value", "1"); - fileDefinitions.AddAttribute("KeyPath", "yes"); - fileDefinitions.EndElement("RegistryValue"); + fileDefinitions.EmitStartMenuShortcutRegistryValue( + registryKey, cpackComponentName); fileDefinitions.EndElement("Component"); fileDefinitions.EndElement("DirectoryRef"); - featureDefinitions.BeginElement("ComponentRef"); - featureDefinitions.AddAttribute("Id", componentId); - featureDefinitions.EndElement("ComponentRef"); + featureDefinitions.EmitComponentRef(componentId); - if (thisHasDesktopShortcuts) + if(thisHasDesktopShortcuts) { this->HasDesktopShortcuts = true; componentId = "CM_DESKTOP_SHORTCUT" + idSuffix; @@ -876,7 +691,7 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( fileDefinitions.AddAttribute("Id", componentId); fileDefinitions.AddAttribute("Guid", "*"); - for (shortcut_map_t::const_iterator + for(shortcut_map_t::const_iterator i = shortcutMap.begin(); i != shortcutMap.end(); ++i) { std::string const& id = i->first; @@ -885,34 +700,16 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( if (!shortcut.desktop) continue; - std::string shortcutId = std::string("CM_DS") + id; - std::string fileId = std::string("CM_F") + id; - - fileDefinitions.BeginElement("Shortcut"); - fileDefinitions.AddAttribute("Id", shortcutId); - fileDefinitions.AddAttribute("Name", shortcut.textLabel); - std::string target = "[#" + fileId + "]"; - fileDefinitions.AddAttribute("Target", target); - fileDefinitions.AddAttribute("WorkingDirectory", - shortcut.workingDirectoryId); - fileDefinitions.EndElement("Shortcut"); + fileDefinitions.EmitShortcut(id, shortcut, true); } - fileDefinitions.BeginElement("RegistryValue"); - fileDefinitions.AddAttribute("Root", "HKCU"); - fileDefinitions.AddAttribute("Key", registryKey); - fileDefinitions.AddAttribute("Name", valueName + "_desktop"); - fileDefinitions.AddAttribute("Type", "integer"); - fileDefinitions.AddAttribute("Value", "1"); - fileDefinitions.AddAttribute("KeyPath", "yes"); - fileDefinitions.EndElement("RegistryValue"); + fileDefinitions.EmitDesktopShortcutRegistryValue( + registryKey, cpackComponentName); fileDefinitions.EndElement("Component"); fileDefinitions.EndElement("DirectoryRef"); - featureDefinitions.BeginElement("ComponentRef"); - featureDefinitions.AddAttribute("Id", componentId); - featureDefinitions.EndElement("ComponentRef"); + featureDefinitions.EmitComponentRef(componentId); } featureDefinitions.EndElement("FeatureRef"); @@ -920,19 +717,6 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( return true; } -void cmCPackWIXGenerator::CreateUninstallShortcut( - std::string const& packageName, - cmWIXSourceWriter& fileDefinitions) -{ - fileDefinitions.BeginElement("Shortcut"); - fileDefinitions.AddAttribute("Id", "UNINSTALL"); - fileDefinitions.AddAttribute("Name", "Uninstall " + packageName); - fileDefinitions.AddAttribute("Description", "Uninstalls " + packageName); - fileDefinitions.AddAttribute("Target", "[SystemFolder]msiexec.exe"); - fileDefinitions.AddAttribute("Arguments", "/x [ProductCode]"); - fileDefinitions.EndElement("Shortcut"); -} - bool cmCPackWIXGenerator::CreateLicenseFile() { std::string licenseSourceFilename; @@ -981,11 +765,11 @@ bool cmCPackWIXGenerator::CreateLicenseFile() } void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( - const std::string& topdir, - const std::string& directoryId, - cmWIXSourceWriter& directoryDefinitions, - cmWIXSourceWriter& fileDefinitions, - cmWIXSourceWriter& featureDefinitions, + std::string const& topdir, + std::string const& directoryId, + cmWIXDirectoriesSourceWriter& directoryDefinitions, + cmWIXFilesSourceWriter& fileDefinitions, + cmWIXFeaturesSourceWriter& featureDefinitions, const std::vector& packageExecutables, const std::vector& desktopExecutables, shortcut_map_t& shortcutMap) @@ -1026,44 +810,15 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( desktopExecutables, shortcutMap); - ApplyPatchFragment(subDirectoryId, directoryDefinitions); + this->Patch.ApplyFragment(subDirectoryId, directoryDefinitions); directoryDefinitions.EndElement("Directory"); } else { - std::string componentId = std::string("CM_C") + id; - std::string fileId = std::string("CM_F") + id; - - fileDefinitions.BeginElement("DirectoryRef"); - fileDefinitions.AddAttribute("Id", directoryId); - - fileDefinitions.BeginElement("Component"); - fileDefinitions.AddAttribute("Id", componentId); - fileDefinitions.AddAttribute("Guid", "*"); + std::string componentId = fileDefinitions.EmitComponentFile( + directoryId, id, fullPath, this->Patch); - fileDefinitions.BeginElement("File"); - fileDefinitions.AddAttribute("Id", fileId); - fileDefinitions.AddAttribute("Source", fullPath); - fileDefinitions.AddAttribute("KeyPath", "yes"); - - mode_t fileMode = 0; - cmSystemTools::GetPermissions(fullPath.c_str(), fileMode); - - if(!(fileMode & S_IWRITE)) - { - fileDefinitions.AddAttribute("ReadOnly", "yes"); - } - - ApplyPatchFragment(fileId, fileDefinitions); - fileDefinitions.EndElement("File"); - - ApplyPatchFragment(componentId, fileDefinitions); - fileDefinitions.EndElement("Component"); - fileDefinitions.EndElement("DirectoryRef"); - - featureDefinitions.BeginElement("ComponentRef"); - featureDefinitions.AddAttribute("Id", componentId); - featureDefinitions.EndElement("ComponentRef"); + featureDefinitions.EmitComponentRef(componentId); for(size_t j = 0; j < packageExecutables.size(); ++j) { @@ -1092,7 +847,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( } bool cmCPackWIXGenerator::RequireOption( - const std::string& name, std::string &value) const + std::string const& name, std::string &value) const { const char* tmp = GetOption(name.c_str()); if(tmp) @@ -1140,13 +895,13 @@ std::string cmCPackWIXGenerator::GenerateGUID() return cmSystemTools::UpperCase(result); } -std::string cmCPackWIXGenerator::QuotePath(const std::string& path) +std::string cmCPackWIXGenerator::QuotePath(std::string const& path) { return std::string("\"") + path + '"'; } std::string cmCPackWIXGenerator::GetRightmostExtension( - const std::string& filename) + std::string const& filename) { std::string extension; @@ -1159,7 +914,7 @@ std::string cmCPackWIXGenerator::GetRightmostExtension( return cmSystemTools::LowerCase(extension); } -std::string cmCPackWIXGenerator::PathToId(const std::string& path) +std::string cmCPackWIXGenerator::PathToId(std::string const& path) { id_map_t::const_iterator i = PathToIdMap.find(path); if(i != PathToIdMap.end()) return i->second; @@ -1168,7 +923,7 @@ std::string cmCPackWIXGenerator::PathToId(const std::string& path) return id; } -std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path) +std::string cmCPackWIXGenerator::CreateNewIdForPath(std::string const& path) { std::vector components; cmSystemTools::SplitPath(path.c_str(), components, false); @@ -1222,7 +977,7 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path) } std::string cmCPackWIXGenerator::CreateHashedId( - const std::string& path, const std::string& normalizedFilename) + std::string const& path, std::string const& normalizedFilename) { cmsys::auto_ptr sha1 = cmCryptoHash::New("SHA1"); std::string hash = sha1->HashString(path.c_str()); @@ -1245,7 +1000,7 @@ std::string cmCPackWIXGenerator::CreateHashedId( } std::string cmCPackWIXGenerator::NormalizeComponentForId( - const std::string& component, size_t& replacementCount) + std::string const& component, size_t& replacementCount) { std::string result; result.resize(component.size()); @@ -1276,7 +1031,7 @@ bool cmCPackWIXGenerator::IsLegalIdCharacter(char c) } void cmCPackWIXGenerator::CollectExtensions( - const std::string& variableName, extension_set_t& extensions) + std::string const& variableName, extension_set_t& extensions) { const char *variableContent = GetOption(variableName.c_str()); if(!variableContent) return; @@ -1292,7 +1047,7 @@ void cmCPackWIXGenerator::CollectExtensions( } void cmCPackWIXGenerator::AddCustomFlags( - const std::string& variableName, std::ostream& stream) + std::string const& variableName, std::ostream& stream) { const char *variableContent = GetOption(variableName.c_str()); if(!variableContent) return; @@ -1306,69 +1061,3 @@ void cmCPackWIXGenerator::AddCustomFlags( stream << " " << QuotePath(*i); } } - -void cmCPackWIXGenerator::CreateStartMenuFolder( - cmWIXSourceWriter& directoryDefinitions) -{ - directoryDefinitions.BeginElement("Directory"); - directoryDefinitions.AddAttribute("Id", "ProgramMenuFolder"); - - directoryDefinitions.BeginElement("Directory"); - directoryDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); - const char *startMenuFolder = GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"); - directoryDefinitions.AddAttribute("Name", startMenuFolder); - directoryDefinitions.EndElement("Directory"); - - directoryDefinitions.EndElement("Directory"); -} - -void cmCPackWIXGenerator::CreateDesktopFolder( - cmWIXSourceWriter& directoryDefinitions) -{ - directoryDefinitions.BeginElement("Directory"); - directoryDefinitions.AddAttribute("Id", "DesktopFolder"); - directoryDefinitions.AddAttribute("Name", "Desktop"); - directoryDefinitions.EndElement("Directory"); -} - -void cmCPackWIXGenerator::LoadPatchFragments(const std::string& patchFilePath) -{ - cmWIXPatchParser parser(Fragments, Logger); - parser.ParseFile(patchFilePath.c_str()); -} - -void cmCPackWIXGenerator::ApplyPatchFragment( - const std::string& id, cmWIXSourceWriter& writer) -{ - cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id); - if(i == Fragments.end()) return; - - const cmWIXPatchElement& fragment = i->second; - for(cmWIXPatchElement::child_list_t::const_iterator - j = fragment.children.begin(); j != fragment.children.end(); ++j) - { - ApplyPatchElement(**j, writer); - } - - Fragments.erase(i); -} - -void cmCPackWIXGenerator::ApplyPatchElement( - const cmWIXPatchElement& element, cmWIXSourceWriter& writer) -{ - writer.BeginElement(element.name); - - for(cmWIXPatchElement::attributes_t::const_iterator - i = element.attributes.begin(); i != element.attributes.end(); ++i) - { - writer.AddAttribute(i->first, i->second); - } - - for(cmWIXPatchElement::child_list_t::const_iterator - i = element.children.begin(); i != element.children.end(); ++i) - { - ApplyPatchElement(**i, writer); - } - - writer.EndElement(element.name); -} diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index 1de4810..ee66c05 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -13,25 +13,18 @@ #ifndef cmCPackWIXGenerator_h #define cmCPackWIXGenerator_h -#include "cmWIXPatchParser.h" +#include "cmWIXPatch.h" +#include "cmWIXShortcut.h" #include #include #include -struct cmWIXShortcut -{ - cmWIXShortcut() - :desktop(false) - {} - - std::string textLabel; - std::string workingDirectoryId; - bool desktop; -}; - class cmWIXSourceWriter; +class cmWIXDirectoriesSourceWriter; +class cmWIXFilesSourceWriter; +class cmWIXFeaturesSourceWriter; /** \class cmCPackWIXGenerator * \brief A generator for WIX files @@ -78,48 +71,37 @@ private: bool PackageFilesImpl(); - bool CreateWiXVariablesIncludeFile(); + void CreateWiXVariablesIncludeFile(); void CopyDefinition( - cmWIXSourceWriter &source, const std::string &name); + cmWIXSourceWriter &source, std::string const& name); void AddDefinition(cmWIXSourceWriter& source, - const std::string& name, const std::string& value); + std::string const& name, std::string const& value); bool CreateWiXSourceFiles(); - bool CreateCMakePackageRegistryEntry( - cmWIXSourceWriter& featureDefinitions); + std::string GetProgramFilesFolderId() const; - bool CreateFeatureHierarchy( - cmWIXSourceWriter& featureDefinitions); - - bool EmitFeatureForComponentGroup( - cmWIXSourceWriter& featureDefinitions, - cmCPackComponentGroup const& group); + bool GenerateMainSourceFileFromTemplate(); - bool EmitFeatureForComponent( - cmWIXSourceWriter& featureDefinitions, - cmCPackComponent const& component); + bool CreateFeatureHierarchy( + cmWIXFeaturesSourceWriter& featureDefinitions); bool AddComponentsToFeature( std::string const& rootPath, std::string const& featureId, - cmWIXSourceWriter& directoryDefinitions, - cmWIXSourceWriter& fileDefinitions, - cmWIXSourceWriter& featureDefinitions, + cmWIXDirectoriesSourceWriter& directoryDefinitions, + cmWIXFilesSourceWriter& fileDefinitions, + cmWIXFeaturesSourceWriter& featureDefinitions, shortcut_map_t& shortcutMap); bool CreateStartMenuShortcuts( std::string const& cpackComponentName, std::string const& featureId, shortcut_map_t& shortcutMap, - cmWIXSourceWriter& fileDefinitions, - cmWIXSourceWriter& featureDefinitions); - - void CreateUninstallShortcut( - std::string const& packageName, - cmWIXSourceWriter& fileDefinitions); + cmWIXFilesSourceWriter& fileDefinitions, + cmWIXFeaturesSourceWriter& featureDefinitions); void AppendUserSuppliedExtraSources(); @@ -127,60 +109,49 @@ private: bool CreateLicenseFile(); - bool RunWiXCommand(const std::string& command); + bool RunWiXCommand(std::string const& command); bool RunCandleCommand( - const std::string& sourceFile, const std::string& objectFile); + std::string const& sourceFile, std::string const& objectFile); - bool RunLightCommand(const std::string& objectFiles); + bool RunLightCommand(std::string const& objectFiles); - void AddDirectoryAndFileDefinitons(const std::string& topdir, - const std::string& directoryId, - cmWIXSourceWriter& directoryDefinitions, - cmWIXSourceWriter& fileDefinitions, - cmWIXSourceWriter& featureDefinitions, + void AddDirectoryAndFileDefinitons(std::string const& topdir, + std::string const& directoryId, + cmWIXDirectoriesSourceWriter& directoryDefinitions, + cmWIXFilesSourceWriter& fileDefinitions, + cmWIXFeaturesSourceWriter& featureDefinitions, const std::vector& pkgExecutables, const std::vector& desktopExecutables, shortcut_map_t& shortcutMap); - bool RequireOption(const std::string& name, std::string& value) const; + bool RequireOption(std::string const& name, std::string& value) const; std::string GetArchitecture() const; static std::string GenerateGUID(); - static std::string QuotePath(const std::string& path); + static std::string QuotePath(std::string const& path); - static std::string GetRightmostExtension(const std::string& filename); + static std::string GetRightmostExtension(std::string const& filename); - std::string PathToId(const std::string& path); + std::string PathToId(std::string const& path); - std::string CreateNewIdForPath(const std::string& path); + std::string CreateNewIdForPath(std::string const& path); static std::string CreateHashedId( - const std::string& path, const std::string& normalizedFilename); + std::string const& path, std::string const& normalizedFilename); std::string NormalizeComponentForId( - const std::string& component, size_t& replacementCount); + std::string const& component, size_t& replacementCount); static bool IsLegalIdCharacter(char c); void CollectExtensions( - const std::string& variableName, extension_set_t& extensions); + std::string const& variableName, extension_set_t& extensions); void AddCustomFlags( - const std::string& variableName, std::ostream& stream); - - void CreateStartMenuFolder(cmWIXSourceWriter& directoryDefinitions); - - void CreateDesktopFolder(cmWIXSourceWriter& directoryDefinitions); - - void LoadPatchFragments(const std::string& patchFilePath); - - void ApplyPatchFragment(const std::string& id, cmWIXSourceWriter& writer); - - void ApplyPatchElement(const cmWIXPatchElement& element, - cmWIXSourceWriter& writer); + std::string const& variableName, std::ostream& stream); std::vector WixSources; id_map_t PathToIdMap; @@ -189,9 +160,11 @@ private: extension_set_t CandleExtensions; extension_set_t LightExtensions; - cmWIXPatchParser::fragment_map_t Fragments; - bool HasDesktopShortcuts; + + std::string CPackTopLevel; + + cmWIXPatch Patch; }; #endif diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx new file mode 100644 index 0000000..a93f89b --- /dev/null +++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx @@ -0,0 +1,87 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmWIXDirectoriesSourceWriter.h" + +cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(cmCPackLog* logger, + std::string const& filename): + cmWIXSourceWriter(logger, filename) +{ + +} + +void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder( + std::string const& startMenuFolder) +{ + BeginElement("Directory"); + AddAttribute("Id", "ProgramMenuFolder"); + + BeginElement("Directory"); + AddAttribute("Id", "PROGRAM_MENU_FOLDER"); + AddAttribute("Name", startMenuFolder); + EndElement("Directory"); + + EndElement("Directory"); +} + +void cmWIXDirectoriesSourceWriter::EmitDesktopFolder() +{ + BeginElement("Directory"); + AddAttribute("Id", "DesktopFolder"); + AddAttribute("Name", "Desktop"); + EndElement("Directory"); +} + +size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory( + std::string const& programFilesFolderId, + std::string const& installRootString) +{ + BeginElement("Directory"); + AddAttribute("Id", programFilesFolderId); + + std::vector installRoot; + + cmSystemTools::SplitPath(installRootString.c_str(), installRoot); + + if(!installRoot.empty() && installRoot.back().empty()) + { + installRoot.pop_back(); + } + + for(size_t i = 1; i < installRoot.size(); ++i) + { + BeginElement("Directory"); + + if(i == installRoot.size() - 1) + { + AddAttribute("Id", "INSTALL_ROOT"); + } + else + { + std::stringstream tmp; + tmp << "INSTALL_PREFIX_" << i; + AddAttribute("Id", tmp.str()); + } + + AddAttribute("Name", installRoot[i]); + } + + return installRoot.size(); +} + +void cmWIXDirectoriesSourceWriter::EndInstallationPrefixDirectory(size_t size) +{ + for(size_t i = 0; i < size; ++i) + { + EndElement("Directory"); + } +} diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h new file mode 100644 index 0000000..f51fdb4 --- /dev/null +++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h @@ -0,0 +1,42 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmWIXDirectoriesSourceWriter_h +#define cmWIXDirectoriesSourceWriter_h + +#include "cmWIXSourceWriter.h" + +#include + +#include + +/** \class cmWIXDirectoriesSourceWriter + * \brief Helper class to generate directories.wxs + */ +class cmWIXDirectoriesSourceWriter : public cmWIXSourceWriter +{ +public: + cmWIXDirectoriesSourceWriter(cmCPackLog* logger, + std::string const& filename); + + void EmitStartMenuFolder(std::string const& startMenuFolder); + + void EmitDesktopFolder(); + + size_t BeginInstallationPrefixDirectory( + std::string const& programFilesFolderId, + std::string const& installRootString); + + void EndInstallationPrefixDirectory(size_t size); +}; + +#endif diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx new file mode 100644 index 0000000..0bcfc38 --- /dev/null +++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx @@ -0,0 +1,102 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmWIXFeaturesSourceWriter.h" + +cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(cmCPackLog* logger, + std::string const& filename): + cmWIXSourceWriter(logger, filename) +{ + +} + +void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry( + std::string const& package, + std::string const& upgradeGuid) +{ + BeginElement("Component"); + AddAttribute("Id", "CM_PACKAGE_REGISTRY"); + AddAttribute("Directory", "TARGETDIR"); + AddAttribute("Guid", "*"); + + std::string registryKey = + std::string("Software\\Kitware\\CMake\\Packages\\") + package; + + BeginElement("RegistryValue"); + AddAttribute("Root", "HKLM"); + AddAttribute("Key", registryKey); + AddAttribute("Name", upgradeGuid); + AddAttribute("Type", "string"); + AddAttribute("Value", "[INSTALL_ROOT]"); + AddAttribute("KeyPath", "yes"); + EndElement("RegistryValue"); + + EndElement("Component"); +} + +void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup( + cmCPackComponentGroup const& group) +{ + BeginElement("Feature"); + AddAttribute("Id", "CM_G_" + group.Name); + + if(group.IsExpandedByDefault) + { + AddAttribute("Display", "expand"); + } + + AddAttributeUnlessEmpty("Title", group.DisplayName); + AddAttributeUnlessEmpty("Description", group.Description); + + for(std::vector::const_iterator + i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i) + { + EmitFeatureForComponentGroup(**i); + } + + for(std::vector::const_iterator + i = group.Components.begin(); i != group.Components.end(); ++i) + { + EmitFeatureForComponent(**i); + } + + EndElement("Feature"); +} + +void cmWIXFeaturesSourceWriter::EmitFeatureForComponent( + cmCPackComponent const& component) +{ + BeginElement("Feature"); + AddAttribute("Id", "CM_C_" + component.Name); + + AddAttributeUnlessEmpty("Title", component.DisplayName); + AddAttributeUnlessEmpty("Description", component.Description); + + if(component.IsRequired) + { + AddAttribute("Absent", "disallow"); + } + + if(component.IsHidden) + { + AddAttribute("Display", "hidden"); + } + + EndElement("Feature"); +} + +void cmWIXFeaturesSourceWriter::EmitComponentRef(std::string const& id) +{ + BeginElement("ComponentRef"); + AddAttribute("Id", id); + EndElement("ComponentRef"); +} diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h new file mode 100644 index 0000000..7670417 --- /dev/null +++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h @@ -0,0 +1,39 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmWIXFeaturesSourceWriter_h +#define cmWIXFeaturesSourceWriter_h + +#include "cmWIXSourceWriter.h" +#include + +/** \class cmWIXFeaturesSourceWriter + * \brief Helper class to generate features.wxs + */ +class cmWIXFeaturesSourceWriter : public cmWIXSourceWriter +{ +public: + cmWIXFeaturesSourceWriter(cmCPackLog* logger, + std::string const& filename); + + void CreateCMakePackageRegistryEntry( + std::string const& package, + std::string const& upgradeGuid); + + void EmitFeatureForComponentGroup(const cmCPackComponentGroup& group); + + void EmitFeatureForComponent(const cmCPackComponent& component); + + void EmitComponentRef(std::string const& id); +}; + +#endif diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx new file mode 100644 index 0000000..0835f3a --- /dev/null +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx @@ -0,0 +1,149 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmWIXFilesSourceWriter.h" + +#include +#include + +cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger, + std::string const& filename): + cmWIXSourceWriter(logger, filename) +{ + +} + +void cmWIXFilesSourceWriter::EmitShortcut( + std::string const& id, + cmWIXShortcut const& shortcut, + bool desktop) +{ + std::string shortcutId; + + if(desktop) + { + shortcutId = "CM_DS"; + } + else + { + shortcutId = "CM_S"; + } + + shortcutId += id; + + std::string fileId = std::string("CM_F") + id; + + BeginElement("Shortcut"); + AddAttribute("Id", shortcutId); + AddAttribute("Name", shortcut.textLabel); + std::string target = "[#" + fileId + "]"; + AddAttribute("Target", target); + AddAttribute("WorkingDirectory", shortcut.workingDirectoryId); + EndElement("Shortcut"); +} + +void cmWIXFilesSourceWriter::EmitRemoveFolder(std::string const& id) +{ + BeginElement("RemoveFolder"); + AddAttribute("Id", id); + AddAttribute("On", "uninstall"); + EndElement("RemoveFolder"); +} + +void cmWIXFilesSourceWriter::EmitStartMenuShortcutRegistryValue( + std::string const& registryKey, + std::string const& cpackComponentName) +{ + EmitInstallRegistryValue(registryKey, cpackComponentName, std::string()); +} + +void cmWIXFilesSourceWriter::EmitDesktopShortcutRegistryValue( + std::string const& registryKey, + std::string const& cpackComponentName) +{ + EmitInstallRegistryValue(registryKey, cpackComponentName, "_desktop"); +} + +void cmWIXFilesSourceWriter::EmitInstallRegistryValue( + std::string const& registryKey, + std::string const& cpackComponentName, + std::string const& suffix) +{ + std::string valueName; + if(!cpackComponentName.empty()) + { + valueName = cpackComponentName + "_"; + } + + valueName += "installed"; + valueName += suffix; + + BeginElement("RegistryValue"); + AddAttribute("Root", "HKCU"); + AddAttribute("Key", registryKey); + AddAttribute("Name", valueName); + AddAttribute("Type", "integer"); + AddAttribute("Value", "1"); + AddAttribute("KeyPath", "yes"); + EndElement("RegistryValue"); +} + +void cmWIXFilesSourceWriter::EmitUninstallShortcut( + std::string const& packageName) +{ + BeginElement("Shortcut"); + AddAttribute("Id", "UNINSTALL"); + AddAttribute("Name", "Uninstall " + packageName); + AddAttribute("Description", "Uninstalls " + packageName); + AddAttribute("Target", "[SystemFolder]msiexec.exe"); + AddAttribute("Arguments", "/x [ProductCode]"); + EndElement("Shortcut"); +} + +std::string cmWIXFilesSourceWriter::EmitComponentFile( + std::string const& directoryId, + std::string const& id, + std::string const& filePath, + cmWIXPatch &patch) +{ + std::string componentId = std::string("CM_C") + id; + std::string fileId = std::string("CM_F") + id; + + BeginElement("DirectoryRef"); + AddAttribute("Id", directoryId); + + BeginElement("Component"); + AddAttribute("Id", componentId); + AddAttribute("Guid", "*"); + + BeginElement("File"); + AddAttribute("Id", fileId); + AddAttribute("Source", filePath); + AddAttribute("KeyPath", "yes"); + + mode_t fileMode = 0; + cmSystemTools::GetPermissions(filePath.c_str(), fileMode); + + if(!(fileMode & S_IWRITE)) + { + AddAttribute("ReadOnly", "yes"); + } + + patch.ApplyFragment(fileId, *this); + EndElement("File"); + + patch.ApplyFragment(componentId, *this); + EndElement("Component"); + EndElement("DirectoryRef"); + + return componentId; +} diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.h b/Source/CPack/WiX/cmWIXFilesSourceWriter.h new file mode 100644 index 0000000..d22d270 --- /dev/null +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.h @@ -0,0 +1,62 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmWIXFilesSourceWriter_h +#define cmWIXFilesSourceWriter_h + +#include "cmWIXSourceWriter.h" +#include "cmWIXShortcut.h" +#include "cmWIXPatch.h" + +#include + +/** \class cmWIXFilesSourceWriter + * \brief Helper class to generate files.wxs + */ +class cmWIXFilesSourceWriter : public cmWIXSourceWriter +{ +public: + cmWIXFilesSourceWriter(cmCPackLog* logger, + std::string const& filename); + + void EmitShortcut( + std::string const& id, + cmWIXShortcut const& shortcut, + bool desktop); + + void EmitRemoveFolder(std::string const& id); + + void EmitStartMenuShortcutRegistryValue( + std::string const& registryKey, + std::string const& cpackComponentName); + + void EmitDesktopShortcutRegistryValue( + std::string const& registryKey, + std::string const& cpackComponentName); + + void EmitUninstallShortcut(std::string const& packageName); + + std::string EmitComponentFile( + std::string const& directoryId, + std::string const& id, + std::string const& filePath, + cmWIXPatch &patch); + +private: + void EmitInstallRegistryValue( + std::string const& registryKey, + std::string const& cpackComponentName, + std::string const& suffix); +}; + + +#endif diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx new file mode 100644 index 0000000..b5202e0 --- /dev/null +++ b/Source/CPack/WiX/cmWIXPatch.cxx @@ -0,0 +1,91 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmWIXPatch.h" + +#include + +cmWIXPatch::cmWIXPatch(cmCPackLog* logger): + Logger(logger) +{ + +} + +void cmWIXPatch::LoadFragments(std::string const& patchFilePath) +{ + cmWIXPatchParser parser(Fragments, Logger); + parser.ParseFile(patchFilePath.c_str()); +} + +void cmWIXPatch::ApplyFragment( + std::string const& id, cmWIXSourceWriter& writer) +{ + cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id); + if(i == Fragments.end()) return; + + const cmWIXPatchElement& fragment = i->second; + for(cmWIXPatchElement::child_list_t::const_iterator + j = fragment.children.begin(); j != fragment.children.end(); ++j) + { + ApplyElement(**j, writer); + } + + Fragments.erase(i); +} + +void cmWIXPatch::ApplyElement( + const cmWIXPatchElement& element, cmWIXSourceWriter& writer) +{ + writer.BeginElement(element.name); + + for(cmWIXPatchElement::attributes_t::const_iterator + i = element.attributes.begin(); i != element.attributes.end(); ++i) + { + writer.AddAttribute(i->first, i->second); + } + + for(cmWIXPatchElement::child_list_t::const_iterator + i = element.children.begin(); i != element.children.end(); ++i) + { + ApplyElement(**i, writer); + } + + writer.EndElement(element.name); +} + + +bool cmWIXPatch::CheckForUnappliedFragments() +{ + std::string fragmentList; + for(cmWIXPatchParser::fragment_map_t::const_iterator + i = Fragments.begin(); i != Fragments.end(); ++i) + { + if(!fragmentList.empty()) + { + fragmentList += ", "; + } + + fragmentList += "'"; + fragmentList += i->first; + fragmentList += "'"; + } + + if(fragmentList.size()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Some XML patch fragments did not have matching IDs: " << + fragmentList << std::endl); + return false; + } + + return true; +} diff --git a/Source/CPack/WiX/cmWIXPatch.h b/Source/CPack/WiX/cmWIXPatch.h new file mode 100644 index 0000000..7b7b2f1 --- /dev/null +++ b/Source/CPack/WiX/cmWIXPatch.h @@ -0,0 +1,45 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmWIXPatch_h +#define cmWIXPatch_h + +#include "cmWIXSourceWriter.h" +#include "cmWIXPatchParser.h" + +#include + +/** \class cmWIXPatch + * \brief Class that maintains and applies patch fragments + */ +class cmWIXPatch +{ +public: + cmWIXPatch(cmCPackLog* logger); + + void LoadFragments(std::string const& patchFilePath); + + void ApplyFragment(std::string const& id, cmWIXSourceWriter& writer); + + bool CheckForUnappliedFragments(); + +private: + void ApplyElement(const cmWIXPatchElement& element, + cmWIXSourceWriter& writer); + + cmCPackLog* Logger; + + cmWIXPatchParser::fragment_map_t Fragments; +}; + + +#endif diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx index 7ceaf1f..10af1f6 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.cxx +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -132,7 +132,7 @@ void cmWIXPatchParser::ReportError(int line, int column, const char* msg) Valid = false; } -void cmWIXPatchParser::ReportValidationError(const std::string& message) +void cmWIXPatchParser::ReportValidationError(std::string const& message) { ReportError(XML_GetCurrentLineNumber(Parser), XML_GetCurrentColumnNumber(Parser), diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h index 91b3b66..da3adf5 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.h +++ b/Source/CPack/WiX/cmWIXPatchParser.h @@ -50,7 +50,7 @@ private: virtual void EndElement(const char *name); virtual void ReportError(int line, int column, const char* msg); - void ReportValidationError(const std::string& message); + void ReportValidationError(std::string const& message); bool IsValid() const; diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx index ddc1d71..f27caa9 100644 --- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx @@ -15,7 +15,7 @@ #include cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter( - const std::string& filename): + std::string const& filename): File(filename.c_str(), std::ios::binary) { StartGroup(); @@ -33,7 +33,7 @@ cmWIXRichTextFormatWriter::~cmWIXRichTextFormatWriter() File.put(0); } -void cmWIXRichTextFormatWriter::AddText(const std::string& text) +void cmWIXRichTextFormatWriter::AddText(std::string const& text) { typedef unsigned char rtf_byte_t; @@ -167,12 +167,12 @@ void cmWIXRichTextFormatWriter::WriteDocumentPrefix() ControlWord("fs20"); } -void cmWIXRichTextFormatWriter::ControlWord(const std::string& keyword) +void cmWIXRichTextFormatWriter::ControlWord(std::string const& keyword) { File << "\\" << keyword; } -void cmWIXRichTextFormatWriter::NewControlWord(const std::string& keyword) +void cmWIXRichTextFormatWriter::NewControlWord(std::string const& keyword) { File << "\\*\\" << keyword; } diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h index 2b665d4..f6327fb 100644 --- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h @@ -22,10 +22,10 @@ class cmWIXRichTextFormatWriter { public: - cmWIXRichTextFormatWriter(const std::string& filename); + cmWIXRichTextFormatWriter(std::string const& filename); ~cmWIXRichTextFormatWriter(); - void AddText(const std::string& text); + void AddText(std::string const& text); private: void WriteHeader(); @@ -35,8 +35,8 @@ private: void WriteDocumentPrefix(); - void ControlWord(const std::string& keyword); - void NewControlWord(const std::string& keyword); + void ControlWord(std::string const& keyword); + void NewControlWord(std::string const& keyword); void StartGroup(); void EndGroup(); diff --git a/Source/CPack/WiX/cmWIXShortcut.h b/Source/CPack/WiX/cmWIXShortcut.h new file mode 100644 index 0000000..93095e0 --- /dev/null +++ b/Source/CPack/WiX/cmWIXShortcut.h @@ -0,0 +1,29 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmWIXFilesShortcut_h +#define cmWIXFilesShortcut_h + +#include + +struct cmWIXShortcut +{ + cmWIXShortcut() + :desktop(false) + {} + + std::string textLabel; + std::string workingDirectoryId; + bool desktop; +}; + +#endif diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index e83c226..aad19da 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -17,7 +17,7 @@ #include cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger, - const std::string& filename, + std::string const& filename, bool isIncludeFile): Logger(logger), File(filename.c_str()), @@ -51,7 +51,7 @@ cmWIXSourceWriter::~cmWIXSourceWriter() EndElement(Elements.back()); } -void cmWIXSourceWriter::BeginElement(const std::string& name) +void cmWIXSourceWriter::BeginElement(std::string const& name) { if(State == BEGIN) { @@ -101,7 +101,7 @@ void cmWIXSourceWriter::EndElement(std::string const& name) } void cmWIXSourceWriter::AddProcessingInstruction( - const std::string& target, const std::string& content) + std::string const& target, std::string const& content) { if(State == BEGIN) { @@ -116,7 +116,7 @@ void cmWIXSourceWriter::AddProcessingInstruction( } void cmWIXSourceWriter::AddAttribute( - const std::string& key, const std::string& value) + std::string const& key, std::string const& value) { std::string utf8 = WindowsCodepageToUtf8(value); @@ -124,7 +124,7 @@ void cmWIXSourceWriter::AddAttribute( } void cmWIXSourceWriter::AddAttributeUnlessEmpty( - const std::string& key, const std::string& value) + std::string const& key, std::string const& value) { if(value.size()) { @@ -132,7 +132,7 @@ void cmWIXSourceWriter::AddAttributeUnlessEmpty( } } -std::string cmWIXSourceWriter::WindowsCodepageToUtf8(const std::string& value) +std::string cmWIXSourceWriter::WindowsCodepageToUtf8(std::string const& value) { if(value.empty()) { @@ -184,7 +184,7 @@ void cmWIXSourceWriter::Indent(size_t count) } std::string cmWIXSourceWriter::EscapeAttributeValue( - const std::string& value) + std::string const& value) { std::string result; result.reserve(value.size()); diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h index 894ad78..65b7240 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.h +++ b/Source/CPack/WiX/cmWIXSourceWriter.h @@ -26,24 +26,24 @@ class cmWIXSourceWriter { public: cmWIXSourceWriter(cmCPackLog* logger, - const std::string& filename, bool isIncludeFile = false); + std::string const& filename, bool isIncludeFile = false); ~cmWIXSourceWriter(); - void BeginElement(const std::string& name); + void BeginElement(std::string const& name); - void EndElement(const std::string& name); + void EndElement(std::string const& name); void AddProcessingInstruction( - const std::string& target, const std::string& content); + std::string const& target, std::string const& content); void AddAttribute( - const std::string& key, const std::string& value); + std::string const& key, std::string const& value); void AddAttributeUnlessEmpty( - const std::string& key, const std::string& value); + std::string const& key, std::string const& value); - static std::string WindowsCodepageToUtf8(const std::string& value); + static std::string WindowsCodepageToUtf8(std::string const& value); private: enum State @@ -56,7 +56,7 @@ private: void Indent(size_t count); - static std::string EscapeAttributeValue(const std::string& value); + static std::string EscapeAttributeValue(std::string const& value); cmCPackLog* Logger; -- cgit v0.12 From 041485bc163c69e5eb2829bc78857a958cad7e87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matth=C3=A4us=20G=2E=20Chajdas?= Date: Sat, 22 Feb 2014 19:57:17 +0100 Subject: Add FindOpenCL module --- Help/manual/cmake-modules.7.rst | 1 + Help/module/FindOpenCL.rst | 1 + Modules/FindOpenCL.cmake | 134 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 Help/module/FindOpenCL.rst create mode 100644 Modules/FindOpenCL.cmake diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index 7a06be6..2bbe622 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -138,6 +138,7 @@ All Modules /module/FindMPEG /module/FindMPI /module/FindOpenAL + /module/FindOpenCL /module/FindOpenGL /module/FindOpenMP /module/FindOpenSceneGraph diff --git a/Help/module/FindOpenCL.rst b/Help/module/FindOpenCL.rst new file mode 100644 index 0000000..e87e289 --- /dev/null +++ b/Help/module/FindOpenCL.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/FindOpenCL.cmake diff --git a/Modules/FindOpenCL.cmake b/Modules/FindOpenCL.cmake new file mode 100644 index 0000000..eee06bf --- /dev/null +++ b/Modules/FindOpenCL.cmake @@ -0,0 +1,134 @@ +#.rst: +# FindOpenCL +# ---------- +# +# Try to find OpenCL +# +# Once done this will define:: +# +# OpenCL_FOUND - True if OpenCL was found +# OpenCL_INCLUDE_DIRS - include directories for OpenCL +# OpenCL_LIBRARIES - link against this library to use OpenCL +# OpenCL_VERSION_STRING - Highest supported OpenCL version (eg. 1.2) +# OpenCL_VERSION_MAJOR - The major version of the OpenCL implementation +# OpenCL_VERSION_MINOR - The minor version of the OpenCL implementation +# +# The module will also define two cache variables:: +# +# OpenCL_INCLUDE_DIR - the OpenCL include directory +# OpenCL_LIBRARY - the path to the OpenCL library +# + +#============================================================================= +# Copyright 2014 Matthaeus G. Chajdas +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +function(_FIND_OPENCL_VERSION) + include(CheckSymbolExists) + include(CMakePushCheckState) + + CMAKE_PUSH_CHECK_STATE() + foreach(VERSION "2_0" "1_2" "1_1" "1_0") + set(CMAKE_REQUIRED_INCLUDES "${OpenCL_INCLUDE_DIR}") + + if(APPLE) + CHECK_SYMBOL_EXISTS( + CL_VERSION_${VERSION} + "${OpenCL_INCLUDE_DIR}/OpenCL/cl.h" + OPENCL_VERSION_${VERSION}) + else() + CHECK_SYMBOL_EXISTS( + CL_VERSION_${VERSION} + "${OpenCL_INCLUDE_DIR}/CL/cl.h" + OPENCL_VERSION_${VERSION}) + endif() + + if(OPENCL_VERSION_${VERSION}) + string(REPLACE "_" "." VERSION "${VERSION}") + set(OpenCL_VERSION_STRING ${VERSION} PARENT_SCOPE) + string(REGEX MATCHALL "[0-9]+" version_components "${VERSION}") + list(GET version_components 0 major_version) + list(GET version_components 1 minor_version) + set(OpenCL_VERSION_MAJOR ${major_version} PARENT_SCOPE) + set(OpenCL_VERSION_MINOR ${minor_version} PARENT_SCOPE) + break() + endif() + endforeach() + CMAKE_POP_CHECK_STATE() +endfunction() + +find_path(OpenCL_INCLUDE_DIR + NAMES + CL/cl.h OpenCL/cl.h + PATHS ENV + "PROGRAMFILES(X86)" + AMDAPPSDKROOT + INTELOCLSDKROOT + NVSDKCOMPUTE_ROOT + CUDA_PATH + ATISTREAMSDKROOT + PATH_SUFFIXES + OpenCL/common/inc + "AMD APP/include") + +_FIND_OPENCL_VERSION() + +if(WIN32) + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + find_library(OpenCL_LIBRARY + NAMES OpenCL + PATHS ENV + "PROGRAMFILES(X86)" + AMDAPPSDKROOT + INTELOCLSDKROOT + CUDA_PATH + NVSDKCOMPUTE_ROOT + ATISTREAMSDKROOT + PATH_SUFFIXES + "AMD APP/lib/x86" + lib/x86 + lib/Win32 + OpenCL/common/lib/Win32) + elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + find_library(OpenCL_LIBRARY + NAMES OpenCL + PATHS ENV + "PROGRAMFILES(X86)" + AMDAPPSDKROOT + INTELOCLSDKROOT + CUDA_PATH + NVSDKCOMPUTE_ROOT + ATISTREAMSDKROOT + PATH_SUFFIXES + "AMD APP/lib/x86_64" + lib/x86_64 + lib/x64 + OpenCL/common/lib/x64) + endif() +else() + find_library(OpenCL_LIBRARY + NAMES OpenCL) +endif() + +set(OpenCL_LIBRARIES ${OpenCL_LIBRARY}) +set(OpenCL_INCLUDE_DIRS ${OpenCL_INCLUDE_DIR}) + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args( + OpenCL + FOUND_VAR OpenCL_FOUND + REQUIRED_VARS OpenCL_LIBRARY OpenCL_INCLUDE_DIR + VERSION_VAR OpenCL_VERSION_STRING) + +mark_as_advanced( + OpenCL_INCLUDE_DIR + OpenCL_LIBRARY) -- cgit v0.12 From fba51b096e2d8ec281653aa05720c11dc9b9bfe6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 24 Feb 2014 14:15:21 -0500 Subject: MSVC: Add properties to configure compiler PDB files (#14762) Since commit v2.8.12~437^2~2 (VS: Separate compiler and linker PDB files 2013-04-05) we no longer set /Fd with the PDB_NAME or PDB_OUTPUT_DIRECTORY properties. Those properties now exclusively handle linker PDB files. Since STATIC libraries do not link their compiler PDB file becomes more important. Add new target properties "COMPILE_PDB_NAME[_]" and "COMPILE_PDB_OUTPUT_DIRECTORY[_]" to specify the compiler PDB file location and pass the value to the MSVC /Fd option. --- Help/manual/cmake-properties.7.rst | 4 ++ Help/manual/cmake-variables.7.rst | 2 + Help/prop_tgt/COMPILE_PDB_NAME.rst | 11 +++++ Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst | 10 ++++ Help/prop_tgt/COMPILE_PDB_NOTE.txt | 8 +++ Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst | 13 +++++ .../COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst | 16 ++++++ Help/prop_tgt/PDB_NAME.rst | 1 + Help/prop_tgt/PDB_NAME_CONFIG.rst | 1 + Help/prop_tgt/PDB_NOTE.txt | 2 +- Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst | 1 + Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst | 1 + Help/release/dev/msvc-compiler-pdb-files.rst | 10 ++++ .../CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst | 8 +++ .../CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst | 11 +++++ Modules/Platform/Windows-MSVC.cmake | 2 +- Source/cmLocalGenerator.cxx | 7 +++ Source/cmLocalGenerator.h | 1 + Source/cmLocalVisualStudio7Generator.cxx | 13 ++++- Source/cmMakefileExecutableTargetGenerator.cxx | 4 ++ Source/cmMakefileLibraryTargetGenerator.cxx | 4 ++ Source/cmMakefileTargetGenerator.cxx | 17 +++++++ Source/cmNinjaTargetGenerator.cxx | 16 ++++++ Source/cmTarget.cxx | 57 ++++++++++++++++++++++ Source/cmTarget.h | 12 +++++ Source/cmVisualStudio10TargetGenerator.cxx | 11 +++++ Tests/PDBDirectoryAndName/CMakeLists.txt | 30 +++++++++--- 27 files changed, 262 insertions(+), 11 deletions(-) create mode 100644 Help/prop_tgt/COMPILE_PDB_NAME.rst create mode 100644 Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst create mode 100644 Help/prop_tgt/COMPILE_PDB_NOTE.txt create mode 100644 Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst create mode 100644 Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst create mode 100644 Help/release/dev/msvc-compiler-pdb-files.rst create mode 100644 Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst create mode 100644 Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index d315fcb..6ea5839 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -100,6 +100,10 @@ Properties on Targets /prop_tgt/COMPILE_DEFINITIONS /prop_tgt/COMPILE_FLAGS /prop_tgt/COMPILE_OPTIONS + /prop_tgt/COMPILE_PDB_NAME + /prop_tgt/COMPILE_PDB_NAME_CONFIG + /prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY + /prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG /prop_tgt/CONFIG_OUTPUT_NAME /prop_tgt/CONFIG_POSTFIX /prop_tgt/DEBUG_POSTFIX diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index c4ae193..5f2ba28 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -198,6 +198,8 @@ Variables that Control the Build /variable/CMAKE_AUTOUIC /variable/CMAKE_AUTOUIC_OPTIONS /variable/CMAKE_BUILD_WITH_INSTALL_RPATH + /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY + /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG /variable/CMAKE_CONFIG_POSTFIX /variable/CMAKE_DEBUG_POSTFIX /variable/CMAKE_EXE_LINKER_FLAGS_CONFIG diff --git a/Help/prop_tgt/COMPILE_PDB_NAME.rst b/Help/prop_tgt/COMPILE_PDB_NAME.rst new file mode 100644 index 0000000..24a9f62 --- /dev/null +++ b/Help/prop_tgt/COMPILE_PDB_NAME.rst @@ -0,0 +1,11 @@ +COMPILE_PDB_NAME +---------------- + +Output name for the MS debug symbol ``.pdb`` file generated by the +compiler while building source files. + +This property specifies the base name for the debug symbols file. +If not set, the default is unspecified. + +.. |PDB_XXX| replace:: :prop_tgt:`PDB_NAME` +.. include:: COMPILE_PDB_NOTE.txt diff --git a/Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst b/Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst new file mode 100644 index 0000000..e4077f5 --- /dev/null +++ b/Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst @@ -0,0 +1,10 @@ +COMPILE_PDB_NAME_ +------------------------- + +Per-configuration output name for the MS debug symbol ``.pdb`` file +generated by the compiler while building source files. + +This is the configuration-specific version of :prop_tgt:`COMPILE_PDB_NAME`. + +.. |PDB_XXX| replace:: :prop_tgt:`PDB_NAME_` +.. include:: COMPILE_PDB_NOTE.txt diff --git a/Help/prop_tgt/COMPILE_PDB_NOTE.txt b/Help/prop_tgt/COMPILE_PDB_NOTE.txt new file mode 100644 index 0000000..5941d72 --- /dev/null +++ b/Help/prop_tgt/COMPILE_PDB_NOTE.txt @@ -0,0 +1,8 @@ +.. note:: + The compiler-generated program database files are specified by the + ``/Fd`` compiler flag and are not the same as linker-generated + program database files specified by the ``/pdb`` linker flag. + Use the |PDB_XXX| property to specify the latter. + + This property is not implemented by the :generator:`Visual Studio 6` + generator. diff --git a/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst new file mode 100644 index 0000000..34f49be --- /dev/null +++ b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst @@ -0,0 +1,13 @@ +COMPILE_PDB_OUTPUT_DIRECTORY +---------------------------- + +Output directory for the MS debug symbol ``.pdb`` file +generated by the compiler while building source files. + +This property specifies the directory into which the MS debug symbols +will be placed by the compiler. This property is initialized by the +value of the :variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY` variable +if it is set when a target is created. + +.. |PDB_XXX| replace:: :prop_tgt:`PDB_OUTPUT_DIRECTORY` +.. include:: COMPILE_PDB_NOTE.txt diff --git a/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst new file mode 100644 index 0000000..52ef013 --- /dev/null +++ b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst @@ -0,0 +1,16 @@ +COMPILE_PDB_OUTPUT_DIRECTORY_ +------------------------------------- + +Per-configuration output directory for the MS debug symbol ``.pdb`` file +generated by the compiler while building source files. + +This is a per-configuration version of +:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY`, +but multi-configuration generators (VS, Xcode) do NOT append a +per-configuration subdirectory to the specified directory. This +property is initialized by the value of the +:variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_` variable +if it is set when a target is created. + +.. |PDB_XXX| replace:: :prop_tgt:`PDB_OUTPUT_DIRECTORY_` +.. include:: COMPILE_PDB_NOTE.txt diff --git a/Help/prop_tgt/PDB_NAME.rst b/Help/prop_tgt/PDB_NAME.rst index 333c865..479dec3 100644 --- a/Help/prop_tgt/PDB_NAME.rst +++ b/Help/prop_tgt/PDB_NAME.rst @@ -7,4 +7,5 @@ linker for an executable or shared library target. This property specifies the base name for the debug symbols file. If not set, the logical target name is used by default. +.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_NAME` .. include:: PDB_NOTE.txt diff --git a/Help/prop_tgt/PDB_NAME_CONFIG.rst b/Help/prop_tgt/PDB_NAME_CONFIG.rst index 7bf9e43..cb3121c 100644 --- a/Help/prop_tgt/PDB_NAME_CONFIG.rst +++ b/Help/prop_tgt/PDB_NAME_CONFIG.rst @@ -6,4 +6,5 @@ generated by the linker for an executable or shared library target. This is the configuration-specific version of :prop_tgt:`PDB_NAME`. +.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_NAME_` .. include:: PDB_NOTE.txt diff --git a/Help/prop_tgt/PDB_NOTE.txt b/Help/prop_tgt/PDB_NOTE.txt index c03bd3a..f90ea81 100644 --- a/Help/prop_tgt/PDB_NOTE.txt +++ b/Help/prop_tgt/PDB_NOTE.txt @@ -6,7 +6,7 @@ The linker-generated program database files are specified by the ``/pdb`` linker flag and are not the same as compiler-generated program database files specified by the ``/Fd`` compiler flag. - This property does not influence the latter. + Use the |COMPILE_PDB_XXX| property to specify the latter. This property is not implemented by the :generator:`Visual Studio 6` generator. diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst index 4877368..730cf57 100644 --- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst +++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst @@ -9,4 +9,5 @@ will be placed by the linker. This property is initialized by the value of the :variable:`CMAKE_PDB_OUTPUT_DIRECTORY` variable if it is set when a target is created. +.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY` .. include:: PDB_NOTE.txt diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst index 7bbc237..6037fa0 100644 --- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst @@ -11,4 +11,5 @@ property is initialized by the value of the :variable:`CMAKE_PDB_OUTPUT_DIRECTORY_` variable if it is set when a target is created. +.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY_` .. include:: PDB_NOTE.txt diff --git a/Help/release/dev/msvc-compiler-pdb-files.rst b/Help/release/dev/msvc-compiler-pdb-files.rst new file mode 100644 index 0000000..d06d202 --- /dev/null +++ b/Help/release/dev/msvc-compiler-pdb-files.rst @@ -0,0 +1,10 @@ +msvc-compiler-pdb-files +----------------------- + +* New :prop_tgt:`COMPILE_PDB_NAME` and + :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY` target properties + were introduced to specify the MSVC compiler program database + file location (``cl /Fd``). This complements the existing + :prop_tgt:`PDB_NAME` and :prop_tgt:`PDB_OUTPUT_DIRECTORY` + target properties that specify the linker program database + file location (``link /pdb``). diff --git a/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst new file mode 100644 index 0000000..ea33c7d --- /dev/null +++ b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst @@ -0,0 +1,8 @@ +CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY +---------------------------------- + +Output directory for MS debug symbol ``.pdb`` files +generated by the compiler while building source files. + +This variable is used to initialize the +:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY` property on all the targets. diff --git a/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst new file mode 100644 index 0000000..fdeb9ab --- /dev/null +++ b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst @@ -0,0 +1,11 @@ +CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_ +------------------------------------------- + +Per-configuration output directory for MS debug symbol ``.pdb`` files +generated by the compiler while building source files. + +This is a per-configuration version of +:variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY`. +This variable is used to initialize the +:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY_` +property on all the targets. diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index e29aaf4..5732170 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -241,7 +241,7 @@ macro(__windows_compiler_msvc lang) set(CMAKE_${lang}_CREATE_STATIC_LIBRARY " /lib ${CMAKE_CL_NOLOGO} /out: ") set(CMAKE_${lang}_COMPILE_OBJECT - " ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} /Fo /Fd/${_FS_${lang}} -c ${CMAKE_END_TEMP_FILE}") + " ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} /Fo /Fd${_FS_${lang}} -c ${CMAKE_END_TEMP_FILE}") set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE " > ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} -E ${CMAKE_END_TEMP_FILE}") set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index aca195c..4266dd0 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -901,6 +901,13 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, return replaceValues.TargetPDB; } } + if(replaceValues.TargetCompilePDB) + { + if(variable == "TARGET_COMPILE_PDB") + { + return replaceValues.TargetCompilePDB; + } + } if(replaceValues.DependencyFile ) { if(variable == "DEP_FILE") diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 9764813..0f7fd25 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -245,6 +245,7 @@ public: } cmTarget* CMTarget; const char* TargetPDB; + const char* TargetCompilePDB; const char* TargetVersionMajor; const char* TargetVersionMinor; const char* Language; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 212b06b..ce24d8d 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -660,7 +660,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, switch(target.GetType()) { case cmTarget::OBJECT_LIBRARY: - targetBuilds = false; // TODO: PDB for object library? + targetBuilds = false; // no manifest tool for object library case cmTarget::STATIC_LIBRARY: projectType = "typeStaticLibrary"; configType = "4"; @@ -846,6 +846,17 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.OutputFlagMap(fout, "\t\t\t\t"); targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX"); fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n"; + if(target.GetType() <= cmTarget::OBJECT_LIBRARY) + { + // Specify the compiler program database file if configured. + std::string pdb = target.GetCompilePDBPath(configName); + if(!pdb.empty()) + { + fout << "\t\t\t\tProgramDataBaseFileName=\"" + << this->ConvertToXMLOutputPathSingle(pdb.c_str()) + << "\"\n"; + } + } fout << "/>\n"; // end of FortranProject) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 664d73e..03fdda2 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -129,6 +129,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } } + std::string compilePdbOutputPath = + this->Target->GetCompilePDBDirectory(this->ConfigName); + cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); + std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(pdbOutputPath.c_str()); pdbOutputPath += "/"; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index b9af638..807aca8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -321,6 +321,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } } + std::string compilePdbOutputPath = + this->Target->GetCompilePDBDirectory(this->ConfigName); + cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); + std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(pdbOutputPath.c_str()); pdbOutputPath += "/"; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index c3ca85d..c6ade7f 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -624,9 +624,11 @@ cmMakefileTargetGenerator std::string targetOutPathReal; std::string targetOutPathPDB; + std::string targetOutPathCompilePDB; { std::string targetFullPathReal; std::string targetFullPathPDB; + std::string targetFullPathCompilePDB; if(this->Target->GetType() == cmTarget::EXECUTABLE || this->Target->GetType() == cmTarget::STATIC_LIBRARY || this->Target->GetType() == cmTarget::SHARED_LIBRARY || @@ -638,12 +640,26 @@ cmMakefileTargetGenerator targetFullPathPDB += "/"; targetFullPathPDB += this->Target->GetPDBName(this->ConfigName); } + if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) + { + targetFullPathCompilePDB = + this->Target->GetCompilePDBPath(this->ConfigName); + if(targetFullPathCompilePDB.empty()) + { + targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/"; + } + } + targetOutPathReal = this->Convert(targetFullPathReal.c_str(), cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); targetOutPathPDB = this->Convert(targetFullPathPDB.c_str(),cmLocalGenerator::NONE, cmLocalGenerator::SHELL); + targetOutPathCompilePDB = + this->Convert(targetFullPathCompilePDB.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); } cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; @@ -651,6 +667,7 @@ cmMakefileTargetGenerator vars.Language = lang; vars.Target = targetOutPathReal.c_str(); vars.TargetPDB = targetOutPathPDB.c_str(); + vars.TargetCompilePDB = targetOutPathCompilePDB.c_str(); vars.Source = sourceFile.c_str(); std::string shellObj = this->Convert(obj.c_str(), diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 900af8d..eaeddef 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -320,6 +320,7 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID")) { std::string pdbPath; + std::string compilePdbPath; if(this->Target->GetType() == cmTarget::EXECUTABLE || this->Target->GetType() == cmTarget::STATIC_LIBRARY || this->Target->GetType() == cmTarget::SHARED_LIBRARY || @@ -329,11 +330,25 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const pdbPath += "/"; pdbPath += this->Target->GetPDBName(this->GetConfigName()); } + if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) + { + compilePdbPath = this->Target->GetCompilePDBPath(this->GetConfigName()); + if(compilePdbPath.empty()) + { + compilePdbPath = this->Target->GetSupportDirectory() + "/"; + } + } vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat( ConvertToNinjaPath(pdbPath.c_str()).c_str(), cmLocalGenerator::SHELL); + vars["TARGET_COMPILE_PDB"] = + this->GetLocalGenerator()->ConvertToOutputFormat( + ConvertToNinjaPath(compilePdbPath.c_str()).c_str(), + cmLocalGenerator::SHELL); + EnsureParentDirectoryExists(pdbPath); + EnsureParentDirectoryExists(compilePdbPath); return true; } return false; @@ -362,6 +377,7 @@ cmNinjaTargetGenerator vars.Object = "$out"; vars.Defines = "$DEFINES"; vars.TargetPDB = "$TARGET_PDB"; + vars.TargetCompilePDB = "$TARGET_COMPILE_PDB"; vars.ObjectDir = "$OBJECT_DIR"; cmMakefile* mf = this->GetMakefile(); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a50d6ad..7a0df74 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -74,6 +74,7 @@ struct cmTarget::ImportInfo //---------------------------------------------------------------------------- struct cmTarget::CompileInfo { + std::string CompilePdbDir; }; struct TargetConfigPair : public std::pair { @@ -275,6 +276,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("PDB_OUTPUT_DIRECTORY", 0); + this->SetPropertyDefault("COMPILE_PDB_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("Fortran_FORMAT", 0); this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0); this->SetPropertyDefault("GNUtoMS", 0); @@ -303,6 +305,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) "LIBRARY_OUTPUT_DIRECTORY_", "RUNTIME_OUTPUT_DIRECTORY_", "PDB_OUTPUT_DIRECTORY_", + "COMPILE_PDB_OUTPUT_DIRECTORY_", "MAP_IMPORTED_CONFIG_", 0}; for(std::vector::iterator ci = configNames.begin(); @@ -2517,6 +2520,7 @@ cmTarget::CompileInfo const* cmTarget::GetCompileInfo(const char* config) const if(i == this->Internal->CompileInfoMap.end()) { CompileInfo info; + this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); CompileInfoMapType::value_type entry(config_upper, info); i = this->Internal->CompileInfoMap.insert(entry).first; } @@ -2553,6 +2557,16 @@ std::string cmTarget::GetPDBDirectory(const char* config) const } //---------------------------------------------------------------------------- +std::string cmTarget::GetCompilePDBDirectory(const char* config) const +{ + if(CompileInfo const* info = this->GetCompileInfo(config)) + { + return info->CompilePdbDir; + } + return ""; +} + +//---------------------------------------------------------------------------- const char* cmTarget::GetLocation(const char* config) const { if (this->IsImported()) @@ -3213,6 +3227,49 @@ std::string cmTarget::GetPDBName(const char* config) const } //---------------------------------------------------------------------------- +std::string cmTarget::GetCompilePDBName(const char* config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->GetFullNameInternal(config, false, prefix, base, suffix); + + // Check for a per-configuration output directory target property. + std::string configUpper = cmSystemTools::UpperCase(config? config : ""); + std::string configProp = "COMPILE_PDB_NAME_"; + configProp += configUpper; + const char* config_name = this->GetProperty(configProp.c_str()); + if(config_name && *config_name) + { + return prefix + config_name + ".pdb"; + } + + const char* name = this->GetProperty("COMPILE_PDB_NAME"); + if(name && *name) + { + return prefix + name + ".pdb"; + } + + return ""; +} + +//---------------------------------------------------------------------------- +std::string cmTarget::GetCompilePDBPath(const char* config) const +{ + std::string dir = this->GetCompilePDBDirectory(config); + std::string name = this->GetCompilePDBName(config); + if(dir.empty() && !name.empty()) + { + dir = this->GetPDBDirectory(config); + } + if(!dir.empty()) + { + dir += "/"; + } + return dir + name; +} + +//---------------------------------------------------------------------------- bool cmTarget::HasSOName(const char* config) const { // soname is supported only for shared libraries and modules, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 6787706..a3f544c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -342,6 +342,12 @@ public: pdb output directory is given. */ std::string GetPDBDirectory(const char* config) const; + /** Get the directory in which to place the target compiler .pdb file. + If the configuration name is given then the generator will add its + subdirectory for that configuration. Otherwise just the canonical + compiler pdb output directory is given. */ + std::string GetCompilePDBDirectory(const char* config = 0) const; + /** Get the location of the target in the build tree for the given configuration. This location is suitable for use as the LOCATION target property. */ @@ -377,6 +383,12 @@ public: /** Get the name of the pdb file for the target. */ std::string GetPDBName(const char* config) const; + /** Get the name of the compiler pdb file for the target. */ + std::string GetCompilePDBName(const char* config=0) const; + + /** Get the path for the MSVC /Fd option for this target. */ + std::string GetCompilePDBPath(const char* config=0) const; + /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const char* config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ed7e243..b1f0974 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1427,6 +1427,17 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", "\n", "CXX"); this->WriteString("$(IntDir)\n", 3); + + // Specify the compiler program database file if configured. + std::string pdb = this->Target->GetCompilePDBPath(configName.c_str()); + if(!pdb.empty()) + { + this->ConvertToWindowsSlash(pdb); + this->WriteString("", 3); + *this->BuildFileStream << cmVS10EscapeXML(pdb) + << "\n"; + } + this->WriteString("\n", 2); } diff --git a/Tests/PDBDirectoryAndName/CMakeLists.txt b/Tests/PDBDirectoryAndName/CMakeLists.txt index 28e46b1..90af600 100644 --- a/Tests/PDBDirectoryAndName/CMakeLists.txt +++ b/Tests/PDBDirectoryAndName/CMakeLists.txt @@ -6,6 +6,13 @@ if(NOT MSVC AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$") message(FATAL_ERROR "The PDBDirectoryAndName test works only with MSVC or Intel") endif() +# Intel 11.1 does not support /Fd but Intel 14.0 does. +# TODO: Did a version in between these add it? +if(CMAKE_C_COMPILER_ID STREQUAL Intel AND + CMAKE_C_COMPILER_VERSION VERSION_LESS 14.0) + set(NO_COMPILE_PDB 1) +endif() + set(my_targets "") add_library(mylibA SHARED mylibA.c) @@ -17,12 +24,12 @@ list(APPEND my_targets mylibA) add_library(mylibB STATIC mylibB.c) set_target_properties(mylibB PROPERTIES - PDB_NAME "mylibB_Special" - PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibB_PDB" + COMPILE_PDB_NAME "mylibB_Special" + COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibB_PDB" ) -# TODO: The only .pdb available for a static library is that generated -# by the compiler /Fd option which is not the same as the linker /pdb. -# list(APPEND my_targets mylibB) +if(NOT NO_COMPILE_PDB) + list(APPEND my_targets mylibB) +endif() add_library(mylibC SHARED mylibC.c) set_target_properties(mylibC PROPERTIES @@ -32,10 +39,11 @@ list(APPEND my_targets mylibC) add_library(mylibD STATIC mylibD.c) set_target_properties(mylibD PROPERTIES - PDB_NAME "mylibD_Special" + COMPILE_PDB_NAME "mylibD_Special" ) -# TODO: See comment for mylibB. -# list(APPEND my_targets mylibD) +if(NOT NO_COMPILE_PDB) + list(APPEND my_targets mylibD) +endif() add_executable(myexe myexe.c) set_target_properties(myexe PROPERTIES @@ -66,6 +74,12 @@ set(pdbs "") foreach(t ${my_targets}) get_property(pdb_name TARGET ${t} PROPERTY PDB_NAME) get_property(pdb_dir TARGET ${t} PROPERTY PDB_OUTPUT_DIRECTORY) + if(NOT pdb_name) + get_property(pdb_name TARGET ${t} PROPERTY COMPILE_PDB_NAME) + endif() + if(NOT pdb_dir) + get_property(pdb_dir TARGET ${t} PROPERTY COMPILE_PDB_OUTPUT_DIRECTORY) + endif() if(NOT pdb_dir) set(pdb_dir ${CMAKE_CURRENT_BINARY_DIR}) endif() -- cgit v0.12 From 0ea3aee825dc45e56bcdffce407fa4decd29cd8a Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 24 Feb 2014 14:15:21 -0500 Subject: MSVC: Add properties to configure compiler PDB files (#14763) Since commit v2.8.12~437^2~2 (VS: Separate compiler and linker PDB files 2013-04-05) we no longer set /Fd with the PDB_NAME or PDB_OUTPUT_DIRECTORY properties. Those properties now exclusively handle linker PDB files. Since STATIC libraries do not link their compiler PDB file becomes more important. Add new target properties "COMPILE_PDB_NAME[_]" and "COMPILE_PDB_OUTPUT_DIRECTORY[_]" to specify the compiler PDB file location and pass the value to the MSVC /Fd option. --- Help/manual/cmake-properties.7.rst | 4 ++ Help/manual/cmake-variables.7.rst | 2 + Help/prop_tgt/COMPILE_PDB_NAME.rst | 11 +++++ Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst | 10 ++++ Help/prop_tgt/COMPILE_PDB_NOTE.txt | 8 +++ Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst | 13 +++++ .../COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst | 16 ++++++ Help/prop_tgt/PDB_NAME.rst | 1 + Help/prop_tgt/PDB_NAME_CONFIG.rst | 1 + Help/prop_tgt/PDB_NOTE.txt | 2 +- Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst | 1 + Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst | 1 + Help/release/dev/msvc-compiler-pdb-files.rst | 10 ++++ .../CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst | 8 +++ .../CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst | 11 +++++ Modules/Platform/Windows-MSVC.cmake | 2 +- Source/cmLocalGenerator.cxx | 7 +++ Source/cmLocalGenerator.h | 1 + Source/cmLocalVisualStudio7Generator.cxx | 13 ++++- Source/cmMakefileExecutableTargetGenerator.cxx | 4 ++ Source/cmMakefileLibraryTargetGenerator.cxx | 4 ++ Source/cmMakefileTargetGenerator.cxx | 17 +++++++ Source/cmNinjaTargetGenerator.cxx | 16 ++++++ Source/cmTarget.cxx | 57 ++++++++++++++++++++++ Source/cmTarget.h | 12 +++++ Source/cmVisualStudio10TargetGenerator.cxx | 11 +++++ Tests/PDBDirectoryAndName/CMakeLists.txt | 30 +++++++++--- 27 files changed, 262 insertions(+), 11 deletions(-) create mode 100644 Help/prop_tgt/COMPILE_PDB_NAME.rst create mode 100644 Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst create mode 100644 Help/prop_tgt/COMPILE_PDB_NOTE.txt create mode 100644 Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst create mode 100644 Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst create mode 100644 Help/release/dev/msvc-compiler-pdb-files.rst create mode 100644 Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst create mode 100644 Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index d315fcb..6ea5839 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -100,6 +100,10 @@ Properties on Targets /prop_tgt/COMPILE_DEFINITIONS /prop_tgt/COMPILE_FLAGS /prop_tgt/COMPILE_OPTIONS + /prop_tgt/COMPILE_PDB_NAME + /prop_tgt/COMPILE_PDB_NAME_CONFIG + /prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY + /prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG /prop_tgt/CONFIG_OUTPUT_NAME /prop_tgt/CONFIG_POSTFIX /prop_tgt/DEBUG_POSTFIX diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index c4ae193..5f2ba28 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -198,6 +198,8 @@ Variables that Control the Build /variable/CMAKE_AUTOUIC /variable/CMAKE_AUTOUIC_OPTIONS /variable/CMAKE_BUILD_WITH_INSTALL_RPATH + /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY + /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG /variable/CMAKE_CONFIG_POSTFIX /variable/CMAKE_DEBUG_POSTFIX /variable/CMAKE_EXE_LINKER_FLAGS_CONFIG diff --git a/Help/prop_tgt/COMPILE_PDB_NAME.rst b/Help/prop_tgt/COMPILE_PDB_NAME.rst new file mode 100644 index 0000000..24a9f62 --- /dev/null +++ b/Help/prop_tgt/COMPILE_PDB_NAME.rst @@ -0,0 +1,11 @@ +COMPILE_PDB_NAME +---------------- + +Output name for the MS debug symbol ``.pdb`` file generated by the +compiler while building source files. + +This property specifies the base name for the debug symbols file. +If not set, the default is unspecified. + +.. |PDB_XXX| replace:: :prop_tgt:`PDB_NAME` +.. include:: COMPILE_PDB_NOTE.txt diff --git a/Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst b/Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst new file mode 100644 index 0000000..e4077f5 --- /dev/null +++ b/Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst @@ -0,0 +1,10 @@ +COMPILE_PDB_NAME_ +------------------------- + +Per-configuration output name for the MS debug symbol ``.pdb`` file +generated by the compiler while building source files. + +This is the configuration-specific version of :prop_tgt:`COMPILE_PDB_NAME`. + +.. |PDB_XXX| replace:: :prop_tgt:`PDB_NAME_` +.. include:: COMPILE_PDB_NOTE.txt diff --git a/Help/prop_tgt/COMPILE_PDB_NOTE.txt b/Help/prop_tgt/COMPILE_PDB_NOTE.txt new file mode 100644 index 0000000..5941d72 --- /dev/null +++ b/Help/prop_tgt/COMPILE_PDB_NOTE.txt @@ -0,0 +1,8 @@ +.. note:: + The compiler-generated program database files are specified by the + ``/Fd`` compiler flag and are not the same as linker-generated + program database files specified by the ``/pdb`` linker flag. + Use the |PDB_XXX| property to specify the latter. + + This property is not implemented by the :generator:`Visual Studio 6` + generator. diff --git a/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst new file mode 100644 index 0000000..34f49be --- /dev/null +++ b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst @@ -0,0 +1,13 @@ +COMPILE_PDB_OUTPUT_DIRECTORY +---------------------------- + +Output directory for the MS debug symbol ``.pdb`` file +generated by the compiler while building source files. + +This property specifies the directory into which the MS debug symbols +will be placed by the compiler. This property is initialized by the +value of the :variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY` variable +if it is set when a target is created. + +.. |PDB_XXX| replace:: :prop_tgt:`PDB_OUTPUT_DIRECTORY` +.. include:: COMPILE_PDB_NOTE.txt diff --git a/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst new file mode 100644 index 0000000..52ef013 --- /dev/null +++ b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst @@ -0,0 +1,16 @@ +COMPILE_PDB_OUTPUT_DIRECTORY_ +------------------------------------- + +Per-configuration output directory for the MS debug symbol ``.pdb`` file +generated by the compiler while building source files. + +This is a per-configuration version of +:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY`, +but multi-configuration generators (VS, Xcode) do NOT append a +per-configuration subdirectory to the specified directory. This +property is initialized by the value of the +:variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_` variable +if it is set when a target is created. + +.. |PDB_XXX| replace:: :prop_tgt:`PDB_OUTPUT_DIRECTORY_` +.. include:: COMPILE_PDB_NOTE.txt diff --git a/Help/prop_tgt/PDB_NAME.rst b/Help/prop_tgt/PDB_NAME.rst index 333c865..479dec3 100644 --- a/Help/prop_tgt/PDB_NAME.rst +++ b/Help/prop_tgt/PDB_NAME.rst @@ -7,4 +7,5 @@ linker for an executable or shared library target. This property specifies the base name for the debug symbols file. If not set, the logical target name is used by default. +.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_NAME` .. include:: PDB_NOTE.txt diff --git a/Help/prop_tgt/PDB_NAME_CONFIG.rst b/Help/prop_tgt/PDB_NAME_CONFIG.rst index 7bf9e43..cb3121c 100644 --- a/Help/prop_tgt/PDB_NAME_CONFIG.rst +++ b/Help/prop_tgt/PDB_NAME_CONFIG.rst @@ -6,4 +6,5 @@ generated by the linker for an executable or shared library target. This is the configuration-specific version of :prop_tgt:`PDB_NAME`. +.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_NAME_` .. include:: PDB_NOTE.txt diff --git a/Help/prop_tgt/PDB_NOTE.txt b/Help/prop_tgt/PDB_NOTE.txt index c03bd3a..f90ea81 100644 --- a/Help/prop_tgt/PDB_NOTE.txt +++ b/Help/prop_tgt/PDB_NOTE.txt @@ -6,7 +6,7 @@ The linker-generated program database files are specified by the ``/pdb`` linker flag and are not the same as compiler-generated program database files specified by the ``/Fd`` compiler flag. - This property does not influence the latter. + Use the |COMPILE_PDB_XXX| property to specify the latter. This property is not implemented by the :generator:`Visual Studio 6` generator. diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst index 4877368..730cf57 100644 --- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst +++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst @@ -9,4 +9,5 @@ will be placed by the linker. This property is initialized by the value of the :variable:`CMAKE_PDB_OUTPUT_DIRECTORY` variable if it is set when a target is created. +.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY` .. include:: PDB_NOTE.txt diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst index 7bbc237..6037fa0 100644 --- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst @@ -11,4 +11,5 @@ property is initialized by the value of the :variable:`CMAKE_PDB_OUTPUT_DIRECTORY_` variable if it is set when a target is created. +.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY_` .. include:: PDB_NOTE.txt diff --git a/Help/release/dev/msvc-compiler-pdb-files.rst b/Help/release/dev/msvc-compiler-pdb-files.rst new file mode 100644 index 0000000..d06d202 --- /dev/null +++ b/Help/release/dev/msvc-compiler-pdb-files.rst @@ -0,0 +1,10 @@ +msvc-compiler-pdb-files +----------------------- + +* New :prop_tgt:`COMPILE_PDB_NAME` and + :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY` target properties + were introduced to specify the MSVC compiler program database + file location (``cl /Fd``). This complements the existing + :prop_tgt:`PDB_NAME` and :prop_tgt:`PDB_OUTPUT_DIRECTORY` + target properties that specify the linker program database + file location (``link /pdb``). diff --git a/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst new file mode 100644 index 0000000..ea33c7d --- /dev/null +++ b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst @@ -0,0 +1,8 @@ +CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY +---------------------------------- + +Output directory for MS debug symbol ``.pdb`` files +generated by the compiler while building source files. + +This variable is used to initialize the +:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY` property on all the targets. diff --git a/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst new file mode 100644 index 0000000..fdeb9ab --- /dev/null +++ b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst @@ -0,0 +1,11 @@ +CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_ +------------------------------------------- + +Per-configuration output directory for MS debug symbol ``.pdb`` files +generated by the compiler while building source files. + +This is a per-configuration version of +:variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY`. +This variable is used to initialize the +:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY_` +property on all the targets. diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index e29aaf4..5732170 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -241,7 +241,7 @@ macro(__windows_compiler_msvc lang) set(CMAKE_${lang}_CREATE_STATIC_LIBRARY " /lib ${CMAKE_CL_NOLOGO} /out: ") set(CMAKE_${lang}_COMPILE_OBJECT - " ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} /Fo /Fd/${_FS_${lang}} -c ${CMAKE_END_TEMP_FILE}") + " ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} /Fo /Fd${_FS_${lang}} -c ${CMAKE_END_TEMP_FILE}") set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE " > ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} -E ${CMAKE_END_TEMP_FILE}") set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index aca195c..4266dd0 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -901,6 +901,13 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, return replaceValues.TargetPDB; } } + if(replaceValues.TargetCompilePDB) + { + if(variable == "TARGET_COMPILE_PDB") + { + return replaceValues.TargetCompilePDB; + } + } if(replaceValues.DependencyFile ) { if(variable == "DEP_FILE") diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 9764813..0f7fd25 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -245,6 +245,7 @@ public: } cmTarget* CMTarget; const char* TargetPDB; + const char* TargetCompilePDB; const char* TargetVersionMajor; const char* TargetVersionMinor; const char* Language; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 212b06b..ce24d8d 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -660,7 +660,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, switch(target.GetType()) { case cmTarget::OBJECT_LIBRARY: - targetBuilds = false; // TODO: PDB for object library? + targetBuilds = false; // no manifest tool for object library case cmTarget::STATIC_LIBRARY: projectType = "typeStaticLibrary"; configType = "4"; @@ -846,6 +846,17 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.OutputFlagMap(fout, "\t\t\t\t"); targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX"); fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n"; + if(target.GetType() <= cmTarget::OBJECT_LIBRARY) + { + // Specify the compiler program database file if configured. + std::string pdb = target.GetCompilePDBPath(configName); + if(!pdb.empty()) + { + fout << "\t\t\t\tProgramDataBaseFileName=\"" + << this->ConvertToXMLOutputPathSingle(pdb.c_str()) + << "\"\n"; + } + } fout << "/>\n"; // end of FortranProject) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 664d73e..03fdda2 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -129,6 +129,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } } + std::string compilePdbOutputPath = + this->Target->GetCompilePDBDirectory(this->ConfigName); + cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); + std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(pdbOutputPath.c_str()); pdbOutputPath += "/"; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index b9af638..807aca8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -321,6 +321,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } } + std::string compilePdbOutputPath = + this->Target->GetCompilePDBDirectory(this->ConfigName); + cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); + std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(pdbOutputPath.c_str()); pdbOutputPath += "/"; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index c3ca85d..c6ade7f 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -624,9 +624,11 @@ cmMakefileTargetGenerator std::string targetOutPathReal; std::string targetOutPathPDB; + std::string targetOutPathCompilePDB; { std::string targetFullPathReal; std::string targetFullPathPDB; + std::string targetFullPathCompilePDB; if(this->Target->GetType() == cmTarget::EXECUTABLE || this->Target->GetType() == cmTarget::STATIC_LIBRARY || this->Target->GetType() == cmTarget::SHARED_LIBRARY || @@ -638,12 +640,26 @@ cmMakefileTargetGenerator targetFullPathPDB += "/"; targetFullPathPDB += this->Target->GetPDBName(this->ConfigName); } + if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) + { + targetFullPathCompilePDB = + this->Target->GetCompilePDBPath(this->ConfigName); + if(targetFullPathCompilePDB.empty()) + { + targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/"; + } + } + targetOutPathReal = this->Convert(targetFullPathReal.c_str(), cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); targetOutPathPDB = this->Convert(targetFullPathPDB.c_str(),cmLocalGenerator::NONE, cmLocalGenerator::SHELL); + targetOutPathCompilePDB = + this->Convert(targetFullPathCompilePDB.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); } cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; @@ -651,6 +667,7 @@ cmMakefileTargetGenerator vars.Language = lang; vars.Target = targetOutPathReal.c_str(); vars.TargetPDB = targetOutPathPDB.c_str(); + vars.TargetCompilePDB = targetOutPathCompilePDB.c_str(); vars.Source = sourceFile.c_str(); std::string shellObj = this->Convert(obj.c_str(), diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 900af8d..eaeddef 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -320,6 +320,7 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID")) { std::string pdbPath; + std::string compilePdbPath; if(this->Target->GetType() == cmTarget::EXECUTABLE || this->Target->GetType() == cmTarget::STATIC_LIBRARY || this->Target->GetType() == cmTarget::SHARED_LIBRARY || @@ -329,11 +330,25 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const pdbPath += "/"; pdbPath += this->Target->GetPDBName(this->GetConfigName()); } + if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) + { + compilePdbPath = this->Target->GetCompilePDBPath(this->GetConfigName()); + if(compilePdbPath.empty()) + { + compilePdbPath = this->Target->GetSupportDirectory() + "/"; + } + } vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat( ConvertToNinjaPath(pdbPath.c_str()).c_str(), cmLocalGenerator::SHELL); + vars["TARGET_COMPILE_PDB"] = + this->GetLocalGenerator()->ConvertToOutputFormat( + ConvertToNinjaPath(compilePdbPath.c_str()).c_str(), + cmLocalGenerator::SHELL); + EnsureParentDirectoryExists(pdbPath); + EnsureParentDirectoryExists(compilePdbPath); return true; } return false; @@ -362,6 +377,7 @@ cmNinjaTargetGenerator vars.Object = "$out"; vars.Defines = "$DEFINES"; vars.TargetPDB = "$TARGET_PDB"; + vars.TargetCompilePDB = "$TARGET_COMPILE_PDB"; vars.ObjectDir = "$OBJECT_DIR"; cmMakefile* mf = this->GetMakefile(); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a50d6ad..7a0df74 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -74,6 +74,7 @@ struct cmTarget::ImportInfo //---------------------------------------------------------------------------- struct cmTarget::CompileInfo { + std::string CompilePdbDir; }; struct TargetConfigPair : public std::pair { @@ -275,6 +276,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("PDB_OUTPUT_DIRECTORY", 0); + this->SetPropertyDefault("COMPILE_PDB_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("Fortran_FORMAT", 0); this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0); this->SetPropertyDefault("GNUtoMS", 0); @@ -303,6 +305,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) "LIBRARY_OUTPUT_DIRECTORY_", "RUNTIME_OUTPUT_DIRECTORY_", "PDB_OUTPUT_DIRECTORY_", + "COMPILE_PDB_OUTPUT_DIRECTORY_", "MAP_IMPORTED_CONFIG_", 0}; for(std::vector::iterator ci = configNames.begin(); @@ -2517,6 +2520,7 @@ cmTarget::CompileInfo const* cmTarget::GetCompileInfo(const char* config) const if(i == this->Internal->CompileInfoMap.end()) { CompileInfo info; + this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); CompileInfoMapType::value_type entry(config_upper, info); i = this->Internal->CompileInfoMap.insert(entry).first; } @@ -2553,6 +2557,16 @@ std::string cmTarget::GetPDBDirectory(const char* config) const } //---------------------------------------------------------------------------- +std::string cmTarget::GetCompilePDBDirectory(const char* config) const +{ + if(CompileInfo const* info = this->GetCompileInfo(config)) + { + return info->CompilePdbDir; + } + return ""; +} + +//---------------------------------------------------------------------------- const char* cmTarget::GetLocation(const char* config) const { if (this->IsImported()) @@ -3213,6 +3227,49 @@ std::string cmTarget::GetPDBName(const char* config) const } //---------------------------------------------------------------------------- +std::string cmTarget::GetCompilePDBName(const char* config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->GetFullNameInternal(config, false, prefix, base, suffix); + + // Check for a per-configuration output directory target property. + std::string configUpper = cmSystemTools::UpperCase(config? config : ""); + std::string configProp = "COMPILE_PDB_NAME_"; + configProp += configUpper; + const char* config_name = this->GetProperty(configProp.c_str()); + if(config_name && *config_name) + { + return prefix + config_name + ".pdb"; + } + + const char* name = this->GetProperty("COMPILE_PDB_NAME"); + if(name && *name) + { + return prefix + name + ".pdb"; + } + + return ""; +} + +//---------------------------------------------------------------------------- +std::string cmTarget::GetCompilePDBPath(const char* config) const +{ + std::string dir = this->GetCompilePDBDirectory(config); + std::string name = this->GetCompilePDBName(config); + if(dir.empty() && !name.empty()) + { + dir = this->GetPDBDirectory(config); + } + if(!dir.empty()) + { + dir += "/"; + } + return dir + name; +} + +//---------------------------------------------------------------------------- bool cmTarget::HasSOName(const char* config) const { // soname is supported only for shared libraries and modules, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 6787706..a3f544c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -342,6 +342,12 @@ public: pdb output directory is given. */ std::string GetPDBDirectory(const char* config) const; + /** Get the directory in which to place the target compiler .pdb file. + If the configuration name is given then the generator will add its + subdirectory for that configuration. Otherwise just the canonical + compiler pdb output directory is given. */ + std::string GetCompilePDBDirectory(const char* config = 0) const; + /** Get the location of the target in the build tree for the given configuration. This location is suitable for use as the LOCATION target property. */ @@ -377,6 +383,12 @@ public: /** Get the name of the pdb file for the target. */ std::string GetPDBName(const char* config) const; + /** Get the name of the compiler pdb file for the target. */ + std::string GetCompilePDBName(const char* config=0) const; + + /** Get the path for the MSVC /Fd option for this target. */ + std::string GetCompilePDBPath(const char* config=0) const; + /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const char* config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ed7e243..b1f0974 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1427,6 +1427,17 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", "\n", "CXX"); this->WriteString("$(IntDir)\n", 3); + + // Specify the compiler program database file if configured. + std::string pdb = this->Target->GetCompilePDBPath(configName.c_str()); + if(!pdb.empty()) + { + this->ConvertToWindowsSlash(pdb); + this->WriteString("", 3); + *this->BuildFileStream << cmVS10EscapeXML(pdb) + << "\n"; + } + this->WriteString("\n", 2); } diff --git a/Tests/PDBDirectoryAndName/CMakeLists.txt b/Tests/PDBDirectoryAndName/CMakeLists.txt index 28e46b1..90af600 100644 --- a/Tests/PDBDirectoryAndName/CMakeLists.txt +++ b/Tests/PDBDirectoryAndName/CMakeLists.txt @@ -6,6 +6,13 @@ if(NOT MSVC AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$") message(FATAL_ERROR "The PDBDirectoryAndName test works only with MSVC or Intel") endif() +# Intel 11.1 does not support /Fd but Intel 14.0 does. +# TODO: Did a version in between these add it? +if(CMAKE_C_COMPILER_ID STREQUAL Intel AND + CMAKE_C_COMPILER_VERSION VERSION_LESS 14.0) + set(NO_COMPILE_PDB 1) +endif() + set(my_targets "") add_library(mylibA SHARED mylibA.c) @@ -17,12 +24,12 @@ list(APPEND my_targets mylibA) add_library(mylibB STATIC mylibB.c) set_target_properties(mylibB PROPERTIES - PDB_NAME "mylibB_Special" - PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibB_PDB" + COMPILE_PDB_NAME "mylibB_Special" + COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibB_PDB" ) -# TODO: The only .pdb available for a static library is that generated -# by the compiler /Fd option which is not the same as the linker /pdb. -# list(APPEND my_targets mylibB) +if(NOT NO_COMPILE_PDB) + list(APPEND my_targets mylibB) +endif() add_library(mylibC SHARED mylibC.c) set_target_properties(mylibC PROPERTIES @@ -32,10 +39,11 @@ list(APPEND my_targets mylibC) add_library(mylibD STATIC mylibD.c) set_target_properties(mylibD PROPERTIES - PDB_NAME "mylibD_Special" + COMPILE_PDB_NAME "mylibD_Special" ) -# TODO: See comment for mylibB. -# list(APPEND my_targets mylibD) +if(NOT NO_COMPILE_PDB) + list(APPEND my_targets mylibD) +endif() add_executable(myexe myexe.c) set_target_properties(myexe PROPERTIES @@ -66,6 +74,12 @@ set(pdbs "") foreach(t ${my_targets}) get_property(pdb_name TARGET ${t} PROPERTY PDB_NAME) get_property(pdb_dir TARGET ${t} PROPERTY PDB_OUTPUT_DIRECTORY) + if(NOT pdb_name) + get_property(pdb_name TARGET ${t} PROPERTY COMPILE_PDB_NAME) + endif() + if(NOT pdb_dir) + get_property(pdb_dir TARGET ${t} PROPERTY COMPILE_PDB_OUTPUT_DIRECTORY) + endif() if(NOT pdb_dir) set(pdb_dir ${CMAKE_CURRENT_BINARY_DIR}) endif() -- cgit v0.12 From b94ecab6d6540512df5e7c11deb9d168566d346f Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Wed, 26 Feb 2014 10:53:53 -0700 Subject: FindQt4: prevent overlinking when using UseQt4.cmake. Now it only links with the Qt libraries specified by the user, instead of automatically including all dependencies. Fixes #14750 and thanks to Orion Poplawski. --- Modules/UseQt4.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index 7478310..cba22af 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -98,7 +98,9 @@ foreach(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN include_directories(SYSTEM ${QT_${module}_INCLUDE_DIR}) endif(QT_INCLUDE_DIRS_NO_SYSTEM) endif() - set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY}) + if(QT_USE_${module} OR QT_IS_STATIC) + set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY}) + endif() set(QT_LIBRARIES_PLUGINS ${QT_LIBRARIES_PLUGINS} ${QT_${module}_PLUGINS}) if(QT_IS_STATIC) set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIB_DEPENDENCIES}) -- cgit v0.12 From 71b14dcb0ad52a65331268bf72808841786bc1d2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 26 Feb 2014 13:18:38 -0500 Subject: Utilities/Release: Do not upload doc staging tarball Restrict the release upload globbing pattern to match the CMake version so that "cmake-*" files go but "cmake--docs.tar.gz" does not. --- Utilities/Release/upload_release.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Utilities/Release/upload_release.cmake b/Utilities/Release/upload_release.cmake index 0d928ba..613d73d 100644 --- a/Utilities/Release/upload_release.cmake +++ b/Utilities/Release/upload_release.cmake @@ -1,10 +1,10 @@ set(CTEST_RUN_CURRENT_SCRIPT 0) -if(NOT DEFINED PROJECT_PREFIX) - set(PROJECT_PREFIX cmake-) -endif() if(NOT VERSION) set(VERSION 3.0) endif() +if(NOT DEFINED PROJECT_PREFIX) + set(PROJECT_PREFIX cmake-${VERSION}) +endif() set(dir "v${VERSION}") if("${VERSION}" MATCHES "master") set(dir "dev") -- cgit v0.12 From 0bba365ff5423fc51d574d17b7934e3a0148ac2e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 26 Feb 2014 21:30:18 +0100 Subject: Add test for find_dependency macro. --- Tests/CMakeLists.txt | 1 + Tests/Module/FindDependency/CMakeLists.txt | 10 ++++++++++ Tests/Module/FindDependency/main.cpp | 17 +++++++++++++++++ .../FindDependency/packages/Pack1/Pack1Config.cmake | 9 +++++++++ .../packages/Pack1/Pack1ConfigVersion.cmake | 11 +++++++++++ .../FindDependency/packages/Pack2/Pack2Config.cmake | 5 +++++ .../packages/Pack2/Pack2ConfigVersion.cmake | 11 +++++++++++ .../FindDependency/packages/Pack3/Pack3Config.cmake | 5 +++++ .../packages/Pack3/Pack3ConfigVersion.cmake | 11 +++++++++++ 9 files changed, 80 insertions(+) create mode 100644 Tests/Module/FindDependency/CMakeLists.txt create mode 100644 Tests/Module/FindDependency/main.cpp create mode 100644 Tests/Module/FindDependency/packages/Pack1/Pack1Config.cmake create mode 100644 Tests/Module/FindDependency/packages/Pack1/Pack1ConfigVersion.cmake create mode 100644 Tests/Module/FindDependency/packages/Pack2/Pack2Config.cmake create mode 100644 Tests/Module/FindDependency/packages/Pack2/Pack2ConfigVersion.cmake create mode 100644 Tests/Module/FindDependency/packages/Pack3/Pack3Config.cmake create mode 100644 Tests/Module/FindDependency/packages/Pack3/Pack3ConfigVersion.cmake diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 8074a01..c414850 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -381,6 +381,7 @@ if(BUILD_TESTING) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Module/ExternalData") ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader) + ADD_TEST_MACRO(Module.FindDependency FindDependency) if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") include(CheckCXXCompilerFlag) diff --git a/Tests/Module/FindDependency/CMakeLists.txt b/Tests/Module/FindDependency/CMakeLists.txt new file mode 100644 index 0000000..b13f48a --- /dev/null +++ b/Tests/Module/FindDependency/CMakeLists.txt @@ -0,0 +1,10 @@ + +cmake_minimum_required(VERSION 3.0) +project(FindDependency) + +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/packages") + +find_package(Pack1 REQUIRED) + +add_executable(FindDependency main.cpp) +target_link_libraries(FindDependency Pack1::Lib) diff --git a/Tests/Module/FindDependency/main.cpp b/Tests/Module/FindDependency/main.cpp new file mode 100644 index 0000000..d635b31 --- /dev/null +++ b/Tests/Module/FindDependency/main.cpp @@ -0,0 +1,17 @@ + +#ifndef HAVE_PACK1 +#error Expected HAVE_PACK1 +#endif + +#ifndef HAVE_PACK2 +#error Expected HAVE_PACK2 +#endif + +#ifndef HAVE_PACK3 +#error Expected HAVE_PACK3 +#endif + +int main(int argc, char** argv) +{ + return 0; +} diff --git a/Tests/Module/FindDependency/packages/Pack1/Pack1Config.cmake b/Tests/Module/FindDependency/packages/Pack1/Pack1Config.cmake new file mode 100644 index 0000000..ff533c2 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack1/Pack1Config.cmake @@ -0,0 +1,9 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack2 2.3) +find_dependency(Pack3) + +add_library(Pack1::Lib INTERFACE IMPORTED) +set_property(TARGET Pack1::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK1) +set_property(TARGET Pack1::Lib PROPERTY INTERFACE_LINK_LIBRARIES Pack2::Lib Pack3::Lib) diff --git a/Tests/Module/FindDependency/packages/Pack1/Pack1ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack1/Pack1ConfigVersion.cmake new file mode 100644 index 0000000..dfb7b6c --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack1/Pack1ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "1.3") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/Module/FindDependency/packages/Pack2/Pack2Config.cmake b/Tests/Module/FindDependency/packages/Pack2/Pack2Config.cmake new file mode 100644 index 0000000..672288e --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack2/Pack2Config.cmake @@ -0,0 +1,5 @@ + +set(PACK2_VAR ON) + +add_library(Pack2::Lib INTERFACE IMPORTED) +set_property(TARGET Pack2::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK2) diff --git a/Tests/Module/FindDependency/packages/Pack2/Pack2ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack2/Pack2ConfigVersion.cmake new file mode 100644 index 0000000..42f58c0 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack2/Pack2ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "2.4") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/Module/FindDependency/packages/Pack3/Pack3Config.cmake b/Tests/Module/FindDependency/packages/Pack3/Pack3Config.cmake new file mode 100644 index 0000000..25c32f3 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack3/Pack3Config.cmake @@ -0,0 +1,5 @@ + +set(PACK3_VAR ON) + +add_library(Pack3::Lib INTERFACE IMPORTED) +set_property(TARGET Pack3::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK3) diff --git a/Tests/Module/FindDependency/packages/Pack3/Pack3ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack3/Pack3ConfigVersion.cmake new file mode 100644 index 0000000..870f747 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack3/Pack3ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "1.4") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() -- cgit v0.12 From 0f9dbc1608969c3b2dd7e4842e338fa5f90f0b43 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 27 Feb 2014 00:01:08 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index a1ae3b3..1146f89 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 0) -set(CMake_VERSION_PATCH 20140226) +set(CMake_VERSION_PATCH 20140227) #set(CMake_VERSION_RC 1) -- cgit v0.12 From c50325b8e55e55306fbf8bca38128303b82a51a9 Mon Sep 17 00:00:00 2001 From: Nikolay Orliuk Date: Wed, 26 Feb 2014 14:47:38 +0200 Subject: FindGTest: Optionally detect sources automatically (#14775) Teach GTEST_ADD_TESTS an "AUTO" option to read the source files from the SOURCES target property of an executable. --- Modules/FindGTest.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index c00a750..aa3c235 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -79,7 +79,7 @@ # extra_args = Pass a list of extra arguments to be passed to # executable enclosed in quotes (or "" for none) # ARGN = A list of source files to search for tests & test -# fixtures. +# fixtures. Or AUTO to find them from executable target. # # # @@ -88,7 +88,7 @@ # Example: # set(FooTestArgs --foo 1 --bar 2) # add_executable(FooTest FooUnitTest.cc) -# GTEST_ADD_TESTS(FooTest "${FooTestArgs}" FooUnitTest.cc) +# GTEST_ADD_TESTS(FooTest "${FooTestArgs}" AUTO) #============================================================================= # Copyright 2009 Kitware, Inc. @@ -111,6 +111,10 @@ function(GTEST_ADD_TESTS executable extra_args) if(NOT ARGN) message(FATAL_ERROR "Missing ARGN: Read the documentation for GTEST_ADD_TESTS") endif() + if(ARGN STREQUAL "AUTO") + # obtain sources used for building that executable + get_property(ARGN TARGET ${executable} PROPERTY SOURCES) + endif() foreach(source ${ARGN}) file(READ "${source}" contents) string(REGEX MATCHALL "TEST_?F?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents}) -- cgit v0.12 From ac42bca8330e0501d2fbf80dbe6d4d93234ba0c0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 27 Feb 2014 08:54:13 -0500 Subject: Help: Add FindGTest-AUTO-SOURCES topic release notes --- Help/release/dev/FindGTest-AUTO-SOURCES.rst | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Help/release/dev/FindGTest-AUTO-SOURCES.rst diff --git a/Help/release/dev/FindGTest-AUTO-SOURCES.rst b/Help/release/dev/FindGTest-AUTO-SOURCES.rst new file mode 100644 index 0000000..17b2a1b --- /dev/null +++ b/Help/release/dev/FindGTest-AUTO-SOURCES.rst @@ -0,0 +1,7 @@ +FindGTest-AUTO-SOURCES +---------------------- + +* The :module:`FindGTest` module ``gtest_add_tests`` macro learned + a new ``AUTO`` option to automatically read the :prop_tgt:`SOURCES` + target property of the test executable and scan the source files + for tests to be added. -- cgit v0.12 From 02a74a7d9f7bd7f8abc789c980a2ecca16471b51 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 27 Feb 2014 09:03:32 -0500 Subject: Help: Add FindHg-WC_INFO topic release notes --- Help/release/dev/FindHg-WC_INFO.rst | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Help/release/dev/FindHg-WC_INFO.rst diff --git a/Help/release/dev/FindHg-WC_INFO.rst b/Help/release/dev/FindHg-WC_INFO.rst new file mode 100644 index 0000000..0caf2b3 --- /dev/null +++ b/Help/release/dev/FindHg-WC_INFO.rst @@ -0,0 +1,5 @@ +FindHg-WC_INFO +-------------- + +* The :module:`FindHg` module gained a new ``Hg_WC_INFO`` macro to + help run ``hg`` to extract information about a Mercurial work copy. -- cgit v0.12 From 755b378e57cf859b3dc28db004b8596e44d07175 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 27 Feb 2014 09:08:25 -0500 Subject: Help: Add ExternalProject-BUILD_ALWAYS topic release notes --- Help/release/dev/ExternalProject-BUILD_ALWAYS.rst | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Help/release/dev/ExternalProject-BUILD_ALWAYS.rst diff --git a/Help/release/dev/ExternalProject-BUILD_ALWAYS.rst b/Help/release/dev/ExternalProject-BUILD_ALWAYS.rst new file mode 100644 index 0000000..5384671 --- /dev/null +++ b/Help/release/dev/ExternalProject-BUILD_ALWAYS.rst @@ -0,0 +1,6 @@ +ExternalProject-BUILD_ALWAYS +---------------------------- + +* The :module:`ExternalProject` module ``ExternalProject_Add`` command + learned a new ``BUILD_ALWAYS`` option to cause the external project + build step to run every time the host project is built. -- cgit v0.12 From 0f55f2547f45090d093a6f0871b107bf1fac4458 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 27 Feb 2014 09:53:16 -0500 Subject: VS: For Intel Fortran .vfproj put OBJECT libs in link line (#14777) The Intel Fortran .vfproj format accepts the $(Configuration) placeholder in the path to an input file but appears to consider it always out of date. Therefore adding OBJECT library objects as external object source files causes the referencing binary to re-link on every build. Work around this problem by putting OBJECT library objects on the link line as is done for VS < 8 already. --- Source/cmLocalVisualStudio7Generator.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index ce24d8d..d11bf55 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1044,7 +1044,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, fout << "\t\t\tGetVersion() < VS8) + if(this->GetVersion() < VS8 || this->FortranProject) { cmOStringStream libdeps; this->Internal->OutputObjects(libdeps, &target); @@ -1104,7 +1104,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, // libraries which may be set by the user to something bad. fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) " << this->Makefile->GetSafeDefinition(standardLibsVar.c_str()); - if(this->GetVersion() < VS8) + if(this->GetVersion() < VS8 || this->FortranProject) { this->Internal->OutputObjects(fout, &target, " "); } @@ -1202,7 +1202,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, // libraries which may be set by the user to something bad. fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) " << this->Makefile->GetSafeDefinition(standardLibsVar.c_str()); - if(this->GetVersion() < VS8) + if(this->GetVersion() < VS8 || this->FortranProject) { this->Internal->OutputObjects(fout, &target, " "); } @@ -1423,7 +1423,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, this->WriteGroup(&sg, target, fout, libName, configs); } - if(this->GetVersion() >= VS8) + if(this->GetVersion() >= VS8 && !this->FortranProject) { // VS >= 8 support per-config source locations so we // list object library content as external objects. -- cgit v0.12 From c53b5cd2215a25e0661cbaf88b22664d1ec09412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Wed, 26 Feb 2014 20:48:18 +0100 Subject: FindPkgConfig: Prefer PKG_CONFIG to find pkg-config (#13175) If the environment variable PKG_CONFIG is set, use this as the default pkg-config executable. --- Modules/FindPkgConfig.cmake | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index e6fdefe..7179d17 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -6,6 +6,11 @@ # # # +# To find the pkg-config executable, it uses the variable +# PKG_CONFIG_EXECUTABLE or the environment variable PKG_CONFIG first. +# +# +# # Usage: # # :: @@ -134,8 +139,9 @@ # pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2) #============================================================================= -# Copyright 2006-2009 Kitware, Inc. -# Copyright 2006 Enrico Scholz +# Copyright 2006-2014 Kitware, Inc. +# Copyright 2014 Christoph Grüninger +# Copyright 2006 Enrico Scholz # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -150,6 +156,10 @@ ### Common stuff #### set(PKG_CONFIG_VERSION 1) +# find pkg-config, use PKG_CONFIG if set +if((NOT PKG_CONFIG_EXECUTABLE) AND (NOT "$ENV{PKG_CONFIG}" STREQUAL "")) + set(PKG_CONFIG_EXECUTABLE "$ENV{PKG_CONFIG}" CACHE FILEPATH "pkg-config executable") +endif() find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable") mark_as_advanced(PKG_CONFIG_EXECUTABLE) -- cgit v0.12 From f0f2b21d52a0c3f1799c7747f0e7f5b52410054f Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 27 Feb 2014 13:03:29 -0500 Subject: Utilities/Release: Update IBM AIX build machine access --- Utilities/Release/create-cmake-release.cmake | 2 +- Utilities/Release/ibm_aix_release.cmake | 15 +++++++++++++++ Utilities/Release/release_cmake.cmake | 11 ++++------- Utilities/Release/release_cmake.sh.in | 5 ----- Utilities/Release/v20n250_aix_release.cmake | 22 ---------------------- 5 files changed, 20 insertions(+), 35 deletions(-) create mode 100644 Utilities/Release/ibm_aix_release.cmake delete mode 100644 Utilities/Release/v20n250_aix_release.cmake diff --git a/Utilities/Release/create-cmake-release.cmake b/Utilities/Release/create-cmake-release.cmake index 95428b6..841aba5 100644 --- a/Utilities/Release/create-cmake-release.cmake +++ b/Utilities/Release/create-cmake-release.cmake @@ -10,7 +10,7 @@ set(RELEASE_SCRIPTS_BATCH_1 dashmacmini2_release.cmake # Mac Darwin universal ppc;i386 dashmacmini5_release.cmake # Mac Darwin64 universal x86_64;i386 magrathea_release.cmake # Linux - v20n250_aix_release.cmake # AIX 5.3 + ibm_aix_release.cmake # AIX ferrari_sgi64_release.cmake # IRIX 64 ferrari_sgi_release.cmake # IRIX ) diff --git a/Utilities/Release/ibm_aix_release.cmake b/Utilities/Release/ibm_aix_release.cmake new file mode 100644 index 0000000..5a6efe6 --- /dev/null +++ b/Utilities/Release/ibm_aix_release.cmake @@ -0,0 +1,15 @@ +set(CMAKE_RELEASE_DIRECTORY "/bench1/noibm34/CMakeReleaseDirectory") +set(PROCESSORS 64) +set(HOST "ibm-backend") +set(SCRIPT_NAME aix) +set(MAKE_PROGRAM "make") +set(CC "xlc_r") +set(CXX "xlC_r") +set(FC "xlf") +set(LDFLAGS "-Wl,-bmaxdata:0x80000000") # Push "Segmentation fault in extend_brk" over horizon +set(INITIAL_CACHE " +CMAKE_BUILD_TYPE:STRING=Release +CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE +") +get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) +include(${path}/release_cmake.cmake) diff --git a/Utilities/Release/release_cmake.cmake b/Utilities/Release/release_cmake.cmake index a8772ee..7a1652d 100644 --- a/Utilities/Release/release_cmake.cmake +++ b/Utilities/Release/release_cmake.cmake @@ -4,9 +4,6 @@ get_filename_component(SCRIPT_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH) if(NOT DEFINED CPACK_BINARY_GENERATORS) set(CPACK_BINARY_GENERATORS "STGZ TGZ TZ") endif() -if(DEFINED EXTRA_COPY) - set(HAS_EXTRA_COPY 1) -endif() if(NOT DEFINED CMAKE_RELEASE_DIRECTORY) set(CMAKE_RELEASE_DIRECTORY "~/CMakeReleaseDirectory") endif() @@ -55,11 +52,11 @@ message("Creating CMake release ${CMAKE_CREATE_VERSION} on ${HOST} with parallel macro(remote_command comment command) message("${comment}") if(${ARGC} GREATER 2) - message("ssh ${HOST} ${EXTRA_HOP} ${command}") - execute_process(COMMAND ssh ${HOST} ${EXTRA_HOP} ${command} RESULT_VARIABLE result INPUT_FILE ${ARGV2}) + message("ssh ${HOST} ${command}") + execute_process(COMMAND ssh ${HOST} ${command} RESULT_VARIABLE result INPUT_FILE ${ARGV2}) else() - message("ssh ${HOST} ${EXTRA_HOP} ${command}") - execute_process(COMMAND ssh ${HOST} ${EXTRA_HOP} ${command} RESULT_VARIABLE result) + message("ssh ${HOST} ${command}") + execute_process(COMMAND ssh ${HOST} ${command} RESULT_VARIABLE result) endif() if(${result} GREATER 0) message(FATAL_ERROR "Error running command: ${command}, return value = ${result}") diff --git a/Utilities/Release/release_cmake.sh.in b/Utilities/Release/release_cmake.sh.in index 1f57c28..76fdb3a 100755 --- a/Utilities/Release/release_cmake.sh.in +++ b/Utilities/Release/release_cmake.sh.in @@ -155,11 +155,6 @@ done -# need to add an extra copy thing here -if [ ! -z "@EXTRA_COPY@" ]; then - @EXTRA_COPY@ - check_exit_value $? "Extra copy step @EXTRA_COPY@" || exit 1 -fi echo "End release" date echo "" diff --git a/Utilities/Release/v20n250_aix_release.cmake b/Utilities/Release/v20n250_aix_release.cmake deleted file mode 100644 index cc8cd05..0000000 --- a/Utilities/Release/v20n250_aix_release.cmake +++ /dev/null @@ -1,22 +0,0 @@ -set(CMAKE_RELEASE_DIRECTORY "/bench1/noibm34/CMakeReleaseDirectory") -set(FINAL_PATH /u/noibm34/cmake-release) -set(PROCESSORS 2) -set(HOST "sshserv.centers.ihost.com") -set(EXTRA_HOP "rsh p90n03") -set(MAKE_PROGRAM "make") -set(CC "xlc_r") -set(CXX "xlC_r") -set(FC "xlf") -set(LDFLAGS "-Wl,-bmaxdata:0x80000000") # Push "Segmentation fault in extend_brk" over horizon -set(INITIAL_CACHE " -CMAKE_BUILD_TYPE:STRING=Release -CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE -") -set(EXTRA_COPY " -rm -rf ~/cmake-release -mkdir ~/cmake-release -mv *.sh ~/cmake-release -mv *.Z ~/cmake-release -mv *.gz ~/cmake-release") -get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) -include(${path}/release_cmake.cmake) -- cgit v0.12 From 7cd239ed38b2951e7fdd506d24a3f8e723e95b5f Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 27 Feb 2014 13:22:58 -0500 Subject: Tests/RunCMake: Tell cmake not to report unused command-line options On OS X we pass -DCMAKE_POLICY_DEFAULT_CMP0025=NEW to all tests. Once tests start using cmake_minimum_required(VERSION 3.0) then CMake will warn that CMAKE_POLICY_DEFAULT_CMP0025 is unused. These warnings are not part of the expected test output and can cause such tests to fail. Pass --no-warn-unused-cli to each test cmake invocation to tell it not to produce these warnings. --- Tests/RunCMake/RunCMake.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 1d1c523..ed3afc5 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -53,6 +53,7 @@ function(run_cmake test) -G "${RunCMake_GENERATOR}" -T "${RunCMake_GENERATOR_TOOLSET}" -DRunCMake_TEST=${test} + --no-warn-unused-cli ${RunCMake_TEST_OPTIONS} WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" OUTPUT_VARIABLE actual_stdout -- cgit v0.12 From 00503d387e60cd4ecda07c05bd501f5bb8df4f07 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 27 Feb 2014 16:22:28 -0500 Subject: Watcom: Fix creation of DLLs without any exported symbols Create each DLL import library by passing "option implib=..." to the linker for its SHARED library. This works even when there are no symbols to be exported. Leave the option out for MODULE libraries because we do not need an import library for them. For executables, retain the separate invocation of wlib because we want an import library only when the ENABLE_EXPORTS property is set, and in that case the project should provide symbols. Suggested-by: J Decker --- Modules/Platform/Windows-wcl386.cmake | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake index 8a03b29..d61ea47 100644 --- a/Modules/Platform/Windows-wcl386.cmake +++ b/Modules/Platform/Windows-wcl386.cmake @@ -65,11 +65,10 @@ set(CMAKE_C_CREATE_PREPROCESSED_SOURCE set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE " ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -dWIN32 -d+ -fo -pl -cc++ ${CMAKE_END_TEMP_FILE}") -set(CMAKE_CXX_CREATE_SHARED_MODULE - "wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name '' option caseexact file {} ${CMAKE_END_TEMP_FILE}") set(CMAKE_CXX_CREATE_SHARED_LIBRARY - ${CMAKE_CXX_CREATE_SHARED_MODULE} - ${CMAKE_CXX_CREATE_IMPORT_LIBRARY}) + "wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name '' option implib= option caseexact file {} ${CMAKE_END_TEMP_FILE}") +string(REPLACE " option implib=" "" + CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}") # create a C shared library set(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) -- cgit v0.12 From a3a178fcac3d141360da343e032ba6c40d2583ee Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 28 Feb 2014 00:01:06 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 1146f89..ccc5183 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 0) -set(CMake_VERSION_PATCH 20140227) +set(CMake_VERSION_PATCH 20140228) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 4b67c4b94cc38814c4ff441b4a2f5cf792725485 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 28 Feb 2014 14:52:40 +0100 Subject: Remove compatibility CTest code. --- CMakeLists.txt | 2 -- CTestConfig.cmake | 5 ----- CTestCustom.ctest.in | 3 --- 3 files changed, 10 deletions(-) delete mode 100644 CTestCustom.ctest.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 761ad20..9e1e7c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,8 +164,6 @@ macro(CMAKE_SETUP_TESTING) ${CMake_BINARY_DIR}/Modules/.NoDartCoverage) configure_file(${CMake_SOURCE_DIR}/CTestCustom.cmake.in ${CMake_BINARY_DIR}/CTestCustom.cmake @ONLY) - configure_file(${CMake_SOURCE_DIR}/CTestCustom.ctest.in - ${CMake_BINARY_DIR}/CTestCustom.ctest @ONLY) if(BUILD_TESTING AND DART_ROOT) configure_file(${CMake_SOURCE_DIR}/CMakeLogo.gif ${CMake_BINARY_DIR}/Testing/HTML/TestingResults/Icons/Logo.gif COPYONLY) diff --git a/CTestConfig.cmake b/CTestConfig.cmake index 92eacd8..819f9ba 100644 --- a/CTestConfig.cmake +++ b/CTestConfig.cmake @@ -18,8 +18,3 @@ set(CTEST_DROP_LOCATION "/CDash/submit.php?project=CMake") set(CTEST_DROP_SITE_CDASH TRUE) set(CTEST_CDASH_VERSION "1.6") set(CTEST_CDASH_QUERY_VERSION TRUE) - -# use old trigger stuff so that cmake 2.4 and below will not -# get errors on trigger -set (TRIGGER_SITE - "http://public.kitware.com/cgi-bin/Submit-CMake-TestingResults.cgi") diff --git a/CTestCustom.ctest.in b/CTestCustom.ctest.in deleted file mode 100644 index 6127843..0000000 --- a/CTestCustom.ctest.in +++ /dev/null @@ -1,3 +0,0 @@ -# This file is provided for compatibility with CMake 2.2 and lower. -# Just include the custom file by its new name. -INCLUDE("CTestCustom.cmake") -- cgit v0.12 From 1b08e6095b71aff5cf16edda125fa28191264ec7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 28 Feb 2014 09:18:06 -0500 Subject: Help: Add release notes for topic 'add-FindOpenCL' --- Help/release/dev/add-FindOpenCL.rst | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Help/release/dev/add-FindOpenCL.rst diff --git a/Help/release/dev/add-FindOpenCL.rst b/Help/release/dev/add-FindOpenCL.rst new file mode 100644 index 0000000..e1e30d1 --- /dev/null +++ b/Help/release/dev/add-FindOpenCL.rst @@ -0,0 +1,4 @@ +add-FindOpenCL +-------------- + +* The :module:`FindOpenCL` module was introduced. -- cgit v0.12 From 0a6f0280672f3b1a638cae4cf5144c1adccef754 Mon Sep 17 00:00:00 2001 From: Zack Galbreath Date: Wed, 26 Feb 2014 10:01:34 -0500 Subject: CTest: notify user if gcov cannot be found Emit an error message when we're performing coverage using gcov and the gcov executable cannot be found. --- Source/CTest/cmCTestCoverageHandler.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 3c65c55..0503d94 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -871,6 +871,12 @@ int cmCTestCoverageHandler::HandleGCovCoverage( { std::string gcovCommand = this->CTest->GetCTestConfiguration("CoverageCommand"); + if (gcovCommand.empty()) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Could not find gcov." << std::endl); + return 0; + } std::string gcovExtraFlags = this->CTest->GetCTestConfiguration("CoverageExtraFlags"); -- cgit v0.12 From 80aa18b4a88d83e630acf5655025b14af0c76475 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 28 Feb 2014 09:48:20 -0500 Subject: Help: Add release notes for topic 'FindPkgConfig-PKG_CONFIG' --- Help/release/dev/FindPkgConfig-PKG_CONFIG.rst | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Help/release/dev/FindPkgConfig-PKG_CONFIG.rst diff --git a/Help/release/dev/FindPkgConfig-PKG_CONFIG.rst b/Help/release/dev/FindPkgConfig-PKG_CONFIG.rst new file mode 100644 index 0000000..c0f6471 --- /dev/null +++ b/Help/release/dev/FindPkgConfig-PKG_CONFIG.rst @@ -0,0 +1,5 @@ +FindPkgConfig-PKG_CONFIG +------------------------ + +* The :module:`FindPkgConfig` module learned to use the ``PKG_CONFIG`` + environment variable value as the ``pkg-config`` executable, if set. -- cgit v0.12 From 5c5be193cf86f86fb6e9c0c0bd4f01eb1dfa8d08 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 28 Feb 2014 18:21:52 +0100 Subject: Watcom: Fix static library name quoting for wlib Use double-quotes instead of single-quotes around the static library target name in 'wlib' invocations. --- Modules/Platform/Windows-wcl386.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake index 8a03b29..2d5050a 100644 --- a/Modules/Platform/Windows-wcl386.cmake +++ b/Modules/Platform/Windows-wcl386.cmake @@ -40,7 +40,7 @@ set (CMAKE_C_STANDARD_LIBRARIES_INIT "library clbrdll.lib library plbrdll.lib l set (CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") set(CMAKE_C_CREATE_IMPORT_LIBRARY - "wlib -c -q -n -b +''") + "wlib -c -q -n -b +") set(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY}) set(CMAKE_C_LINK_EXECUTABLE @@ -78,7 +78,7 @@ set(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) set(CMAKE_C_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_MODULE}) # create a C++ static library -set(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -c -n -b '' ") +set(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -c -n -b ") # create a C static library set(CMAKE_C_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY}) -- cgit v0.12 From c0afb8867518e7b7ef17d5ce90f1a99051d2fd14 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 1 Mar 2014 00:01:10 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index ccc5183..3afaf52 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 0) -set(CMake_VERSION_PATCH 20140228) +set(CMake_VERSION_PATCH 20140301) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 378eb5b712bb8f131e62aa343e3ec27d446dc098 Mon Sep 17 00:00:00 2001 From: Nils Gladitz Date: Sat, 1 Mar 2014 23:13:35 +0100 Subject: CPackWIX: Allow Windows Installer property customization --- Modules/CPackWIX.cmake | 17 ++++++++++++++- Modules/WIX.template.in | 2 ++ Source/CPack/WiX/cmCPackWIXGenerator.cxx | 37 ++++++++++++++++++++++++++++++++ Source/CPack/WiX/cmCPackWIXGenerator.h | 2 ++ Source/CPack/cmCPackGenerator.cxx | 6 ++++++ Source/CPack/cmCPackGenerator.h | 1 + Tests/CPackWiXGenerator/CMakeLists.txt | 3 +++ 7 files changed, 67 insertions(+), 1 deletion(-) diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake index 39183c6..0a47e19 100644 --- a/Modules/CPackWIX.cmake +++ b/Modules/CPackWIX.cmake @@ -216,9 +216,24 @@ # allow other CMake projects to find your package with # the :command:`find_package` command. # +# .. variable:: CPACK_WIX_PROPERTY_ +# +# This variable can be used to provide a value for +# the Windows Installer property ```` +# +# The follwing list contains some example properties that can be used to +# customize information under +# "Programs and Features" (also known as "Add or Remove Programs") +# +# * ARPCOMMENTS - Comments +# * ARPHELPLINK - Help and support information URL +# * ARPURLINFOABOUT - General information URL +# * URLUPDATEINFO - Update information URL +# * ARPHELPTELEPHONE - Help and support telephone number +# * ARPSIZE - Size (in kilobytes) of the application #============================================================================= -# Copyright 2013 Kitware, Inc. +# Copyright 2014 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. diff --git a/Modules/WIX.template.in b/Modules/WIX.template.in index 59a75c7..bbb7c88 100644 --- a/Modules/WIX.template.in +++ b/Modules/WIX.template.in @@ -40,5 +40,7 @@ + + diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 8e671cc..1ba43b3 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -215,6 +215,13 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() SetOption("CPACK_WIX_UI_REF", defaultRef.c_str()); } + const char* packageContact = GetOption("CPACK_PACKAGE_CONTACT"); + if(packageContact != 0 && + GetOption("CPACK_WIX_PROPERTY_ARPCONTACT") == 0) + { + SetOption("CPACK_WIX_PROPERTY_ARPCONTACT", packageContact); + } + CollectExtensions("CPACK_WIX_EXTENSIONS", this->CandleExtensions); CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", this->CandleExtensions); @@ -239,6 +246,7 @@ bool cmCPackWIXGenerator::PackageFilesImpl() } CreateWiXVariablesIncludeFile(); + CreateWiXPropertiesIncludeFile(); if(!CreateWiXSourceFiles()) { @@ -315,6 +323,35 @@ void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile() CopyDefinition(includeFile, "CPACK_WIX_UI_REF"); } +void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile() +{ + std::string includeFilename = + this->CPackTopLevel + "/properties.wxi"; + + cmWIXSourceWriter includeFile( + this->Logger, includeFilename, true); + + std::string prefix = "CPACK_WIX_PROPERTY_"; + std::vector options = GetOptions(); + + for(size_t i = 0; i < options.size(); ++i) + { + std::string const& name = options[i]; + + if(name.length() > prefix.length() && + name.substr(0, prefix.length()) == prefix) + { + std::string id = name.substr(prefix.length()); + std::string value = GetOption(name.c_str()); + + includeFile.BeginElement("Property"); + includeFile.AddAttribute("Id", id); + includeFile.AddAttribute("Value", value); + includeFile.EndElement("Property"); + } + } +} + void cmCPackWIXGenerator::CopyDefinition( cmWIXSourceWriter &source, std::string const& name) { diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index ee66c05..4c9f8c7 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -73,6 +73,8 @@ private: void CreateWiXVariablesIncludeFile(); + void CreateWiXPropertiesIncludeFile(); + void CopyDefinition( cmWIXSourceWriter &source, std::string const& name); diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 96491aa..e1dd4e9 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -1202,6 +1202,12 @@ const char* cmCPackGenerator::GetOption(const char* op) const } //---------------------------------------------------------------------- +std::vector cmCPackGenerator::GetOptions() const +{ + return this->MakefileMap->GetDefinitions(); +} + +//---------------------------------------------------------------------- int cmCPackGenerator::PackageFiles() { return 0; diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index bb33aa0..b1a7840 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -102,6 +102,7 @@ public: void SetOption(const char* op, const char* value); void SetOptionIfNotSet(const char* op, const char* value); const char* GetOption(const char* op) const; + std::vector GetOptions() const; bool IsSet(const char* name) const; bool IsOn(const char* name) const; diff --git a/Tests/CPackWiXGenerator/CMakeLists.txt b/Tests/CPackWiXGenerator/CMakeLists.txt index d673d14..9957f6b 100644 --- a/Tests/CPackWiXGenerator/CMakeLists.txt +++ b/Tests/CPackWiXGenerator/CMakeLists.txt @@ -58,6 +58,9 @@ set(CPACK_WIX_PATCH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/patch.xml") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/license.txt") +set(CPACK_WIX_PROPERTY_ARPCOMMENTS "My Custom ARPCOMMENTS") +set(CPACK_WIX_PROPERTY_ARPHELPLINK "http://www.cmake.org") + include(CPack) cpack_add_install_type(Full DISPLAY_NAME "Everything") -- cgit v0.12 From 642fa25da095b346d559ad39624eda79b0bd2ff8 Mon Sep 17 00:00:00 2001 From: Nils Gladitz Date: Sun, 2 Mar 2014 00:51:42 +0100 Subject: CPackWIX: support installation of empty directories --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 10 ++++++++++ Source/CPack/WiX/cmWIXFilesSourceWriter.cxx | 22 ++++++++++++++++++++++ Source/CPack/WiX/cmWIXFilesSourceWriter.h | 4 ++++ Tests/CPackWiXGenerator/CMakeLists.txt | 11 +++++++++++ 4 files changed, 47 insertions(+) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 1ba43b3..a385e40 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -814,6 +814,16 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( cmsys::Directory dir; dir.Load(topdir.c_str()); + if(dir.GetNumberOfFiles() == 2) + { + std::string componentId = fileDefinitions.EmitComponentCreateFolder( + directoryId, GenerateGUID()); + + featureDefinitions.EmitComponentRef(componentId); + + return; + } + for(size_t i = 0; i < dir.GetNumberOfFiles(); ++i) { std::string fileName = dir.GetFile(static_cast(i)); diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx index 0835f3a..3fd959e 100644 --- a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx @@ -109,6 +109,28 @@ void cmWIXFilesSourceWriter::EmitUninstallShortcut( EndElement("Shortcut"); } +std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder( + std::string const& directoryId, std::string const& guid) +{ + std::string componentId = + std::string("CM_C_EMPTY_") + directoryId; + + BeginElement("DirectoryRef"); + AddAttribute("Id", directoryId); + + BeginElement("Component"); + AddAttribute("Id", componentId); + AddAttribute("Guid", guid); + + BeginElement("CreateFolder"); + + EndElement("CreateFolder"); + EndElement("Component"); + EndElement("DirectoryRef"); + + return componentId; +} + std::string cmWIXFilesSourceWriter::EmitComponentFile( std::string const& directoryId, std::string const& id, diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.h b/Source/CPack/WiX/cmWIXFilesSourceWriter.h index d22d270..13122c2 100644 --- a/Source/CPack/WiX/cmWIXFilesSourceWriter.h +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.h @@ -45,6 +45,10 @@ public: void EmitUninstallShortcut(std::string const& packageName); + std::string EmitComponentCreateFolder( + std::string const& directoryId, + std::string const& guid); + std::string EmitComponentFile( std::string const& directoryId, std::string const& id, diff --git a/Tests/CPackWiXGenerator/CMakeLists.txt b/Tests/CPackWiXGenerator/CMakeLists.txt index 9957f6b..638e788 100644 --- a/Tests/CPackWiXGenerator/CMakeLists.txt +++ b/Tests/CPackWiXGenerator/CMakeLists.txt @@ -9,6 +9,11 @@ target_link_libraries(my-libapp mylib) add_executable(my-other-app myotherapp.cpp) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/empty) +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/empty + DESTINATION extras + COMPONENT extras) + install(TARGETS mylib ARCHIVE DESTINATION lib @@ -72,6 +77,12 @@ cpack_add_component_group(Development EXPANDED DESCRIPTION "All of the tools you'll ever need to develop software") +cpack_add_component(extras + DISPLAY_NAME "Extras" + DESCRIPTION "Extras" + GROUP Runtime + INSTALL_TYPES Full) + cpack_add_component(applications REQUIRED DISPLAY_NAME "MyLib Application" -- cgit v0.12 From 115ffb0e4da65becff69e99436468a8c96cb7639 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 2 Mar 2014 00:01:09 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 3afaf52..64cc5c4 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 0) -set(CMake_VERSION_PATCH 20140301) +set(CMake_VERSION_PATCH 20140302) #set(CMake_VERSION_RC 1) -- cgit v0.12 From ace6fa5a8b047c80cfd5c10f58446226616c1663 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 3 Mar 2014 00:01:05 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 64cc5c4..3262d09 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 0) -set(CMake_VERSION_PATCH 20140302) +set(CMake_VERSION_PATCH 20140303) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 3816cd2dc7a7cc220e4f1b1e87fee986545b9cb3 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 26 Feb 2014 21:47:20 -0500 Subject: FindPythonLibs: Find consistent Python interp, headers, libs (#13794) When possible, get consistent version of the Python interpreter, headers path, and library. Now find_package(PythonLibs) internally calls find_package(PythonInterp QUIET) and uses the resulting PYTHON_VERSION_MAJOR and PYTHON_VERSION_MINOR to prefer these versions when looking for the header path and library. The Python_ADDITIONAL_VERSIONS variable has priority over the interpreter version. Co-Author: Adam Wolf Co-Author: Gert Wollny --- Modules/FindPythonLibs.cmake | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 0749efc..27d9e45 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -80,10 +80,15 @@ endif() # Set up the versions we know about, in the order we will search. Always add # the user supplied additional versions to the front. -set(_Python_VERSIONS - ${Python_ADDITIONAL_VERSIONS} - ${_PYTHON_FIND_OTHER_VERSIONS} - ) +# If FindPythonInterp has already found the major and minor version, +# insert that version between the user supplied versions and the stock +# version list. +find_package(PythonInterp QUIET) +set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS}) +if(DEFINED PYTHON_VERSION_MAJOR AND DEFINED PYTHON_VERSION_MINOR) + list(APPEND _Python_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) +endif() +list(APPEND _Python_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS}) unset(_PYTHON_FIND_OTHER_VERSIONS) unset(_PYTHON1_VERSIONS) -- cgit v0.12 From d348cd1bc50b74786d3e350a3b29aa92eeca1339 Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Fri, 28 Feb 2014 17:36:38 +0100 Subject: FeatureSummary: Allow to combine and reorder values for the "WHAT" option For example it is now possible to do: feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES) That produces an output like: -- -- The following features have been enabled: * Feature1 * Feature2 -- The following features have been disabled: * Feature2 Skipping the lists that are empty. Without this patch this would require to do: message(STATUS "") feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "The following features have been enabled:") feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "The following features have been disabled:") And empty lists would not be skipped. The behaviour when WHAT has a single argument (ALL or any option) is unchanged. --- Modules/FeatureSummary.cmake | 56 ++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake index c0e63d5..6696515 100644 --- a/Modules/FeatureSummary.cmake +++ b/Modules/FeatureSummary.cmake @@ -71,6 +71,13 @@ # RUNTIME_PACKAGES_FOUND: only those packages which have been found which have the type RUNTIME # RUNTIME_PACKAGES_NOT_FOUND: only those packages which have not been found which have the type RUNTIME # +# With the exception of the ``ALL`` value, these values can be combined +# in order to customize the output. For example: +# +# :: +# +# feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES) +# # # # If a FILENAME is given, the information is printed into this file. If @@ -417,8 +424,8 @@ endfunction() function(FEATURE_SUMMARY) # CMAKE_PARSE_ARGUMENTS( args...) set(options APPEND INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) - set(oneValueArgs FILENAME VAR DESCRIPTION WHAT) - set(multiValueArgs ) # none + set(oneValueArgs FILENAME VAR DESCRIPTION) + set(multiValueArgs WHAT) CMAKE_PARSE_ARGUMENTS(_FS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) @@ -451,20 +458,37 @@ function(FEATURE_SUMMARY) set(requiredPackagesNotFound TRUE) endif() - elseif("${_FS_WHAT}" STREQUAL "ALL") - - set(allWhatParts "ENABLED_FEATURES" - "RUNTIME_PACKAGES_FOUND" - "OPTIONAL_PACKAGES_FOUND" - "RECOMMENDED_PACKAGES_FOUND" - "REQUIRED_PACKAGES_FOUND" + else() + if("${_FS_WHAT}" STREQUAL "ALL") + + set(allWhatParts "ENABLED_FEATURES" + "RUNTIME_PACKAGES_FOUND" + "OPTIONAL_PACKAGES_FOUND" + "RECOMMENDED_PACKAGES_FOUND" + "REQUIRED_PACKAGES_FOUND" + + "DISABLED_FEATURES" + "RUNTIME_PACKAGES_NOT_FOUND" + "OPTIONAL_PACKAGES_NOT_FOUND" + "RECOMMENDED_PACKAGES_NOT_FOUND" + "REQUIRED_PACKAGES_NOT_FOUND" + ) - "DISABLED_FEATURES" - "RUNTIME_PACKAGES_NOT_FOUND" - "OPTIONAL_PACKAGES_NOT_FOUND" - "RECOMMENDED_PACKAGES_NOT_FOUND" - "REQUIRED_PACKAGES_NOT_FOUND" - ) + else() + set(allWhatParts) + foreach(part ${_FS_WHAT}) + list(FIND validWhatParts "${part}" indexInList) + if(NOT "${indexInList}" STREQUAL "-1") + list(APPEND allWhatParts "${part}") + else() + if("${part}" STREQUAL "ALL") + message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() contains ALL, which cannot be combined with other values.") + else() + message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() contains ${part}, which is not a valid value.") + endif() + endif() + endforeach() + endif() set(title_ENABLED_FEATURES "The following features have been enabled:") set(title_DISABLED_FEATURES "The following features have been disabled:") @@ -488,8 +512,6 @@ function(FEATURE_SUMMARY) endif() endif() endforeach() - else() - message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() is set to ${_FS_WHAT}, which is not a valid value.") endif() if(_FS_FILENAME) -- cgit v0.12 From 8372b4553bc58c00ad3ef923919ff5547746b95e Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Mon, 3 Mar 2014 19:51:57 +0100 Subject: FeatureSummary: Add unit tests --- Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/FeatureSummary/CMakeLists.txt | 3 +++ Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt | 7 +++++++ Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll.cmake | 9 +++++++++ Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt | 7 +++++++ Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList.cmake | 9 +++++++++ .../RunCMake/FeatureSummary/FeatureSummaryWhatListAll-result.txt | 1 + .../RunCMake/FeatureSummary/FeatureSummaryWhatListAll-stderr.txt | 6 ++++++ Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll.cmake | 9 +++++++++ .../FeatureSummary/FeatureSummaryWhatListUnknown-result.txt | 1 + .../FeatureSummary/FeatureSummaryWhatListUnknown-stderr.txt | 6 ++++++ .../RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown.cmake | 9 +++++++++ .../RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt | 1 + Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle.cmake | 9 +++++++++ .../FeatureSummary/FeatureSummaryWhatSingleUnknown-result.txt | 1 + .../FeatureSummary/FeatureSummaryWhatSingleUnknown-stderr.txt | 6 ++++++ .../FeatureSummary/FeatureSummaryWhatSingleUnknown.cmake | 9 +++++++++ Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake | 8 ++++++++ 18 files changed, 102 insertions(+) create mode 100644 Tests/RunCMake/FeatureSummary/CMakeLists.txt create mode 100644 Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt create mode 100644 Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll.cmake create mode 100644 Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt create mode 100644 Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList.cmake create mode 100644 Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-result.txt create mode 100644 Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-stderr.txt create mode 100644 Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll.cmake create mode 100644 Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-result.txt create mode 100644 Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-stderr.txt create mode 100644 Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown.cmake create mode 100644 Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt create mode 100644 Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle.cmake create mode 100644 Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-result.txt create mode 100644 Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-stderr.txt create mode 100644 Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown.cmake create mode 100644 Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 9bb097b..c043e57 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -42,6 +42,7 @@ add_RunCMake_test(CompilerNotFound) add_RunCMake_test(Configure) add_RunCMake_test(DisallowedCommands) add_RunCMake_test(ExternalData) +add_RunCMake_test(FeatureSummary) add_RunCMake_test(FPHSA) add_RunCMake_test(GeneratorExpression) add_RunCMake_test(GeneratorToolset) diff --git a/Tests/RunCMake/FeatureSummary/CMakeLists.txt b/Tests/RunCMake/FeatureSummary/CMakeLists.txt new file mode 100644 index 0000000..72abfc8 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.11) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt new file mode 100644 index 0000000..9a3f023 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt @@ -0,0 +1,7 @@ +-- The following features have been enabled: + + \* Foo , Foo\. + +-- The following features have been disabled: + + \* Bar , Bar\. diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll.cmake new file mode 100644 index 0000000..ec5ebcb --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll.cmake @@ -0,0 +1,9 @@ +include(FeatureSummary) + +set(WITH_FOO 1) +set(WITH_BAR 0) + +add_feature_info(Foo WITH_FOO "Foo.") +add_feature_info(Bar WITH_BAR "Bar.") + +feature_summary(WHAT ALL) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt new file mode 100644 index 0000000..4d8f25f --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt @@ -0,0 +1,7 @@ +-- The following features have been disabled: + + \* Bar , Bar\. + +-- The following features have been enabled: + + \* Foo , Foo\. diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList.cmake new file mode 100644 index 0000000..d04ba88 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList.cmake @@ -0,0 +1,9 @@ +include(FeatureSummary) + +set(WITH_FOO 1) +set(WITH_BAR 0) + +add_feature_info(Foo WITH_FOO "Foo.") +add_feature_info(Bar WITH_BAR "Bar.") + +feature_summary(WHAT DISABLED_FEATURES ENABLED_FEATURES) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-result.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-stderr.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-stderr.txt new file mode 100644 index 0000000..18d9ebd --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\): + The WHAT argument of FEATURE_SUMMARY\(\) contains ALL, which cannot be + combined with other values\. +Call Stack \(most recent call first\): + FeatureSummaryWhatListAll\.cmake:[0-9]+ \(feature_summary\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll.cmake new file mode 100644 index 0000000..1877ea5 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll.cmake @@ -0,0 +1,9 @@ +include(FeatureSummary) + +set(WITH_FOO 1) +set(WITH_BAR 0) + +add_feature_info(Foo WITH_FOO "Foo.") +add_feature_info(Bar WITH_BAR "Bar.") + +feature_summary(WHAT ENABLED_FEATURES ALL) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-result.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-stderr.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-stderr.txt new file mode 100644 index 0000000..3ad3750 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\): + The WHAT argument of FEATURE_SUMMARY\(\) contains FOO, which is not a valid + value\. +Call Stack \(most recent call first\): + FeatureSummaryWhatListUnknown\.cmake:[0-9]+ \(feature_summary\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown.cmake new file mode 100644 index 0000000..46088d4 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown.cmake @@ -0,0 +1,9 @@ +include(FeatureSummary) + +set(WITH_FOO 1) +set(WITH_BAR 0) + +add_feature_info(Foo WITH_FOO "Foo.") +add_feature_info(Bar WITH_BAR "Bar.") + +feature_summary(WHAT ENABLED_FEATURES FOO) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt new file mode 100644 index 0000000..240632d --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt @@ -0,0 +1 @@ + \* Foo , Foo\. diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle.cmake new file mode 100644 index 0000000..593dfb6 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle.cmake @@ -0,0 +1,9 @@ +include(FeatureSummary) + +set(WITH_FOO 1) +set(WITH_BAR 0) + +add_feature_info(Foo WITH_FOO "Foo.") +add_feature_info(Bar WITH_BAR "Bar.") + +feature_summary(WHAT ENABLED_FEATURES) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-result.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-stderr.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-stderr.txt new file mode 100644 index 0000000..c78853c --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\): + The WHAT argument of FEATURE_SUMMARY\(\) contains FOO, which is not a valid + value\. +Call Stack \(most recent call first\): + FeatureSummaryWhatSingleUnknown\.cmake:[0-9]+ \(feature_summary\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown.cmake new file mode 100644 index 0000000..c2d6d2e --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown.cmake @@ -0,0 +1,9 @@ +include(FeatureSummary) + +set(WITH_FOO 1) +set(WITH_BAR 0) + +add_feature_info(Foo WITH_FOO "Foo.") +add_feature_info(Bar WITH_BAR "Bar.") + +feature_summary(WHAT FOO) diff --git a/Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake b/Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake new file mode 100644 index 0000000..1417338 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake @@ -0,0 +1,8 @@ +include(RunCMake) + +run_cmake(FeatureSummaryWhatAll) +run_cmake(FeatureSummaryWhatSingle) +run_cmake(FeatureSummaryWhatSingleUnknown) +run_cmake(FeatureSummaryWhatList) +run_cmake(FeatureSummaryWhatListUnknown) +run_cmake(FeatureSummaryWhatListAll) -- cgit v0.12 From e5096312378f97cca24f4190082b3b8991812608 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 3 Mar 2014 15:25:01 -0500 Subject: Tests: Drop kwsys test KWSys now has its own dashboard and test clients that run on all the machines where we test CMake. We no longer need a test inside CMake to test KWSys independently. --- Tests/CMakeLists.txt | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index c414850..6cf5814 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1453,19 +1453,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ) endif() - if(NOT CMAKE_TEST_DIFFERENT_GENERATOR) - add_test(kwsys ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Source/kwsys" - "${CMake_BINARY_DIR}/Tests/kwsys" - ${build_generator_args} - --build-project kwsys - --build-options ${build_options} - --test-command kwsysTestsCxx testIOS - ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/kwsys") - endif() - if(MAKE_SUPPORTS_SPACES) add_test(SubDirSpaces ${CMAKE_CTEST_COMMAND} --build-and-test -- cgit v0.12 From daf0a5fedebb2dac66ac26516eeeff502ddcf432 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 3 Mar 2014 12:39:10 -0500 Subject: Tests: Drop CMAKE_TEST_GENERATOR and CMAKE_TEST_MAKEPROGRAM options Drop the option to test with a different generator and make program than was used to build. This was used only to test support for the Open Watcom compiler which at one time could not build CMake. Instead we will allow CMake to be configured to skip building binaries and just run the test suite using an external CMake (in a future change). For now leave the two option variables hard-coded to the old option defaults until code can be updated to stop using them. --- CMakeLists.txt | 13 ++----------- Tests/CMakeLists.txt | 18 ++++++++---------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e1e7c3..4c2c20b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,17 +114,8 @@ endif() #----------------------------------------------------------------------- macro(CMAKE_SETUP_TESTING) if(BUILD_TESTING) - set(CMAKE_TEST_GENERATOR "" CACHE STRING - "Generator used when running tests") - set(CMAKE_TEST_MAKEPROGRAM "" CACHE FILEPATH - "Generator used when running tests") - if(NOT CMAKE_TEST_GENERATOR) - set(CMAKE_TEST_GENERATOR "${CMAKE_GENERATOR}") - set(CMAKE_TEST_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}") - else() - set(CMAKE_TEST_DIFFERENT_GENERATOR TRUE) - set(CMAKE_TEST_GENERATOR_TOOLSET "") - endif() + set(CMAKE_TEST_GENERATOR "${CMAKE_GENERATOR}") + set(CMAKE_TEST_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}") # Are we testing with the MSVC compiler? set(CMAKE_TEST_MSVC 0) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 6cf5814..fa98a2b 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -46,16 +46,14 @@ configure_file(${CMake_SOURCE_DIR}/Tests/EnforceConfig.cmake.in # Testing if(BUILD_TESTING) set(CMAKE_TEST_DEVENV "") - if(NOT CMAKE_TEST_DIFFERENT_GENERATOR) - if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio") - set(CMAKE_TEST_MAKEPROGRAM "") - else() - set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}") - endif() - if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio [7-9] " AND - NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]") - set(CMAKE_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}") - endif() + if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio") + set(CMAKE_TEST_MAKEPROGRAM "") + else() + set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}") + endif() + if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio [7-9] " AND + NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]") + set(CMAKE_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}") endif() if("${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_TEST_GENERATOR}" MATCHES Ninja AND NOT WIN32)) -- cgit v0.12 From 3c01ee5adceafb0febd9cedab9211f830f953c03 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 3 Mar 2014 12:39:30 -0500 Subject: Tests: Drop CMAKE_TEST_MSVC and test MSVC directly Now that we no longer support running tests using a different generator we can trust the MSVC platform indicator directly. --- CMakeLists.txt | 11 ----------- Tests/CMakeLists.txt | 4 ++-- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c2c20b..b9f96e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,17 +117,6 @@ macro(CMAKE_SETUP_TESTING) set(CMAKE_TEST_GENERATOR "${CMAKE_GENERATOR}") set(CMAKE_TEST_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}") - # Are we testing with the MSVC compiler? - set(CMAKE_TEST_MSVC 0) - if(MSVC AND NOT CMAKE_TEST_DIFFERENT_GENERATOR) - set(CMAKE_TEST_MSVC 1) - else() - if("${CMAKE_TEST_GENERATOR}" MATCHES "NMake" OR - "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio") - set(CMAKE_TEST_MSVC 1) - endif() - endif() - set(CMAKE_TEST_SYSTEM_LIBRARIES 0) foreach(util CURL EXPAT XMLRPC ZLIB) if(CMAKE_USE_SYSTEM_${util}) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index fa98a2b..9ca354d 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1497,12 +1497,12 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ endif () list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDir") - if(CMAKE_TEST_MSVC) + if(MSVC) ADD_TEST_MACRO(ForceInclude foo) ADD_TEST_MACRO(PDBDirectoryAndName myexe) ADD_TEST_MACRO(PrecompiledHeader foo) endif() - if(CMAKE_TEST_MSVC OR + if(MSVC OR "${CMAKE_TEST_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles") ADD_TEST_MACRO(ModuleDefinition example_exe) endif() -- cgit v0.12 From f99734b2da43af21b9c023d117eb3d0daba9b30e Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 3 Mar 2014 12:40:58 -0500 Subject: Tests: Rename CMAKE_TEST_DEVENV -> CMake_TEST_DEVENV Follow the convention of naming variables related to the CMake build itself as "CMake_" rather than "CMAKE_". While at it, consolidate the code computing CMake_TEST_DEVENV to be more localized. --- Tests/CMakeLists.txt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 9ca354d..55e1fc4 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -45,16 +45,17 @@ configure_file(${CMake_SOURCE_DIR}/Tests/EnforceConfig.cmake.in # Testing if(BUILD_TESTING) - set(CMAKE_TEST_DEVENV "") + set(CMake_TEST_DEVENV "") + if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio [7-9] " AND + NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]") + set(CMake_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}") + endif() + if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio") set(CMAKE_TEST_MAKEPROGRAM "") else() set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}") endif() - if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio [7-9] " AND - NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]") - set(CMAKE_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}") - endif() if("${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_TEST_GENERATOR}" MATCHES Ninja AND NOT WIN32)) set(TEST_CompileCommandOutput 1) @@ -1660,7 +1661,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --test-command VSMidl) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSMidl") - if(CMAKE_TEST_DEVENV) + if(CMake_TEST_DEVENV) # The test (and tested property) works with .sln files, so it's skipped when: # * Using VS6, which doesn't use .sln files # * cmake --build is set up to use MSBuild, since the MSBuild invocation does not use the .sln file @@ -1673,7 +1674,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-config ${config} --build-two-config --build-generator ${CMAKE_TEST_GENERATOR} - --build-makeprogram ${CMAKE_TEST_DEVENV} + --build-makeprogram ${CMake_TEST_DEVENV} --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" --build-project VSExcludeFromDefaultBuild --test-command ${CMAKE_COMMAND} -- cgit v0.12 From 4047557379c34223f2e27a626e1a06e6702329f4 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 3 Mar 2014 12:46:41 -0500 Subject: Tests: Rename CMAKE_TEST_MAKEPROGRAM uses for nested test projects In the ExportImport, Fortran, and MacRuntimePath tests the CMAKE_TEST_MAKEPROGRAM variable is used to pass an explicit request for a CMAKE_MAKE_PROGRAM value to be used when building the inner projects. Rename these use cases to CMake_TEST_NESTED_MAKE_PROGRAM. --- Tests/CMakeLists.txt | 6 +++--- Tests/ExportImport/CMakeLists.txt | 4 ++-- Tests/ExportImport/InitialCache.cmake.in | 2 +- Tests/Fortran/CMakeLists.txt | 6 +++--- Tests/MacRuntimePath/CMakeLists.txt | 4 ++-- Tests/MacRuntimePath/InitialCache.cmake.in | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 55e1fc4..654b717 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -259,7 +259,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(Assembler HelloAsm) ADD_TEST_MACRO(SourceGroups SourceGroups) ADD_TEST_MACRO(Preprocess Preprocess) - set(ExportImport_BUILD_OPTIONS -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}) + set(ExportImport_BUILD_OPTIONS -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}) ADD_TEST_MACRO(ExportImport ExportImport) ADD_TEST_MACRO(Unset Unset) ADD_TEST_MACRO(PolicyScope PolicyScope) @@ -1405,7 +1405,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project MacRuntimePath --build-options ${build_options} - -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM} + -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM} ) endif() @@ -2567,7 +2567,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-project testf --build-two-config --build-options ${build_options} - -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM} + -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM} --test-command testf) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran") diff --git a/Tests/ExportImport/CMakeLists.txt b/Tests/ExportImport/CMakeLists.txt index 02a0371..a6f8921 100644 --- a/Tests/ExportImport/CMakeLists.txt +++ b/Tests/ExportImport/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 2.7.20090711) project(ExportImport C CXX) -if(NOT DEFINED CMAKE_TEST_MAKEPROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") - set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}") +if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") + set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") endif() # Wipe out the install tree to make sure the exporter works. diff --git a/Tests/ExportImport/InitialCache.cmake.in b/Tests/ExportImport/InitialCache.cmake.in index fba6ee2..f600d90 100644 --- a/Tests/ExportImport/InitialCache.cmake.in +++ b/Tests/ExportImport/InitialCache.cmake.in @@ -1,4 +1,4 @@ -set(CMAKE_MAKE_PROGRAM "@CMAKE_TEST_MAKEPROGRAM@" CACHE FILEPATH "Make Program") +set(CMAKE_MAKE_PROGRAM "@CMake_TEST_NESTED_MAKE_PROGRAM@" CACHE FILEPATH "Make Program") set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@" CACHE STRING "C Compiler") set(CMAKE_C_FLAGS "@CMAKE_C_FLAGS@" CACHE STRING "C Flags") set(CMAKE_C_FLAGS_DEBUG "@CMAKE_C_FLAGS_DEBUG@" CACHE STRING "C Flags") diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index adc4308..bf6d629 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 2.6) project(testf C CXX Fortran) -if(NOT DEFINED CMAKE_TEST_MAKEPROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") - set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}") +if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") + set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") endif() message("CTEST_FULL_OUTPUT ") @@ -208,7 +208,7 @@ if(TEST_MODULE_DEPENDS) -DCMAKE_Fortran_FLAGS_RELEASE:STRING=${CMAKE_Fortran_FLAGS_RELEASE} -DCMAKE_Fortran_FLAGS_MINSIZEREL:STRING=${CMAKE_Fortran_FLAGS_MINSIZEREL} -DCMAKE_Fortran_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} - -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM} + -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_NESTED_MAKE_PROGRAM} ${External_BUILD_TYPE} VERBATIM ) diff --git a/Tests/MacRuntimePath/CMakeLists.txt b/Tests/MacRuntimePath/CMakeLists.txt index 5c7b921..eeb3653 100644 --- a/Tests/MacRuntimePath/CMakeLists.txt +++ b/Tests/MacRuntimePath/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 2.8) project(MacRuntimePath) -if(NOT DEFINED CMAKE_TEST_MAKEPROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") - set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}") +if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") + set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") endif() # Wipe out the install tree to make sure the exporter works. diff --git a/Tests/MacRuntimePath/InitialCache.cmake.in b/Tests/MacRuntimePath/InitialCache.cmake.in index 3dc9041..a9f6a3c 100644 --- a/Tests/MacRuntimePath/InitialCache.cmake.in +++ b/Tests/MacRuntimePath/InitialCache.cmake.in @@ -1,4 +1,4 @@ -set(CMAKE_MAKE_PROGRAM "@CMAKE_TEST_MAKEPROGRAM@" CACHE FILEPATH "Make Program") +set(CMAKE_MAKE_PROGRAM "@CMake_TEST_NESTED_MAKE_PROGRAM@" CACHE FILEPATH "Make Program") set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@" CACHE STRING "C Compiler") set(CMAKE_C_FLAGS "@CMAKE_C_FLAGS@" CACHE STRING "C Flags") set(CMAKE_C_FLAGS_DEBUG "@CMAKE_C_FLAGS_DEBUG@" CACHE STRING "C Flags") -- cgit v0.12 From a8a9fb7edd2e3631388c9e18e4700cbb12207be8 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 3 Mar 2014 13:58:19 -0500 Subject: Tests: Rename CMAKE_TEST_MAKEPROGRAM uses for explicit make program Rename uses of the variable for specifying the make program used to build test projects to CMake_TEST_EXPLICIT_MAKE_PROGRAM. --- Tests/CMakeLists.txt | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 654b717..b2ff3bb 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -51,10 +51,11 @@ if(BUILD_TESTING) set(CMake_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}") endif() + set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}") if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio") - set(CMAKE_TEST_MAKEPROGRAM "") + set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "") else() - set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}") + set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") endif() if("${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_TEST_GENERATOR}" MATCHES Ninja AND NOT WIN32)) @@ -91,8 +92,8 @@ if(BUILD_TESTING) endif() set(build_options) - if(CMAKE_TEST_MAKEPROGRAM) - list(APPEND build_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}) + if(CMake_TEST_EXPLICIT_MAKE_PROGRAM) + list(APPEND build_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}) endif() add_subdirectory(CMakeLib) @@ -259,7 +260,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(Assembler HelloAsm) ADD_TEST_MACRO(SourceGroups SourceGroups) ADD_TEST_MACRO(Preprocess Preprocess) - set(ExportImport_BUILD_OPTIONS -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}) + set(ExportImport_BUILD_OPTIONS -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}) ADD_TEST_MACRO(ExportImport ExportImport) ADD_TEST_MACRO(Unset Unset) ADD_TEST_MACRO(PolicyScope PolicyScope) @@ -536,9 +537,9 @@ if(BUILD_TESTING) # the bar library which should be referenced because # foo links to the static library bar, but bar is not # directly in the foo sub project - if(CMAKE_TEST_MAKEPROGRAM) + if(CMake_TEST_EXPLICIT_MAKE_PROGRAM) set(SubProject-Stage2_BUILD_MAKEPROGRAM - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-makeprogram ${CMake_TEST_EXPLICIT_MAKE_PROGRAM} ) endif() add_test(SubProject-Stage2 ${CMAKE_CTEST_COMMAND} @@ -1405,7 +1406,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project MacRuntimePath --build-options ${build_options} - -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM} + -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM} ) endif() @@ -1866,8 +1867,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ if(CMAKE_TEST_GENERATOR_TOOLSET) list(APPEND ctest_configure_options -T ${CMAKE_TEST_GENERATOR_TOOLSET}) endif() - if(CMAKE_TEST_MAKEPROGRAM) - list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}) + if(CMake_TEST_EXPLICIT_MAKE_PROGRAM) + list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}) endif() configure_file("${CMake_SOURCE_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake" @ONLY) @@ -2567,7 +2568,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-project testf --build-two-config --build-options ${build_options} - -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM} + -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM} --test-command testf) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran") -- cgit v0.12 From 76477267bda58d10b8e00229bffd841f9e73d041 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 3 Mar 2014 13:58:37 -0500 Subject: Tests: Drop CMAKE_TEST_MAKEPROGRAM variable Remaining uses of the variable simply test its value so use CMAKE_MAKE_PROGRAM directly instead. --- Tests/CMakeLists.txt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index b2ff3bb..4c247fd 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -51,7 +51,6 @@ if(BUILD_TESTING) set(CMake_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}") endif() - set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}") if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio") set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "") else() @@ -63,8 +62,8 @@ if(BUILD_TESTING) endif() set(MAKE_IS_GNU ) - if(CMAKE_TEST_MAKEPROGRAM MATCHES make) - execute_process(COMMAND ${CMAKE_TEST_MAKEPROGRAM} no_such_target --version + if(CMAKE_MAKE_PROGRAM MATCHES make) + execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} no_such_target --version RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out) if("${res}" STREQUAL "0") if("${out}" MATCHES "GNU") @@ -75,7 +74,7 @@ if(BUILD_TESTING) # some old versions of make simply cannot handle spaces in paths if (MAKE_IS_GNU OR - CMAKE_TEST_MAKEPROGRAM MATCHES "nmake|gmake|wmake" OR + CMAKE_MAKE_PROGRAM MATCHES "nmake|gmake|wmake" OR CMAKE_TEST_GENERATOR MATCHES "Visual Studio|XCode|Borland") set(MAKE_SUPPORTS_SPACES 1) else() @@ -1533,10 +1532,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ # Look for evidence that this is a VCExpress build. If so, avoid # the MFC test by default. - string(TOLOWER "${CMAKE_MAKE_PROGRAM};${CMAKE_TEST_MAKEPROGRAM}" mkprog) + string(TOLOWER "${CMAKE_MAKE_PROGRAM}" mkprog) if(mkprog MATCHES "vcexpress") message(STATUS - "CMAKE_TEST_MAKEPROGRAM indicates vcexpress, avoiding MFC test") + "CMAKE_MAKE_PROGRAM indicates vcexpress, avoiding MFC test") set(CTEST_RUN_MFC OFF) endif() -- cgit v0.12 From 9f5bd180c8e0114ff153deeaa1690ce9eb250005 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 3 Mar 2014 14:06:34 -0500 Subject: Tests: Drop CMAKE_TEST_GENERATOR(|_TOOLSET) variables s/CMAKE_TEST_GENERATOR/CMAKE_GENERATOR/g --- CMakeLists.txt | 5 +- Tests/CMakeBuildTest.cmake.in | 4 +- Tests/CMakeLists.txt | 84 +++++++++++----------- Tests/CMakeOnly/Test.cmake.in | 4 +- .../CTestBuildCommandProjectInSubdir.cmake.in | 2 +- Tests/CTestConfig/dashboard.cmake.in | 4 +- Tests/CTestConfig/script.cmake.in | 4 +- Tests/CTestTestBadExe/test.cmake.in | 4 +- Tests/CTestTestChecksum/test.cmake.in | 4 +- Tests/CTestTestConfigFileInBuildDir/test1.cmake.in | 4 +- Tests/CTestTestConfigFileInBuildDir/test2.cmake.in | 4 +- Tests/CTestTestCostSerial/test.cmake.in | 4 +- Tests/CTestTestCrash/test.cmake.in | 4 +- Tests/CTestTestCycle/test.cmake.in | 4 +- Tests/CTestTestDepends/test.cmake.in | 4 +- Tests/CTestTestFailure/testNoBuild.cmake.in | 4 +- Tests/CTestTestFailure/testNoExe.cmake.in | 4 +- Tests/CTestTestFdSetSize/test.cmake.in | 4 +- Tests/CTestTestMemcheck/test.cmake.in | 4 +- Tests/CTestTestParallel/test.cmake.in | 4 +- Tests/CTestTestResourceLock/test.cmake.in | 4 +- Tests/CTestTestScheduler/test.cmake.in | 4 +- Tests/CTestTestSkipReturnCode/test.cmake.in | 4 +- Tests/CTestTestStopTime/test.cmake.in | 4 +- Tests/CTestTestSubdir/test.cmake.in | 4 +- Tests/CTestTestTimeout/test.cmake.in | 4 +- Tests/CTestTestUpload/test.cmake.in | 4 +- Tests/CTestTestZeroTimeout/test.cmake.in | 4 +- .../ExternalProjectUpdateTest.cmake | 2 +- Tests/FortranC/Flags.cmake.in | 4 +- Tests/RunCMake/CMakeLists.txt | 8 +-- 31 files changed, 101 insertions(+), 104 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9f96e2..a043838 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,9 +114,6 @@ endif() #----------------------------------------------------------------------- macro(CMAKE_SETUP_TESTING) if(BUILD_TESTING) - set(CMAKE_TEST_GENERATOR "${CMAKE_GENERATOR}") - set(CMAKE_TEST_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}") - set(CMAKE_TEST_SYSTEM_LIBRARIES 0) foreach(util CURL EXPAT XMLRPC ZLIB) if(CMAKE_USE_SYSTEM_${util}) @@ -547,7 +544,7 @@ endif() # add a test add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}" - --system-information -G "${CMAKE_TEST_GENERATOR}" ) + --system-information -G "${CMAKE_GENERATOR}" ) # Install license file as it requires. install(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR}) diff --git a/Tests/CMakeBuildTest.cmake.in b/Tests/CMakeBuildTest.cmake.in index 0f7074b..aaefe43 100644 --- a/Tests/CMakeBuildTest.cmake.in +++ b/Tests/CMakeBuildTest.cmake.in @@ -11,8 +11,8 @@ file(REMOVE "@CMAKE_BUILD_TEST_SOURCE_DIR@/CMakeCache.txt") message("running: ${CMAKE_COMMAND}") execute_process(COMMAND "${CMAKE_COMMAND}" "@CMAKE_BUILD_TEST_SOURCE_DIR@" - "-G@CMAKE_TEST_GENERATOR@" - -T "@CMAKE_TEST_GENERATOR_TOOLSET@" + "-G@CMAKE_GENERATOR@" + -T "@CMAKE_GENERATOR_TOOLSET@" WORKING_DIRECTORY "@CMAKE_BUILD_TEST_BINARY_DIR@" RESULT_VARIABLE RESULT) if(RESULT) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 4c247fd..1c7f29c 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -46,18 +46,18 @@ configure_file(${CMake_SOURCE_DIR}/Tests/EnforceConfig.cmake.in # Testing if(BUILD_TESTING) set(CMake_TEST_DEVENV "") - if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio [7-9] " AND + if(CMAKE_GENERATOR MATCHES "Visual Studio [7-9] " AND NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]") set(CMake_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}") endif() - if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio") + if(CMAKE_GENERATOR MATCHES "Visual Studio") set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "") else() set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") endif() - if("${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_TEST_GENERATOR}" MATCHES Ninja AND NOT WIN32)) + if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_GENERATOR}" MATCHES Ninja AND NOT WIN32)) set(TEST_CompileCommandOutput 1) endif() @@ -75,18 +75,18 @@ if(BUILD_TESTING) # some old versions of make simply cannot handle spaces in paths if (MAKE_IS_GNU OR CMAKE_MAKE_PROGRAM MATCHES "nmake|gmake|wmake" OR - CMAKE_TEST_GENERATOR MATCHES "Visual Studio|XCode|Borland") + CMAKE_GENERATOR MATCHES "Visual Studio|XCode|Borland") set(MAKE_SUPPORTS_SPACES 1) else() set(MAKE_SUPPORTS_SPACES 0) endif() set(build_generator_args - --build-generator ${CMAKE_TEST_GENERATOR} + --build-generator ${CMAKE_GENERATOR} ) - if(CMAKE_TEST_GENERATOR_TOOLSET) + if(CMAKE_GENERATOR_TOOLSET) list(APPEND build_generator_args - --build-generator-toolset ${CMAKE_TEST_GENERATOR_TOOLSET} + --build-generator-toolset ${CMAKE_GENERATOR_TOOLSET} ) endif() @@ -198,8 +198,8 @@ if(BUILD_TESTING) set(TEST_RESOURCES TRUE) endif() # for borland and watcom there is no resource support - if("${CMAKE_TEST_GENERATOR}" MATCHES "WMake" OR - "${CMAKE_TEST_GENERATOR}" MATCHES "Borland") + if("${CMAKE_GENERATOR}" MATCHES "WMake" OR + "${CMAKE_GENERATOR}" MATCHES "Borland") set(TEST_RESOURCES FALSE) endif() if(TEST_RESOURCES) @@ -275,7 +275,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(CrossCompile CrossCompile) set_tests_properties(CrossCompile PROPERTIES PASS_REGULAR_EXPRESSION "TRY_RUN.. invoked in cross-compiling mode") - if("${CMAKE_TEST_GENERATOR}" MATCHES "Make") + if("${CMAKE_GENERATOR}" MATCHES "Make") ADD_TEST_MACRO(Policy0002 Policy0002) endif() if(CTEST_TEST_OSX_ARCH) @@ -314,7 +314,7 @@ if(BUILD_TESTING) MINGW OR CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") - if(NOT "${CMAKE_TEST_GENERATOR}" STREQUAL "Watcom WMake") + if(NOT "${CMAKE_GENERATOR}" STREQUAL "Watcom WMake") add_test(BundleUtilities ${CMAKE_CTEST_COMMAND} --build-and-test @@ -465,7 +465,7 @@ if(BUILD_TESTING) # build the "Simple" test with the ExtraGenerators, if available # This doesn't test whether the generated project files work (unfortunately), # mainly it tests that cmake doesn't crash when generating these project files. - if(${CMAKE_TEST_GENERATOR} MATCHES "Unix Makefiles" OR ${CMAKE_TEST_GENERATOR} MATCHES "KDevelop") + if(${CMAKE_GENERATOR} MATCHES "Unix Makefiles" OR ${CMAKE_GENERATOR} MATCHES "KDevelop") # check which generators we have execute_process(COMMAND ${CMAKE_CMAKE_COMMAND} --help OUTPUT_VARIABLE cmakeOutput ERROR_VARIABLE cmakeOutput) @@ -477,7 +477,7 @@ if(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/Simple_EclipseGenerator" --build-two-config --build-generator "Eclipse CDT4 - Unix Makefiles" - --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" + --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" --build-project Simple --build-options ${build_options} --test-command Simple) @@ -492,7 +492,7 @@ if(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/Simple_CodeBlocksGenerator" --build-two-config --build-generator "CodeBlocks - Unix Makefiles" - --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" + --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" --build-project Simple --build-options ${build_options} --test-command Simple) @@ -506,7 +506,7 @@ if(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/Simple_KDevelop3Generator" --build-two-config --build-generator "KDevelop3 - Unix Makefiles" - --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" + --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" --build-project Simple --build-options ${build_options} --test-command Simple) @@ -517,7 +517,7 @@ if(BUILD_TESTING) # test for correct sub-project generation # not implemented in VS 6, VS 7.0, Xcode, or Ninja - if(NOT CMAKE_TEST_GENERATOR MATCHES "Visual Studio [67]$|Xcode|Ninja") + if(NOT CMAKE_GENERATOR MATCHES "Visual Studio [67]$|Xcode|Ninja") # run cmake and configure all of SubProject # but only build the independent executable car add_test(SubProject ${CMAKE_CTEST_COMMAND} @@ -545,8 +545,8 @@ if(BUILD_TESTING) --build-and-test "${CMake_SOURCE_DIR}/Tests/SubProject/foo" "${CMake_BINARY_DIR}/Tests/SubProject/foo" - --build-generator ${CMAKE_TEST_GENERATOR} - --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" + --build-generator ${CMAKE_GENERATOR} + --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" ${SubProject-Stage2_BUILD_MAKEPROGRAM} --build-nocmake --build-project foo @@ -995,7 +995,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ if(CTEST_RUN_CMakeTestBadCommandLines) add_test(CMakeTestBadCommandLines ${CMAKE_CMAKE_COMMAND} -D dir=${CMake_BINARY_DIR}/Tests/CMakeTestBadCommandLines - -D gen=${CMAKE_TEST_GENERATOR} + -D gen=${CMAKE_GENERATOR} -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR} -P ${CMake_SOURCE_DIR}/Tests/CMakeTestBadCommandLines/RunCMake.cmake ) @@ -1010,7 +1010,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ if(CTEST_RUN_CMakeTestMultipleConfigures) add_test(CMakeTestMultipleConfigures ${CMAKE_CMAKE_COMMAND} -D dir=${CMake_BINARY_DIR}/Tests/CMakeTestMultipleConfigures - -D gen=${CMAKE_TEST_GENERATOR} + -D gen=${CMAKE_GENERATOR} -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR} -P ${CMake_SOURCE_DIR}/Tests/CMakeTestMultipleConfigures/RunCMake.cmake ) @@ -1233,8 +1233,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ COMMAND ${CMAKE_CMAKE_COMMAND} -DExternalProjectUpdate_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate -DExternalProjectUpdate_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate - -DCMAKE_TEST_GENERATOR=${CMAKE_TEST_GENERATOR} - -DCMAKE_TEST_GENERATOR_TOOLSET=${CMAKE_TEST_GENERATOR_TOOLSET} + -DCMAKE_GENERATOR=${CMAKE_GENERATOR} + -DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET} -DCMAKE_CTEST_COMMAND=${CMAKE_CTEST_COMMAND} -P ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake ) @@ -1504,13 +1504,13 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ADD_TEST_MACRO(PrecompiledHeader foo) endif() if(MSVC OR - "${CMAKE_TEST_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles") + "${CMAKE_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles") ADD_TEST_MACRO(ModuleDefinition example_exe) endif() ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables) - if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile") + if("${CMAKE_GENERATOR}" MATCHES "Makefile") add_test(MakeClean ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/MakeClean" @@ -1556,7 +1556,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ # For the Watcom WMake generator, avoid the MFC test by default. if(CTEST_RUN_MFC) - if("${CMAKE_TEST_GENERATOR}" MATCHES "WMake") + if("${CMAKE_GENERATOR}" MATCHES "WMake") message(STATUS "using the Watcom WMake generator, avoiding MFC test") set(CTEST_RUN_MFC OFF) @@ -1629,13 +1629,13 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MFC") endif() - if(${CMAKE_TEST_GENERATOR} MATCHES "Visual Studio") + if(${CMAKE_GENERATOR} MATCHES "Visual Studio") if(NOT MSVC60) ADD_TEST_MACRO(SBCS SBCS) endif() - if(NOT "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [6789]( |$)" - AND NOT CMAKE_TEST_GENERATOR_TOOLSET) + if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio [6789]( |$)" + AND NOT CMAKE_GENERATOR_TOOLSET) ADD_TEST_MACRO(VSWindowsFormsResx VSWindowsFormsResx) endif() @@ -1673,9 +1673,9 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild" --build-config ${config} --build-two-config - --build-generator ${CMAKE_TEST_GENERATOR} + --build-generator ${CMAKE_GENERATOR} --build-makeprogram ${CMake_TEST_DEVENV} - --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" + --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" --build-project VSExcludeFromDefaultBuild --test-command ${CMAKE_COMMAND} -D "activeConfig=${config}" @@ -1691,15 +1691,15 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild") endif() - if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio ([0-5]|[6-9][0-9])") + if(CMAKE_GENERATOR MATCHES "Visual Studio ([0-5]|[6-9][0-9])") # This is Visual Studio 10 or above, so the default build tool is MSBuild. add_test(NAME VSProjectInSubdir COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/VSProjectInSubdir" "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir" --build-two-config - --build-generator ${CMAKE_TEST_GENERATOR} - --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" + --build-generator ${CMAKE_GENERATOR} + --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" --build-project VSProjectInSubdir --build-target test) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir") @@ -1737,7 +1737,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --test-command ${CMAKE_CMAKE_COMMAND} -DCTEST_CONFIGURATION_TYPE=\${CTEST_CONFIGURATION_TYPE} -Ddir=${CMake_BINARY_DIR}/Tests/CFBundleTest - -Dgen=${CMAKE_TEST_GENERATOR} + -Dgen=${CMAKE_GENERATOR} -P ${CMake_SOURCE_DIR}/Tests/CFBundleTest/VerifyResult.cmake) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CFBundleTest") @@ -1790,7 +1790,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ FAIL_REGULAR_EXPRESSION "CMake Warning .*VariableUnusedViaUnset.CMakeLists.txt:5 \\(set\\):") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset") - if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile" AND NOT WIN32) + if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND NOT WIN32) # Ninja does not support ADDITIONAL_MAKE_CLEAN_FILES and therefore fails # this test. (See #13371) # Apparently Visual Studio does not support it either. As the MakeClean @@ -1863,8 +1863,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ # A test for ctest_build() with targets in subdirectories set(ctest_configure_options) - if(CMAKE_TEST_GENERATOR_TOOLSET) - list(APPEND ctest_configure_options -T ${CMAKE_TEST_GENERATOR_TOOLSET}) + if(CMAKE_GENERATOR_TOOLSET) + list(APPEND ctest_configure_options -T ${CMAKE_GENERATOR_TOOLSET}) endif() if(CMake_TEST_EXPLICIT_MAKE_PROGRAM) list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}) @@ -2206,7 +2206,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCrash/testOutput.log" ) # with watcom the SEGFAULT is not found, it just fails - if(CMAKE_TEST_GENERATOR MATCHES "Watcom WMake") + if(CMAKE_GENERATOR MATCHES "Watcom WMake") set_tests_properties(CTestTestCrash PROPERTIES PASS_REGULAR_EXPRESSION "Failed") else() @@ -2485,7 +2485,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log" ) - if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_TEST_GENERATOR}" MATCHES "Ninja") + if("${CMAKE_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_GENERATOR}" MATCHES "Ninja") configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestLaunchers/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/test.cmake" @ONLY ESCAPE_QUOTES) add_test(CTestTestLaunchers ${CMAKE_CTEST_COMMAND} @@ -2522,7 +2522,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ endif () endif () - if("${CMAKE_TEST_GENERATOR}" MATCHES Xcode) + if("${CMAKE_GENERATOR}" MATCHES Xcode) set(CMAKE_SKIP_BOOTSTRAP_TEST 1) endif() if(EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt") @@ -2594,7 +2594,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ find_package(Java COMPONENTS Development QUIET) if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE AND Java_JAR_EXECUTABLE AND NOT MINGW - AND NOT "${CMAKE_TEST_GENERATOR}" MATCHES "Xcode") + AND NOT "${CMAKE_GENERATOR}" MATCHES "Xcode") get_filename_component(JNIPATH ${JAVA_COMPILE} PATH) find_file(JNI_H jni.h "${JNIPATH}/../include" @@ -2618,7 +2618,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ endif() # add some cross compiler tests, for now only with makefile based generators - if(CMAKE_TEST_GENERATOR MATCHES "Makefiles" OR CMAKE_TEST_GENERATOR MATCHES "KDevelop") + if(CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "KDevelop") # if sdcc is found, build the SimpleCOnly project with sdcc find_program(SDCC_EXECUTABLE sdcc) diff --git a/Tests/CMakeOnly/Test.cmake.in b/Tests/CMakeOnly/Test.cmake.in index a266415..285643a 100644 --- a/Tests/CMakeOnly/Test.cmake.in +++ b/Tests/CMakeOnly/Test.cmake.in @@ -8,8 +8,8 @@ file(REMOVE_RECURSE "${binary_dir}") file(MAKE_DIRECTORY "${binary_dir}") execute_process( COMMAND ${CMAKE_COMMAND} ${CMAKE_ARGS} - "${source_dir}" -G "@CMAKE_TEST_GENERATOR@" - -T "@CMAKE_TEST_GENERATOR_TOOLSET@" + "${source_dir}" -G "@CMAKE_GENERATOR@" + -T "@CMAKE_GENERATOR_TOOLSET@" WORKING_DIRECTORY "${binary_dir}" RESULT_VARIABLE result ) diff --git a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in b/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in index abf010b..670a874 100644 --- a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in +++ b/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.10) set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/VSProjectInSubdir") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestBuildCommandProjectInSubdir/Nested") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") set(CTEST_PROJECT_NAME "VSProjectInSubdir") set(CTEST_BUILD_CONFIGURATION "@CTestTest_CONFIG@") diff --git a/Tests/CTestConfig/dashboard.cmake.in b/Tests/CTestConfig/dashboard.cmake.in index 0bba6d6..608501c 100644 --- a/Tests/CTestConfig/dashboard.cmake.in +++ b/Tests/CTestConfig/dashboard.cmake.in @@ -18,8 +18,8 @@ endif() message("cmake initial configure") execute_process(COMMAND ${CMAKE_COMMAND} ${arg} - -G "@CMAKE_TEST_GENERATOR@" - -T "@CMAKE_TEST_GENERATOR_TOOLSET@" + -G "@CMAKE_GENERATOR@" + -T "@CMAKE_GENERATOR_TOOLSET@" ${CTEST_SOURCE_DIRECTORY} WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} RESULT_VARIABLE rv) diff --git a/Tests/CTestConfig/script.cmake.in b/Tests/CTestConfig/script.cmake.in index 83267a4..166de3b 100644 --- a/Tests/CTestConfig/script.cmake.in +++ b/Tests/CTestConfig/script.cmake.in @@ -1,5 +1,5 @@ -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_PROJECT_NAME "CTestConfig") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestConfig") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig/@cfg@-script") diff --git a/Tests/CTestTestBadExe/test.cmake.in b/Tests/CTestTestBadExe/test.cmake.in index a7420fc..601aab4 100644 --- a/Tests/CTestTestBadExe/test.cmake.in +++ b/Tests/CTestTestBadExe/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-BadExe") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestBadExe") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestBadExe") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestChecksum/test.cmake.in b/Tests/CTestTestChecksum/test.cmake.in index b18cdf3..8413443 100644 --- a/Tests/CTestTestChecksum/test.cmake.in +++ b/Tests/CTestTestChecksum/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Checksum") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestParallel") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestParallel") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in b/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in index 42225d3..d3510bb 100644 --- a/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in +++ b/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ConfigFileInBuild set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestConfigFileInBuildDir") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestConfigFileInBuildDir1") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in b/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in index 010fe1c..99b002c 100644 --- a/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in +++ b/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ConfigFileInBuild set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestConfigFileInBuildDir") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestConfigFileInBuildDir2") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestCostSerial/test.cmake.in b/Tests/CTestTestCostSerial/test.cmake.in index e2dda95..ce8720c 100644 --- a/Tests/CTestTestCostSerial/test.cmake.in +++ b/Tests/CTestTestCostSerial/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-CostSerial") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestCostSerial") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCostSerial") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestCrash/test.cmake.in b/Tests/CTestTestCrash/test.cmake.in index 7ac1bb9..5906d12 100644 --- a/Tests/CTestTestCrash/test.cmake.in +++ b/Tests/CTestTestCrash/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Crash") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestCrash") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCrash") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestCycle/test.cmake.in b/Tests/CTestTestCycle/test.cmake.in index 94b9cac..478badb 100644 --- a/Tests/CTestTestCycle/test.cmake.in +++ b/Tests/CTestTestCycle/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Cycle") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestCycle") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCycle") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestDepends/test.cmake.in b/Tests/CTestTestDepends/test.cmake.in index 98b2a27..a7de8cc 100644 --- a/Tests/CTestTestDepends/test.cmake.in +++ b/Tests/CTestTestDepends/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Depends") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestDepends") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestDepends") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestFailure/testNoBuild.cmake.in b/Tests/CTestTestFailure/testNoBuild.cmake.in index 1dee1ae..143daf8 100644 --- a/Tests/CTestTestFailure/testNoBuild.cmake.in +++ b/Tests/CTestTestFailure/testNoBuild.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-NoBuild") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestFailure") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFailure") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestFailure/testNoExe.cmake.in b/Tests/CTestTestFailure/testNoExe.cmake.in index 04e444d..11a1930 100644 --- a/Tests/CTestTestFailure/testNoExe.cmake.in +++ b/Tests/CTestTestFailure/testNoExe.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-NoExe") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestFailure") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFailure") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestFdSetSize/test.cmake.in b/Tests/CTestTestFdSetSize/test.cmake.in index c24f505..fbe0e82 100644 --- a/Tests/CTestTestFdSetSize/test.cmake.in +++ b/Tests/CTestTestFdSetSize/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-FdSetSize") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestFdSetSize") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFdSetSize") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestMemcheck/test.cmake.in b/Tests/CTestTestMemcheck/test.cmake.in index 6c388c5..471e5a5 100644 --- a/Tests/CTestTestMemcheck/test.cmake.in +++ b/Tests/CTestTestMemcheck/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Memcheck@SUBTEST_ set(CTEST_SOURCE_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/@SUBTEST_NAME@") set(CTEST_BINARY_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/@SUBTEST_NAME@") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestParallel/test.cmake.in b/Tests/CTestTestParallel/test.cmake.in index 5826342..48631ca 100644 --- a/Tests/CTestTestParallel/test.cmake.in +++ b/Tests/CTestTestParallel/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Parallel") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestParallel") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestParallel") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestResourceLock/test.cmake.in b/Tests/CTestTestResourceLock/test.cmake.in index f69b519..6ec6dfe 100644 --- a/Tests/CTestTestResourceLock/test.cmake.in +++ b/Tests/CTestTestResourceLock/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ResourceLock") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestResourceLock") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestResourceLock") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestScheduler/test.cmake.in b/Tests/CTestTestScheduler/test.cmake.in index 26d8058..06ba33e 100644 --- a/Tests/CTestTestScheduler/test.cmake.in +++ b/Tests/CTestTestScheduler/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Scheduler") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestScheduler") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestScheduler") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestSkipReturnCode/test.cmake.in b/Tests/CTestTestSkipReturnCode/test.cmake.in index ebee01b..d3c44f5 100644 --- a/Tests/CTestTestSkipReturnCode/test.cmake.in +++ b/Tests/CTestTestSkipReturnCode/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-SkipReturnCode") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestSkipReturnCode") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestSkipReturnCode") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestStopTime/test.cmake.in b/Tests/CTestTestStopTime/test.cmake.in index d4e5a25..8adf941 100644 --- a/Tests/CTestTestStopTime/test.cmake.in +++ b/Tests/CTestTestStopTime/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-StopTime") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestStopTime") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestStopTime") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestSubdir/test.cmake.in b/Tests/CTestTestSubdir/test.cmake.in index 2b4ef4f..5a6caf1 100644 --- a/Tests/CTestTestSubdir/test.cmake.in +++ b/Tests/CTestTestSubdir/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Subdir") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestSubdir") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestSubdir") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestTimeout/test.cmake.in b/Tests/CTestTestTimeout/test.cmake.in index d3d0888..4178849 100644 --- a/Tests/CTestTestTimeout/test.cmake.in +++ b/Tests/CTestTestTimeout/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Timeout") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestTimeout") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestTimeout") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestUpload/test.cmake.in b/Tests/CTestTestUpload/test.cmake.in index 340877f..bb6ba25 100644 --- a/Tests/CTestTestUpload/test.cmake.in +++ b/Tests/CTestTestUpload/test.cmake.in @@ -7,8 +7,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Upload") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestUpload") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestUpload") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") CTEST_START(Experimental) diff --git a/Tests/CTestTestZeroTimeout/test.cmake.in b/Tests/CTestTestZeroTimeout/test.cmake.in index 3252754..beb6d90 100644 --- a/Tests/CTestTestZeroTimeout/test.cmake.in +++ b/Tests/CTestTestZeroTimeout/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ZeroTimeout") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestZeroTimeout") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestZeroTimeout") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake index b6f848a..ea59a8e 100644 --- a/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake +++ b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake @@ -12,7 +12,7 @@ macro(check_a_tag desired_tag resulting_sha fetch_expected) # Configure execute_process(COMMAND ${CMAKE_COMMAND} - -G ${CMAKE_TEST_GENERATOR} -T "${CMAKE_TEST_GENERATOR_TOOLSET}" + -G ${CMAKE_GENERATOR} -T "${CMAKE_GENERATOR_TOOLSET}" -DTEST_GIT_TAG:STRING=${desired_tag} ${ExternalProjectUpdate_SOURCE_DIR} WORKING_DIRECTORY ${ExternalProjectUpdate_BINARY_DIR} diff --git a/Tests/FortranC/Flags.cmake.in b/Tests/FortranC/Flags.cmake.in index 3436309..28c38e4 100644 --- a/Tests/FortranC/Flags.cmake.in +++ b/Tests/FortranC/Flags.cmake.in @@ -14,8 +14,8 @@ set(COMMAND) execute_process( WORKING_DIRECTORY "${bld}" - COMMAND ${CMAKE_COMMAND} "${src}" -G "@CMAKE_TEST_GENERATOR@" - -T "@CMAKE_TEST_GENERATOR_TOOLSET@" + COMMAND ${CMAKE_COMMAND} "${src}" -G "@CMAKE_GENERATOR@" + -T "@CMAKE_GENERATOR_TOOLSET@" "-DFortranC_TEST_FLAGS=1" "-DCMAKE_C_COMPILER=${bld}/cc.sh" "-DCMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@" diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 9bb097b..cb44102 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -3,8 +3,8 @@ macro(add_RunCMake_test test) add_test(RunCMake.${test} ${CMAKE_CMAKE_COMMAND} -DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR} - -DRunCMake_GENERATOR=${CMAKE_TEST_GENERATOR} - -DRunCMake_GENERATOR_TOOLSET=${CMAKE_TEST_GENERATOR_TOOLSET} + -DRunCMake_GENERATOR=${CMAKE_GENERATOR} + -DRunCMake_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET} -DRunCMake_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${test} -DRunCMake_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/${test} ${${test}_ARGS} @@ -35,7 +35,7 @@ add_RunCMake_test(CMP0046) add_RunCMake_test(CMP0049) add_RunCMake_test(CMP0050) add_RunCMake_test(CTest) -if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles") +if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") add_RunCMake_test(CompilerChange) endif() add_RunCMake_test(CompilerNotFound) @@ -105,7 +105,7 @@ if (QT4_FOUND) add_RunCMake_test(ObsoleteQtMacros) endif() -if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]") +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio [^6]") add_RunCMake_test(include_external_msproject) add_RunCMake_test(SolutionGlobalSections) endif() -- cgit v0.12 From 9608ef6f402bc5730dbf3276abf27b4e4b1abb2b Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 3 Mar 2014 15:24:03 -0500 Subject: Tests: Optionally configure tests exclusively, with an external CMake Add an undocumented CMake_TEST_EXTERNAL_CMAKE option to name an external CMake 'bin' directory. Skip all main CMake binary builds and instead configure the Tests directory to run using the external CMake provided. This will provide a means to exercise the CMake test suite generating for target platforms and compilers with which the CMake source does not build. That will allow us to raise the level of C++ features required of a compiler to build our source while retaining tests for generating projects with older compiler tools. --- CMakeLists.txt | 302 ++++++++++++++++++++++++++++----------------------- Tests/CMakeLists.txt | 44 +++++--- 2 files changed, 193 insertions(+), 153 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a043838..5f83015 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,9 @@ if(CMAKE_BOOTSTRAP) unset(CMAKE_BOOTSTRAP CACHE) endif() -set(CMake_BIN_DIR ${CMake_BINARY_DIR}/bin) +if(NOT CMake_TEST_EXTERNAL_CMAKE) + set(CMake_BIN_DIR ${CMake_BINARY_DIR}/bin) +endif() if("${CMake_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") # Disallow architecture-specific try_run. It may not run on the host. @@ -102,9 +104,11 @@ endmacro() -set(CMAKE_BUILD_ON_VISUAL_STUDIO 0) -if(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW ) - set(CMAKE_BUILD_ON_VISUAL_STUDIO 1) +if(NOT CMake_TEST_EXTERNAL_CMAKE) + set(CMAKE_BUILD_ON_VISUAL_STUDIO 0) + if(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW ) + set(CMAKE_BUILD_ON_VISUAL_STUDIO 1) + endif() endif() @@ -126,9 +130,19 @@ macro(CMAKE_SETUP_TESTING) # the ctest from this cmake is used for testing # and not the ctest from the cmake building and testing # cmake. - set(CMAKE_CTEST_COMMAND "${CMake_BIN_DIR}/ctest") - set(CMAKE_CMAKE_COMMAND "${CMake_BIN_DIR}/cmake") - set(CMAKE_CPACK_COMMAND "${CMake_BIN_DIR}/cpack") + if(CMake_TEST_EXTERNAL_CMAKE) + set(CMAKE_CTEST_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/ctest") + set(CMAKE_CMAKE_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cmake") + set(CMAKE_CPACK_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cpack") + foreach(exe cmake ctest cpack) + add_executable(${exe} IMPORTED) + set_property(TARGET ${exe} PROPERTY IMPORTED_LOCATION ${CMake_TEST_EXTERNAL_CMAKE}/${exe}) + endforeach() + else() + set(CMAKE_CTEST_COMMAND "${CMake_BIN_DIR}/ctest") + set(CMAKE_CMAKE_COMMAND "${CMake_BIN_DIR}/cmake") + set(CMAKE_CPACK_COMMAND "${CMake_BIN_DIR}/cpack") + endif() endif() # configure some files for testing @@ -362,18 +376,20 @@ macro (CMAKE_BUILD_UTILITIES) endmacro () #----------------------------------------------------------------------- -if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD") - execute_process(COMMAND ${CMAKE_CXX_COMPILER} - ${CMAKE_CXX_COMPILER_ARG1} -dumpversion - OUTPUT_VARIABLE _GXX_VERSION - ) - string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2" - _GXX_VERSION_SHORT ${_GXX_VERSION}) - if(_GXX_VERSION_SHORT EQUAL 33) - message(FATAL_ERROR - "GXX 3.3 on OpenBSD is known to cause CPack to Crash.\n" - "Please use GXX 4.2 or greater to build CMake on OpenBSD\n" - "${CMAKE_CXX_COMPILER} version is: ${_GXX_VERSION}") +if(NOT CMake_TEST_EXTERNAL_CMAKE) + if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD") + execute_process(COMMAND ${CMAKE_CXX_COMPILER} + ${CMAKE_CXX_COMPILER_ARG1} -dumpversion + OUTPUT_VARIABLE _GXX_VERSION + ) + string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2" + _GXX_VERSION_SHORT ${_GXX_VERSION}) + if(_GXX_VERSION_SHORT EQUAL 33) + message(FATAL_ERROR + "GXX 3.3 on OpenBSD is known to cause CPack to Crash.\n" + "Please use GXX 4.2 or greater to build CMake on OpenBSD\n" + "${CMAKE_CXX_COMPILER} version is: ${_GXX_VERSION}") + endif() endif() endif() @@ -392,30 +408,32 @@ include (${CMAKE_ROOT}/Modules/Dart.cmake) set_directory_properties(PROPERTIES TEST_INCLUDE_FILE "${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake") -# where to write the resulting executables and libraries -set(BUILD_SHARED_LIBS OFF) -set(EXECUTABLE_OUTPUT_PATH "" CACHE INTERNAL "No configurable exe dir.") -set(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL - "Where to put the libraries for CMake") +if(NOT CMake_TEST_EXTERNAL_CMAKE) + # where to write the resulting executables and libraries + set(BUILD_SHARED_LIBS OFF) + set(EXECUTABLE_OUTPUT_PATH "" CACHE INTERNAL "No configurable exe dir.") + set(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL + "Where to put the libraries for CMake") -# The CMake executables usually do not need any rpath to run in the build or -# install tree. -set(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.") + # The CMake executables usually do not need any rpath to run in the build or + # install tree. + set(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.") -# Load install destinations. -include(Source/CMakeInstallDestinations.cmake) + # Load install destinations. + include(Source/CMakeInstallDestinations.cmake) -if(BUILD_TESTING) - include(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake) -endif() + if(BUILD_TESTING) + include(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake) + endif() -# include special compile flags for some compilers -include(CompileFlags.cmake) + # include special compile flags for some compilers + include(CompileFlags.cmake) -# no clue why we are testing for this here -include(CheckSymbolExists) -CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV) -CHECK_SYMBOL_EXISTS(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE) + # no clue why we are testing for this here + include(CheckSymbolExists) + CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV) + CHECK_SYMBOL_EXISTS(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE) +endif() # CMAKE_TESTS_CDASH_SERVER: CDash server used by CMake/Tests. # @@ -434,69 +452,72 @@ if("x${CMAKE_TESTS_CDASH_SERVER}" STREQUAL "x") set(CMAKE_TESTS_CDASH_SERVER "http://www.cdash.org/CDash") endif() -# build the utilities (a macro defined in this file) -CMAKE_BUILD_UTILITIES() - -# On NetBSD ncurses is required, since curses doesn't have the wsyncup() -# function. ncurses is installed via pkgsrc, so the library is in /usr/pkg/lib, -# which isn't in the default linker search path. So without RPATH ccmake -# doesn't run and the build doesn't succeed since ccmake is executed for -# generating the documentation. -if(BUILD_CursesDialog) - get_filename_component(_CURSES_DIR "${CURSES_LIBRARY}" PATH) - set(CURSES_NEED_RPATH FALSE) - if(NOT "${_CURSES_DIR}" STREQUAL "/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/lib64" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib64") - set(CURSES_NEED_RPATH TRUE) - endif() -endif() +if(NOT CMake_TEST_EXTERNAL_CMAKE) + # build the utilities (a macro defined in this file) + CMAKE_BUILD_UTILITIES() -if(BUILD_QtDialog) - if(APPLE) - set(CMAKE_BUNDLE_VERSION - "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") - set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}") - # make sure CMAKE_INSTALL_PREFIX ends in / - string(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN) - math(EXPR LEN "${LEN} -1" ) - string(SUBSTRING "${CMAKE_INSTALL_PREFIX}" ${LEN} 1 ENDCH) - if(NOT "${ENDCH}" STREQUAL "/") - set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/") + # On NetBSD ncurses is required, since curses doesn't have the wsyncup() + # function. ncurses is installed via pkgsrc, so the library is in /usr/pkg/lib, + # which isn't in the default linker search path. So without RPATH ccmake + # doesn't run and the build doesn't succeed since ccmake is executed for + # generating the documentation. + if(BUILD_CursesDialog) + get_filename_component(_CURSES_DIR "${CURSES_LIBRARY}" PATH) + set(CURSES_NEED_RPATH FALSE) + if(NOT "${_CURSES_DIR}" STREQUAL "/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/lib64" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib64") + set(CURSES_NEED_RPATH TRUE) endif() - set(CMAKE_INSTALL_PREFIX - "${CMAKE_INSTALL_PREFIX}CMake.app/Contents") endif() - set(QT_NEED_RPATH FALSE) - if(NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib64" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib64") - set(QT_NEED_RPATH TRUE) + if(BUILD_QtDialog) + if(APPLE) + set(CMAKE_BUNDLE_VERSION + "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") + set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}") + # make sure CMAKE_INSTALL_PREFIX ends in / + string(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN) + math(EXPR LEN "${LEN} -1" ) + string(SUBSTRING "${CMAKE_INSTALL_PREFIX}" ${LEN} 1 ENDCH) + if(NOT "${ENDCH}" STREQUAL "/") + set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/") + endif() + set(CMAKE_INSTALL_PREFIX + "${CMAKE_INSTALL_PREFIX}CMake.app/Contents") + endif() + + set(QT_NEED_RPATH FALSE) + if(NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib64" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib64") + set(QT_NEED_RPATH TRUE) + endif() endif() -endif() -# The same might be true on other systems for other libraries. -# Then only enable RPATH if we have are building at least with cmake 2.4, -# since this one has much better RPATH features than cmake 2.2. -# The executables are then built with the RPATH for the libraries outside -# the build tree, which is both the build and the install RPATH. -if (UNIX) - if( CMAKE_USE_SYSTEM_CURL OR CMAKE_USE_SYSTEM_ZLIB - OR CMAKE_USE_SYSTEM_EXPAT OR CTEST_USE_XMLRPC OR CURSES_NEED_RPATH OR QT_NEED_RPATH) - set(CMAKE_SKIP_RPATH OFF CACHE INTERNAL "CMake built with RPATH.") - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - endif() -endif () + # The same might be true on other systems for other libraries. + # Then only enable RPATH if we have are building at least with cmake 2.4, + # since this one has much better RPATH features than cmake 2.2. + # The executables are then built with the RPATH for the libraries outside + # the build tree, which is both the build and the install RPATH. + if (UNIX) + if( CMAKE_USE_SYSTEM_CURL OR CMAKE_USE_SYSTEM_ZLIB + OR CMAKE_USE_SYSTEM_EXPAT OR CTEST_USE_XMLRPC OR CURSES_NEED_RPATH OR QT_NEED_RPATH) + set(CMAKE_SKIP_RPATH OFF CACHE INTERNAL "CMake built with RPATH.") + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) + endif() + endif () -# add the uninstall support -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" - @ONLY) -add_custom_target(uninstall - "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") + # add the uninstall support + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + @ONLY) + add_custom_target(uninstall + "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") -include (CMakeCPack.cmake) + include (CMakeCPack.cmake) + +endif() # setup some Testing support (a macro defined in this file) CMAKE_SETUP_TESTING() @@ -505,62 +526,69 @@ configure_file( "${CMAKE_CURRENT_BINARY_DIR}/DartLocal.conf" COPYONLY) -if(NOT CMake_VERSION_IS_RELEASE) - if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND - NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2) - set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts - -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security - -Wmissing-format-attribute -fno-common -Wundef - ) - set(CXX_FLAGS_LIST -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W - -Wshadow -Wpointer-arith -Wformat-security -Wundef - ) - - foreach(FLAG_LANG C CXX) - foreach(FLAG ${${FLAG_LANG}_FLAGS_LIST}) - if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ") - set(CMAKE_${FLAG_LANG}_FLAGS "${CMAKE_${FLAG_LANG}_FLAGS} ${FLAG}") - endif() +if(NOT CMake_TEST_EXTERNAL_CMAKE) + if(NOT CMake_VERSION_IS_RELEASE) + if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND + NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2) + set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts + -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security + -Wmissing-format-attribute -fno-common -Wundef + ) + set(CXX_FLAGS_LIST -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W + -Wshadow -Wpointer-arith -Wformat-security -Wundef + ) + + foreach(FLAG_LANG C CXX) + foreach(FLAG ${${FLAG_LANG}_FLAGS_LIST}) + if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ") + set(CMAKE_${FLAG_LANG}_FLAGS "${CMAKE_${FLAG_LANG}_FLAGS} ${FLAG}") + endif() + endforeach() endforeach() - endforeach() - unset(C_FLAGS_LIST) - unset(CXX_FLAGS_LIST) + unset(C_FLAGS_LIST) + unset(CXX_FLAGS_LIST) + endif() endif() + + # build the remaining subdirectories + add_subdirectory(Source) + add_subdirectory(Utilities) endif() -# build the remaining subdirectories -add_subdirectory(Source) -add_subdirectory(Utilities) add_subdirectory(Tests) -if(BUILD_TESTING) - CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests") -endif() -CMAKE_SET_TARGET_FOLDER(cmw9xcom "Utilities/Win9xCompat") -if(TARGET documentation) - CMAKE_SET_TARGET_FOLDER(documentation "Documentation") +if(NOT CMake_TEST_EXTERNAL_CMAKE) + if(BUILD_TESTING) + CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests") + endif() + CMAKE_SET_TARGET_FOLDER(cmw9xcom "Utilities/Win9xCompat") + if(TARGET documentation) + CMAKE_SET_TARGET_FOLDER(documentation "Documentation") + endif() endif() # add a test add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}" --system-information -G "${CMAKE_GENERATOR}" ) -# Install license file as it requires. -install(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR}) - -# Install script directories. -install( - DIRECTORY Help Modules Templates - DESTINATION ${CMAKE_DATA_DIR} - FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - DIRECTORY_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE - GROUP_READ GROUP_EXECUTE - WORLD_READ WORLD_EXECUTE - PATTERN "*.sh*" PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE - GROUP_READ GROUP_EXECUTE - WORLD_READ WORLD_EXECUTE - ) - -# Install auxiliary files integrating with other tools. -add_subdirectory(Auxiliary) +if(NOT CMake_TEST_EXTERNAL_CMAKE) + # Install license file as it requires. + install(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR}) + + # Install script directories. + install( + DIRECTORY Help Modules Templates + DESTINATION ${CMAKE_DATA_DIR} + FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + DIRECTORY_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + PATTERN "*.sh*" PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + ) + + # Install auxiliary files integrating with other tools. + add_subdirectory(Auxiliary) +endif() diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 1c7f29c..854b239 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -57,8 +57,10 @@ if(BUILD_TESTING) set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") endif() - if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_GENERATOR}" MATCHES Ninja AND NOT WIN32)) - set(TEST_CompileCommandOutput 1) + if(NOT CMake_TEST_EXTERNAL_CMAKE) + if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_GENERATOR}" MATCHES Ninja AND NOT WIN32)) + set(TEST_CompileCommandOutput 1) + endif() endif() set(MAKE_IS_GNU ) @@ -95,13 +97,17 @@ if(BUILD_TESTING) list(APPEND build_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}) endif() - add_subdirectory(CMakeLib) + if(NOT CMake_TEST_EXTERNAL_CMAKE) + add_subdirectory(CMakeLib) + endif() add_subdirectory(CMakeOnly) add_subdirectory(RunCMake) add_subdirectory(FindPackageModeMakefileTest) - add_subdirectory(CTestTestMemcheck) + if(NOT CMake_TEST_EXTERNAL_CMAKE) + add_subdirectory(CTestTestMemcheck) + endif() # Collect a list of all test build directories. set(TEST_BUILD_DIRS) @@ -248,7 +254,9 @@ if(BUILD_TESTING) ADD_TEST_MACRO(SetLang SetLang) ADD_TEST_MACRO(EmptyProperty EmptyProperty) ADD_TEST_MACRO(ExternalOBJ ExternalOBJ) - ADD_TEST_MACRO(LoadCommand LoadedCommand) + if(NOT CMake_TEST_EXTERNAL_CMAKE) + ADD_TEST_MACRO(LoadCommand LoadedCommand) + endif() ADD_TEST_MACRO(LinkDirectory bin/LinkDirectory) ADD_TEST_MACRO(LinkLanguage LinkLanguage) ADD_TEST_MACRO(LinkLine LinkLine) @@ -1018,16 +1026,18 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/CMakeTestMultipleConfigures") endif() - add_test(LoadedCommandOneConfig ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/LoadCommandOneConfig" - "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig" - ${build_generator_args} - --build-project LoadCommand - --build-options ${build_options} - --test-command LoadedCommand - ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig") + if(NOT CMake_TEST_EXTERNAL_CMAKE) + add_test(LoadedCommandOneConfig ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/LoadCommandOneConfig" + "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig" + ${build_generator_args} + --build-project LoadCommand + --build-options ${build_options} + --test-command LoadedCommand + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig") + endif() add_test(complex ${CMAKE_CTEST_COMMAND} --build-and-test @@ -2771,5 +2781,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ WORKING_DIRECTORY ${CMake_BINARY_DIR}/Utilities/KWStyle) endif() - add_subdirectory(CMakeTests) + if(NOT CMake_TEST_EXTERNAL_CMAKE) + add_subdirectory(CMakeTests) + endif() endif() -- cgit v0.12 From 74b982ce734dd55a4155ba8ba0462fef894d6ec0 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 4 Mar 2014 00:01:05 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 3262d09..505e7cb 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 0) -set(CMake_VERSION_PATCH 20140303) +set(CMake_VERSION_PATCH 20140304) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 7e187eeacd609c18940aa7cd700b048f72fd5568 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 4 Mar 2014 09:28:48 -0500 Subject: CMP0017: Fix check when including from CMake source tree When running CMake from the build tree the CMAKE_ROOT is the entire source tree. Fix the CMP0017 check to be specific to the Modules/ directory under CMAKE_ROOT so that Tests/ does not count. Fix the FindPackageTest modules to include FPHSA by full path from CMAKE_ROOT so that they do not include the local FPHSA which reports an error meant to test that CMP0017 works. --- Source/cmMakefile.cxx | 3 ++- Tests/FindPackageTest/FindLotsOfComponents.cmake | 2 +- Tests/FindPackageTest/FindSomePackage.cmake | 2 +- Tests/FindPackageTest/FindUpperCasePackage.cmake | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f248c57..556e7a4 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3337,7 +3337,8 @@ std::string cmMakefile::GetModulesFile(const char* filename) const if ((moduleInCMakeModulePath.size()>0) && (moduleInCMakeRoot.size()>0)) { const char* currentFile = this->GetDefinition("CMAKE_CURRENT_LIST_FILE"); - if (currentFile && (strstr(currentFile, cmakeRoot) == currentFile)) + std::string mods = cmakeRoot + std::string("/Modules/"); + if (currentFile && strncmp(currentFile, mods.c_str(), mods.size()) == 0) { switch (this->GetPolicyStatus(cmPolicies::CMP0017)) { diff --git a/Tests/FindPackageTest/FindLotsOfComponents.cmake b/Tests/FindPackageTest/FindLotsOfComponents.cmake index 9076d86..5d959c5 100644 --- a/Tests/FindPackageTest/FindLotsOfComponents.cmake +++ b/Tests/FindPackageTest/FindLotsOfComponents.cmake @@ -4,7 +4,7 @@ set(LotsOfComponents_AComp_FOUND TRUE) set(LotsOfComponents_BComp_FOUND FALSE) set(LotsOfComponents_CComp_FOUND TRUE) -include(FindPackageHandleStandardArgs) +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(LotsOfComponents REQUIRED_VARS LOC_FOO HANDLE_COMPONENTS) diff --git a/Tests/FindPackageTest/FindSomePackage.cmake b/Tests/FindPackageTest/FindSomePackage.cmake index 83d1d0e..7283d24 100644 --- a/Tests/FindPackageTest/FindSomePackage.cmake +++ b/Tests/FindPackageTest/FindSomePackage.cmake @@ -1,6 +1,6 @@ set(SOP_FOO TRUE) -include(FindPackageHandleStandardArgs) +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(SomePackage REQUIRED_VARS SOP_FOO FOUND_VAR SomePackage_FOUND ) diff --git a/Tests/FindPackageTest/FindUpperCasePackage.cmake b/Tests/FindPackageTest/FindUpperCasePackage.cmake index 66c2fea..425d417 100644 --- a/Tests/FindPackageTest/FindUpperCasePackage.cmake +++ b/Tests/FindPackageTest/FindUpperCasePackage.cmake @@ -1,6 +1,6 @@ set(UCP_FOO TRUE) -include(FindPackageHandleStandardArgs) +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(UpperCasePackage REQUIRED_VARS UCP_FOO FOUND_VAR UPPERCASEPACKAGE_FOUND ) -- cgit v0.12 From 06986afc4b4708bd6ac74117474bc2738e4a20f7 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 4 Mar 2014 07:25:02 +0100 Subject: Help: Update CMAKE_SYSTEM* and CMAKE_HOST_SYSTEM* documentation Update to documentation for HOST/TARGET system related variables to be consistent with current functionality. --- Help/variable/CMAKE_HOST_SYSTEM.rst | 9 ++++++--- Help/variable/CMAKE_HOST_SYSTEM_NAME.rst | 5 +++-- Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst | 5 +++-- Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst | 7 ++++--- Help/variable/CMAKE_SYSTEM.rst | 11 ++++++----- Help/variable/CMAKE_SYSTEM_NAME.rst | 7 +++---- Help/variable/CMAKE_SYSTEM_PROCESSOR.rst | 6 +++--- Help/variable/CMAKE_SYSTEM_VERSION.rst | 8 ++++---- 8 files changed, 32 insertions(+), 26 deletions(-) diff --git a/Help/variable/CMAKE_HOST_SYSTEM.rst b/Help/variable/CMAKE_HOST_SYSTEM.rst index 4366ee3..c2a8f1a 100644 --- a/Help/variable/CMAKE_HOST_SYSTEM.rst +++ b/Help/variable/CMAKE_HOST_SYSTEM.rst @@ -1,7 +1,10 @@ CMAKE_HOST_SYSTEM ----------------- -Name of system cmake is being run on. +Composit Name of OS CMake is being run on. -The same as CMAKE_SYSTEM but for the host system instead of the target -system when cross compiling. +This variable is the composite of :variable:`CMAKE_HOST_SYSTEM_NAME` and +:variable:`CMAKE_HOST_SYSTEM_VERSION`, e.g. +``${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_VERSION}``. If +:variable:`CMAKE_HOST_SYSTEM_VERSION` is not set, then this variable is +the same as :variable:`CMAKE_HOST_SYSTEM_NAME`. diff --git a/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst b/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst index 718208a..a221de9 100644 --- a/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst +++ b/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst @@ -3,5 +3,6 @@ CMAKE_HOST_SYSTEM_NAME Name of the OS CMake is running on. -The same as CMAKE_SYSTEM_NAME but for the host system instead of the -target system when cross compiling. +On systems that have the uname command, this variable is set to the +output of uname -s. ``Linux``, ``Windows``, and ``Darwin`` for Mac OS X +are the values found on the big three operating systems. diff --git a/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst b/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst index 2700b66..790565a 100644 --- a/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst +++ b/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst @@ -3,5 +3,6 @@ CMAKE_HOST_SYSTEM_PROCESSOR The name of the CPU CMake is running on. -The same as CMAKE_SYSTEM_PROCESSOR but for the host system instead of -the target system when cross compiling. +On systems that support uname, this variable is set to the output of +uname -p, on windows it is set to the value of the environment variable +``PROCESSOR_ARCHITECTURE``. diff --git a/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst b/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst index a8451e8..e7e0052 100644 --- a/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst +++ b/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst @@ -1,7 +1,8 @@ CMAKE_HOST_SYSTEM_VERSION ------------------------- -OS version CMake is running on. +The OS version CMake is running on. -The same as CMAKE_SYSTEM_VERSION but for the host system instead of -the target system when cross compiling. +A numeric version string for the system. On systems that support +uname, this variable is set to the output of uname -r. On other +systems this is set to major-minor version numbers. diff --git a/Help/variable/CMAKE_SYSTEM.rst b/Help/variable/CMAKE_SYSTEM.rst index 283d0be..23f5980 100644 --- a/Help/variable/CMAKE_SYSTEM.rst +++ b/Help/variable/CMAKE_SYSTEM.rst @@ -1,9 +1,10 @@ CMAKE_SYSTEM ------------ -Name of system cmake is compiling for. +Composit Name of OS CMake is compiling for. -This variable is the composite of CMAKE_SYSTEM_NAME and -CMAKE_SYSTEM_VERSION, like this -${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_VERSION}. If CMAKE_SYSTEM_VERSION -is not set, then CMAKE_SYSTEM is the same as CMAKE_SYSTEM_NAME. +This variable is the composite of :variable:`CMAKE_SYSTEM_NAME` and +:variable:`CMAKE_SYSTEM_VERSION`, e.g. +``${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_VERSION}``. If +:variable:`CMAKE_SYSTEM_VERSION` is not set, then this variable is +the same as :variable:`CMAKE_SYSTEM_NAME`. diff --git a/Help/variable/CMAKE_SYSTEM_NAME.rst b/Help/variable/CMAKE_SYSTEM_NAME.rst index 9871dd9..189dc18 100644 --- a/Help/variable/CMAKE_SYSTEM_NAME.rst +++ b/Help/variable/CMAKE_SYSTEM_NAME.rst @@ -3,7 +3,6 @@ CMAKE_SYSTEM_NAME Name of the OS CMake is building for. -This is the name of the operating system on which CMake is targeting. -On systems that have the uname command, this variable is set to the -output of uname -s. Linux, Windows, and Darwin for Mac OS X are the -values found on the big three operating systems. +This is the name of the OS on which CMake is targeting. This variable +is the same as :variable:`CMAKE_HOST_SYSTEM_NAME` if you build for the +host system instead of the target system when cross compiling. diff --git a/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst b/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst index 1655ada..8ad89f1 100644 --- a/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst +++ b/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst @@ -3,6 +3,6 @@ CMAKE_SYSTEM_PROCESSOR The name of the CPU CMake is building for. -On systems that support uname, this variable is set to the output of -uname -p, on windows it is set to the value of the environment -variable PROCESSOR_ARCHITECTURE +This variable is the same as :variable:`CMAKE_HOST_SYSTEM_PROCESSOR` if +you build for the host system instead of the target system when +cross compiling. diff --git a/Help/variable/CMAKE_SYSTEM_VERSION.rst b/Help/variable/CMAKE_SYSTEM_VERSION.rst index 61bb40e..33510bb 100644 --- a/Help/variable/CMAKE_SYSTEM_VERSION.rst +++ b/Help/variable/CMAKE_SYSTEM_VERSION.rst @@ -1,8 +1,8 @@ CMAKE_SYSTEM_VERSION -------------------- -OS version CMake is building for. +The OS version CMake is building for. -A numeric version string for the system, on systems that support -uname, this variable is set to the output of uname -r. On other -systems this is set to major-minor version numbers. +This variable is the same as :variable:`CMAKE_HOST_SYSTEM_VERSION` if +you build for the host system instead of the target system when +cross compiling. -- cgit v0.12 From f096786d5428505f8313f6b01f4631f5a34b27a2 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 3 Mar 2014 08:32:13 -0500 Subject: KWSys 2014-03-03 (b1916e0a) Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ b1916e0a | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' 606d7d6f..b1916e0a Adrien Destugues (1): b1916e0a SystemInformation: Update CPU count code for Haiku Clinton Stimpson (3): 0d8ef429 Encoding: Help enforce the use of wide apis on Windows. cfbc1cc8 FStream: Remove unused basic_filebuf declaration. b3b20cc0 FStream: Add ability to detect BOM. Jiri Malak (1): e66d99b8 SystemTools: Fix compilation with Open Watcom Matt McCormick (1): b3db597b SystemInformation: Mark EXECINFO_LIB as advanced Change-Id: I154a92be7a3ec4c7c12bffbfcd7b50ec7de53c5f --- CMakeLists.txt | 6 +++ FStream.cxx | 76 +++++++++++++++++++++++++++ FStream.hxx.in | 21 ++++++-- SharedForward.h.in | 8 +-- SystemInformation.cxx | 21 +++++++- SystemTools.cxx | 3 ++ testFStream.cxx | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 268 insertions(+), 9 deletions(-) create mode 100644 FStream.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index 736e30a..083d865 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -682,6 +682,7 @@ IF(KWSYS_USE_SystemInformation) # usually it's in libc but on FreeBSD # it's in libexecinfo FIND_LIBRARY(EXECINFO_LIB "execinfo") + MARK_AS_ADVANCED(EXECINFO_LIB) IF (NOT EXECINFO_LIB) SET(EXECINFO_LIB "") ENDIF() @@ -1073,6 +1074,11 @@ IF(MSVC OR (WIN32 AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$")) ) ENDIF() +IF(WIN32) + # Help enforce the use of wide Windows apis. + ADD_DEFINITIONS(-DUNICODE -D_UNICODE) +ENDIF() + IF(KWSYS_USE_String) # Activate code in "String.c". See the comment in the source. SET_SOURCE_FILES_PROPERTIES(String.c PROPERTIES diff --git a/FStream.cxx b/FStream.cxx new file mode 100644 index 0000000..018652c --- /dev/null +++ b/FStream.cxx @@ -0,0 +1,76 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "kwsysPrivate.h" +#include KWSYS_HEADER(FStream.hxx) + +// Work-around CMake dependency scanning limitation. This must +// duplicate the above list of headers. +#if 0 +# include "FStream.hxx.in" +#endif + +namespace KWSYS_NAMESPACE +{ +namespace FStream +{ + +BOM ReadBOM(std::istream& in) +{ + if(!in.good()) + { + return BOM_None; + } + unsigned long orig = in.tellg(); + unsigned char bom[4]; + in.read(reinterpret_cast(bom), 2); + if(!in.good()) + { + in.seekg(orig); + return BOM_None; + } + if(bom[0] == 0xEF && bom[1] == 0xBB) + { + in.read(reinterpret_cast(bom+2), 1); + if(in.good() && bom[2] == 0xBF) + { + return BOM_UTF8; + } + } + else if(bom[0] == 0xFE && bom[1] == 0xFF) + { + return BOM_UTF16BE; + } + else if(bom[0] == 0x00 && bom[1] == 0x00) + { + in.read(reinterpret_cast(bom+2), 2); + if(in.good() && bom[2] == 0xFE && bom[3] == 0xFF) + { + return BOM_UTF32BE; + } + } + else if(bom[0] == 0xFF && bom[1] == 0xFE) + { + unsigned long p = in.tellg(); + in.read(reinterpret_cast(bom+2), 2); + if(in.good() && bom[2] == 0x00 && bom[3] == 0x00) + { + return BOM_UTF32LE; + } + in.seekg(p); + return BOM_UTF16LE; + } + in.seekg(orig); + return BOM_None; +} + +} // FStream namespace +} //KWSYS_NAMESPACE diff --git a/FStream.hxx.in b/FStream.hxx.in index 916a93e..45425ff 100644 --- a/FStream.hxx.in +++ b/FStream.hxx.in @@ -161,13 +161,28 @@ class basic_ofstream : public std::basic_ostream typedef basic_ofstream ofstream; #else - using @KWSYS_NAMESPACE@_ios_namespace::basic_filebuf; using @KWSYS_NAMESPACE@_ios_namespace::ofstream; using @KWSYS_NAMESPACE@_ios_namespace::ifstream; #endif + namespace FStream + { + enum BOM + { + BOM_None, + BOM_UTF8, + BOM_UTF16BE, + BOM_UTF16LE, + BOM_UTF32BE, + BOM_UTF32LE + }; + + // Read a BOM, if one exists. + // If a BOM exists, the stream is advanced to after the BOM. + // This function requires a seekable stream (but not a relative + // seekable stream). + BOM ReadBOM(std::istream& in); + } } - - #endif diff --git a/SharedForward.h.in b/SharedForward.h.in index 8bbc74a..dd4d462 100644 --- a/SharedForward.h.in +++ b/SharedForward.h.in @@ -415,7 +415,7 @@ static int kwsys_shared_forward_realpath(const char* in_path, char* out_path) { #if defined(_WIN32) && !defined(__CYGWIN__) /* Implementation for Windows. */ - DWORD n = GetFullPathName(in_path, KWSYS_SHARED_FORWARD_MAXPATH, + DWORD n = GetFullPathNameA(in_path, KWSYS_SHARED_FORWARD_MAXPATH, out_path, 0); return n > 0 && n <= KWSYS_SHARED_FORWARD_MAXPATH; #else @@ -429,9 +429,9 @@ static int kwsys_shared_forward_samepath(const char* file1, const char* file2) { #if defined(_WIN32) int result = 0; - HANDLE h1 = CreateFile(file1, GENERIC_READ, FILE_SHARE_READ, NULL, + HANDLE h1 = CreateFileA(file1, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); - HANDLE h2 = CreateFile(file2, GENERIC_READ, FILE_SHARE_READ, NULL, + HANDLE h2 = CreateFileA(file2, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); if(h1 != INVALID_HANDLE_VALUE && h2 != INVALID_HANDLE_VALUE) { @@ -462,7 +462,7 @@ static void kwsys_shared_forward_strerror(char* message) #if defined(_WIN32) && !defined(__CYGWIN__) /* Implementation for Windows. */ DWORD original = GetLastError(); - DWORD length = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | + DWORD length = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, original, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), message, KWSYS_SHARED_FORWARD_MAXPATH, 0); diff --git a/SystemInformation.cxx b/SystemInformation.cxx index 5f20853..9c26380 100644 --- a/SystemInformation.cxx +++ b/SystemInformation.cxx @@ -4698,11 +4698,28 @@ bool SystemInformationImplementation::QueryHaikuInfo() { #if defined(__HAIKU__) + // CPU count system_info info; get_system_info(&info); - this->NumberOfPhysicalCPU = info.cpu_count; - this->CPUSpeedInMHz = info.cpu_clock_speed / 1000000.0F; + + // CPU speed + uint32 topologyNodeCount = 0; + cpu_topology_node_info* topology = 0; + get_cpu_topology_info(0, &topologyNodeCount); + if (topologyNodeCount != 0) + topology = new cpu_topology_node_info[topologyNodeCount]; + get_cpu_topology_info(topology, &topologyNodeCount); + + for (uint32 i = 0; i < topologyNodeCount; i++) { + if (topology[i].type == B_TOPOLOGY_CORE) { + this->CPUSpeedInMHz = topology[i].data.core.default_frequency / + 1000000.0f; + break; + } + } + + delete[] topology; // Physical Memory this->TotalPhysicalMemory = (info.max_pages * B_PAGE_SIZE) / (1024 * 1024) ; diff --git a/SystemTools.cxx b/SystemTools.cxx index f4a443f..b6a2437 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -188,6 +188,9 @@ static inline char *realpath(const char *path, char *resolved_path) #endif #if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__)) + +#include + inline int Mkdir(const char* dir) { return _wmkdir(KWSYS_NAMESPACE::Encoding::ToWide(dir).c_str()); diff --git a/testFStream.cxx b/testFStream.cxx index 8942549..9abfd4c 100644 --- a/testFStream.cxx +++ b/testFStream.cxx @@ -16,11 +16,17 @@ #endif #include KWSYS_HEADER(FStream.hxx) +#include KWSYS_HEADER(ios/iostream) +#include +#ifdef __BORLANDC__ +# include /* memcmp */ +#endif // Work-around CMake dependency scanning limitation. This must // duplicate the above list of headers. #if 0 # include "FStream.hxx.in" +# include "kwsys_ios_iostream.h.in" #endif @@ -36,6 +42,141 @@ static int testNoFile() return 0; } +static kwsys::FStream::BOM expected_bom[5] = +{ + kwsys::FStream::BOM_UTF8, + kwsys::FStream::BOM_UTF16LE, + kwsys::FStream::BOM_UTF16BE, + kwsys::FStream::BOM_UTF32LE, + kwsys::FStream::BOM_UTF32BE +}; + +static unsigned char expected_bom_data[5][5] = +{ + {3, 0xEF, 0xBB, 0xBF}, + {2, 0xFF, 0xFE}, + {2, 0xFE, 0xFF}, + {4, 0xFF, 0xFE, 0x00, 0x00}, + {4, 0x00, 0x00, 0xFE, 0xFF}, +}; + +static unsigned char file_data[5][45] = +{ + {11, 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'}, + {22, 0x48, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x20, 0x00, + 0x57, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6C, 0x00, 0x64, 0x00}, + {22, 0x00, 0x48, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x20, + 0x00, 0x57, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6C, 0x00, 0x64}, + {44, 0x48, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, + 0x6C, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x57, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, + 0x6C, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00}, + {44, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x6C, + 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x20, + 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x72, + 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x64}, +}; + +//---------------------------------------------------------------------------- +static int testBOM() +{ + // test various encodings in binary mode + for(int i=0; i<5; i++) + { + { + kwsys::ofstream out("bom.txt", kwsys::ofstream::binary); + out.write(reinterpret_cast(expected_bom_data[i]+1), + *expected_bom_data[i]); + out.write(reinterpret_cast(file_data[i]+1), + file_data[i][0]); + } + + kwsys::ifstream in("bom.txt", kwsys::ofstream::binary); + kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(in); + if(bom != expected_bom[i]) + { + kwsys_ios::cout << "Unexpected BOM " << i << std::endl; + return 1; + } + char data[45]; + in.read(data, file_data[i][0]); + if(!in.good()) + { + kwsys_ios::cout << "Unable to read data " << i << std::endl; + return 1; + } + + if(memcmp(data, file_data[i]+1, file_data[i][0]) != 0) + { + kwsys_ios::cout << "Incorrect read data " << i << std::endl; + return 1; + } + + } + + // test text file without bom + { + { + kwsys::ofstream out("bom.txt"); + out << "Hello World"; + } + + kwsys::ifstream in("bom.txt"); + kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(in); + if(bom != kwsys::FStream::BOM_None) + { + kwsys_ios::cout << "Unexpected BOM for none case" << std::endl; + return 1; + } + char data[45]; + in.read(data, file_data[0][0]); + if(!in.good()) + { + kwsys_ios::cout << "Unable to read data for none case" << std::endl; + return 1; + } + + if(memcmp(data, file_data[0]+1, file_data[0][0]) != 0) + { + kwsys_ios::cout << "Incorrect read data for none case" << std::endl; + return 1; + } + } + + // test text file with utf-8 bom + { + { + kwsys::ofstream out("bom.txt"); + out.write(reinterpret_cast(expected_bom_data[0]+1), + *expected_bom_data[0]); + out << "Hello World"; + } + + kwsys::ifstream in("bom.txt"); + kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(in); + if(bom != kwsys::FStream::BOM_UTF8) + { + kwsys_ios::cout << "Unexpected BOM for utf-8 case" << std::endl; + return 1; + } + char data[45]; + in.read(data, file_data[0][0]); + if(!in.good()) + { + kwsys_ios::cout << "Unable to read data for utf-8 case" << std::endl; + return 1; + } + + if(memcmp(data, file_data[0]+1, file_data[0][0]) != 0) + { + kwsys_ios::cout << "Incorrect read data for utf-8 case" << std::endl; + return 1; + } + } + + return 0; +} + //---------------------------------------------------------------------------- int testFStream(int, char*[]) @@ -43,6 +184,7 @@ int testFStream(int, char*[]) int ret = 0; ret |= testNoFile(); + ret |= testBOM(); return ret; } -- cgit v0.12 From c87517099abbef70b9718a3920954e9097f36bbe Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 4 Mar 2014 11:20:27 -0500 Subject: Makefile: Factor out some duplicate link libraries generation The generators for executable and library targets duplicate the logic to call the OutputLinkLibraries helper on the local generator. Factor it out into a cmMakefileTargetGenerator::CreateLinkLibs method to avoid dpulication. --- Source/cmMakefileExecutableTargetGenerator.cxx | 8 ++------ Source/cmMakefileLibraryTargetGenerator.cxx | 7 +------ Source/cmMakefileTargetGenerator.cxx | 14 ++++++++++++++ Source/cmMakefileTargetGenerator.h | 4 ++++ 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 03fdda2..696ce94 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -325,12 +325,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Collect up flags to link in needed libraries. std::string linkLibs; - std::string frameworkPath; - std::string linkPath; - this->LocalGenerator->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, - *this->GeneratorTarget, - relink); - linkLibs = frameworkPath + linkPath + linkLibs; + this->CreateLinkLibs(linkLibs, relink, depends); + // Construct object file lists that may be needed to expand the // rule. std::string buildObjs; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 807aca8..2832515 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -546,12 +546,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string linkLibs; if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) { - std::string frameworkPath; - std::string linkPath; - this->LocalGenerator - ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, - *this->GeneratorTarget, relink); - linkLibs = frameworkPath + linkPath + linkLibs; + this->CreateLinkLibs(linkLibs, relink, depends); } // Construct object file lists that may be needed to expand the diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index e8a9fd1..e5b163b 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1833,6 +1833,20 @@ cmMakefileTargetGenerator //---------------------------------------------------------------------------- void cmMakefileTargetGenerator +::CreateLinkLibs(std::string& linkLibs, bool relink, + std::vector& makefile_depends) +{ + std::string frameworkPath; + std::string linkPath; + this->LocalGenerator + ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, + *this->GeneratorTarget, relink); + linkLibs = frameworkPath + linkPath + linkLibs; +} + +//---------------------------------------------------------------------------- +void +cmMakefileTargetGenerator ::CreateObjectLists(bool useLinkScript, bool useArchiveRules, bool useResponseFile, std::string& buildObjs, std::vector& makefile_depends) diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 4f8fafa..d47708d 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -163,6 +163,10 @@ protected: std::string const& options, std::vector& makefile_depends); + /** Create list of flags for link libraries. */ + void CreateLinkLibs(std::string& linkLibs, bool relink, + std::vector& makefile_depends); + /** Create lists of object files for linking and cleaning. */ void CreateObjectLists(bool useLinkScript, bool useArchiveRules, bool useResponseFile, std::string& buildObjs, -- cgit v0.12 From 02bebd60e9255b6e3eb4bbd6208b4c5cd8f5da40 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 4 Mar 2014 12:57:44 -0500 Subject: cmLocalGenerator: Add format option to ConvertToOutputForExisting Replace the hard-coded SHELL output format with an optional argument. --- Source/cmLocalGenerator.cxx | 19 +++++++++++-------- Source/cmLocalGenerator.h | 9 ++++++--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 4266dd0..87685d5 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1228,7 +1228,8 @@ void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target, //---------------------------------------------------------------------------- std::string cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote, - std::string const& result) + std::string const& result, + OutputFormat format) { // If this is a windows shell, the result has a space, and the path // already exists, we can use a short-path to reference it without a @@ -1239,7 +1240,7 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote, std::string tmp; if(cmSystemTools::GetShortPath(remote, tmp)) { - return this->Convert(tmp.c_str(), NONE, SHELL, true); + return this->Convert(tmp.c_str(), NONE, format, true); } } @@ -1250,26 +1251,28 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote, //---------------------------------------------------------------------------- std::string cmLocalGenerator::ConvertToOutputForExisting(const char* remote, - RelativeRoot local) + RelativeRoot local, + OutputFormat format) { // Perform standard conversion. - std::string result = this->Convert(remote, local, SHELL, true); + std::string result = this->Convert(remote, local, format, true); // Consider short-path. - return this->ConvertToOutputForExistingCommon(remote, result); + return this->ConvertToOutputForExistingCommon(remote, result, format); } //---------------------------------------------------------------------------- std::string cmLocalGenerator::ConvertToOutputForExisting(RelativeRoot remote, - const char* local) + const char* local, + OutputFormat format) { // Perform standard conversion. - std::string result = this->Convert(remote, local, SHELL, true); + std::string result = this->Convert(remote, local, format, true); // Consider short-path. const char* remotePath = this->GetRelativeRootPath(remote); - return this->ConvertToOutputForExistingCommon(remotePath, result); + return this->ConvertToOutputForExistingCommon(remotePath, result, format); } //---------------------------------------------------------------------------- diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 0f7fd25..9e47120 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -198,12 +198,14 @@ public: ///! for existing files convert to output path and short path if spaces std::string ConvertToOutputForExisting(const char* remote, - RelativeRoot local = START_OUTPUT); + RelativeRoot local = START_OUTPUT, + OutputFormat format = SHELL); /** For existing path identified by RelativeRoot convert to output path and short path if spaces. */ std::string ConvertToOutputForExisting(RelativeRoot remote, - const char* local = 0); + const char* local = 0, + OutputFormat format = SHELL); virtual std::string ConvertToIncludeReference(std::string const& path); @@ -465,7 +467,8 @@ protected: bool BackwardsCompatibilityFinal; private: std::string ConvertToOutputForExistingCommon(const char* remote, - std::string const& result); + std::string const& result, + OutputFormat format); void AddSharedFlags(std::string& flags, const char* lang, bool shared); bool GetShouldUseOldFlags(bool shared, const std::string &lang) const; -- cgit v0.12 From 0c0ef9e7b7016f8ce6310c30660151b15e062a93 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 4 Mar 2014 13:04:02 -0500 Subject: cmLocalGenerator: Add format option to ConvertToIncludeReference Replace the hard-coded SHELL output format with an optional argument. --- Source/cmLocalGenerator.cxx | 5 +++-- Source/cmLocalGenerator.h | 3 ++- Source/cmLocalNinjaGenerator.cxx | 5 +++-- Source/cmLocalNinjaGenerator.h | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 87685d5..2090cc6 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1277,9 +1277,10 @@ cmLocalGenerator::ConvertToOutputForExisting(RelativeRoot remote, //---------------------------------------------------------------------------- std::string -cmLocalGenerator::ConvertToIncludeReference(std::string const& path) +cmLocalGenerator::ConvertToIncludeReference(std::string const& path, + OutputFormat format) { - return this->ConvertToOutputForExisting(path.c_str()); + return this->ConvertToOutputForExisting(path.c_str(), START_OUTPUT, format); } //---------------------------------------------------------------------------- diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 9e47120..986f405 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -207,7 +207,8 @@ public: const char* local = 0, OutputFormat format = SHELL); - virtual std::string ConvertToIncludeReference(std::string const& path); + virtual std::string ConvertToIncludeReference(std::string const& path, + OutputFormat format = SHELL); /** Called from command-line hook to clear dependencies. */ virtual void ClearDependencies(cmMakefile* /* mf */, diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index cd12c9d..c989cfb 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -149,9 +149,10 @@ cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib) } std::string -cmLocalNinjaGenerator::ConvertToIncludeReference(std::string const& path) +cmLocalNinjaGenerator::ConvertToIncludeReference(std::string const& path, + OutputFormat format) { - return this->Convert(path.c_str(), HOME_OUTPUT, SHELL); + return this->Convert(path.c_str(), HOME_OUTPUT, format); } //---------------------------------------------------------------------------- diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index ea854c6..b3d3b6b 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -101,7 +101,8 @@ public: protected: - virtual std::string ConvertToIncludeReference(std::string const& path); + virtual std::string ConvertToIncludeReference(std::string const& path, + OutputFormat format = SHELL); private: -- cgit v0.12 From 971653b767f2e5e81085c525c94d5e596474aa88 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 4 Mar 2014 13:06:29 -0500 Subject: cmLocalGenerator: Add format option to ConvertToLinkReference Replace the hard-coded SHELL output format with an optional argument. --- Source/cmLocalGenerator.cxx | 7 ++++--- Source/cmLocalGenerator.h | 3 ++- Source/cmLocalNinjaGenerator.cxx | 5 +++-- Source/cmLocalNinjaGenerator.h | 3 ++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 2090cc6..1372c2a 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1759,7 +1759,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, } } -std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib) +std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib, + OutputFormat format) { #if defined(_WIN32) && !defined(__CYGWIN__) // Work-ardound command line parsing limitations in MSVC 6.0 and @@ -1781,14 +1782,14 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib) sp += lib.substr(pos); // Convert to an output path. - return this->Convert(sp.c_str(), NONE, SHELL); + return this->Convert(sp.c_str(), NONE, format); } } } #endif // Normal behavior. - return this->Convert(lib.c_str(), START_OUTPUT, SHELL); + return this->Convert(lib.c_str(), START_OUTPUT, format); } /** diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 986f405..2a76124 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -415,7 +415,8 @@ protected: std::string FindRelativePathTopBinary(); void SetupPathConversions(); - virtual std::string ConvertToLinkReference(std::string const& lib); + virtual std::string ConvertToLinkReference(std::string const& lib, + OutputFormat format = SHELL); /** Check whether the native build system supports the given definition. Issues a warning. */ diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index c989cfb..862823f 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -143,9 +143,10 @@ cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator() // Virtual protected methods. std::string -cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib) +cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib, + OutputFormat format) { - return this->Convert(lib.c_str(), HOME_OUTPUT, SHELL); + return this->Convert(lib.c_str(), HOME_OUTPUT, format); } std::string diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index b3d3b6b..8b26806 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -97,7 +97,8 @@ public: void AppendCustomCommandDeps(const cmCustomCommand *cc, cmNinjaDeps &ninjaDeps); - virtual std::string ConvertToLinkReference(std::string const& lib); + virtual std::string ConvertToLinkReference(std::string const& lib, + OutputFormat format = SHELL); protected: -- cgit v0.12 From b9aa5041989a415a360e61291142e760ae7eb9e1 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 4 Mar 2014 13:12:54 -0500 Subject: cmLocalGenerator: Simplify GetIncludeFlags output formatting Use the output format argument to ConvertToIncludeReference. --- Source/cmLocalGenerator.cxx | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 1372c2a..aa64e80 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1295,6 +1295,7 @@ std::string cmLocalGenerator::GetIncludeFlags( return ""; } + OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL; cmOStringStream includeFlags; std::string flagVar = "CMAKE_INCLUDE_FLAG_"; @@ -1354,10 +1355,9 @@ std::string cmLocalGenerator::GetIncludeFlags( frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str()); if(emitted.insert(frameworkDir).second) { - OutputFormat format = forResponseFile? RESPONSE : SHELL; includeFlags << fwSearchFlag << this->Convert(frameworkDir.c_str(), - START_OUTPUT, format, true) + START_OUTPUT, shellFormat, true) << " "; } continue; @@ -1376,16 +1376,8 @@ std::string cmLocalGenerator::GetIncludeFlags( } flagUsed = true; } - std::string includePath; - if(forResponseFile) - { - includePath = this->Convert(i->c_str(), START_OUTPUT, - RESPONSE, true); - } - else - { - includePath = this->ConvertToIncludeReference(*i); - } + std::string includePath = + this->ConvertToIncludeReference(*i, shellFormat); if(quotePaths && includePath.size() && includePath[0] != '\"') { includeFlags << "\""; -- cgit v0.12 From 5e8e4d0f8819052d3a69eb3cb1a4bdbc674a956c Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 4 Mar 2014 13:20:04 -0500 Subject: cmLocalGenerator: Add response file option to OutputLinkLibraries Response files require different path conversion to be threaded through construction of the link libraries flags. --- Source/cmLocalGenerator.cxx | 23 ++++++++++++++--------- Source/cmLocalGenerator.h | 3 ++- Source/cmMakefileTargetGenerator.cxx | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index aa64e80..b86a956 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1671,7 +1671,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, } } this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, - *target, false); + *target, false, false); } break; case cmTarget::EXECUTABLE: @@ -1696,7 +1696,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, } this->AddLanguageFlags(flags, linkLanguage, buildType.c_str()); this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, - *target, false); + *target, false, false); if(cmSystemTools::IsOn (this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { @@ -1793,8 +1793,11 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget &tgt, - bool relink) + bool relink, + bool forResponseFile) { + OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL; + bool escapeAllowMakeVars = !forResponseFile; cmOStringStream fout; const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config); @@ -1837,7 +1840,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, fdi != fwDirs.end(); ++fdi) { frameworkPath += fwSearchFlag; - frameworkPath += this->Convert(fdi->c_str(), NONE, SHELL, false); + frameworkPath += this->Convert(fdi->c_str(), NONE, shellFormat, false); frameworkPath += " "; } } @@ -1847,7 +1850,9 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, for(std::vector::const_iterator libDir = libDirs.begin(); libDir != libDirs.end(); ++libDir) { - std::string libpath = this->ConvertToOutputForExisting(libDir->c_str()); + std::string libpath = this->ConvertToOutputForExisting(libDir->c_str(), + START_OUTPUT, + shellFormat); linkPath += " " + libPathFlag; linkPath += libpath; linkPath += libPathTerminator; @@ -1865,7 +1870,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, } if(li->IsPath) { - linkLibs += this->ConvertToLinkReference(li->Value); + linkLibs += this->ConvertToLinkReference(li->Value, shellFormat); } else { @@ -1890,7 +1895,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, ri != runtimeDirs.end(); ++ri) { rpath += cli.GetRuntimeFlag(); - rpath += this->Convert(ri->c_str(), NONE, SHELL, false); + rpath += this->Convert(ri->c_str(), NONE, shellFormat, false); rpath += " "; } fout << rpath; @@ -1904,7 +1909,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, if(!rpath.empty()) { fout << cli.GetRuntimeFlag(); - fout << this->EscapeForShell(rpath.c_str(), true); + fout << this->EscapeForShell(rpath.c_str(), escapeAllowMakeVars); fout << " "; } } @@ -1914,7 +1919,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, if(!cli.GetRPathLinkFlag().empty() && !rpath_link.empty()) { fout << cli.GetRPathLinkFlag(); - fout << this->EscapeForShell(rpath_link.c_str(), true); + fout << this->EscapeForShell(rpath_link.c_str(), escapeAllowMakeVars); fout << " "; } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 2a76124..2e05804 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -372,7 +372,8 @@ protected: std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget &, - bool relink); + bool relink, + bool forResponseFile); // Expand rule variables in CMake of the type found in language rules void ExpandRuleVariables(std::string& string, diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index e5b163b..0f2b6e3 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1840,7 +1840,7 @@ cmMakefileTargetGenerator std::string linkPath; this->LocalGenerator ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, - *this->GeneratorTarget, relink); + *this->GeneratorTarget, relink, false); linkLibs = frameworkPath + linkPath + linkLibs; } -- cgit v0.12 From b052902c32190f6c10c703ab07310a91fa50d46a Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 3 Mar 2014 21:36:09 +0100 Subject: Remove hard-coded version of RTDLL for Open Watcom In InstallRequiredSystemLibraries the version number for RTDLL can be calculated from the compiler version. This will support current and future OW versions without updating the module again. --- Modules/InstallRequiredSystemLibraries.cmake | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 013a028..7e68e8f 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -366,18 +366,22 @@ endif() if(WATCOM) get_filename_component( CompilerPath ${CMAKE_C_COMPILER} PATH ) - if(WATCOM17) - set( __install__libs ${CompilerPath}/clbr17.dll - ${CompilerPath}/mt7r17.dll ${CompilerPath}/plbr17.dll ) - endif() - if(WATCOM18) - set( __install__libs ${CompilerPath}/clbr18.dll - ${CompilerPath}/mt7r18.dll ${CompilerPath}/plbr18.dll ) + if(CMAKE_C_COMPILER_VERSION) + set(_compiler_version ${CMAKE_C_COMPILER_VERSION}) + else() + set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION}) endif() - if(WATCOM19) - set( __install__libs ${CompilerPath}/clbr19.dll - ${CompilerPath}/mt7r19.dll ${CompilerPath}/plbr19.dll ) + string(REGEX MATCHALL "[0-9]+" _watcom_version_list "${_compiler_version}") + list(GET _watcom_version_list 0 _watcom_major) + list(GET _watcom_version_list 1 _watcom_minor) + if(${_watcom_major} GREATER 11) + math(EXPR _watcom_major "${_watcom_major} - 11") endif() + math(EXPR _watcom_minor "${_watcom_minor} / 10") + set( __install__libs + ${CompilerPath}/clbr${_watcom_major}${_watcom_minor}.dll + ${CompilerPath}/mt7r${_watcom_major}${_watcom_minor}.dll + ${CompilerPath}/plbr${_watcom_major}${_watcom_minor}.dll ) foreach(lib ${__install__libs} ) -- cgit v0.12 From ea95e3eae32b35711e23de30b4cbdb5ad2bd930a Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 5 Mar 2014 00:01:06 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 505e7cb..66c8761 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 0) -set(CMake_VERSION_PATCH 20140304) +set(CMake_VERSION_PATCH 20140305) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 745caae6dddc9ab5c38a669adf3906f6e3484c80 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 4 Mar 2014 13:21:15 -0500 Subject: Makefile: Rename linker response file boolean to be more specific Rename local variable useResponseFile to useResponseFileForObjects when it represents CMAKE__USE_RESPONSE_FILE_FOR_OBJECTS. --- Source/cmMakefileExecutableTargetGenerator.cxx | 8 ++++---- Source/cmMakefileLibraryTargetGenerator.cxx | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 696ce94..6754525 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -307,14 +307,14 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } // Select whether to use a response file for objects. - bool useResponseFile = false; + bool useResponseFileForObjects = false; { std::string responseVar = "CMAKE_"; responseVar += linkLanguage; responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS"; if(this->Makefile->IsOn(responseVar.c_str())) { - useResponseFile = true; + useResponseFileForObjects = true; } } @@ -330,8 +330,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Construct object file lists that may be needed to expand the // rule. std::string buildObjs; - this->CreateObjectLists(useLinkScript, false, useResponseFile, - buildObjs, depends); + this->CreateObjectLists(useLinkScript, false, + useResponseFileForObjects, buildObjs, depends); cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_LINK"; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 2832515..c639f3e 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -474,14 +474,14 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules bool useLinkScript = this->GlobalGenerator->GetUseLinkScript(); // Select whether to use a response file for objects. - bool useResponseFile = false; + bool useResponseFileForObjects = false; { std::string responseVar = "CMAKE_"; responseVar += linkLanguage; responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS"; if(this->Makefile->IsOn(responseVar.c_str())) { - useResponseFile = true; + useResponseFileForObjects = true; } } @@ -528,7 +528,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules useLinkScript = true; // Archiving rules never use a response file. - useResponseFile = false; + useResponseFileForObjects = false; // Limit the length of individual object lists to less than the // 32K command line length limit on Windows. We could make this a @@ -552,8 +552,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Construct object file lists that may be needed to expand the // rule. std::string buildObjs; - this->CreateObjectLists(useLinkScript, useArchiveRules, useResponseFile, - buildObjs, depends); + this->CreateObjectLists(useLinkScript, useArchiveRules, + useResponseFileForObjects, buildObjs, depends); cmLocalGenerator::RuleVariables vars; vars.TargetPDB = targetOutPathPDB.c_str(); -- cgit v0.12 From 4da09d1a3f1541f075ce9614b9b7bd0cabbd800c Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 5 Mar 2014 11:20:28 -0500 Subject: Help: Add release notes for topic 'FeatureSummary_combine_WHAT_values' --- Help/release/dev/FeatureSummary_combine_WHAT_values.rst | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Help/release/dev/FeatureSummary_combine_WHAT_values.rst diff --git a/Help/release/dev/FeatureSummary_combine_WHAT_values.rst b/Help/release/dev/FeatureSummary_combine_WHAT_values.rst new file mode 100644 index 0000000..174ef15 --- /dev/null +++ b/Help/release/dev/FeatureSummary_combine_WHAT_values.rst @@ -0,0 +1,6 @@ +FeatureSummary_combine_WHAT_values +---------------------------------- + +* The :module:`FeatureSummary` module ``feature_summary`` API + learned to accept multiple values for the ``WHAT`` option and + combine them appropriately. -- cgit v0.12 From bf28ff1f422407f10ecc283f03ce8c5ee57f1812 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 5 Mar 2014 11:57:00 -0500 Subject: FindPythonLibs: Do not try to find the interpreter (#13794) The parent commit taught FindPythonLibs to try to find PythonInterp unconditionally. Some projects may want the libraries of a specific version even when the corresponding interpreter is not available. Drop the internal use of FindPythonInterp and just use the versions from it if it happens to have been found by the project first. That will allow projects to get a consistent version when they want both but not otherwise force them to find the interpreter. --- Modules/FindPythonLibs.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 27d9e45..656ed7b 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -83,7 +83,6 @@ endif() # If FindPythonInterp has already found the major and minor version, # insert that version between the user supplied versions and the stock # version list. -find_package(PythonInterp QUIET) set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS}) if(DEFINED PYTHON_VERSION_MAJOR AND DEFINED PYTHON_VERSION_MINOR) list(APPEND _Python_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) -- cgit v0.12 From 489b1c23b9a880da0012427b60cce7b6f5ddaa27 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 4 Mar 2014 13:25:42 -0500 Subject: Windows: Use response files to specify link libraries for GNU tools Work around the command-line-length limit by using an @linklibs.rsp response file to pass the flags for link libraries. This allows very long lists of libraries to be used in addition to the existing support for passing object files via response file. Suggested-by: Peter Keuschnigg --- Help/release/dev/link-libraries-response-files.rst | 5 ++++ Modules/Platform/Windows-GNU.cmake | 5 +++- Source/cmMakefileExecutableTargetGenerator.cxx | 14 ++++++++++- Source/cmMakefileLibraryTargetGenerator.cxx | 14 ++++++++++- Source/cmMakefileTargetGenerator.cxx | 28 +++++++++++++++++++++- Source/cmMakefileTargetGenerator.h | 1 + 6 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 Help/release/dev/link-libraries-response-files.rst diff --git a/Help/release/dev/link-libraries-response-files.rst b/Help/release/dev/link-libraries-response-files.rst new file mode 100644 index 0000000..cecf7f6 --- /dev/null +++ b/Help/release/dev/link-libraries-response-files.rst @@ -0,0 +1,5 @@ +link-libraries-response-files +----------------------------- + +* The Makefile generators learned to use response files with GNU tools + on Windows to pass library directories and names to the linker. diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index 2bb7a20..5c5b360 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -87,6 +87,7 @@ macro(__windows_compiler_gnu lang) set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS ${__WINDOWS_GNU_LD_RESPONSE}) + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES ${__WINDOWS_GNU_LD_RESPONSE}) set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1) # We prefer "@" for response files but it is not supported by gcc 3. @@ -103,7 +104,9 @@ macro(__windows_compiler_gnu lang) endif() # The GNU 3.x compilers do not support response files (only linkers). set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 0) - elseif(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS) + # Link libraries are generated only for the front-end. + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES 0) + else() # Use "@" to pass the response file to the front-end. set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "@") endif() diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 6754525..1802054 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -318,6 +318,18 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } } + // Select whether to use a response file for libraries. + bool useResponseFileForLibs = false; + { + std::string responseVar = "CMAKE_"; + responseVar += linkLanguage; + responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES"; + if(this->Makefile->IsOn(responseVar.c_str())) + { + useResponseFileForLibs = true; + } + } + // Expand the rule variables. { // Set path conversion for link script shells. @@ -325,7 +337,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Collect up flags to link in needed libraries. std::string linkLibs; - this->CreateLinkLibs(linkLibs, relink, depends); + this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends); // Construct object file lists that may be needed to expand the // rule. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index c639f3e..39e00b2 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -485,6 +485,18 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } } + // Select whether to use a response file for libraries. + bool useResponseFileForLibs = false; + { + std::string responseVar = "CMAKE_"; + responseVar += linkLanguage; + responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES"; + if(this->Makefile->IsOn(responseVar.c_str())) + { + useResponseFileForLibs = true; + } + } + // For static libraries there might be archiving rules. bool haveStaticLibraryRule = false; std::vector archiveCreateCommands; @@ -546,7 +558,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string linkLibs; if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) { - this->CreateLinkLibs(linkLibs, relink, depends); + this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends); } // Construct object file lists that may be needed to expand the diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 0f2b6e3..facbcc6 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1834,14 +1834,40 @@ cmMakefileTargetGenerator void cmMakefileTargetGenerator ::CreateLinkLibs(std::string& linkLibs, bool relink, + bool useResponseFile, std::vector& makefile_depends) { std::string frameworkPath; std::string linkPath; this->LocalGenerator ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, - *this->GeneratorTarget, relink, false); + *this->GeneratorTarget, relink, + useResponseFile); linkLibs = frameworkPath + linkPath + linkLibs; + + if(useResponseFile) + { + // Lookup the response file reference flag. + std::string responseFlagVar = "CMAKE_"; + responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; + const char* responseFlag = + this->Makefile->GetDefinition(responseFlagVar.c_str()); + if(!responseFlag) + { + responseFlag = "@"; + } + + // Create this response file. + std::string link_rsp = + this->CreateResponseFile("linklibs.rsp", linkLibs, makefile_depends); + + // Reference the response file. + linkLibs = responseFlag; + linkLibs += this->Convert(link_rsp.c_str(), + cmLocalGenerator::NONE, + cmLocalGenerator::SHELL); + } } //---------------------------------------------------------------------------- diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index d47708d..72dc6bc 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -165,6 +165,7 @@ protected: /** Create list of flags for link libraries. */ void CreateLinkLibs(std::string& linkLibs, bool relink, + bool useResponseFile, std::vector& makefile_depends); /** Create lists of object files for linking and cleaning. */ -- cgit v0.12 From 70da6f198f8def8201c562365b914c700b10b95b Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 6 Mar 2014 00:01:05 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 66c8761..8fdad13 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 0) -set(CMake_VERSION_PATCH 20140305) +set(CMake_VERSION_PATCH 20140306) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 25fb430e96ecd33d437ad833f58fce509de6dc48 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 6 Mar 2014 09:31:26 -0500 Subject: Utilities/Release: Fix nightly build upload Since commit 71b14dcb (Utilities/Release: Do not upload doc staging tarball, 2014-02-26) the prefix upload_release.cmake computes does not match any files when used with -DVERSION=master as has been done for the nightly binary builds. Since the version is not actually 'master' anyway, change the nightly binary upload logic to explicitly pass the destination directory. Do not pass any VERSION so the default is taken and matches the binaries. --- Tests/CMakeLists.txt | 2 +- Utilities/Release/upload_release.cmake | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 854b239..ea04911 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -575,7 +575,7 @@ if(BUILD_TESTING) file(WRITE "${_TEST_DIR}/nightly-cmake.sh" "cd ${_TEST_DIR} ${CMake_BINARY_DIR}/bin/cmake -DCMAKE_CREATE_VERSION=nightly -P ${CMake_SOURCE_DIR}/Utilities/Release/${script} -${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake +${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake ") add_test(${name} /bin/sh ${_TEST_DIR}/nightly-cmake.sh) if(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY) diff --git a/Utilities/Release/upload_release.cmake b/Utilities/Release/upload_release.cmake index 613d73d..5f4da8f 100644 --- a/Utilities/Release/upload_release.cmake +++ b/Utilities/Release/upload_release.cmake @@ -5,16 +5,15 @@ endif() if(NOT DEFINED PROJECT_PREFIX) set(PROJECT_PREFIX cmake-${VERSION}) endif() -set(dir "v${VERSION}") -if("${VERSION}" MATCHES "master") - set(dir "dev") +if(NOT DEFINED DIR) + set(DIR "v${VERSION}") endif() file(GLOB FILES ${CMAKE_CURRENT_SOURCE_DIR} "${PROJECT_PREFIX}*") list(SORT FILES) list(REVERSE FILES) message("${FILES}") set(UPLOAD_LOC - "kitware@www.cmake.org:/projects/FTP/pub/cmake/${dir}") + "kitware@www.cmake.org:/projects/FTP/pub/cmake/${DIR}") set(count 0) foreach(file ${FILES}) if(NOT IS_DIRECTORY ${file}) -- cgit v0.12 From 87d66066059509d355f87dfbf2b38b4738a10659 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 6 Mar 2014 13:04:16 -0500 Subject: CTestCustom: Suppress MIPSpro warnings about Olimit Since we compile command implementations in large batches the translation units get too big for MIPSpro optimization limits. Suppress the warnings it produces: Warning: Olimit was exceeded on function ... Warning: To override Olimit for all functions in file, use -OPT:Olimit=3201 --- CTestCustom.cmake.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index eb0b2f6..b0f86ec 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -39,6 +39,8 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION "Warning: public.*BZ2_bz.*in module.*bzlib.*clashes with prior module.*bzlib.*" "Warning: public.*_archive.*clashes with prior module.*" "Warning: LINN32: Last line.*is less.*" + "Warning: Olimit was exceeded on function.*" + "Warning: To override Olimit for all functions in file.*" "warning.*directory name.*CMake-Xcode.*/bin/.*does not exist.*" "stl_deque.h:1051" "(Lexer|Parser).*warning.*conversion.*may (alter its value|change the sign)" -- cgit v0.12 From 00da6ac784dbd5cb7d5b316e262700b22117b2b1 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 7 Mar 2014 00:01:08 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 8fdad13..357c393 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 0) -set(CMake_VERSION_PATCH 20140306) +set(CMake_VERSION_PATCH 20140307) #set(CMake_VERSION_RC 1) -- cgit v0.12 From c236691b32f4532d4da6db77322b4446e3802e3f Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 6 Mar 2014 13:01:40 -0500 Subject: KWSys 2014-03-06 (9c653603) Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ 9c653603 | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' b1916e0a..9c653603 Brad King (1): 9c653603 Process: Suppress IBM XL warning about infinite loop in test Change-Id: I3a1f36707bcfff0f34e0176528d9c792384ac8c5 --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 083d865..52bcfe1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1225,6 +1225,9 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) # Some Apple compilers produce bad optimizations in this source. IF(APPLE AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|LLVM)$") SET_SOURCE_FILES_PROPERTIES(testProcess.c PROPERTIES COMPILE_FLAGS -O0) + ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "XL") + # Tell IBM XL not to warn about our test infinite loop + SET_PROPERTY(SOURCE testProcess.c PROPERTY COMPILE_FLAGS -qsuppress=1500-010) ENDIF() # Test SharedForward -- cgit v0.12 From 666c0009319e4c2a73a000f41dc54544df894dfe Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 8 Mar 2014 00:01:07 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 357c393..f1302da 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 0) -set(CMake_VERSION_PATCH 20140307) +set(CMake_VERSION_PATCH 20140308) #set(CMake_VERSION_RC 1) -- cgit v0.12 From ec97ed7d0c67b635caf3ada65541b2eaf0818a93 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 2 Sep 2013 16:27:32 -0400 Subject: stringapi: Use strings for property names Property names are always generated by CMake and should never be NULL. --- Source/cmCacheManager.cxx | 34 +++++---- Source/cmCacheManager.h | 18 ++--- Source/cmExportFileGenerator.cxx | 15 ++-- Source/cmExportFileGenerator.h | 8 +- Source/cmExportTryCompileFileGenerator.cxx | 5 +- Source/cmExportTryCompileFileGenerator.h | 2 +- Source/cmGeneratorTarget.cxx | 4 +- Source/cmGeneratorTarget.h | 4 +- Source/cmGetTargetPropertyCommand.cxx | 12 ++- Source/cmLocalGenerator.cxx | 16 ++-- Source/cmLocalGenerator.h | 4 +- Source/cmMakefile.cxx | 89 +++++++++------------- Source/cmMakefile.h | 16 ++-- Source/cmProperty.cxx | 5 +- Source/cmProperty.h | 5 +- Source/cmPropertyDefinition.cxx | 2 +- Source/cmPropertyDefinition.h | 2 +- Source/cmPropertyDefinitionMap.cxx | 21 +---- Source/cmPropertyDefinitionMap.h | 6 +- Source/cmPropertyMap.cxx | 16 ++-- Source/cmPropertyMap.h | 8 +- Source/cmQtAutoGenerators.cxx | 2 +- Source/cmSourceFile.cxx | 25 ++---- Source/cmSourceFile.h | 11 +-- Source/cmTarget.cxx | 118 +++++++++++++---------------- Source/cmTarget.h | 19 +++-- Source/cmTargetPropCommandBase.cxx | 5 +- Source/cmTargetPropCommandBase.h | 3 +- Source/cmTest.cxx | 18 ++--- Source/cmTest.h | 9 ++- Source/cmake.cxx | 50 +++++------- Source/cmake.h | 20 ++--- 32 files changed, 262 insertions(+), 310 deletions(-) diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 9e0064e..04542d8 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -807,13 +807,13 @@ bool cmCacheManager::CacheIterator::GetValueAsBool() const //---------------------------------------------------------------------------- const char* -cmCacheManager::CacheEntry::GetProperty(const char* prop) const +cmCacheManager::CacheEntry::GetProperty(const std::string& prop) const { - if(strcmp(prop, "TYPE") == 0) + if(prop == "TYPE") { return cmCacheManagerTypes[this->Type]; } - else if(strcmp(prop, "VALUE") == 0) + else if(prop == "VALUE") { return this->Value.c_str(); } @@ -823,14 +823,14 @@ cmCacheManager::CacheEntry::GetProperty(const char* prop) const } //---------------------------------------------------------------------------- -void cmCacheManager::CacheEntry::SetProperty(const char* prop, +void cmCacheManager::CacheEntry::SetProperty(const std::string& prop, const char* value) { - if(strcmp(prop, "TYPE") == 0) + if(prop == "TYPE") { this->Type = cmCacheManager::StringToType(value? value : "STRING"); } - else if(strcmp(prop, "VALUE") == 0) + else if(prop == "VALUE") { this->Value = value? value : ""; } @@ -841,15 +841,15 @@ void cmCacheManager::CacheEntry::SetProperty(const char* prop, } //---------------------------------------------------------------------------- -void cmCacheManager::CacheEntry::AppendProperty(const char* prop, +void cmCacheManager::CacheEntry::AppendProperty(const std::string& prop, const char* value, bool asString) { - if(strcmp(prop, "TYPE") == 0) + if(prop == "TYPE") { this->Type = cmCacheManager::StringToType(value? value : "STRING"); } - else if(strcmp(prop, "VALUE") == 0) + else if(prop == "VALUE") { if(value) { @@ -867,7 +867,8 @@ void cmCacheManager::CacheEntry::AppendProperty(const char* prop, } //---------------------------------------------------------------------------- -const char* cmCacheManager::CacheIterator::GetProperty(const char* prop) const +const char* cmCacheManager::CacheIterator::GetProperty( + const std::string& prop) const { if(!this->IsAtEnd()) { @@ -877,7 +878,8 @@ const char* cmCacheManager::CacheIterator::GetProperty(const char* prop) const } //---------------------------------------------------------------------------- -void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v) +void cmCacheManager::CacheIterator::SetProperty(const std::string& p, + const char* v) { if(!this->IsAtEnd()) { @@ -886,7 +888,7 @@ void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v) } //---------------------------------------------------------------------------- -void cmCacheManager::CacheIterator::AppendProperty(const char* p, +void cmCacheManager::CacheIterator::AppendProperty(const std::string& p, const char* v, bool asString) { @@ -897,7 +899,8 @@ void cmCacheManager::CacheIterator::AppendProperty(const char* p, } //---------------------------------------------------------------------------- -bool cmCacheManager::CacheIterator::GetPropertyAsBool(const char* prop) const +bool cmCacheManager::CacheIterator::GetPropertyAsBool( + const std::string& prop) const { if(const char* value = this->GetProperty(prop)) { @@ -907,13 +910,14 @@ bool cmCacheManager::CacheIterator::GetPropertyAsBool(const char* prop) const } //---------------------------------------------------------------------------- -void cmCacheManager::CacheIterator::SetProperty(const char* p, bool v) +void cmCacheManager::CacheIterator::SetProperty(const std::string& p, bool v) { this->SetProperty(p, v ? "ON" : "OFF"); } //---------------------------------------------------------------------------- -bool cmCacheManager::CacheIterator::PropertyExists(const char* prop) const +bool cmCacheManager::CacheIterator::PropertyExists( + const std::string& prop) const { return this->GetProperty(prop)? true:false; } diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index f487e8e..ac6187b 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -39,9 +39,9 @@ private: std::string Value; CacheEntryType Type; cmPropertyMap Properties; - const char* GetProperty(const char*) const; - void SetProperty(const char* property, const char* value); - void AppendProperty(const char* property, const char* value, + const char* GetProperty(const std::string&) const; + void SetProperty(const std::string& property, const char* value); + void AppendProperty(const std::string& property, const char* value, bool asString=false); bool Initialized; CacheEntry() : Value(""), Type(UNINITIALIZED), Initialized(false) @@ -58,13 +58,13 @@ public: void Next(); const char *GetName() const { return this->Position->first.c_str(); } - const char* GetProperty(const char*) const ; - bool GetPropertyAsBool(const char*) const ; - bool PropertyExists(const char*) const; - void SetProperty(const char* property, const char* value); - void AppendProperty(const char* property, const char* value, + const char* GetProperty(const std::string&) const ; + bool GetPropertyAsBool(const std::string&) const ; + bool PropertyExists(const std::string&) const; + void SetProperty(const std::string& property, const char* value); + void AppendProperty(const std::string& property, const char* value, bool asString=false); - void SetProperty(const char* property, bool value); + void SetProperty(const std::string& property, bool value); const char* GetValue() const { return this->GetEntry().Value.c_str(); } bool GetValueAsBool() const; void SetValue(const char*); diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 4a161ee..79566a9 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -136,7 +136,8 @@ void cmExportFileGenerator::GenerateImportConfig(std::ostream& os, } //---------------------------------------------------------------------------- -void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, +void cmExportFileGenerator::PopulateInterfaceProperty( + const std::string& propName, cmTarget *target, ImportPropertyMap &properties) { @@ -148,8 +149,9 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, } //---------------------------------------------------------------------------- -void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, - const char *outputName, +void cmExportFileGenerator::PopulateInterfaceProperty( + const std::string& propName, + const cmStdString& outputName, cmTarget *target, cmGeneratorExpression::PreprocessContext preprocessRule, ImportPropertyMap &properties, @@ -391,7 +393,8 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( } //---------------------------------------------------------------------------- -void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, +void cmExportFileGenerator::PopulateInterfaceProperty( + const std::string& propName, cmTarget *target, cmGeneratorExpression::PreprocessContext preprocessRule, ImportPropertyMap &properties, @@ -403,7 +406,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, //---------------------------------------------------------------------------- -void getPropertyContents(cmTarget const* tgt, const char *prop, +void getPropertyContents(cmTarget const* tgt, const std::string& prop, std::set &ifaceProperties) { const char *p = tgt->GetProperty(prop); @@ -825,7 +828,7 @@ void cmExportFileGenerator ::SetImportLinkProperty(std::string const& suffix, cmTarget* target, - const char* propName, + const std::string& propName, std::vector const& entries, ImportPropertyMap& properties, std::vector& missingTargets diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 57ab378..326fe36 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -95,7 +95,7 @@ protected: ImportPropertyMap& properties, std::vector& missingTargets); void SetImportLinkProperty(std::string const& suffix, - cmTarget* target, const char* propName, + cmTarget* target, const std::string& propName, std::vector const& entries, ImportPropertyMap& properties, std::vector& missingTargets); @@ -116,7 +116,7 @@ protected: cmMakefile* mf, cmTarget* depender, cmTarget* dependee) = 0; - void PopulateInterfaceProperty(const char *, + void PopulateInterfaceProperty(const std::string&, cmTarget *target, cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, @@ -125,7 +125,7 @@ protected: cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, std::vector &missingTargets); - void PopulateInterfaceProperty(const char *propName, cmTarget *target, + void PopulateInterfaceProperty(const std::string& propName, cmTarget *target, ImportPropertyMap &properties); void PopulateCompatibleInterfaceProperties(cmTarget *target, ImportPropertyMap &properties); @@ -174,7 +174,7 @@ protected: std::set ExportedTargets; private: - void PopulateInterfaceProperty(const char *, const char *, + void PopulateInterfaceProperty(const std::string&, const cmStdString&, cmTarget *target, cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index a8a91d6..fe8c8ec 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -46,8 +46,9 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) return true; } -std::string cmExportTryCompileFileGenerator::FindTargets(const char *propName, - cmTarget const* tgt, +std::string cmExportTryCompileFileGenerator::FindTargets( + const std::string& propName, + cmTarget const* tgt, std::set &emitted) { const char *prop = tgt->GetProperty(propName); diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 71ac0dd..a16fe6b 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -46,7 +46,7 @@ protected: std::string InstallNameDir(cmTarget* target, const std::string& config); private: - std::string FindTargets(const char *prop, cmTarget const* tgt, + std::string FindTargets(const std::string& prop, cmTarget const* tgt, std::set &emitted); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a7b2fb6..d9885b9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -234,7 +234,7 @@ const char *cmGeneratorTarget::GetName() const } //---------------------------------------------------------------------------- -const char *cmGeneratorTarget::GetProperty(const char *prop) const +const char *cmGeneratorTarget::GetProperty(const std::string& prop) const { return this->Target->GetProperty(prop); } @@ -486,7 +486,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, } //---------------------------------------------------------------------------- -bool cmGeneratorTarget::GetPropertyAsBool(const char *prop) const +bool cmGeneratorTarget::GetPropertyAsBool(const std::string& prop) const { return this->Target->GetPropertyAsBool(prop); } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1e6ce64..6e19f7d 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -28,8 +28,8 @@ public: int GetType() const; const char *GetName() const; - const char *GetProperty(const char *prop) const; - bool GetPropertyAsBool(const char *prop) const; + const char *GetProperty(const std::string& prop) const; + bool GetPropertyAsBool(const std::string& prop) const; void GetSourceFiles(std::vector& files) const; void GetObjectSources(std::vector &) const; diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx index 4aa49fe..b64f847 100644 --- a/Source/cmGetTargetPropertyCommand.cxx +++ b/Source/cmGetTargetPropertyCommand.cxx @@ -22,7 +22,7 @@ bool cmGetTargetPropertyCommand } std::string var = args[0].c_str(); const std::string& targetName = args[1]; - const char *prop = 0; + std::string prop; if(args[2] == "ALIASED_TARGET") { @@ -38,7 +38,11 @@ bool cmGetTargetPropertyCommand else if(cmTarget* tgt = this->Makefile->FindTargetToUse(targetName)) { cmTarget& target = *tgt; - prop = target.GetProperty(args[2].c_str()); + const char* prop_cstr = target.GetProperty(args[2].c_str()); + if(prop_cstr) + { + prop = prop_cstr; + } } else { @@ -70,9 +74,9 @@ bool cmGetTargetPropertyCommand } } } - if (prop) + if (!prop.empty()) { - this->Makefile->AddDefinition(var.c_str(), prop); + this->Makefile->AddDefinition(var.c_str(), prop.c_str()); return true; } this->Makefile->AddDefinition(var.c_str(), (var+"-NOTFOUND").c_str()); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index b86a956..5bfd9da 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1156,8 +1156,11 @@ void cmLocalGenerator::ExpandRuleVariables(std::string& s, const RuleVariables& replaceValues) { - this->InsertRuleLauncher(s, replaceValues.CMTarget, - replaceValues.RuleLauncher); + if(replaceValues.RuleLauncher) + { + this->InsertRuleLauncher(s, replaceValues.CMTarget, + replaceValues.RuleLauncher); + } std::string::size_type start = s.find('<'); // no variables to expand if(start == s.npos) @@ -1201,7 +1204,7 @@ cmLocalGenerator::ExpandRuleVariables(std::string& s, //---------------------------------------------------------------------------- const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target, - const char* prop) + const std::string& prop) { if(target) { @@ -1215,7 +1218,7 @@ const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target, //---------------------------------------------------------------------------- void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target, - const char* prop) + const std::string& prop) { if(const char* val = this->GetRuleLauncher(target, prop)) { @@ -3455,11 +3458,12 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const } //---------------------------------------------------------------------------- -static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, const char* prop) +static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, + const std::string& prop) { if(const char* val = target->GetProperty(prop)) { - mf->AddDefinition(prop, val); + mf->AddDefinition(prop.c_str(), val); } } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 2e05804..888611d 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -382,9 +382,9 @@ protected: std::string ExpandRuleVariable(std::string const& variable, const RuleVariables& replaceValues); - const char* GetRuleLauncher(cmTarget* target, const char* prop); + const char* GetRuleLauncher(cmTarget* target, const std::string& prop); void InsertRuleLauncher(std::string& s, cmTarget* target, - const char* prop); + const std::string& prop); /** Convert a target to a utility target for unsupported diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 556e7a4..0fce1f4 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3548,17 +3548,9 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, return res; } -void cmMakefile::SetProperty(const char* prop, const char* value) +void cmMakefile::SetProperty(const std::string& prop, const char* value) { - if (!prop) - { - return; - } - - // handle special props - std::string propname = prop; - - if ( propname == "LINK_DIRECTORIES" ) + if ( prop == "LINK_DIRECTORIES" ) { std::vector varArgsExpanded; if(value) @@ -3568,7 +3560,7 @@ void cmMakefile::SetProperty(const char* prop, const char* value) this->SetLinkDirectories(varArgsExpanded); return; } - if (propname == "INCLUDE_DIRECTORIES") + if (prop == "INCLUDE_DIRECTORIES") { this->IncludeDirectoriesEntries.clear(); if (!value) @@ -3581,7 +3573,7 @@ void cmMakefile::SetProperty(const char* prop, const char* value) cmValueWithOrigin(value, lfbt)); return; } - if (propname == "COMPILE_OPTIONS") + if (prop == "COMPILE_OPTIONS") { this->CompileOptionsEntries.clear(); if (!value) @@ -3593,7 +3585,7 @@ void cmMakefile::SetProperty(const char* prop, const char* value) this->CompileOptionsEntries.push_back(cmValueWithOrigin(value, lfbt)); return; } - if (propname == "COMPILE_DEFINITIONS") + if (prop == "COMPILE_DEFINITIONS") { this->CompileDefinitionsEntries.clear(); if (!value) @@ -3607,13 +3599,13 @@ void cmMakefile::SetProperty(const char* prop, const char* value) return; } - if ( propname == "INCLUDE_REGULAR_EXPRESSION" ) + if ( prop == "INCLUDE_REGULAR_EXPRESSION" ) { this->SetIncludeRegularExpression(value); return; } - if ( propname == "ADDITIONAL_MAKE_CLEAN_FILES" ) + if ( prop == "ADDITIONAL_MAKE_CLEAN_FILES" ) { // This property is not inherrited if ( strcmp(this->GetCurrentDirectory(), @@ -3626,18 +3618,11 @@ void cmMakefile::SetProperty(const char* prop, const char* value) this->Properties.SetProperty(prop,value,cmProperty::DIRECTORY); } -void cmMakefile::AppendProperty(const char* prop, const char* value, +void cmMakefile::AppendProperty(const std::string& prop, + const char* value, bool asString) { - if (!prop) - { - return; - } - - // handle special props - std::string propname = prop; - - if (propname == "INCLUDE_DIRECTORIES") + if (prop == "INCLUDE_DIRECTORIES") { cmListFileBacktrace lfbt; this->GetBacktrace(lfbt); @@ -3645,7 +3630,7 @@ void cmMakefile::AppendProperty(const char* prop, const char* value, cmValueWithOrigin(value, lfbt)); return; } - if (propname == "COMPILE_OPTIONS") + if (prop == "COMPILE_OPTIONS") { cmListFileBacktrace lfbt; this->GetBacktrace(lfbt); @@ -3653,7 +3638,7 @@ void cmMakefile::AppendProperty(const char* prop, const char* value, cmValueWithOrigin(value, lfbt)); return; } - if (propname == "COMPILE_DEFINITIONS") + if (prop == "COMPILE_DEFINITIONS") { cmListFileBacktrace lfbt; this->GetBacktrace(lfbt); @@ -3661,7 +3646,7 @@ void cmMakefile::AppendProperty(const char* prop, const char* value, cmValueWithOrigin(value, lfbt)); return; } - if ( propname == "LINK_DIRECTORIES" ) + if ( prop == "LINK_DIRECTORIES" ) { std::vector varArgsExpanded; cmSystemTools::ExpandListArgument(value, varArgsExpanded); @@ -3676,32 +3661,28 @@ void cmMakefile::AppendProperty(const char* prop, const char* value, this->Properties.AppendProperty(prop,value,cmProperty::DIRECTORY,asString); } -const char *cmMakefile::GetPropertyOrDefinition(const char* prop) const +const char *cmMakefile::GetPropertyOrDefinition(const std::string& prop) const { const char *ret = this->GetProperty(prop, cmProperty::DIRECTORY); if (!ret) { - ret = this->GetDefinition(prop); + ret = this->GetDefinition(prop.c_str()); } return ret; } -const char *cmMakefile::GetProperty(const char* prop) const +const char *cmMakefile::GetProperty(const std::string& prop) const { return this->GetProperty(prop, cmProperty::DIRECTORY); } -const char *cmMakefile::GetProperty(const char* prop, +const char *cmMakefile::GetProperty(const std::string& prop, cmProperty::ScopeType scope) const { - if(!prop) - { - return 0; - } // watch for specific properties static std::string output; output = ""; - if (!strcmp("PARENT_DIRECTORY",prop)) + if (prop == "PARENT_DIRECTORY") { if(cmLocalGenerator* plg = this->LocalGenerator->GetParent()) { @@ -3709,12 +3690,12 @@ const char *cmMakefile::GetProperty(const char* prop, } return output.c_str(); } - else if (!strcmp("INCLUDE_REGULAR_EXPRESSION",prop) ) + else if (prop == "INCLUDE_REGULAR_EXPRESSION" ) { output = this->GetIncludeRegularExpression(); return output.c_str(); } - else if (!strcmp("LISTFILE_STACK",prop)) + else if (prop == "LISTFILE_STACK") { for (std::deque::const_iterator i = this->ListFileStack.begin(); @@ -3728,10 +3709,10 @@ const char *cmMakefile::GetProperty(const char* prop, } return output.c_str(); } - else if (!strcmp("VARIABLES",prop) || !strcmp("CACHE_VARIABLES",prop)) + else if (prop == "VARIABLES" || prop == "CACHE_VARIABLES") { int cacheonly = 0; - if ( !strcmp("CACHE_VARIABLES",prop) ) + if ( prop == "CACHE_VARIABLES" ) { cacheonly = 1; } @@ -3746,17 +3727,17 @@ const char *cmMakefile::GetProperty(const char* prop, } return output.c_str(); } - else if (!strcmp("MACROS",prop)) + else if (prop == "MACROS") { this->GetListOfMacros(output); return output.c_str(); } - else if (!strcmp("DEFINITIONS",prop)) + else if (prop == "DEFINITIONS") { output += this->DefineFlagsOrig; return output.c_str(); } - else if (!strcmp("LINK_DIRECTORIES",prop)) + else if (prop == "LINK_DIRECTORIES") { cmOStringStream str; for (std::vector::const_iterator @@ -3773,7 +3754,7 @@ const char *cmMakefile::GetProperty(const char* prop, output = str.str(); return output.c_str(); } - else if (!strcmp("INCLUDE_DIRECTORIES",prop)) + else if (prop == "INCLUDE_DIRECTORIES") { std::string sep; for (std::vector::const_iterator @@ -3787,7 +3768,7 @@ const char *cmMakefile::GetProperty(const char* prop, } return output.c_str(); } - else if (!strcmp("COMPILE_OPTIONS",prop)) + else if (prop == "COMPILE_OPTIONS") { std::string sep; for (std::vector::const_iterator @@ -3801,7 +3782,7 @@ const char *cmMakefile::GetProperty(const char* prop, } return output.c_str(); } - else if (!strcmp("COMPILE_DEFINITIONS",prop)) + else if (prop == "COMPILE_DEFINITIONS") { std::string sep; for (std::vector::const_iterator @@ -3832,7 +3813,7 @@ const char *cmMakefile::GetProperty(const char* prop, return retVal; } -bool cmMakefile::GetPropertyAsBool(const char* prop) const +bool cmMakefile::GetPropertyAsBool(const std::string& prop) const { return cmSystemTools::IsOn(this->GetProperty(prop)); } @@ -4014,9 +3995,9 @@ void cmMakefile::PopScope() } } -void cmMakefile::RaiseScope(const char *var, const char *varDef) +void cmMakefile::RaiseScope(const cmStdString& var, const char *varDef) { - if (!var || !strlen(var)) + if (var.empty()) { return; } @@ -4025,10 +4006,10 @@ void cmMakefile::RaiseScope(const char *var, const char *varDef) if(cmDefinitions* up = cur.GetParent()) { // First localize the definition in the current scope. - cur.Get(var); + cur.Get(var.c_str()); // Now update the definition in the parent scope. - up->Set(var, varDef); + up->Set(var.c_str(), varDef); } else if(cmLocalGenerator* plg = this->LocalGenerator->GetParent()) { @@ -4038,11 +4019,11 @@ void cmMakefile::RaiseScope(const char *var, const char *varDef) cmMakefile* parent = plg->GetMakefile(); if (varDef) { - parent->AddDefinition(var, varDef); + parent->AddDefinition(var.c_str(), varDef); } else { - parent->RemoveDefinition(var); + parent->RemoveDefinition(var.c_str()); } } else diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 45f3b9f..5f4b803 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -800,12 +800,14 @@ public: std::string GetModulesFile(const char* name) const; ///! Set/Get a property of this directory - void SetProperty(const char *prop, const char *value); - void AppendProperty(const char *prop, const char *value,bool asString=false); - const char *GetProperty(const char *prop) const; - const char *GetPropertyOrDefinition(const char *prop) const; - const char *GetProperty(const char *prop, cmProperty::ScopeType scope) const; - bool GetPropertyAsBool(const char *prop) const; + void SetProperty(const std::string& prop, const char *value); + void AppendProperty(const std::string& prop, const char *value, + bool asString=false); + const char *GetProperty(const std::string& prop) const; + const char *GetPropertyOrDefinition(const std::string& prop) const; + const char *GetProperty(const std::string& prop, + cmProperty::ScopeType scope) const; + bool GetPropertyAsBool(const std::string& prop) const; const char* GetFeature(const char* feature, const char* config); @@ -835,7 +837,7 @@ public: // push and pop variable scopes void PushScope(); void PopScope(); - void RaiseScope(const char *var, const char *value); + void RaiseScope(const cmStdString& var, const char *value); /** Helper class to push and pop scopes automatically. */ class ScopePushPop diff --git a/Source/cmProperty.cxx b/Source/cmProperty.cxx index 3b37cf3..40976db 100644 --- a/Source/cmProperty.cxx +++ b/Source/cmProperty.cxx @@ -12,14 +12,15 @@ #include "cmProperty.h" #include "cmSystemTools.h" -void cmProperty::Set(const char *name, const char *value) +void cmProperty::Set(const std::string& name, const char *value) { this->Name = name; this->Value = value; this->ValueHasBeenSet = true; } -void cmProperty::Append(const char *name, const char *value, bool asString) +void cmProperty::Append(const std::string& name, const char *value, + bool asString) { this->Name = name; if(!this->Value.empty() && *value && !asString) diff --git a/Source/cmProperty.h b/Source/cmProperty.h index bb75bb0..789be1d 100644 --- a/Source/cmProperty.h +++ b/Source/cmProperty.h @@ -21,10 +21,11 @@ public: TEST, VARIABLE, CACHED_VARIABLE }; // set this property - void Set(const char *name, const char *value); + void Set(const std::string& name, const char *value); // append to this property - void Append(const char *name, const char *value, bool asString = false); + void Append(const std::string& name, const char *value, + bool asString = false); // get the value const char *GetValue() const; diff --git a/Source/cmPropertyDefinition.cxx b/Source/cmPropertyDefinition.cxx index abc57ce..1af967c 100644 --- a/Source/cmPropertyDefinition.cxx +++ b/Source/cmPropertyDefinition.cxx @@ -13,7 +13,7 @@ #include "cmSystemTools.h" void cmPropertyDefinition -::DefineProperty(const char *name, cmProperty::ScopeType scope, +::DefineProperty(const std::string& name, cmProperty::ScopeType scope, const char *shortDescription, const char *fullDescription, bool chain) diff --git a/Source/cmPropertyDefinition.h b/Source/cmPropertyDefinition.h index 1b6a7a6..9ca8222 100644 --- a/Source/cmPropertyDefinition.h +++ b/Source/cmPropertyDefinition.h @@ -27,7 +27,7 @@ class cmPropertyDefinition { public: /// Define this property - void DefineProperty(const char *name, cmProperty::ScopeType scope, + void DefineProperty(const std::string& name, cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, bool chained); diff --git a/Source/cmPropertyDefinitionMap.cxx b/Source/cmPropertyDefinitionMap.cxx index db29504..9ebbaa4 100644 --- a/Source/cmPropertyDefinitionMap.cxx +++ b/Source/cmPropertyDefinitionMap.cxx @@ -14,16 +14,11 @@ #include "cmDocumentationSection.h" void cmPropertyDefinitionMap -::DefineProperty(const char *name, cmProperty::ScopeType scope, +::DefineProperty(const cmStdString& name, cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, bool chain) { - if (!name) - { - return; - } - cmPropertyDefinitionMap::iterator it = this->find(name); cmPropertyDefinition *prop; if (it == this->end()) @@ -34,13 +29,8 @@ void cmPropertyDefinitionMap } } -bool cmPropertyDefinitionMap::IsPropertyDefined(const char *name) +bool cmPropertyDefinitionMap::IsPropertyDefined(const cmStdString& name) { - if (!name) - { - return false; - } - cmPropertyDefinitionMap::iterator it = this->find(name); if (it == this->end()) { @@ -50,13 +40,8 @@ bool cmPropertyDefinitionMap::IsPropertyDefined(const char *name) return true; } -bool cmPropertyDefinitionMap::IsPropertyChained(const char *name) +bool cmPropertyDefinitionMap::IsPropertyChained(const cmStdString& name) { - if (!name) - { - return false; - } - cmPropertyDefinitionMap::iterator it = this->find(name); if (it == this->end()) { diff --git a/Source/cmPropertyDefinitionMap.h b/Source/cmPropertyDefinitionMap.h index 736e243..68c3ff3 100644 --- a/Source/cmPropertyDefinitionMap.h +++ b/Source/cmPropertyDefinitionMap.h @@ -21,16 +21,16 @@ public std::map { public: // define the property - void DefineProperty(const char *name, cmProperty::ScopeType scope, + void DefineProperty(const cmStdString& name, cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, bool chain); // has a named property been defined - bool IsPropertyDefined(const char *name); + bool IsPropertyDefined(const cmStdString& name); // is a named property set to chain - bool IsPropertyChained(const char *name); + bool IsPropertyChained(const cmStdString& name); }; #endif diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index e94e3e9..e335b3b 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -13,7 +13,7 @@ #include "cmSystemTools.h" #include "cmake.h" -cmProperty *cmPropertyMap::GetOrCreateProperty(const char *name) +cmProperty *cmPropertyMap::GetOrCreateProperty(const std::string& name) { cmPropertyMap::iterator it = this->find(name); cmProperty *prop; @@ -28,13 +28,9 @@ cmProperty *cmPropertyMap::GetOrCreateProperty(const char *name) return prop; } -void cmPropertyMap::SetProperty(const char *name, const char *value, +void cmPropertyMap::SetProperty(const std::string& name, const char *value, cmProperty::ScopeType scope) { - if (!name) - { - return; - } if(!value) { this->erase(name); @@ -46,11 +42,11 @@ void cmPropertyMap::SetProperty(const char *name, const char *value, prop->Set(name,value); } -void cmPropertyMap::AppendProperty(const char* name, const char* value, +void cmPropertyMap::AppendProperty(const std::string& name, const char* value, cmProperty::ScopeType scope, bool asString) { // Skip if nothing to append. - if(!name || !value || !*value) + if(!value || !*value) { return; } @@ -61,12 +57,12 @@ void cmPropertyMap::AppendProperty(const char* name, const char* value, } const char *cmPropertyMap -::GetPropertyValue(const char *name, +::GetPropertyValue(const std::string& name, cmProperty::ScopeType scope, bool &chain) const { chain = false; - if (!name) + if (name.empty()) { return 0; } diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index 0c3aad4..a13ac35 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -19,15 +19,15 @@ class cmake; class cmPropertyMap : public std::map { public: - cmProperty *GetOrCreateProperty(const char *name); + cmProperty *GetOrCreateProperty(const std::string& name); - void SetProperty(const char *name, const char *value, + void SetProperty(const std::string& name, const char *value, cmProperty::ScopeType scope); - void AppendProperty(const char* name, const char* value, + void AppendProperty(const std::string& name, const char* value, cmProperty::ScopeType scope, bool asString=false); - const char *GetPropertyValue(const char *name, + const char *GetPropertyValue(const std::string& name, cmProperty::ScopeType scope, bool &chain) const; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index dfb310e..7d0ce5f 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -105,7 +105,7 @@ static std::string extractSubDir(const std::string& absPath, static void copyTargetProperty(cmTarget* destinationTarget, cmTarget* sourceTarget, - const char* propertyName) + const std::string& propertyName) { const char* propertyValue = sourceTarget->GetProperty(propertyName); if (propertyValue) diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 23422a2..dd95f23 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -279,13 +279,8 @@ bool cmSourceFile::Matches(cmSourceFileLocation const& loc) } //---------------------------------------------------------------------------- -void cmSourceFile::SetProperty(const char* prop, const char* value) +void cmSourceFile::SetProperty(const std::string& prop, const char* value) { - if (!prop) - { - return; - } - this->Properties.SetProperty(prop, value, cmProperty::SOURCE_FILE); std::string ext = @@ -293,7 +288,7 @@ void cmSourceFile::SetProperty(const char* prop, const char* value) if (ext == ".ui") { cmMakefile const* mf = this->Location.GetMakefile(); - if (strcmp(prop, "AUTOUIC_OPTIONS") == 0) + if (prop == "AUTOUIC_OPTIONS") { const_cast(mf)->AddQtUiFileWithOptions(this); } @@ -301,19 +296,15 @@ void cmSourceFile::SetProperty(const char* prop, const char* value) } //---------------------------------------------------------------------------- -void cmSourceFile::AppendProperty(const char* prop, const char* value, +void cmSourceFile::AppendProperty(const std::string& prop, const char* value, bool asString) { - if (!prop) - { - return; - } this->Properties.AppendProperty(prop, value, cmProperty::SOURCE_FILE, asString); } //---------------------------------------------------------------------------- -const char* cmSourceFile::GetPropertyForUser(const char *prop) +const char* cmSourceFile::GetPropertyForUser(const std::string& prop) { // This method is a consequence of design history and backwards // compatibility. GetProperty is (and should be) a const method. @@ -329,7 +320,7 @@ const char* cmSourceFile::GetPropertyForUser(const char *prop) // cmSourceFileLocation class to commit to a particular full path to // the source file as late as possible. If the users requests the // LOCATION property we must commit now. - if(strcmp(prop, "LOCATION") == 0) + if(prop == "LOCATION") { // Commit to a location. this->GetFullPath(); @@ -340,10 +331,10 @@ const char* cmSourceFile::GetPropertyForUser(const char *prop) } //---------------------------------------------------------------------------- -const char* cmSourceFile::GetProperty(const char* prop) const +const char* cmSourceFile::GetProperty(const std::string& prop) const { // Check for computed properties. - if(strcmp(prop, "LOCATION") == 0) + if(prop == "LOCATION") { if(this->FullPath.empty()) { @@ -368,7 +359,7 @@ const char* cmSourceFile::GetProperty(const char* prop) const } //---------------------------------------------------------------------------- -bool cmSourceFile::GetPropertyAsBool(const char* prop) const +bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const { return cmSystemTools::IsOn(this->GetProperty(prop)); } diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 4440b05..85d6332 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -43,14 +43,15 @@ public: void SetCustomCommand(cmCustomCommand *cc); ///! Set/Get a property of this source file - void SetProperty(const char *prop, const char *value); - void AppendProperty(const char* prop, const char* value,bool asString=false); - const char *GetProperty(const char *prop) const; - bool GetPropertyAsBool(const char *prop) const; + void SetProperty(const std::string& prop, const char *value); + void AppendProperty(const std::string& prop, + const char* value,bool asString=false); + const char *GetProperty(const std::string& prop) const; + bool GetPropertyAsBool(const std::string& prop) const; /** Implement getting a property when called from a CMake language command like get_property or get_source_file_property. */ - const char* GetPropertyForUser(const char *prop); + const char* GetPropertyForUser(const std::string& prop); /** * The full path to the file. The non-const version of this method diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1c2b27a..fc2ab25 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1293,7 +1293,7 @@ void cmTarget::GatherDependencies( const cmMakefile& mf, } //---------------------------------------------------------------------------- -static bool whiteListedInterfaceProperty(const char *prop) +static bool whiteListedInterfaceProperty(const std::string& prop) { if(cmHasLiteralPrefix(prop, "INTERFACE_")) { @@ -1313,8 +1313,8 @@ static bool whiteListedInterfaceProperty(const char *prop) if (std::binary_search(cmArrayBegin(builtIns), cmArrayEnd(builtIns), - prop, - cmStrCmp(prop))) + prop.c_str(), + cmStrCmp(prop.c_str()))) { return true; } @@ -1328,12 +1328,8 @@ static bool whiteListedInterfaceProperty(const char *prop) } //---------------------------------------------------------------------------- -void cmTarget::SetProperty(const char* prop, const char* value) +void cmTarget::SetProperty(const std::string& prop, const char* value) { - if (!prop) - { - return; - } if (this->GetType() == INTERFACE_LIBRARY && !whiteListedInterfaceProperty(prop)) { @@ -1344,14 +1340,14 @@ void cmTarget::SetProperty(const char* prop, const char* value) return; } - if (strcmp(prop, "NAME") == 0) + if (prop == "NAME") { cmOStringStream e; e << "NAME property is read-only\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); return; } - if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0) + if(prop == "INCLUDE_DIRECTORIES") { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); @@ -1362,7 +1358,7 @@ void cmTarget::SetProperty(const char* prop, const char* value) new cmTargetInternals::TargetPropertyEntry(cge)); return; } - if(strcmp(prop,"COMPILE_OPTIONS") == 0) + if(prop == "COMPILE_OPTIONS") { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); @@ -1373,7 +1369,7 @@ void cmTarget::SetProperty(const char* prop, const char* value) new cmTargetInternals::TargetPropertyEntry(cge)); return; } - if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) + if(prop == "COMPILE_DEFINITIONS") { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); @@ -1384,7 +1380,7 @@ void cmTarget::SetProperty(const char* prop, const char* value) new cmTargetInternals::TargetPropertyEntry(cge)); return; } - if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported()) + if(prop == "EXPORT_NAME" && this->IsImported()) { cmOStringStream e; e << "EXPORT_NAME property can't be set on imported targets (\"" @@ -1392,7 +1388,7 @@ void cmTarget::SetProperty(const char* prop, const char* value) this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); return; } - if (strcmp(prop, "LINK_LIBRARIES") == 0) + if (prop == "LINK_LIBRARIES") { this->Internal->LinkImplementationPropertyEntries.clear(); cmListFileBacktrace lfbt; @@ -1406,13 +1402,9 @@ void cmTarget::SetProperty(const char* prop, const char* value) } //---------------------------------------------------------------------------- -void cmTarget::AppendProperty(const char* prop, const char* value, +void cmTarget::AppendProperty(const std::string& prop, const char* value, bool asString) { - if (!prop) - { - return; - } if (this->GetType() == INTERFACE_LIBRARY && !whiteListedInterfaceProperty(prop)) { @@ -1422,14 +1414,14 @@ void cmTarget::AppendProperty(const char* prop, const char* value, this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); return; } - if (strcmp(prop, "NAME") == 0) + if (prop == "NAME") { cmOStringStream e; e << "NAME property is read-only\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); return; } - if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0) + if(prop == "INCLUDE_DIRECTORIES") { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); @@ -1438,7 +1430,7 @@ void cmTarget::AppendProperty(const char* prop, const char* value, new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); return; } - if(strcmp(prop,"COMPILE_OPTIONS") == 0) + if(prop == "COMPILE_OPTIONS") { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); @@ -1447,7 +1439,7 @@ void cmTarget::AppendProperty(const char* prop, const char* value, new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); return; } - if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) + if(prop == "COMPILE_DEFINITIONS") { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); @@ -1456,7 +1448,7 @@ void cmTarget::AppendProperty(const char* prop, const char* value, new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); return; } - if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported()) + if(prop == "EXPORT_NAME" && this->IsImported()) { cmOStringStream e; e << "EXPORT_NAME property can't be set on imported targets (\"" @@ -1464,7 +1456,7 @@ void cmTarget::AppendProperty(const char* prop, const char* value, this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); return; } - if (strcmp(prop, "LINK_LIBRARIES") == 0) + if (prop == "LINK_LIBRARIES") { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); @@ -2215,7 +2207,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, } //---------------------------------------------------------------------------- -void cmTarget::MaybeInvalidatePropertyCache(const char* prop) +void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop) { // Wipe out maps caching information affected by this property. if(this->IsImported() && cmHasLiteralPrefix(prop, "IMPORTED")) @@ -2230,8 +2222,8 @@ void cmTarget::MaybeInvalidatePropertyCache(const char* prop) //---------------------------------------------------------------------------- static void cmTargetCheckLINK_INTERFACE_LIBRARIES( - const char* prop, const char* value, cmMakefile* context, bool imported - ) + const std::string& prop, const char* value, cmMakefile* context, + bool imported) { // Look for link-type keywords in the value. static cmsys::RegularExpression @@ -2295,7 +2287,8 @@ static void cmTargetCheckINTERFACE_LINK_LIBRARIES(const char* value, } //---------------------------------------------------------------------------- -void cmTarget::CheckProperty(const char* prop, cmMakefile* context) const +void cmTarget::CheckProperty(const std::string& prop, + cmMakefile* context) const { // Certain properties need checking. if(cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES")) @@ -2579,7 +2572,7 @@ const char* cmTarget::GetFeature(const char* feature, const char* config) const } //---------------------------------------------------------------------------- -const char *cmTarget::GetProperty(const char* prop) const +const char *cmTarget::GetProperty(const std::string& prop) const { return this->GetProperty(prop, cmProperty::TARGET); } @@ -2622,14 +2615,9 @@ bool cmTarget::HandleLocationPropertyPolicy() const } //---------------------------------------------------------------------------- -const char *cmTarget::GetProperty(const char* prop, +const char *cmTarget::GetProperty(const std::string& prop, cmProperty::ScopeType scope) const { - if(!prop) - { - return 0; - } - if (this->GetType() == INTERFACE_LIBRARY && !whiteListedInterfaceProperty(prop)) { @@ -2640,7 +2628,7 @@ const char *cmTarget::GetProperty(const char* prop, return 0; } - if (strcmp(prop, "NAME") == 0) + if (prop == "NAME") { return this->GetName(); } @@ -2653,7 +2641,7 @@ const char *cmTarget::GetProperty(const char* prop, this->GetType() == cmTarget::MODULE_LIBRARY || this->GetType() == cmTarget::UNKNOWN_LIBRARY) { - if(strcmp(prop,"LOCATION") == 0) + if(prop == "LOCATION") { if (!this->HandleLocationPropertyPolicy()) { @@ -2680,13 +2668,13 @@ const char *cmTarget::GetProperty(const char* prop, { return 0; } - std::string configName = prop+9; + const char* configName = prop.c_str() + 9; this->Properties.SetProperty(prop, - this->GetLocation(configName.c_str()), + this->GetLocation(configName), cmProperty::TARGET); } } - if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0) + if(prop == "INCLUDE_DIRECTORIES") { static std::string output; output = ""; @@ -2704,7 +2692,7 @@ const char *cmTarget::GetProperty(const char* prop, } return output.c_str(); } - if(strcmp(prop,"COMPILE_OPTIONS") == 0) + if(prop == "COMPILE_OPTIONS") { static std::string output; output = ""; @@ -2722,7 +2710,7 @@ const char *cmTarget::GetProperty(const char* prop, } return output.c_str(); } - if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) + if(prop == "COMPILE_DEFINITIONS") { static std::string output; output = ""; @@ -2740,7 +2728,7 @@ const char *cmTarget::GetProperty(const char* prop, } return output.c_str(); } - if(strcmp(prop,"LINK_LIBRARIES") == 0) + if(prop == "LINK_LIBRARIES") { static std::string output; output = ""; @@ -2757,12 +2745,12 @@ const char *cmTarget::GetProperty(const char* prop, return output.c_str(); } - if (strcmp(prop,"IMPORTED") == 0) + if (prop == "IMPORTED") { return this->IsImported()?"TRUE":"FALSE"; } - if(!strcmp(prop,"SOURCES")) + if(prop == "SOURCES") { cmOStringStream ss; const char* sep = ""; @@ -2791,7 +2779,7 @@ const char *cmTarget::GetProperty(const char* prop, } // the type property returns what type the target is - if (!strcmp(prop,"TYPE")) + if (prop == "TYPE") { return cmTarget::GetTargetTypeName(this->GetType()); } @@ -2806,7 +2794,7 @@ const char *cmTarget::GetProperty(const char* prop, } //---------------------------------------------------------------------------- -bool cmTarget::GetPropertyAsBool(const char* prop) const +bool cmTarget::GetPropertyAsBool(const std::string& prop) const { return cmSystemTools::IsOn(this->GetProperty(prop)); } @@ -3804,7 +3792,7 @@ bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName, } //---------------------------------------------------------------------------- -void cmTarget::SetPropertyDefault(const char* property, +void cmTarget::SetPropertyDefault(const std::string& property, const char* default_value) { // Compute the name of the variable holding the default value. @@ -4740,7 +4728,7 @@ const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( //---------------------------------------------------------------------------- bool isLinkDependentProperty(cmTarget const* tgt, const std::string &p, - const char *interfaceProperty, + const std::string& interfaceProperty, const char *config) { std::vector deps; @@ -5984,14 +5972,14 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const template PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string prop, + const std::string& prop, const char *config, CompatibleType, PropertyType *); template<> bool getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string prop, + const std::string& prop, const char *config, CompatibleType, bool *) { @@ -6000,7 +5988,7 @@ bool getLinkInterfaceDependentProperty(cmTarget const* tgt, template<> const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string prop, + const std::string& prop, const char *config, CompatibleType t, const char **) @@ -6025,7 +6013,7 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, template void checkPropertyConsistency(cmTarget const* depender, cmTarget const* dependee, - const char *propName, + const cmStdString& propName, std::set &emitted, const char *config, CompatibleType t, @@ -6135,32 +6123,32 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, } checkPropertyConsistency(this, li->Target, - "COMPATIBLE_INTERFACE_BOOL", - emittedBools, config, BoolType, 0); + std::string("COMPATIBLE_INTERFACE_BOOL"), + emittedBools, config, BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } checkPropertyConsistency(this, li->Target, - "COMPATIBLE_INTERFACE_STRING", - emittedStrings, config, - StringType, 0); + std::string("COMPATIBLE_INTERFACE_STRING"), + emittedStrings, config, + StringType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } checkPropertyConsistency(this, li->Target, - "COMPATIBLE_INTERFACE_NUMBER_MIN", - emittedMinNumbers, config, - NumberMinType, 0); + std::string("COMPATIBLE_INTERFACE_NUMBER_MIN"), + emittedMinNumbers, config, + NumberMinType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } checkPropertyConsistency(this, li->Target, - "COMPATIBLE_INTERFACE_NUMBER_MAX", - emittedMaxNumbers, config, - NumberMaxType, 0); + std::string("COMPATIBLE_INTERFACE_NUMBER_MAX"), + emittedMaxNumbers, config, + NumberMaxType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 471ea94..f0dd708 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -223,12 +223,14 @@ public: void FinishConfigure(); ///! Set/Get a property of this target file - void SetProperty(const char *prop, const char *value); - void AppendProperty(const char* prop, const char* value,bool asString=false); - const char *GetProperty(const char *prop) const; - const char *GetProperty(const char *prop, cmProperty::ScopeType scope) const; - bool GetPropertyAsBool(const char *prop) const; - void CheckProperty(const char* prop, cmMakefile* context) const; + void SetProperty(const std::string& prop, const char *value); + void AppendProperty(const std::string& prop, const char* value, + bool asString=false); + const char *GetProperty(const std::string& prop) const; + const char *GetProperty(const std::string& prop, + cmProperty::ScopeType scope) const; + bool GetPropertyAsBool(const std::string& prop) const; + void CheckProperty(const std::string& prop, cmMakefile* context) const; const char* GetFeature(const char* feature, const char* config) const; @@ -632,7 +634,8 @@ private: // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. - void SetPropertyDefault(const char* property, const char* default_value); + void SetPropertyDefault(const std::string& property, + const char* default_value); // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. const char* GetOutputTargetType(bool implib) const; @@ -729,7 +732,7 @@ private: void ClearLinkMaps(); - void MaybeInvalidatePropertyCache(const char* prop); + void MaybeInvalidatePropertyCache(const std::string& prop); void ProcessSourceExpression(std::string const& expr); diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 195690e..2a20516 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -16,8 +16,9 @@ //---------------------------------------------------------------------------- bool cmTargetPropCommandBase -::HandleArguments(std::vector const& args, const char *prop, - ArgumentFlags flags) +::HandleArguments(std::vector const& args, + const std::string& prop, + ArgumentFlags flags) { if(args.size() < 2) { diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index c402836..555a08a 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -29,7 +29,8 @@ public: }; bool HandleArguments(std::vector const& args, - const char *prop, ArgumentFlags flags = NO_FLAGS); + const std::string& prop, + ArgumentFlags flags = NO_FLAGS); cmTypeMacro(cmTargetPropCommandBase, cmCommand); protected: diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index 9cda978..4ff71ac 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -54,7 +54,7 @@ void cmTest::SetCommand(std::vector const& command) } //---------------------------------------------------------------------------- -const char *cmTest::GetProperty(const char* prop) const +const char *cmTest::GetProperty(const std::string& prop) const { bool chain = false; const char *retVal = @@ -67,28 +67,20 @@ const char *cmTest::GetProperty(const char* prop) const } //---------------------------------------------------------------------------- -bool cmTest::GetPropertyAsBool(const char* prop) const +bool cmTest::GetPropertyAsBool(const std::string& prop) const { return cmSystemTools::IsOn(this->GetProperty(prop)); } //---------------------------------------------------------------------------- -void cmTest::SetProperty(const char* prop, const char* value) +void cmTest::SetProperty(const std::string& prop, const char* value) { - if (!prop) - { - return; - } - this->Properties.SetProperty(prop, value, cmProperty::TEST); } //---------------------------------------------------------------------------- -void cmTest::AppendProperty(const char* prop, const char* value, bool asString) +void cmTest::AppendProperty(const std::string& prop, + const char* value, bool asString) { - if (!prop) - { - return; - } this->Properties.AppendProperty(prop, value, cmProperty::TEST, asString); } diff --git a/Source/cmTest.h b/Source/cmTest.h index 1fe8fc0..1becbf7 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -46,10 +46,11 @@ public: void Print() const; ///! Set/Get a property of this source file - void SetProperty(const char *prop, const char *value); - void AppendProperty(const char* prop, const char* value,bool asString=false); - const char *GetProperty(const char *prop) const; - bool GetPropertyAsBool(const char *prop) const; + void SetProperty(const std::string& prop, const char *value); + void AppendProperty(const std::string& prop, + const char* value,bool asString=false); + const char *GetProperty(const std::string& prop) const; + bool GetPropertyAsBool(const std::string& prop) const; cmPropertyMap &GetProperties() { return this->Properties; }; /** Get the cmMakefile instance that owns this test. */ diff --git a/Source/cmake.cxx b/Source/cmake.cxx index abbabe7..149e299 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2144,7 +2144,8 @@ void cmake::GenerateGraphViz(const char* fileName) const #endif } -void cmake::DefineProperty(const char *name, cmProperty::ScopeType scope, +void cmake::DefineProperty(const std::string& name, + cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, bool chained) @@ -2155,7 +2156,7 @@ void cmake::DefineProperty(const char *name, cmProperty::ScopeType scope, } cmPropertyDefinition *cmake -::GetPropertyDefinition(const char *name, +::GetPropertyDefinition(const std::string& name, cmProperty::ScopeType scope) { if (this->IsPropertyDefined(name,scope)) @@ -2165,25 +2166,22 @@ cmPropertyDefinition *cmake return 0; } -bool cmake::IsPropertyDefined(const char *name, cmProperty::ScopeType scope) +bool cmake::IsPropertyDefined(const std::string& name, + cmProperty::ScopeType scope) { return this->PropertyDefinitions[scope].IsPropertyDefined(name); } -bool cmake::IsPropertyChained(const char *name, cmProperty::ScopeType scope) +bool cmake::IsPropertyChained(const std::string& name, + cmProperty::ScopeType scope) { return this->PropertyDefinitions[scope].IsPropertyChained(name); } -void cmake::SetProperty(const char* prop, const char* value) +void cmake::SetProperty(const std::string& prop, const char* value) { - if (!prop) - { - return; - } - // Special hook to invalidate cached value. - if(strcmp(prop, "DEBUG_CONFIGURATIONS") == 0) + if(prop == "DEBUG_CONFIGURATIONS") { this->DebugConfigs.clear(); } @@ -2191,15 +2189,11 @@ void cmake::SetProperty(const char* prop, const char* value) this->Properties.SetProperty(prop, value, cmProperty::GLOBAL); } -void cmake::AppendProperty(const char* prop, const char* value, bool asString) +void cmake::AppendProperty(const std::string& prop, + const char* value, bool asString) { - if (!prop) - { - return; - } - // Special hook to invalidate cached value. - if(strcmp(prop, "DEBUG_CONFIGURATIONS") == 0) + if(prop == "DEBUG_CONFIGURATIONS") { this->DebugConfigs.clear(); } @@ -2207,23 +2201,19 @@ void cmake::AppendProperty(const char* prop, const char* value, bool asString) this->Properties.AppendProperty(prop, value, cmProperty::GLOBAL, asString); } -const char *cmake::GetProperty(const char* prop) +const char *cmake::GetProperty(const std::string& prop) { return this->GetProperty(prop, cmProperty::GLOBAL); } -const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope) +const char *cmake::GetProperty(const std::string& prop, + cmProperty::ScopeType scope) { - if(!prop) - { - return 0; - } bool chain = false; // watch for special properties - std::string propname = prop; std::string output = ""; - if ( propname == "CACHE_VARIABLES" ) + if ( prop == "CACHE_VARIABLES" ) { cmCacheManager::CacheIterator cit = this->GetCacheManager()->GetCacheIterator(); @@ -2237,7 +2227,7 @@ const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope) } this->SetProperty("CACHE_VARIABLES", output.c_str()); } - else if ( propname == "COMMANDS" ) + else if ( prop == "COMMANDS" ) { cmake::RegisteredCommandsMap::iterator cmds = this->GetCommands()->begin(); @@ -2252,12 +2242,12 @@ const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope) } this->SetProperty("COMMANDS",output.c_str()); } - else if ( propname == "IN_TRY_COMPILE" ) + else if ( prop == "IN_TRY_COMPILE" ) { this->SetProperty("IN_TRY_COMPILE", this->GetIsInTryCompile()? "1":"0"); } - else if ( propname == "ENABLED_LANGUAGES" ) + else if ( prop == "ENABLED_LANGUAGES" ) { std::string lang; if(this->GlobalGenerator) @@ -2278,7 +2268,7 @@ const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope) return this->Properties.GetPropertyValue(prop, scope, chain); } -bool cmake::GetPropertyAsBool(const char* prop) +bool cmake::GetPropertyAsBool(const std::string& prop) { return cmSystemTools::IsOn(this->GetProperty(prop)); } diff --git a/Source/cmake.h b/Source/cmake.h index dfec55c..e89868c 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -269,11 +269,13 @@ class cmake void GetGeneratorDocumentation(std::vector&); ///! Set/Get a property of this target file - void SetProperty(const char *prop, const char *value); - void AppendProperty(const char *prop, const char *value,bool asString=false); - const char *GetProperty(const char *prop); - const char *GetProperty(const char *prop, cmProperty::ScopeType scope); - bool GetPropertyAsBool(const char *prop); + void SetProperty(const std::string& prop, const char *value); + void AppendProperty(const std::string& prop, + const char *value,bool asString=false); + const char *GetProperty(const std::string& prop); + const char *GetProperty(const std::string& prop, + cmProperty::ScopeType scope); + bool GetPropertyAsBool(const std::string& prop); // Get the properties cmPropertyMap &GetProperties() { return this->Properties; }; @@ -317,18 +319,18 @@ class cmake void MarkCliAsUsed(const std::string& variable); // Define a property - void DefineProperty(const char *name, cmProperty::ScopeType scope, + void DefineProperty(const std::string& name, cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, bool chain = false); // get property definition cmPropertyDefinition *GetPropertyDefinition - (const char *name, cmProperty::ScopeType scope); + (const std::string& name, cmProperty::ScopeType scope); // Is a property defined? - bool IsPropertyDefined(const char *name, cmProperty::ScopeType scope); - bool IsPropertyChained(const char *name, cmProperty::ScopeType scope); + bool IsPropertyDefined(const std::string& name, cmProperty::ScopeType scope); + bool IsPropertyChained(const std::string& name, cmProperty::ScopeType scope); /** Get the list of configurations (in upper case) considered to be debugging configurations.*/ -- cgit v0.12 From 3742bb0d324b971f63cc7e557b1cb8a9d08c5cdd Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 4 Feb 2014 16:06:56 -0500 Subject: stringapi: Use strings for variable names Variable names are always generated by CMake and should never be NULL. --- Source/CPack/cmCPackGenerator.cxx | 14 +++----- Source/CPack/cmCPackGenerator.h | 10 +++--- Source/CTest/cmCTestGenericHandler.cxx | 14 ++------ Source/CTest/cmCTestGenericHandler.h | 6 ++-- .../CursesDialog/cmCursesCacheEntryComposite.cxx | 9 +++--- Source/CursesDialog/cmCursesCacheEntryComposite.h | 5 +-- Source/CursesDialog/cmCursesMainForm.cxx | 10 +++--- Source/CursesDialog/cmCursesMainForm.h | 2 +- Source/cmCTest.cxx | 17 +++------- Source/cmCTest.h | 8 ++--- Source/cmCacheManager.cxx | 11 ++++--- Source/cmCacheManager.h | 10 +++--- Source/cmDefinitions.cxx | 8 ++--- Source/cmDefinitions.h | 8 ++--- Source/cmExportFileGenerator.cxx | 2 +- Source/cmExportFileGenerator.h | 2 +- Source/cmFindBase.cxx | 6 ++-- Source/cmFindBase.h | 4 +-- Source/cmFindCommon.cxx | 2 +- Source/cmFindCommon.h | 2 +- Source/cmFindPackageCommand.cxx | 3 +- Source/cmFindPackageCommand.h | 2 +- Source/cmIfCommand.cxx | 18 +++++------ Source/cmIfCommand.h | 2 +- Source/cmListCommand.cxx | 10 +++--- Source/cmListCommand.h | 4 +-- Source/cmLocalGenerator.cxx | 2 +- Source/cmLocalGenerator.h | 2 +- Source/cmMakefile.cxx | 37 +++++++++++----------- Source/cmMakefile.h | 32 +++++++++---------- Source/cmMakefileLibraryTargetGenerator.cxx | 4 +-- Source/cmMakefileLibraryTargetGenerator.h | 3 +- Source/cmMakefileTargetGenerator.cxx | 3 +- Source/cmMakefileTargetGenerator.h | 2 +- Source/cmScriptGenerator.cxx | 2 +- Source/cmScriptGenerator.h | 2 +- Source/cmake.cxx | 10 +++--- Source/cmake.h | 10 +++--- 38 files changed, 142 insertions(+), 156 deletions(-) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index e1dd4e9..b46fd86 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -972,7 +972,7 @@ bool cmCPackGenerator::ReadListFile(const char* moduleName) } //---------------------------------------------------------------------- -void cmCPackGenerator::SetOptionIfNotSet(const char* op, +void cmCPackGenerator::SetOptionIfNotSet(const std::string& op, const char* value) { const char* def = this->MakefileMap->GetDefinition(op); @@ -984,12 +984,8 @@ void cmCPackGenerator::SetOptionIfNotSet(const char* op, } //---------------------------------------------------------------------- -void cmCPackGenerator::SetOption(const char* op, const char* value) +void cmCPackGenerator::SetOption(const std::string& op, const char* value) { - if ( !op ) - { - return; - } if ( !value ) { this->MakefileMap->RemoveDefinition(op); @@ -1176,19 +1172,19 @@ int cmCPackGenerator::InitializeInternal() } //---------------------------------------------------------------------- -bool cmCPackGenerator::IsSet(const char* name) const +bool cmCPackGenerator::IsSet(const std::string& name) const { return this->MakefileMap->IsSet(name); } //---------------------------------------------------------------------- -bool cmCPackGenerator::IsOn(const char* name) const +bool cmCPackGenerator::IsOn(const std::string& name) const { return cmSystemTools::IsOn(GetOption(name)); } //---------------------------------------------------------------------- -const char* cmCPackGenerator::GetOption(const char* op) const +const char* cmCPackGenerator::GetOption(const std::string& op) const { const char* ret = this->MakefileMap->GetDefinition(op); if(!ret) diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index b1a7840..39ef64d 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -99,12 +99,12 @@ public: virtual ~cmCPackGenerator(); //! Set and get the options - void SetOption(const char* op, const char* value); - void SetOptionIfNotSet(const char* op, const char* value); - const char* GetOption(const char* op) const; + void SetOption(const std::string& op, const char* value); + void SetOptionIfNotSet(const std::string& op, const char* value); + const char* GetOption(const std::string& op) const; std::vector GetOptions() const; - bool IsSet(const char* name) const; - bool IsOn(const char* name) const; + bool IsSet(const std::string& name) const; + bool IsOn(const std::string& name) const; //! Set the logger void SetLogger(cmCPackLog* log) { this->Logger = log; } diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index 5338f30..ae498ea 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -30,12 +30,8 @@ cmCTestGenericHandler::~cmCTestGenericHandler() } //---------------------------------------------------------------------- -void cmCTestGenericHandler::SetOption(const char* op, const char* value) +void cmCTestGenericHandler::SetOption(const std::string& op, const char* value) { - if ( !op ) - { - return; - } if ( !value ) { cmCTestGenericHandler::t_StringToString::iterator remit @@ -51,14 +47,10 @@ void cmCTestGenericHandler::SetOption(const char* op, const char* value) } //---------------------------------------------------------------------- -void cmCTestGenericHandler::SetPersistentOption(const char* op, +void cmCTestGenericHandler::SetPersistentOption(const std::string& op, const char* value) { this->SetOption(op, value); - if ( !op ) - { - return; - } if ( !value ) { cmCTestGenericHandler::t_StringToString::iterator remit @@ -88,7 +80,7 @@ void cmCTestGenericHandler::Initialize() } //---------------------------------------------------------------------- -const char* cmCTestGenericHandler::GetOption(const char* op) +const char* cmCTestGenericHandler::GetOption(const std::string& op) { cmCTestGenericHandler::t_StringToString::iterator remit = this->Options.find(op); diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h index ba8febb..d05e230 100644 --- a/Source/CTest/cmCTestGenericHandler.h +++ b/Source/CTest/cmCTestGenericHandler.h @@ -74,9 +74,9 @@ public: typedef std::map t_StringToString; - void SetPersistentOption(const char* op, const char* value); - void SetOption(const char* op, const char* value); - const char* GetOption(const char* op); + void SetPersistentOption(const std::string& op, const char* value); + void SetOption(const std::string& op, const char* value); + const char* GetOption(const std::string& op); void SetCommand(cmCTestCommand* command) { diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx index 249137f..7929ce7 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx @@ -19,9 +19,10 @@ #include "cmCursesDummyWidget.h" #include "../cmSystemTools.h" -cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(const char* key, - int labelwidth, - int entrywidth) : +cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( + const std::string& key, + int labelwidth, + int entrywidth) : Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth) { this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key); @@ -31,7 +32,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(const char* key, } cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( - const char* key, const cmCacheManager::CacheIterator& it, bool isNew, + const std::string& key, const cmCacheManager::CacheIterator& it, bool isNew, int labelwidth, int entrywidth) : Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth) { diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.h b/Source/CursesDialog/cmCursesCacheEntryComposite.h index 1357a02..98107cc 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.h +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.h @@ -18,8 +18,9 @@ class cmCursesCacheEntryComposite { public: - cmCursesCacheEntryComposite(const char* key, int labelwidth, int entrywidth); - cmCursesCacheEntryComposite(const char* key, + cmCursesCacheEntryComposite(const std::string& key, int labelwidth, + int entrywidth); + cmCursesCacheEntryComposite(const std::string& key, const cmCacheManager::CacheIterator& it, bool isNew, int labelwidth, int entrywidth); ~cmCursesCacheEntryComposite(); diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index d94cd37..0734927 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -84,9 +84,9 @@ cmCursesMainForm::~cmCursesMainForm() } // See if a cache entry is in the list of entries in the ui. -bool cmCursesMainForm::LookForCacheEntry(const char* key) +bool cmCursesMainForm::LookForCacheEntry(const std::string& key) { - if (!key || !this->Entries) + if (!this->Entries) { return false; } @@ -94,7 +94,7 @@ bool cmCursesMainForm::LookForCacheEntry(const char* key) std::vector::iterator it; for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { - if (!strcmp(key, (*it)->Key.c_str())) + if (key == (*it)->Key) { return true; } @@ -146,7 +146,7 @@ void cmCursesMainForm::InitializeUI() this->CMakeInstance->GetCacheManager()->NewIterator(); !i.IsAtEnd(); i.Next()) { - const char* key = i.GetName(); + std::string key = i.GetName(); if ( i.GetType() == cmCacheManager::INTERNAL || i.GetType() == cmCacheManager::STATIC || i.GetType() == cmCacheManager::UNINITIALIZED ) @@ -168,7 +168,7 @@ void cmCursesMainForm::InitializeUI() this->CMakeInstance->GetCacheManager()->NewIterator(); !i.IsAtEnd(); i.Next()) { - const char* key = i.GetName(); + std::string key = i.GetName(); if ( i.GetType() == cmCacheManager::INTERNAL || i.GetType() == cmCacheManager::STATIC || i.GetType() == cmCacheManager::UNINITIALIZED ) diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index 883a2b3..fba9bc5 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -51,7 +51,7 @@ public: * Returns true if an entry with the given key is in the * list of current composites. */ - bool LookForCacheEntry(const char* key); + bool LookForCacheEntry(const std::string& key); enum { MIN_WIDTH = 65, diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index acedc1a..39b623d 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2593,13 +2593,9 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) } //---------------------------------------------------------------------- -void cmCTest::PopulateCustomVector(cmMakefile* mf, const char* def, +void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def, VectorOfStrings& vec) { - if ( !def) - { - return; - } const char* dval = mf->GetDefinition(def); if ( !dval ) { @@ -2620,12 +2616,9 @@ void cmCTest::PopulateCustomVector(cmMakefile* mf, const char* def, } //---------------------------------------------------------------------- -void cmCTest::PopulateCustomInteger(cmMakefile* mf, const char* def, int& val) +void cmCTest::PopulateCustomInteger(cmMakefile* mf, const std::string& def, + int& val) { - if ( !def) - { - return; - } const char* dval = mf->GetDefinition(def); if ( !dval ) { @@ -2702,7 +2695,7 @@ std::string cmCTest::GetShortPathToFile(const char* cfname) } //---------------------------------------------------------------------- -std::string cmCTest::GetCTestConfiguration(const char *name) +std::string cmCTest::GetCTestConfiguration(const std::string& name) { if ( this->CTestConfigurationOverwrites.find(name) != this->CTestConfigurationOverwrites.end() ) @@ -2877,7 +2870,7 @@ void cmCTest::SetConfigType(const char* ct) //---------------------------------------------------------------------- bool cmCTest::SetCTestConfigurationFromCMakeVariable(cmMakefile* mf, - const char* dconfig, const char* cmake_var) + const char* dconfig, const std::string& cmake_var) { const char* ctvar; ctvar = mf->GetDefinition(cmake_var); diff --git a/Source/cmCTest.h b/Source/cmCTest.h index becb0f5..6418f09 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -172,7 +172,7 @@ public: std::string GetTestModelString(); static int GetTestModelFromString(const char* str); static std::string CleanString(const std::string& str); - std::string GetCTestConfiguration(const char *name); + std::string GetCTestConfiguration(const std::string& name); void SetCTestConfiguration(const char *name, const char* value); void EmptyCTestConfiguration(); @@ -185,9 +185,9 @@ public: //! Set the notes files to be created. void SetNotesFiles(const char* notes); - void PopulateCustomVector(cmMakefile* mf, const char* definition, + void PopulateCustomVector(cmMakefile* mf, const std::string& definition, VectorOfStrings& vec); - void PopulateCustomInteger(cmMakefile* mf, const char* def, + void PopulateCustomInteger(cmMakefile* mf, const std::string& def, int& val); ///! Get the current time as string @@ -332,7 +332,7 @@ public: * Set the CTest variable from CMake variable */ bool SetCTestConfigurationFromCMakeVariable(cmMakefile* mf, - const char* dconfig, const char* cmake_var); + const char* dconfig, const std::string& cmake_var); //! Make string safe to be send as an URL static std::string MakeURLSafe(const std::string&); diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 04542d8..7a71482 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -650,7 +650,7 @@ void cmCacheManager::OutputHelpString(std::ostream& fout, } } -void cmCacheManager::RemoveCacheEntry(const char* key) +void cmCacheManager::RemoveCacheEntry(const std::string& key) { CacheEntryMap::iterator i = this->Cache.find(key); if(i != this->Cache.end()) @@ -660,7 +660,8 @@ void cmCacheManager::RemoveCacheEntry(const char* key) } -cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry(const char* key) +cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry( + const std::string& key) { CacheEntryMap::iterator i = this->Cache.find(key); if(i != this->Cache.end()) @@ -676,7 +677,7 @@ cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator( return CacheIterator(*this, key); } -const char* cmCacheManager::GetCacheValue(const char* key) const +const char* cmCacheManager::GetCacheValue(const std::string& key) const { CacheEntryMap::const_iterator i = this->Cache.find(key); if(i != this->Cache.end() && @@ -708,7 +709,7 @@ void cmCacheManager::PrintCache(std::ostream& out) const } -void cmCacheManager::AddCacheEntry(const char* key, +void cmCacheManager::AddCacheEntry(const std::string& key, const char* value, const char* helpString, CacheEntryType type) @@ -767,7 +768,7 @@ void cmCacheManager::CacheIterator::Begin() this->Position = this->Container.Cache.begin(); } -bool cmCacheManager::CacheIterator::Find(const char* key) +bool cmCacheManager::CacheIterator::Find(const std::string& key) { this->Position = this->Container.Cache.find(key); return !this->IsAtEnd(); diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index ac6187b..7a61394 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -53,7 +53,7 @@ public: { public: void Begin(); - bool Find(const char*); + bool Find(const std::string&); bool IsAtEnd() const; void Next(); const char *GetName() const { @@ -129,7 +129,7 @@ public: cmCacheManager::CacheIterator GetCacheIterator(const char *key=0); ///! Remove an entry from the cache - void RemoveCacheEntry(const char* key); + void RemoveCacheEntry(const std::string& key); ///! Get the number of entries in the cache int GetSize() { @@ -142,7 +142,7 @@ public: CacheEntryType& type); ///! Get a value from the cache given a key - const char* GetCacheValue(const char* key) const; + const char* GetCacheValue(const std::string& key) const; /** Get the version of CMake that wrote the cache. */ unsigned int GetCacheMajorVersion() const @@ -153,11 +153,11 @@ public: protected: ///! Add an entry into the cache - void AddCacheEntry(const char* key, const char* value, + void AddCacheEntry(const std::string& key, const char* value, const char* helpString, CacheEntryType type); ///! Get a cache entry object for a key - CacheEntry *GetCacheEntry(const char *key); + CacheEntry *GetCacheEntry(const std::string& key); ///! Clean out the CMakeFiles directory if no CMakeCache.txt void CleanCMakeFiles(const char* path); diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 9d28700..5fa3877 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -28,7 +28,7 @@ void cmDefinitions::Reset(cmDefinitions* parent) //---------------------------------------------------------------------------- cmDefinitions::Def const& -cmDefinitions::GetInternal(const char* key) +cmDefinitions::GetInternal(const std::string& key) { MapType::const_iterator i = this->Map.find(key); if(i != this->Map.end()) @@ -46,7 +46,7 @@ cmDefinitions::GetInternal(const char* key) //---------------------------------------------------------------------------- cmDefinitions::Def const& -cmDefinitions::SetInternal(const char* key, Def const& def) +cmDefinitions::SetInternal(const std::string& key, Def const& def) { if(this->Up || def.Exists) { @@ -71,14 +71,14 @@ cmDefinitions::SetInternal(const char* key, Def const& def) } //---------------------------------------------------------------------------- -const char* cmDefinitions::Get(const char* key) +const char* cmDefinitions::Get(const std::string& key) { Def const& def = this->GetInternal(key); return def.Exists? def.c_str() : 0; } //---------------------------------------------------------------------------- -const char* cmDefinitions::Set(const char* key, const char* value) +const char* cmDefinitions::Set(const std::string& key, const char* value) { Def const& def = this->SetInternal(key, Def(value)); return def.Exists? def.c_str() : 0; diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 4834d84..24dad29 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -35,10 +35,10 @@ public: /** Get the value associated with a key; null if none. Store the result locally if it came from a parent. */ - const char* Get(const char* key); + const char* Get(const std::string& key); /** Set (or unset if null) a value associated with a key. */ - const char* Set(const char* key, const char* value); + const char* Set(const std::string& key, const char* value); /** Get the set of all local keys. */ std::set LocalKeys() const; @@ -69,8 +69,8 @@ private: MapType Map; // Internal query and update methods. - Def const& GetInternal(const char* key); - Def const& SetInternal(const char* key, Def const& def); + Def const& GetInternal(const std::string& key); + Def const& SetInternal(const std::string& key, Def const& def); // Implementation of Closure() method. struct ClosureTag {}; diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 79566a9..c06f889 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -151,7 +151,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty( //---------------------------------------------------------------------------- void cmExportFileGenerator::PopulateInterfaceProperty( const std::string& propName, - const cmStdString& outputName, + const std::string& outputName, cmTarget *target, cmGeneratorExpression::PreprocessContext preprocessRule, ImportPropertyMap &properties, diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 326fe36..f93e72a 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -174,7 +174,7 @@ protected: std::set ExportedTargets; private: - void PopulateInterfaceProperty(const std::string&, const cmStdString&, + void PopulateInterfaceProperty(const std::string&, const std::string&, cmTarget *target, cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index ae15ee7..86fd54b 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -268,7 +268,7 @@ void cmFindBase::AddPrefixPaths(std::vector const& in_paths, } //---------------------------------------------------------------------------- -void cmFindBase::AddCMakePrefixPath(const char* variable) +void cmFindBase::AddCMakePrefixPath(const std::string& variable) { // Get a path from a CMake variable. if(const char* varPath = this->Makefile->GetDefinition(variable)) @@ -280,11 +280,11 @@ void cmFindBase::AddCMakePrefixPath(const char* variable) } //---------------------------------------------------------------------------- -void cmFindBase::AddEnvPrefixPath(const char* variable) +void cmFindBase::AddEnvPrefixPath(const std::string& variable) { // Get a path from the environment. std::vector tmp; - cmSystemTools::GetPath(tmp, variable); + cmSystemTools::GetPath(tmp, variable.c_str()); this->AddPrefixPaths(tmp, EnvPath); } diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h index 0562b1b..e590d6e 100644 --- a/Source/cmFindBase.h +++ b/Source/cmFindBase.h @@ -63,8 +63,8 @@ private: void AddUserGuessPath(); // Helpers. - void AddCMakePrefixPath(const char* variable); - void AddEnvPrefixPath(const char* variable); + void AddCMakePrefixPath(const std::string& variable); + void AddEnvPrefixPath(const std::string& variable); void AddPrefixPaths(std::vector const& in_paths, PathType pathType); }; diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index e8c8da3..bd75e10 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -374,7 +374,7 @@ void cmFindCommon::AddUserPath(std::string const& p, } //---------------------------------------------------------------------------- -void cmFindCommon::AddCMakePath(const char* variable) +void cmFindCommon::AddCMakePath(const std::string& variable) { // Get a path from a CMake variable. if(const char* varPath = this->Makefile->GetDefinition(variable)) diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h index 6109a9f..ba90a84 100644 --- a/Source/cmFindCommon.h +++ b/Source/cmFindCommon.h @@ -63,7 +63,7 @@ protected: void AddPathSuffix(std::string const& arg); void AddUserPath(std::string const& p, std::vector& paths); - void AddCMakePath(const char* variable); + void AddCMakePath(const std::string& variable); void AddEnvPath(const char* variable); void AddPathsInternal(std::vector const& in_paths, PathType pathType); diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 73eba51..d557fba 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -535,7 +535,8 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components) } //---------------------------------------------------------------------------- -void cmFindPackageCommand::AddFindDefinition(const char* var, const char* val) +void cmFindPackageCommand::AddFindDefinition(const std::string& var, + const char* val) { if(const char* old = this->Makefile->GetDefinition(var)) { diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 0d80e48..9819d4f 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -57,7 +57,7 @@ private: void AppendToFoundProperty(bool found); void SetModuleVariables(const std::string& components); bool FindModule(bool& found); - void AddFindDefinition(const char* var, const char* val); + void AddFindDefinition(const std::string& var, const char* val); void RestoreFindDefinitions(); bool HandlePackageMode(); bool FindConfig(); diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index ee95c05..bd12327 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -593,7 +593,7 @@ namespace if (argP1 != newArgs.end() && argP2 != newArgs.end() && *(argP1) == "MATCHES") { - def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile); + def = cmIfCommand::GetVariableOrString(*arg, makefile); const char* rex = (argP2)->c_str(); cmStringCommand::ClearMatches(makefile); cmsys::RegularExpression regEntry; @@ -634,8 +634,8 @@ namespace (*(argP1) == "LESS" || *(argP1) == "GREATER" || *(argP1) == "EQUAL")) { - def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile); - def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile); + def = cmIfCommand::GetVariableOrString(*arg, makefile); + def2 = cmIfCommand::GetVariableOrString(*argP2, makefile); double lhs; double rhs; bool result; @@ -665,8 +665,8 @@ namespace *(argP1) == "STREQUAL" || *(argP1) == "STRGREATER")) { - def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile); - def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile); + def = cmIfCommand::GetVariableOrString(*arg, makefile); + def2 = cmIfCommand::GetVariableOrString(*argP2, makefile); int val = strcmp(def,def2); bool result; if (*(argP1) == "STRLESS") @@ -689,8 +689,8 @@ namespace (*(argP1) == "VERSION_LESS" || *(argP1) == "VERSION_GREATER" || *(argP1) == "VERSION_EQUAL")) { - def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile); - def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile); + def = cmIfCommand::GetVariableOrString(*arg, makefile); + def2 = cmIfCommand::GetVariableOrString(*argP2, makefile); cmSystemTools::CompareOp op = cmSystemTools::OP_EQUAL; if(*argP1 == "VERSION_LESS") { @@ -907,13 +907,13 @@ bool cmIfCommand::IsTrue(const std::vector &args, } //========================================================================= -const char* cmIfCommand::GetVariableOrString(const char* str, +const char* cmIfCommand::GetVariableOrString(const std::string& str, const cmMakefile* mf) { const char* def = mf->GetDefinition(str); if(!def) { - def = str; + def = str.c_str(); } return def; } diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h index f2633ad..02d87ed 100644 --- a/Source/cmIfCommand.h +++ b/Source/cmIfCommand.h @@ -79,7 +79,7 @@ public: // Get a definition from the makefile. If it doesn't exist, // return the original string. - static const char* GetVariableOrString(const char* str, + static const char* GetVariableOrString(const std::string& str, const cmMakefile* mf); cmTypeMacro(cmIfCommand, cmCommand); diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index df64695..20e760a 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -74,12 +74,9 @@ bool cmListCommand } //---------------------------------------------------------------------------- -bool cmListCommand::GetListString(std::string& listString, const char* var) +bool cmListCommand::GetListString(std::string& listString, + const std::string& var) { - if ( !var ) - { - return false; - } // get the old value const char* cacheValue = this->Makefile->GetDefinition(var); @@ -92,7 +89,8 @@ bool cmListCommand::GetListString(std::string& listString, const char* var) } //---------------------------------------------------------------------------- -bool cmListCommand::GetList(std::vector& list, const char* var) +bool cmListCommand::GetList(std::vector& list, + const std::string& var) { std::string listString; if ( !this->GetListString(listString, var) ) diff --git a/Source/cmListCommand.h b/Source/cmListCommand.h index 0cb5da2..b79ff0d 100644 --- a/Source/cmListCommand.h +++ b/Source/cmListCommand.h @@ -60,8 +60,8 @@ protected: bool HandleReverseCommand(std::vector const& args); - bool GetList(std::vector& list, const char* var); - bool GetListString(std::string& listString, const char* var); + bool GetList(std::vector& list, const std::string& var); + bool GetListString(std::string& listString, const std::string& var); }; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 5bfd9da..476c95d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2324,7 +2324,7 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags, //---------------------------------------------------------------------------- void cmLocalGenerator::AddConfigVariableFlags(std::string& flags, - const char* var, + const std::string& var, const char* config) { // Add the flags from the variable itself. diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 888611d..80a1421 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -145,7 +145,7 @@ public: std::string const& lang, const char *config); void AddVisibilityPresetFlags(std::string &flags, cmTarget* target, const char *lang); - void AddConfigVariableFlags(std::string& flags, const char* var, + void AddConfigVariableFlags(std::string& flags, const std::string& var, const char* config); ///! Append flags to a string. virtual void AppendFlags(std::string& flags, const char* newFlags); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 0fce1f4..edf33c1 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1769,7 +1769,7 @@ cmMakefile::AddSystemIncludeDirectories(const std::set &incs) } } -void cmMakefile::AddDefinition(const char* name, const char* value) +void cmMakefile::AddDefinition(const std::string& name, const char* value) { if (!value ) { @@ -1798,14 +1798,14 @@ void cmMakefile::AddDefinition(const char* name, const char* value) } -void cmMakefile::AddCacheDefinition(const char* name, const char* value, +void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, const char* doc, cmCacheManager::CacheEntryType type, bool force) { const char* val = value; cmCacheManager::CacheIterator it = - this->GetCacheManager()->GetCacheIterator(name); + this->GetCacheManager()->GetCacheIterator(name.c_str()); if(!it.IsAtEnd() && (it.GetType() == cmCacheManager::UNINITIALIZED) && it.Initialized()) { @@ -1845,7 +1845,7 @@ void cmMakefile::AddCacheDefinition(const char* name, const char* value, } -void cmMakefile::AddDefinition(const char* name, bool value) +void cmMakefile::AddDefinition(const std::string& name, bool value) { this->Internal->VarStack.top().Set(name, value? "ON" : "OFF"); if (this->Internal->VarUsageStack.size() && @@ -1880,12 +1880,12 @@ void cmMakefile::CheckForUnusedVariables() const } } -void cmMakefile::MarkVariableAsUsed(const char* var) +void cmMakefile::MarkVariableAsUsed(const std::string& var) { this->Internal->VarUsageStack.top().insert(var); } -bool cmMakefile::VariableInitialized(const char* var) const +bool cmMakefile::VariableInitialized(const std::string& var) const { if(this->Internal->VarInitStack.top().find(var) != this->Internal->VarInitStack.top().end()) @@ -1895,7 +1895,7 @@ bool cmMakefile::VariableInitialized(const char* var) const return false; } -bool cmMakefile::VariableUsed(const char* var) const +bool cmMakefile::VariableUsed(const std::string& var) const { if(this->Internal->VarUsageStack.top().find(var) != this->Internal->VarUsageStack.top().end()) @@ -1905,7 +1905,8 @@ bool cmMakefile::VariableUsed(const char* var) const return false; } -void cmMakefile::CheckForUnused(const char* reason, const char* name) const +void cmMakefile::CheckForUnused(const char* reason, + const std::string& name) const { if (this->WarnUnused && !this->VariableUsed(name)) { @@ -1943,7 +1944,7 @@ void cmMakefile::CheckForUnused(const char* reason, const char* name) const } } -void cmMakefile::RemoveDefinition(const char* name) +void cmMakefile::RemoveDefinition(const std::string& name) { this->Internal->VarStack.top().Set(name, 0); if (this->Internal->VarUsageStack.size() && @@ -1963,7 +1964,7 @@ void cmMakefile::RemoveDefinition(const char* name) #endif } -void cmMakefile::RemoveCacheDefinition(const char* name) +void cmMakefile::RemoveCacheDefinition(const std::string& name) { this->GetCacheManager()->RemoveCacheEntry(name); } @@ -2329,13 +2330,13 @@ void cmMakefile::ExpandVariablesCMP0019() } } -bool cmMakefile::IsOn(const char* name) const +bool cmMakefile::IsOn(const std::string& name) const { const char* value = this->GetDefinition(name); return cmSystemTools::IsOn(value); } -bool cmMakefile::IsSet(const char* name) const +bool cmMakefile::IsSet(const std::string& name) const { const char* value = this->GetDefinition(name); if ( !value ) @@ -2406,7 +2407,7 @@ bool cmMakefile::CanIWriteThisFile(const char* fileName) const return true; } -const char* cmMakefile::GetRequiredDefinition(const char* name) const +const char* cmMakefile::GetRequiredDefinition(const std::string& name) const { const char* ret = this->GetDefinition(name); if(!ret) @@ -2414,13 +2415,13 @@ const char* cmMakefile::GetRequiredDefinition(const char* name) const cmSystemTools::Error("Error required internal CMake variable not " "set, cmake may be not be built correctly.\n", "Missing variable is:\n", - name); + name.c_str()); return ""; } return ret; } -bool cmMakefile::IsDefinitionSet(const char* name) const +bool cmMakefile::IsDefinitionSet(const std::string& name) const { const char* def = this->Internal->VarStack.top().Get(name); this->Internal->VarUsageStack.top().insert(name); @@ -2442,7 +2443,7 @@ bool cmMakefile::IsDefinitionSet(const char* name) const return def?true:false; } -const char* cmMakefile::GetDefinition(const char* name) const +const char* cmMakefile::GetDefinition(const std::string& name) const { if (this->WarnUnused) { @@ -2483,7 +2484,7 @@ const char* cmMakefile::GetDefinition(const char* name) const return def; } -const char* cmMakefile::GetSafeDefinition(const char* def) const +const char* cmMakefile::GetSafeDefinition(const std::string& def) const { const char* ret = this->GetDefinition(def); if(!ret) @@ -3995,7 +3996,7 @@ void cmMakefile::PopScope() } } -void cmMakefile::RaiseScope(const cmStdString& var, const char *varDef) +void cmMakefile::RaiseScope(const std::string& var, const char *varDef) { if (var.empty()) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 5f4b803..fc71ab7 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -69,11 +69,11 @@ public: /* Check for unused variables in this scope */ void CheckForUnusedVariables() const; /* Mark a variable as used */ - void MarkVariableAsUsed(const char* var); + void MarkVariableAsUsed(const std::string& var); /* return true if a variable has been initialized */ - bool VariableInitialized(const char* ) const; + bool VariableInitialized(const std::string& ) const; /* return true if a variable has been used */ - bool VariableUsed(const char* ) const; + bool VariableUsed(const std::string& ) const; /** Return whether compatibility features needed for a version of the cache or lower should be enabled. */ bool NeedCacheCompatibility(int major, int minor) const; @@ -283,9 +283,9 @@ public: * Add a variable definition to the build. This variable * can be used in CMake to refer to lists, directories, etc. */ - void AddDefinition(const char* name, const char* value); + void AddDefinition(const std::string& name, const char* value); ///! Add a definition to this makefile and the global cmake cache. - void AddCacheDefinition(const char* name, const char* value, + void AddCacheDefinition(const std::string& name, const char* value, const char* doc, cmCacheManager::CacheEntryType type, bool force = false); @@ -293,15 +293,15 @@ public: /** * Add bool variable definition to the build. */ - void AddDefinition(const char* name, bool); + void AddDefinition(const std::string& name, bool); /** * Remove a variable definition from the build. This is not valid * for cache entries, and will only affect the current makefile. */ - void RemoveDefinition(const char* name); + void RemoveDefinition(const std::string& name); ///! Remove a definition from the cache. - void RemoveCacheDefinition(const char* name); + void RemoveCacheDefinition(const std::string& name); /** * Specify the name of the project for this build. @@ -587,10 +587,10 @@ public: * If the variable is not found in this makefile instance, the * cache is then queried. */ - const char* GetDefinition(const char*) const; - const char* GetSafeDefinition(const char*) const; - const char* GetRequiredDefinition(const char* name) const; - bool IsDefinitionSet(const char*) const; + const char* GetDefinition(const std::string&) const; + const char* GetSafeDefinition(const std::string&) const; + const char* GetRequiredDefinition(const std::string& name) const; + bool IsDefinitionSet(const std::string&) const; /** * Get the list of all variables in the current space. If argument * cacheonly is specified and is greater than 0, then only cache @@ -601,8 +601,8 @@ public: /** Test a boolean cache entry to see if it is true or false, * returns false if no entry defined. */ - bool IsOn(const char* name) const; - bool IsSet(const char* name) const; + bool IsOn(const std::string& name) const; + bool IsSet(const std::string& name) const; /** Return whether the target platform is 64-bit. */ bool PlatformIs64Bit() const; @@ -837,7 +837,7 @@ public: // push and pop variable scopes void PushScope(); void PopScope(); - void RaiseScope(const cmStdString& var, const char *value); + void RaiseScope(const std::string& var, const char *value); /** Helper class to push and pop scopes automatically. */ class ScopePushPop @@ -882,7 +882,7 @@ protected: void AddGlobalLinkInformation(const char* name, cmTarget& target); // Check for a an unused variable - void CheckForUnused(const char* reason, const char* name) const; + void CheckForUnused(const char* reason, const std::string& name) const; std::string Prefix; std::vector AuxSourceDirectories; // diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 39e00b2..10418d0 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -237,7 +237,7 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) //---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator::WriteLibraryRules -(const char* linkRuleVar, const char* extraFlags, bool relink) +(const std::string& linkRuleVar, const std::string& extraFlags, bool relink) { // TODO: Merge the methods that call this method to avoid // code duplication. @@ -261,7 +261,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Create set of linking flags. std::string linkFlags; - this->LocalGenerator->AppendFlags(linkFlags, extraFlags); + this->LocalGenerator->AppendFlags(linkFlags, extraFlags.c_str()); // Add OSX version flags, if any. if(this->Target->GetType() == cmTarget::SHARED_LIBRARY || diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h index 1487b56..4873516 100644 --- a/Source/cmMakefileLibraryTargetGenerator.h +++ b/Source/cmMakefileLibraryTargetGenerator.h @@ -30,7 +30,8 @@ protected: void WriteStaticLibraryRules(); void WriteSharedLibraryRules(bool relink); void WriteModuleLibraryRules(bool relink); - void WriteLibraryRules(const char *linkRule, const char *extraFlags, + void WriteLibraryRules(const std::string& linkRule, + const std::string& extraFlags, bool relink); // MacOSX Framework support methods void WriteFrameworkRules(bool relink); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index facbcc6..bf0dc51 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1682,7 +1682,8 @@ void cmMakefileTargetGenerator } //---------------------------------------------------------------------------- -std::string cmMakefileTargetGenerator::GetLinkRule(const char* linkRuleVar) +std::string cmMakefileTargetGenerator::GetLinkRule( + const cmStdString& linkRuleVar) { std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar); if(this->Target->HasImplibGNUtoMS()) diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 72dc6bc..f960afc 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -138,7 +138,7 @@ protected: void AppendLinkDepends(std::vector& depends); // Lookup the link rule for this target. - std::string GetLinkRule(const char* linkRuleVar); + std::string GetLinkRule(const cmStdString& linkRuleVar); /** In order to support parallel builds for custom commands with multiple outputs the outputs are given a serial order, and only diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx index 3b6a49b..7a8efc1 100644 --- a/Source/cmScriptGenerator.cxx +++ b/Source/cmScriptGenerator.cxx @@ -15,7 +15,7 @@ //---------------------------------------------------------------------------- cmScriptGenerator -::cmScriptGenerator(const char* config_var, +::cmScriptGenerator(const std::string& config_var, std::vector const& configurations): RuntimeConfigVariable(config_var), Configurations(configurations), diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h index 8b2ca33..3515e20 100644 --- a/Source/cmScriptGenerator.h +++ b/Source/cmScriptGenerator.h @@ -47,7 +47,7 @@ inline std::ostream& operator<<(std::ostream& os, class cmScriptGenerator { public: - cmScriptGenerator(const char* config_var, + cmScriptGenerator(const std::string& config_var, std::vector const& configurations); virtual ~cmScriptGenerator(); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 149e299..ad1d0fa 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1202,7 +1202,7 @@ struct SaveCacheEntry cmCacheManager::CacheEntryType type; }; -int cmake::HandleDeleteCacheVariables(const char* var) +int cmake::HandleDeleteCacheVariables(const std::string& var) { std::vector argsSplit; cmSystemTools::ExpandListArgument(std::string(var), argsSplit, true); @@ -1725,7 +1725,7 @@ int cmake::Generate() return 0; } -void cmake::AddCacheEntry(const char* key, const char* value, +void cmake::AddCacheEntry(const std::string& key, const char* value, const char* helpString, int type) { @@ -1734,7 +1734,7 @@ void cmake::AddCacheEntry(const char* key, const char* value, cmCacheManager::CacheEntryType(type)); } -const char* cmake::GetCacheDefinition(const char* name) const +const char* cmake::GetCacheDefinition(const std::string& name) const { return this->CacheManager->GetCacheValue(name); } @@ -2676,7 +2676,7 @@ int cmake::Build(const std::string& dir, nativeOptions); } -void cmake::WatchUnusedCli(const char* var) +void cmake::WatchUnusedCli(const std::string& var) { #ifdef CMAKE_BUILD_WITH_CMAKE this->VariableWatch->AddWatch(var, cmWarnUnusedCliWarning, this); @@ -2687,7 +2687,7 @@ void cmake::WatchUnusedCli(const char* var) #endif } -void cmake::UnwatchUnusedCli(const char* var) +void cmake::UnwatchUnusedCli(const std::string& var) { #ifdef CMAKE_BUILD_WITH_CMAKE this->VariableWatch->RemoveWatch(var, cmWarnUnusedCliWarning); diff --git a/Source/cmake.h b/Source/cmake.h index e89868c..2d78e8f 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -203,9 +203,9 @@ class cmake /** * Given a variable name, return its value (as a string). */ - const char* GetCacheDefinition(const char*) const; + const char* GetCacheDefinition(const std::string&) const; ///! Add an entry into the cache - void AddCacheEntry(const char* key, const char* value, + void AddCacheEntry(const std::string& key, const char* value, const char* helpString, int type); @@ -357,12 +357,12 @@ class cmake const std::vector& nativeOptions, bool clean); - void UnwatchUnusedCli(const char* var); - void WatchUnusedCli(const char* var); + void UnwatchUnusedCli(const std::string& var); + void WatchUnusedCli(const std::string& var); protected: void RunCheckForUnusedVariables(); void InitializeProperties(); - int HandleDeleteCacheVariables(const char* var); + int HandleDeleteCacheVariables(const std::string& var); cmPropertyMap Properties; std::set > AccessedProperties; -- cgit v0.12 From 381d50c149183183378b446fd789b1bd18c7524c Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 17 Jan 2014 13:38:27 -0500 Subject: stringapi: Accept strings in cmStrCmp --- Source/cmQtAutoGenerators.cxx | 4 ++-- Source/cmStandardIncludes.h | 11 ++++++++--- Source/cmTarget.cxx | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 7d0ce5f..d940fe2 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -660,7 +660,7 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector &opts, ++o; } if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions), - cmStrCmp(o)) != cmArrayEnd(valueOptions)) + cmStrCmp(*it)) != cmArrayEnd(valueOptions)) { assert(existingIt + 1 != opts.end()); *(existingIt + 1) = *(it + 1); @@ -831,7 +831,7 @@ void cmQtAutoGenerators::MergeRccOptions(std::vector &opts, ++o; } if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions), - cmStrCmp(o)) != cmArrayEnd(valueOptions)) + cmStrCmp(*it)) != cmArrayEnd(valueOptions)) { assert(existingIt + 1 != opts.end()); *(existingIt + 1) = *(it + 1); diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index b4ae657..04e1bc8 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -449,11 +449,16 @@ bool cmHasLiteralSuffix(T str1, const char (&str2)[N]) struct cmStrCmp { cmStrCmp(const char *test) : m_test(test) {} - cmStrCmp(std::string &test) : m_test(test.c_str()) {} + cmStrCmp(const std::string &test) : m_test(test) {} + + bool operator()(const std::string& input) const + { + return m_test == input; + } bool operator()(const char * input) const { - return strcmp(input, m_test) == 0; + return strcmp(input, m_test.c_str()) == 0; } // For use with binary_search @@ -463,7 +468,7 @@ struct cmStrCmp { } private: - const char * const m_test; + const cmStdString m_test; }; #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index fc2ab25..d5cd140 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1314,7 +1314,7 @@ static bool whiteListedInterfaceProperty(const std::string& prop) if (std::binary_search(cmArrayBegin(builtIns), cmArrayEnd(builtIns), prop.c_str(), - cmStrCmp(prop.c_str()))) + cmStrCmp(prop))) { return true; } -- cgit v0.12 From f29754573d2b2a199f17be80eb01ae309699bb23 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 3 Feb 2014 21:06:17 -0500 Subject: stringapi: Accept string parameters in methods which store to strings --- Source/cmMakefile.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index fc71ab7..79931ad 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -494,7 +494,7 @@ public: * Set a regular expression that include files that are not found * must match in order to be considered a problem. */ - void SetComplainRegularExpression(const char* regex) + void SetComplainRegularExpression(const std::string& regex) { this->ComplainFileRegularExpression = regex; } -- cgit v0.12 From 22c54a109050d026269f57dddc0ce0f146fc149d Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 31 Jan 2014 10:45:30 -0500 Subject: makefile: Remove an unused method --- Source/cmMakefile.cxx | 10 ---------- Source/cmMakefile.h | 1 - 2 files changed, 11 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index edf33c1..76b3b09 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3662,16 +3662,6 @@ void cmMakefile::AppendProperty(const std::string& prop, this->Properties.AppendProperty(prop,value,cmProperty::DIRECTORY,asString); } -const char *cmMakefile::GetPropertyOrDefinition(const std::string& prop) const -{ - const char *ret = this->GetProperty(prop, cmProperty::DIRECTORY); - if (!ret) - { - ret = this->GetDefinition(prop.c_str()); - } - return ret; -} - const char *cmMakefile::GetProperty(const std::string& prop) const { return this->GetProperty(prop, cmProperty::DIRECTORY); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 79931ad..559d49c 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -804,7 +804,6 @@ public: void AppendProperty(const std::string& prop, const char *value, bool asString=false); const char *GetProperty(const std::string& prop) const; - const char *GetPropertyOrDefinition(const std::string& prop) const; const char *GetProperty(const std::string& prop, cmProperty::ScopeType scope) const; bool GetPropertyAsBool(const std::string& prop) const; -- cgit v0.12 From 24e8b929eef74098d4ddf4581619322e0f4b5108 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 6 Feb 2014 13:59:50 -0500 Subject: genex: Store predicates as a map for faster searching May warrant a fast path for predicates which more frequently. --- Source/cmGeneratorExpressionEvaluator.cxx | 135 ++++++++++++------------------ 1 file changed, 52 insertions(+), 83 deletions(-) diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index bdefcfb..c27c03f 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -1555,89 +1555,58 @@ TargetFilesystemArtifact targetSoNameFileDirNode; static const cmGeneratorExpressionNode* GetNode(const std::string &identifier) { - if (identifier == "0") - return &zeroNode; - else if (identifier == "1") - return &oneNode; - else if (identifier == "AND") - return &andNode; - else if (identifier == "OR") - return &orNode; - else if (identifier == "NOT") - return ¬Node; - else if (identifier == "C_COMPILER_ID") - return &cCompilerIdNode; - else if (identifier == "CXX_COMPILER_ID") - return &cxxCompilerIdNode; - else if (identifier == "VERSION_GREATER") - return &versionGreaterNode; - else if (identifier == "VERSION_LESS") - return &versionLessNode; - else if (identifier == "VERSION_EQUAL") - return &versionEqualNode; - else if (identifier == "C_COMPILER_VERSION") - return &cCompilerVersionNode; - else if (identifier == "CXX_COMPILER_VERSION") - return &cxxCompilerVersionNode; - else if (identifier == "PLATFORM_ID") - return &platformIdNode; - else if (identifier == "CONFIGURATION") - return &configurationNode; - else if (identifier == "CONFIG") - return &configurationTestNode; - else if (identifier == "TARGET_FILE") - return &targetFileNode; - else if (identifier == "TARGET_LINKER_FILE") - return &targetLinkerFileNode; - else if (identifier == "TARGET_SONAME_FILE") - return &targetSoNameFileNode; - else if (identifier == "TARGET_FILE_NAME") - return &targetFileNameNode; - else if (identifier == "TARGET_LINKER_FILE_NAME") - return &targetLinkerFileNameNode; - else if (identifier == "TARGET_SONAME_FILE_NAME") - return &targetSoNameFileNameNode; - else if (identifier == "TARGET_FILE_DIR") - return &targetFileDirNode; - else if (identifier == "TARGET_LINKER_FILE_DIR") - return &targetLinkerFileDirNode; - else if (identifier == "TARGET_SONAME_FILE_DIR") - return &targetSoNameFileDirNode; - else if (identifier == "STREQUAL") - return &strEqualNode; - else if (identifier == "EQUAL") - return &equalNode; - else if (identifier == "LOWER_CASE") - return &lowerCaseNode; - else if (identifier == "UPPER_CASE") - return &upperCaseNode; - else if (identifier == "MAKE_C_IDENTIFIER") - return &makeCIdentifierNode; - else if (identifier == "BOOL") - return &boolNode; - else if (identifier == "ANGLE-R") - return &angle_rNode; - else if (identifier == "COMMA") - return &commaNode; - else if (identifier == "SEMICOLON") - return &semicolonNode; - else if (identifier == "TARGET_PROPERTY") - return &targetPropertyNode; - else if (identifier == "TARGET_NAME") - return &targetNameNode; - else if (identifier == "TARGET_POLICY") - return &targetPolicyNode; - else if (identifier == "BUILD_INTERFACE") - return &buildInterfaceNode; - else if (identifier == "INSTALL_INTERFACE") - return &installInterfaceNode; - else if (identifier == "INSTALL_PREFIX") - return &installPrefixNode; - else if (identifier == "JOIN") - return &joinNode; - else if (identifier == "LINK_ONLY") - return &linkOnlyNode; - return 0; + typedef std::map NodeMap; + static NodeMap nodeMap; + if (nodeMap.empty()) + { + nodeMap["0"] = &zeroNode; + nodeMap["1"] = &oneNode; + nodeMap["AND"] = &andNode; + nodeMap["OR"] = &orNode; + nodeMap["NOT"] = ¬Node; + nodeMap["C_COMPILER_ID"] = &cCompilerIdNode; + nodeMap["CXX_COMPILER_ID"] = &cxxCompilerIdNode; + nodeMap["VERSION_GREATER"] = &versionGreaterNode; + nodeMap["VERSION_LESS"] = &versionLessNode; + nodeMap["VERSION_EQUAL"] = &versionEqualNode; + nodeMap["C_COMPILER_VERSION"] = &cCompilerVersionNode; + nodeMap["CXX_COMPILER_VERSION"] = &cxxCompilerVersionNode; + nodeMap["PLATFORM_ID"] = &platformIdNode; + nodeMap["CONFIGURATION"] = &configurationNode; + nodeMap["CONFIG"] = &configurationTestNode; + nodeMap["TARGET_FILE"] = &targetFileNode; + nodeMap["TARGET_LINKER_FILE"] = &targetLinkerFileNode; + nodeMap["TARGET_SONAME_FILE"] = &targetSoNameFileNode; + nodeMap["TARGET_FILE_NAME"] = &targetFileNameNode; + nodeMap["TARGET_LINKER_FILE_NAME"] = &targetLinkerFileNameNode; + nodeMap["TARGET_SONAME_FILE_NAME"] = &targetSoNameFileNameNode; + nodeMap["TARGET_FILE_DIR"] = &targetFileDirNode; + nodeMap["TARGET_LINKER_FILE_DIR"] = &targetLinkerFileDirNode; + nodeMap["TARGET_SONAME_FILE_DIR"] = &targetSoNameFileDirNode; + nodeMap["STREQUAL"] = &strEqualNode; + nodeMap["EQUAL"] = &equalNode; + nodeMap["LOWER_CASE"] = &lowerCaseNode; + nodeMap["UPPER_CASE"] = &upperCaseNode; + nodeMap["MAKE_C_IDENTIFIER"] = &makeCIdentifierNode; + nodeMap["BOOL"] = &boolNode; + nodeMap["ANGLE-R"] = &angle_rNode; + nodeMap["COMMA"] = &commaNode; + nodeMap["SEMICOLON"] = &semicolonNode; + nodeMap["TARGET_PROPERTY"] = &targetPropertyNode; + nodeMap["TARGET_NAME"] = &targetNameNode; + nodeMap["TARGET_POLICY"] = &targetPolicyNode; + nodeMap["BUILD_INTERFACE"] = &buildInterfaceNode; + nodeMap["INSTALL_INTERFACE"] = &installInterfaceNode; + nodeMap["INSTALL_PREFIX"] = &installPrefixNode; + nodeMap["JOIN"] = &joinNode; + nodeMap["LINK_ONLY"] = &linkOnlyNode; + } + NodeMap::const_iterator i = nodeMap.find(identifier); + if (i == nodeMap.end()) + { + return 0; + } + return i->second; } -- cgit v0.12 From 310ef08fed57b1c60ea8dc8ed98520e2cb0bff4e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 6 Feb 2014 14:05:57 -0500 Subject: stringapi: Use strings for source names --- Source/cmMakefile.cxx | 31 +++++++++++++------------------ Source/cmMakefile.h | 14 +++++++------- Source/cmSourceFile.cxx | 2 +- Source/cmSourceFile.h | 2 +- Source/cmSourceFileLocation.cxx | 13 +++++++------ Source/cmSourceFileLocation.h | 8 ++++---- Source/cmSourceGroup.cxx | 2 +- Source/cmSourceGroup.h | 2 +- Source/cmTarget.cxx | 2 +- Source/cmTarget.h | 2 +- 10 files changed, 37 insertions(+), 41 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 76b3b09..97628f3 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2060,9 +2060,8 @@ cmMakefile::AddNewTarget(cmTarget::TargetType type, const char* name) } cmSourceFile* -cmMakefile::LinearGetSourceFileWithOutput(const char *cname) const +cmMakefile::LinearGetSourceFileWithOutput(const std::string& name) const { - std::string name = cname; std::string out; // look through all the source files that have custom commands @@ -2096,15 +2095,14 @@ cmMakefile::LinearGetSourceFileWithOutput(const char *cname) const return 0; } -cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname) const +cmSourceFile *cmMakefile::GetSourceFileWithOutput( + const std::string& name) const { - std::string name = cname; - // 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(cname)) + if(!cmSystemTools::FileIsFullPath(name.c_str())) { - return LinearGetSourceFileWithOutput(cname); + return LinearGetSourceFileWithOutput(name.c_str()); } // Otherwise we use an efficient lookup map. OutputToSourceMap::const_iterator o = this->OutputToSource.find(name); @@ -2149,15 +2147,12 @@ cmMakefile::GetSourceGroup(const std::vector&name) const return sg; } - void cmMakefile::AddSourceGroup(const char* name, +void cmMakefile::AddSourceGroup(const std::string& name, const char* regex) { - if (name) - { - std::vector nameVector; - nameVector.push_back(name); - AddSourceGroup(nameVector, regex); - } + std::vector nameVector; + nameVector.push_back(name); + AddSourceGroup(nameVector, regex); } void cmMakefile::AddSourceGroup(const std::vector& name, @@ -3011,9 +3006,9 @@ void cmMakefile::SetArgcArgv(const std::vector& args) } //---------------------------------------------------------------------------- -cmSourceFile* cmMakefile::GetSource(const char* sourceName) const +cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const { - cmSourceFileLocation sfl(this, sourceName); + cmSourceFileLocation sfl(this, sourceName.c_str()); for(std::vector::const_iterator sfi = this->SourceFiles.begin(); sfi != this->SourceFiles.end(); ++sfi) @@ -3028,7 +3023,7 @@ cmSourceFile* cmMakefile::GetSource(const char* sourceName) const } //---------------------------------------------------------------------------- -cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName, +cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName, bool generated) { if(cmSourceFile* esf = this->GetSource(sourceName)) @@ -3037,7 +3032,7 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName, } else { - cmSourceFile* sf = new cmSourceFile(this, sourceName); + cmSourceFile* sf = new cmSourceFile(this, sourceName.c_str()); if(generated) { sf->SetProperty("GENERATED", "1"); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 559d49c..a8ad1e2 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -332,7 +332,7 @@ public: /** * Add a root source group for consideration when adding a new source. */ - void AddSourceGroup(const char* name, const char* regex=0); + void AddSourceGroup(const std::string& name, const char* regex=0); /** * Add a source group for consideration when adding a new source. @@ -555,14 +555,14 @@ public: /** Get a cmSourceFile pointer for a given source name, if the name is * not found, then a null pointer is returned. */ - cmSourceFile* GetSource(const char* sourceName) const; + cmSourceFile* GetSource(const std::string& sourceName) const; /** Get a cmSourceFile pointer for a given source name, if the name is * not found, then create the source file and return it. generated * indicates if it is a generated file, this is used in determining * how to create the source file instance e.g. name */ - cmSourceFile* GetOrCreateSource(const char* sourceName, + cmSourceFile* GetOrCreateSource(const std::string& sourceName, bool generated = false); /** @@ -773,7 +773,7 @@ public: * Is there a source file that has the provided source file as an output? * if so then return it */ - cmSourceFile *GetSourceFileWithOutput(const char *outName) const; + cmSourceFile *GetSourceFileWithOutput(const std::string& outName) const; /** * Add a macro to the list of macros. The arguments should be name of the @@ -1030,12 +1030,12 @@ private: bool GeneratingBuildSystem; /** - * Old version of GetSourceFileWithOutput(const char*) kept for + * Old version of GetSourceFileWithOutput(const std::string&) kept for * backward-compatibility. It implements a linear search and support * relative file paths. It is used as a fall back by - * GetSourceFileWithOutput(const char*). + * GetSourceFileWithOutput(const std::string&). */ - cmSourceFile *LinearGetSourceFileWithOutput(const char *cname) const; + cmSourceFile *LinearGetSourceFileWithOutput(const std::string& cname) const; // A map for fast output to input look up. #if defined(CMAKE_BUILD_WITH_CMAKE) diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index dd95f23..9feda6c 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -18,7 +18,7 @@ #include "cmake.h" //---------------------------------------------------------------------------- -cmSourceFile::cmSourceFile(cmMakefile* mf, const char* name): +cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name): Location(mf, name) { this->CustomCommand = 0; diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 85d6332..833a490 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -31,7 +31,7 @@ public: * Construct with the makefile storing the source and the initial * name referencing it. */ - cmSourceFile(cmMakefile* mf, const char* name); + cmSourceFile(cmMakefile* mf, const std::string& name); ~cmSourceFile(); diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index 5a8578b..832a6a7 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -18,9 +18,10 @@ //---------------------------------------------------------------------------- cmSourceFileLocation -::cmSourceFileLocation(cmMakefile const* mf, const char* name): Makefile(mf) +::cmSourceFileLocation(cmMakefile const* mf, const std::string& name) + : Makefile(mf) { - this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name); + this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name.c_str()); this->AmbiguousExtension = true; this->Directory = cmSystemTools::GetFilenamePath(name); this->Name = cmSystemTools::GetFilenameName(name); @@ -28,7 +29,7 @@ cmSourceFileLocation } //---------------------------------------------------------------------------- -void cmSourceFileLocation::Update(const char* name) +void cmSourceFileLocation::Update(const std::string& name) { if(this->AmbiguousDirectory) { @@ -80,7 +81,7 @@ void cmSourceFileLocation::DirectoryUseBinary() } //---------------------------------------------------------------------------- -void cmSourceFileLocation::UpdateExtension(const char* name) +void cmSourceFileLocation::UpdateExtension(const std::string& name) { // Check the extension. std::string ext = cmSystemTools::GetFilenameLastExtension(name); @@ -136,10 +137,10 @@ void cmSourceFileLocation::UpdateExtension(const char* name) } //---------------------------------------------------------------------------- -void cmSourceFileLocation::UpdateDirectory(const char* name) +void cmSourceFileLocation::UpdateDirectory(const std::string& name) { // If a full path was given we know the directory. - if(cmSystemTools::FileIsFullPath(name)) + if(cmSystemTools::FileIsFullPath(name.c_str())) { this->Directory = cmSystemTools::GetFilenamePath(name); this->AmbiguousDirectory = false; diff --git a/Source/cmSourceFileLocation.h b/Source/cmSourceFileLocation.h index c03eee7..64b8c1f 100644 --- a/Source/cmSourceFileLocation.h +++ b/Source/cmSourceFileLocation.h @@ -33,7 +33,7 @@ public: * Construct for a source file created in a given cmMakefile * instance with an initial name. */ - cmSourceFileLocation(cmMakefile const* mf, const char* name); + cmSourceFileLocation(cmMakefile const* mf, const std::string& name); /** * Return whether the givne source file location could refers to the @@ -93,9 +93,9 @@ private: // Update the location with additional knowledge. void Update(cmSourceFileLocation const& loc); - void Update(const char* name); - void UpdateExtension(const char* name); - void UpdateDirectory(const char* name); + void Update(const std::string& name); + void UpdateExtension(const std::string& name); + void UpdateDirectory(const std::string& name); }; #endif diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx index d272b6c..195feb5 100644 --- a/Source/cmSourceGroup.cxx +++ b/Source/cmSourceGroup.cxx @@ -73,7 +73,7 @@ void cmSourceGroup::SetGroupRegex(const char* regex) } //---------------------------------------------------------------------------- -void cmSourceGroup::AddGroupFile(const char* name) +void cmSourceGroup::AddGroupFile(const std::string& name) { this->GroupFiles.insert(name); } diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h index 3bbdef9..2d891d1 100644 --- a/Source/cmSourceGroup.h +++ b/Source/cmSourceGroup.h @@ -46,7 +46,7 @@ public: /** * Add a file name to the explicit list of files for this group. */ - void AddGroupFile(const char* name); + void AddGroupFile(const std::string& name); /** * Add child to this sourcegroup diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d5cd140..34d92fa 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -592,7 +592,7 @@ void cmTarget::AddSources(std::vector const& srcs) } //---------------------------------------------------------------------------- -cmSourceFile* cmTarget::AddSource(const char* s) +cmSourceFile* cmTarget::AddSource(const std::string& s) { std::string src = s; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f0dd708..9f7b811 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -143,7 +143,7 @@ public: * Add sources to the target. */ void AddSources(std::vector const& srcs); - cmSourceFile* AddSource(const char* src); + cmSourceFile* AddSource(const std::string& src); enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED}; -- cgit v0.12 From 971eb4d56e3d3c9bc11acf6082e21d5388d808bb Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 3 Feb 2014 17:00:21 -0500 Subject: stringapi: Use strings for TryFullPath --- Source/cmSourceFile.cxx | 9 +++++---- Source/cmSourceFile.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 9feda6c..f052044 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -164,7 +164,7 @@ bool cmSourceFile::FindFullPath(std::string* error) } tryPath += this->Location.GetName(); tryPath = cmSystemTools::CollapseFullPath(tryPath.c_str(), *di); - if(this->TryFullPath(tryPath.c_str(), 0)) + if(this->TryFullPath(tryPath.c_str(), "")) { return true; } @@ -217,10 +217,11 @@ bool cmSourceFile::FindFullPath(std::string* error) } //---------------------------------------------------------------------------- -bool cmSourceFile::TryFullPath(const char* tp, const char* ext) +bool cmSourceFile::TryFullPath(const std::string& path, + const std::string& ext) { - std::string tryPath = tp; - if(ext && *ext) + std::string tryPath = path; + if(!ext.empty()) { tryPath += "."; tryPath += ext; diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 833a490..b362c98 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -107,7 +107,7 @@ private: bool FindFullPathFailed; bool FindFullPath(std::string* error); - bool TryFullPath(const char* tryPath, const char* ext); + bool TryFullPath(const std::string& path, const std::string& ext); void CheckExtension(); void CheckLanguage(std::string const& ext); -- cgit v0.12 From 9f48d3bac22118fc1dddbf1eec6da4cb24c585c4 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 3 Feb 2014 21:04:22 -0500 Subject: stringapi: Use strings in CPack generator parameters Most of these are turned into strings in the body of the method (multiple times in some cases). Accept strings to simplify the API and keep string construction down. --- Source/CPack/cmCPackGenerator.cxx | 12 +++++++----- Source/CPack/cmCPackGenerator.h | 14 ++++++++------ Source/CPack/cmCPackGeneratorFactory.cxx | 13 +++++-------- Source/CPack/cmCPackGeneratorFactory.h | 6 +++--- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index b46fd86..bed3891 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -1482,8 +1482,8 @@ bool cmCPackGenerator::WantsComponentInstallation() const //---------------------------------------------------------------------- cmCPackInstallationType* -cmCPackGenerator::GetInstallationType(const char *projectName, - const char *name) +cmCPackGenerator::GetInstallationType(const std::string& projectName, + const std::string& name) { (void) projectName; bool hasInstallationType = this->InstallationTypes.count(name) != 0; @@ -1514,7 +1514,8 @@ cmCPackGenerator::GetInstallationType(const char *projectName, //---------------------------------------------------------------------- cmCPackComponent* -cmCPackGenerator::GetComponent(const char *projectName, const char *name) +cmCPackGenerator::GetComponent(const std::string& projectName, + const std::string& name) { bool hasComponent = this->Components.count(name) != 0; cmCPackComponent *component = &this->Components[name]; @@ -1582,7 +1583,7 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) ++installTypesIt) { component->InstallationTypes.push_back( - this->GetInstallationType(projectName, installTypesIt->c_str())); + this->GetInstallationType(projectName, *installTypesIt)); } } @@ -1609,7 +1610,8 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) //---------------------------------------------------------------------- cmCPackComponentGroup* -cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name) +cmCPackGenerator::GetComponentGroup(const std::string& projectName, + const std::string& name) { (void) projectName; std::string macroPrefix = "CPACK_COMPONENT_GROUP_" diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 39ef64d..7e7c94f 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -245,12 +245,14 @@ protected: * @return true if component installation is supported and wanted. */ virtual bool WantsComponentInstallation() const; - virtual cmCPackInstallationType* GetInstallationType(const char *projectName, - const char* name); - virtual cmCPackComponent* GetComponent(const char *projectName, - const char* name); - virtual cmCPackComponentGroup* GetComponentGroup(const char *projectName, - const char* name); + virtual cmCPackInstallationType* GetInstallationType( + const std::string& projectName, + const std::string& name); + virtual cmCPackComponent* GetComponent(const std::string& projectName, + const std::string& name); + virtual cmCPackComponentGroup* GetComponentGroup( + const std::string& projectName, + const std::string& name); cmSystemTools::OutputOption GeneratorVerbose; std::string Name; diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index b36c2a2..9faf2b0 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -151,7 +151,8 @@ cmCPackGeneratorFactory::~cmCPackGeneratorFactory() } //---------------------------------------------------------------------- -cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(const char* name) +cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator( + const std::string& name) { cmCPackGenerator* gen = this->NewGeneratorInternal(name); if ( !gen ) @@ -165,12 +166,8 @@ cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(const char* name) //---------------------------------------------------------------------- cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal( - const char* name) + const std::string& name) { - if ( !name ) - { - return 0; - } cmCPackGeneratorFactory::t_GeneratorCreatorsMap::iterator it = this->GeneratorCreators.find(name); if ( it == this->GeneratorCreators.end() ) @@ -181,11 +178,11 @@ cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal( } //---------------------------------------------------------------------- -void cmCPackGeneratorFactory::RegisterGenerator(const char* name, +void cmCPackGeneratorFactory::RegisterGenerator(const std::string& name, const char* generatorDescription, CreateGeneratorCall* createGenerator) { - if ( !name || !createGenerator ) + if ( !createGenerator ) { cmCPack_Log(this->Logger, cmCPackLog::LOG_ERROR, "Cannot register generator" << std::endl); diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h index dff2e49..e6f74f9 100644 --- a/Source/CPack/cmCPackGeneratorFactory.h +++ b/Source/CPack/cmCPackGeneratorFactory.h @@ -31,12 +31,12 @@ public: ~cmCPackGeneratorFactory(); //! Get the generator - cmCPackGenerator* NewGenerator(const char* name); + cmCPackGenerator* NewGenerator(const std::string& name); void DeleteGenerator(cmCPackGenerator* gen); typedef cmCPackGenerator* CreateGeneratorCall(); - void RegisterGenerator(const char* name, + void RegisterGenerator(const std::string& name, const char* generatorDescription, CreateGeneratorCall* createGenerator); @@ -47,7 +47,7 @@ public: { return this->GeneratorDescriptions; } private: - cmCPackGenerator* NewGeneratorInternal(const char* name); + cmCPackGenerator* NewGeneratorInternal(const std::string& name); std::vector Generators; typedef std::map t_GeneratorCreatorsMap; -- cgit v0.12 From b26c70cc9a59de5b8ece8b00b67d571aaf6ee8f0 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 3 Feb 2014 21:16:12 -0500 Subject: stringapi: Use strings for AddString methods It gets turned into a string anyways, so pass them in. --- Source/cmCommandArgumentParserHelper.cxx | 12 ++++++------ Source/cmCommandArgumentParserHelper.h | 2 +- Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmGlobalXCodeGenerator.h | 2 +- Source/cmXCodeObject.cxx | 2 +- Source/cmXCodeObject.h | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index dbeeb07..6284cb7 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -49,14 +49,14 @@ void cmCommandArgumentParserHelper::SetLineFile(long line, const char* file) this->FileName = file; } -char* cmCommandArgumentParserHelper::AddString(const char* str) +char* cmCommandArgumentParserHelper::AddString(const std::string& str) { - if ( !str || !*str ) + if ( str.empty() ) { return this->EmptyVariable; } - char* stVal = new char[strlen(str)+1]; - strcpy(stVal, str); + char* stVal = new char[str.size()+1]; + strcpy(stVal, str.c_str()); this->Variables.push_back(stVal); return stVal; } @@ -153,7 +153,7 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) { return this->AddString(cmSystemTools::EscapeQuotes(value).c_str()); } - return this->AddString(value); + return this->AddString(value ? value : ""); } char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var) @@ -166,7 +166,7 @@ char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var) // then return an empty string if(!ret && this->RemoveEmpty) { - return this->AddString(ret); + return this->AddString(""); } // if the ret was not 0, then return it if(ret) diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h index f8c672f..da00124 100644 --- a/Source/cmCommandArgumentParserHelper.h +++ b/Source/cmCommandArgumentParserHelper.h @@ -86,7 +86,7 @@ private: void Print(const char* place, const char* str); void SafePrintMissing(const char* str, int line, int cnt); - char* AddString(const char* str); + char* AddString(const std::string& str); void CleanupParser(); void SetError(std::string const& msg); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 004f7ac..ab92c6e 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -613,7 +613,7 @@ cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type) //---------------------------------------------------------------------------- cmXCodeObject* -cmGlobalXCodeGenerator::CreateString(const char* s) +cmGlobalXCodeGenerator::CreateString(const std::string& s) { cmXCodeObject* obj = this->CreateObject(cmXCodeObject::STRING); obj->SetString(s); diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index c9d20c2..31c2cfb 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -135,7 +135,7 @@ private: // correctly. All objects created are stored in this->XCodeObjects. cmXCodeObject* CreateObject(cmXCodeObject::PBXType ptype); cmXCodeObject* CreateObject(cmXCodeObject::Type type); - cmXCodeObject* CreateString(const char* s); + cmXCodeObject* CreateString(const std::string& s); cmXCodeObject* CreateObjectReference(cmXCodeObject*); cmXCodeObject* CreateXCodeTarget(cmTarget& target, cmXCodeObject* buildPhases); diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 6abf6bf..3b9035f 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -266,7 +266,7 @@ void cmXCodeObject::PrintString(std::ostream& os) const } //---------------------------------------------------------------------------- -void cmXCodeObject::SetString(const char* s) +void cmXCodeObject::SetString(const std::string& s) { this->String = s; } diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index b89f78c..0761136 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -37,7 +37,7 @@ public: Type GetType() { return this->TypeValue;} PBXType GetIsA() { return this->IsA;} - void SetString(const char* s); + void SetString(const std::string& s); const char* GetString() { return this->String.c_str(); -- cgit v0.12 From 83a5e453f8c0dc0fc9b6bdee9723478aafefd0da Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 3 Feb 2014 21:20:33 -0500 Subject: stringapi: Use strings for test names --- Source/cmCTest.cxx | 5 ++--- Source/cmCTest.h | 6 +++--- Source/cmMakefile.cxx | 21 +++++++-------------- Source/cmMakefile.h | 4 ++-- Source/cmSetTestsPropertiesCommand.cxx | 2 +- Source/cmSetTestsPropertiesCommand.h | 2 +- Source/cmTest.cxx | 6 +----- Source/cmTest.h | 4 ++-- 8 files changed, 19 insertions(+), 31 deletions(-) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 39b623d..72bb7fd 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2126,7 +2126,7 @@ void cmCTest::HandleCommandLineArguments(size_t &i, if(this->CheckArgument(arg, "--overwrite") && i < args.size() - 1) { i++; - this->AddCTestConfigurationOverwrite(args[i].c_str()); + this->AddCTestConfigurationOverwrite(args[i]); } if(this->CheckArgument(arg, "-A", "--add-notes") && i < args.size() - 1) { @@ -2840,9 +2840,8 @@ void cmCTest::AddSubmitFile(Part part, const char* name) } //---------------------------------------------------------------------- -void cmCTest::AddCTestConfigurationOverwrite(const char* encstr) +void cmCTest::AddCTestConfigurationOverwrite(const std::string& overStr) { - std::string overStr = encstr; size_t epos = overStr.find("="); if ( epos == overStr.npos ) { diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 6418f09..1eb0e01 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -70,8 +70,8 @@ public: { PartInfo(): Enabled(false) {} - void SetName(const char* name) { this->Name = name; } - const char* GetName() const { return this->Name.c_str(); } + void SetName(const std::string& name) { this->Name = name; } + const std::string& GetName() const { return this->Name; } void Enable() { this->Enabled = true; } operator bool() const { return this->Enabled; } @@ -349,7 +349,7 @@ public: //! Add overwrite to ctest configuration. // The format is key=value - void AddCTestConfigurationOverwrite(const char* encstr); + void AddCTestConfigurationOverwrite(const std::string& encstr); //! Create XML file that contains all the notes specified int GenerateNotesFile(const std::vector &files); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 97628f3..ff0576e 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3852,34 +3852,27 @@ cmTarget* cmMakefile::FindTarget(const std::string& name, } //---------------------------------------------------------------------------- -cmTest* cmMakefile::CreateTest(const char* testName) +cmTest* cmMakefile::CreateTest(const std::string& testName) { - if ( !testName ) - { - return 0; - } cmTest* test = this->GetTest(testName); if ( test ) { return test; } test = new cmTest(this); - test->SetName(testName); + test->SetName(testName.c_str()); this->Tests[testName] = test; return test; } //---------------------------------------------------------------------------- -cmTest* cmMakefile::GetTest(const char* testName) const +cmTest* cmMakefile::GetTest(const std::string& testName) const { - if(testName) + std::map::const_iterator + mi = this->Tests.find(testName); + if(mi != this->Tests.end()) { - std::map::const_iterator - mi = this->Tests.find(testName); - if(mi != this->Tests.end()) - { - return mi->second; - } + return mi->second; } return 0; } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index a8ad1e2..044324e 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -782,12 +782,12 @@ public: void AddMacro(const char* name, const char* signature); ///! Add a new cmTest to the list of tests for this makefile. - cmTest* CreateTest(const char* testName); + cmTest* CreateTest(const std::string& testName); /** Get a cmTest pointer for a given test name, if the name is * not found, then a null pointer is returned. */ - cmTest* GetTest(const char* testName) const; + cmTest* GetTest(const std::string& testName) const; /** * Get a list of macros as a ; separated string diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx index 3d52cf2..c725d35 100644 --- a/Source/cmSetTestsPropertiesCommand.cxx +++ b/Source/cmSetTestsPropertiesCommand.cxx @@ -91,7 +91,7 @@ bool cmSetTestsPropertiesCommand bool cmSetTestsPropertiesCommand -::SetOneTest(const char *tname, +::SetOneTest(const std::string& tname, std::vector &propertyPairs, cmMakefile *mf, std::string &errors) { diff --git a/Source/cmSetTestsPropertiesCommand.h b/Source/cmSetTestsPropertiesCommand.h index 9e85495..7f8d57d 100644 --- a/Source/cmSetTestsPropertiesCommand.h +++ b/Source/cmSetTestsPropertiesCommand.h @@ -36,7 +36,7 @@ public: cmTypeMacro(cmSetTestsPropertiesCommand, cmCommand); - static bool SetOneTest(const char *tname, + static bool SetOneTest(const std::string& tname, std::vector &propertyPairs, cmMakefile *mf, std::string &errors); diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index 4ff71ac..28a7bb1 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -38,12 +38,8 @@ cmListFileBacktrace const& cmTest::GetBacktrace() const } //---------------------------------------------------------------------------- -void cmTest::SetName(const char* name) +void cmTest::SetName(const std::string& name) { - if ( !name ) - { - name = ""; - } this->Name = name; } diff --git a/Source/cmTest.h b/Source/cmTest.h index 1becbf7..a5795c3 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -31,8 +31,8 @@ public: ~cmTest(); ///! Set the test name - void SetName(const char* name); - const char* GetName() const { return this->Name.c_str(); } + void SetName(const std::string& name); + std::string GetName() const { return this->Name; } void SetCommand(std::vector const& command); std::vector const& GetCommand() const -- cgit v0.12 From ce5114354c357df973e54872ab7abebbff36793b Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 3 Feb 2014 21:20:56 -0500 Subject: stringapi: Use strings for the languages --- Source/cmComputeLinkInformation.cxx | 4 +- Source/cmComputeLinkInformation.h | 4 +- Source/cmCoreTryCompile.cxx | 3 +- Source/cmDepends.cxx | 2 +- Source/cmDepends.h | 4 +- Source/cmDependsC.cxx | 2 +- Source/cmDependsC.h | 3 +- Source/cmExtraCodeBlocksGenerator.cxx | 3 +- Source/cmExtraCodeLiteGenerator.cxx | 3 +- Source/cmExtraSublimeTextGenerator.cxx | 10 ++--- Source/cmGeneratorExpressionEvaluator.cxx | 3 +- Source/cmGeneratorTarget.cxx | 2 +- Source/cmGetSourceFilePropertyCommand.cxx | 2 +- Source/cmGlobalGenerator.cxx | 36 +++++++++-------- Source/cmGlobalGenerator.h | 21 +++++----- Source/cmGlobalVisualStudioGenerator.h | 3 +- Source/cmGlobalXCodeGenerator.cxx | 41 ++++++++----------- Source/cmGlobalXCodeGenerator.h | 11 +++--- Source/cmLocalGenerator.cxx | 55 ++++++++++++++------------ Source/cmLocalGenerator.h | 28 +++++++------ Source/cmLocalUnixMakefileGenerator3.cxx | 2 +- Source/cmLocalUnixMakefileGenerator3.h | 4 +- Source/cmLocalVisualStudio6Generator.cxx | 41 +++++++++---------- Source/cmLocalVisualStudio7Generator.cxx | 32 +++++++-------- Source/cmMakefile.cxx | 4 +- Source/cmMakefile.h | 2 +- Source/cmMakefileExecutableTargetGenerator.cxx | 6 +-- Source/cmMakefileLibraryTargetGenerator.cxx | 36 ++++++----------- Source/cmMakefileLibraryTargetGenerator.h | 2 +- Source/cmMakefileTargetGenerator.cxx | 22 +++++------ Source/cmMakefileTargetGenerator.h | 8 ++-- Source/cmNinjaNormalTargetGenerator.cxx | 8 ++-- Source/cmNinjaNormalTargetGenerator.h | 2 +- Source/cmNinjaTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.h | 2 +- Source/cmSourceFile.cxx | 11 +++--- Source/cmSourceFile.h | 4 +- Source/cmSourceFileLocation.cxx | 2 +- Source/cmTarget.cxx | 20 +++++----- Source/cmTarget.h | 2 +- Source/cmVisualStudio10TargetGenerator.cxx | 39 +++++++++--------- Source/cmVisualStudioGeneratorOptions.cxx | 4 +- Source/cmVisualStudioGeneratorOptions.h | 2 +- Source/cmXCodeObject.h | 2 +- 44 files changed, 246 insertions(+), 253 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 6986965..716eb4d 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -268,7 +268,7 @@ cmComputeLinkInformation // Get the language used for linking this target. this->LinkLanguage = this->Target->GetLinkerLanguage(config, headTarget); - if(!this->LinkLanguage) + if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the // initialization. @@ -496,7 +496,7 @@ bool cmComputeLinkInformation::Compute() } // We require a link language for the target. - if(!this->LinkLanguage) + if(this->LinkLanguage.empty()) { cmSystemTools:: Error("CMake can not determine linker language for target: ", diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 356e6ed..26ee8f0 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -50,7 +50,7 @@ public: std::vector const& GetDirectories(); std::vector const& GetDepends(); std::vector const& GetFrameworkPaths(); - const char* GetLinkLanguage() const { return this->LinkLanguage; } + std::string GetLinkLanguage() const { return this->LinkLanguage; } std::vector const& GetRuntimeSearchPath(); std::string const& GetRuntimeFlag() const { return this->RuntimeFlag; } std::string const& GetRuntimeSep() const { return this->RuntimeSep; } @@ -83,7 +83,7 @@ private: // Configuration information. const char* Config; - const char* LinkLanguage; + std::string LinkLanguage; bool LinkDependsNoShared; // Modes for dealing with dependent shared libraries. diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 7b52069..1e8e4d0 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -249,7 +249,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) si != sources.end(); ++si) { std::string ext = cmSystemTools::GetFilenameLastExtension(*si); - if(const char* lang = gg->GetLanguageFromExtension(ext.c_str())) + std::string lang = gg->GetLanguageFromExtension(ext.c_str()); + if(!lang.empty()) { testLangs.insert(lang); } diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index 1a0e93f..51150f2 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -297,7 +297,7 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends, } //---------------------------------------------------------------------------- -void cmDepends::SetIncludePathFromLanguage(const char* lang) +void cmDepends::SetIncludePathFromLanguage(const std::string& lang) { // Look for the new per "TARGET_" variant first: const char * includePath = 0; diff --git a/Source/cmDepends.h b/Source/cmDepends.h index d787edd..b293c5b 100644 --- a/Source/cmDepends.h +++ b/Source/cmDepends.h @@ -41,7 +41,7 @@ public: void SetLocalGenerator(cmLocalGenerator* lg) { this->LocalGenerator = lg; } /** Set the specific language to be scanned. */ - void SetLanguage(const char* lang) { this->Language = lang; } + void SetLanguage(const std::string& lang) { this->Language = lang; } /** Set the target build directory. */ void SetTargetDirectory(const char* dir) { this->TargetDirectory = dir; } @@ -114,7 +114,7 @@ protected: // The include file search path. std::vector IncludePath; - void SetIncludePathFromLanguage(const char* lang); + void SetIncludePathFromLanguage(const std::string& lang); private: cmDepends(cmDepends const&); // Purposely not implemented. diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 4fc5efb..585f959 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -37,7 +37,7 @@ cmDependsC::cmDependsC() //---------------------------------------------------------------------------- cmDependsC::cmDependsC(cmLocalGenerator* lg, const char* targetDir, - const char* lang, + const std::string& lang, const std::map* validDeps) : cmDepends(lg, targetDir) , ValidDeps(validDeps) diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h index 16dfad7..cd1e7a4 100644 --- a/Source/cmDependsC.h +++ b/Source/cmDependsC.h @@ -25,7 +25,8 @@ public: /** Checking instances need to know the build directory name and the relative path from the build directory to the target file. */ cmDependsC(); - cmDependsC(cmLocalGenerator* lg, const char* targetDir, const char* lang, + cmDependsC(cmLocalGenerator* lg, const char* targetDir, + const std::string& lang, const std::map* validDeps); /** Virtual destructor to cleanup subclasses properly. */ diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 548c88b..8d4cf85 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -411,7 +411,8 @@ void cmExtraCodeBlocksGenerator // check whether it is a C/C++ implementation file bool isCFile = false; - if ((*si)->GetLanguage() && (*(*si)->GetLanguage() == 'C')) + std::string lang = (*si)->GetLanguage(); + if (lang == "C" || lang == "CXX") { for(std::vector::const_iterator ext = mf->GetSourceExtensions().begin(); diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index ff84fb7..028d3d5 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -220,7 +220,8 @@ void cmExtraCodeLiteGenerator { // check whether it is a C/C++ implementation file bool isCFile = false; - if ((*si)->GetLanguage() && (*(*si)->GetLanguage() == 'C')) + std::string lang = (*si)->GetLanguage(); + if (lang == "C" || lang == "CXX") { for(std::vector::const_iterator ext = mf->GetSourceExtensions().begin(); diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 604bfcc..1c9ac02 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -369,8 +369,8 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source, std::string flags; cmMakefile *makefile = lg->GetMakefile(); - const char* language = source->GetLanguage(); - if (language == NULL) + std::string language = source->GetLanguage(); + if (language.empty()) { language = "C"; } @@ -423,11 +423,7 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target, { std::set defines; cmMakefile *makefile = lg->GetMakefile(); - const char* language = source->GetLanguage(); - if (language == NULL) - { - language = ""; - } + const std::string& language = source->GetLanguage(); const char* config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); // Add the export symbol definition for shared library objects. diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index c27c03f..d12a66d 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -990,8 +990,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "link libraries for a static library"); return std::string(); } - const char *lang = target->GetLinkerLanguage(context->Config); - return lang ? lang : ""; + return target->GetLinkerLanguage(context->Config); } cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index d9885b9..4e7c71e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -168,7 +168,7 @@ struct TagVisitor this->BadObjLibFiles.push_back(sf); } } - else if(sf->GetLanguage()) + else if(!sf->GetLanguage().empty()) { DoAccept::Result>::Do(this->Data, sf); } diff --git a/Source/cmGetSourceFilePropertyCommand.cxx b/Source/cmGetSourceFilePropertyCommand.cxx index 3d85e6d..a6e4fcc 100644 --- a/Source/cmGetSourceFilePropertyCommand.cxx +++ b/Source/cmGetSourceFilePropertyCommand.cxx @@ -35,7 +35,7 @@ bool cmGetSourceFilePropertyCommand { if(args[2] == "LANGUAGE") { - this->Makefile->AddDefinition(var, sf->GetLanguage()); + this->Makefile->AddDefinition(var, sf->GetLanguage().c_str()); return true; } const char *prop = sf->GetPropertyForUser(args[2].c_str()); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index f76c6d1..7e93676 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -722,7 +722,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, //---------------------------------------------------------------------------- void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os, - std::string lang, + std::string const& lang, const char* envVar) const { // Subclasses override this method if they do not support this advice. @@ -744,7 +744,7 @@ void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os, //---------------------------------------------------------------------------- void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, - std::string lang) const + std::string const& lang) const { std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID"; const char* compilerId = mf->GetDefinition(compilerIdVar.c_str()); @@ -817,17 +817,18 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, } //---------------------------------------------------------------------------- -const char* +std::string cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const { - if(const char* lang = source.GetLanguage()) + const std::string& lang = source.GetLanguage(); + if(!lang.empty()) { std::map::const_iterator it = this->LanguageToOutputExtension.find(lang); if(it != this->LanguageToOutputExtension.end()) { - return it->second.c_str(); + return it->second; } } else @@ -840,7 +841,7 @@ cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const { if(this->OutputExtensions.count(ext)) { - return ext.c_str(); + return ext; } } } @@ -848,7 +849,7 @@ cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const } -const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const +std::string cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const { // if there is an extension and it starts with . then move past the // . because the extensions are not stored with a . in the map @@ -860,9 +861,9 @@ const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const = this->ExtensionToLanguage.find(ext); if(it != this->ExtensionToLanguage.end()) { - return it->second.c_str(); + return it->second; } - return 0; + return ""; } /* SetLanguageEnabled() is now split in two parts: @@ -877,13 +878,15 @@ files could change the object file extension (CMAKE__OUTPUT_EXTENSION) before the CMake variables were copied to the C++ maps. */ -void cmGlobalGenerator::SetLanguageEnabled(const char* l, cmMakefile* mf) +void cmGlobalGenerator::SetLanguageEnabled(const std::string& l, + cmMakefile* mf) { this->SetLanguageEnabledFlag(l, mf); this->SetLanguageEnabledMaps(l, mf); } -void cmGlobalGenerator::SetLanguageEnabledFlag(const char* l, cmMakefile* mf) +void cmGlobalGenerator::SetLanguageEnabledFlag(const std::string& l, + cmMakefile* mf) { this->LanguageEnabled[l] = true; @@ -895,7 +898,8 @@ void cmGlobalGenerator::SetLanguageEnabledFlag(const char* l, cmMakefile* mf) this->FillExtensionToLanguageMap(l, mf); } -void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf) +void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l, + cmMakefile* mf) { // use LanguageToLinkerPreference to detect whether this functions has // run before @@ -969,7 +973,7 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf) } -void cmGlobalGenerator::FillExtensionToLanguageMap(const char* l, +void cmGlobalGenerator::FillExtensionToLanguageMap(const std::string& l, cmMakefile* mf) { std::string extensionsVar = std::string("CMAKE_") + @@ -986,14 +990,14 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const char* l, bool cmGlobalGenerator::IgnoreFile(const char* l) const { - if(this->GetLanguageFromExtension(l)) + if(!this->GetLanguageFromExtension(l).empty()) { return false; } return (this->IgnoreExtensions.count(l) > 0); } -bool cmGlobalGenerator::GetLanguageEnabled(const char* l) const +bool cmGlobalGenerator::GetLanguageEnabled(const std::string& l) const { return (this->LanguageEnabled.find(l)!= this->LanguageEnabled.end()); } @@ -1958,7 +1962,7 @@ cmGlobalGenerator::GetEnabledLanguages(std::vector& lang) const } } -int cmGlobalGenerator::GetLinkerPreference(const char* lang) const +int cmGlobalGenerator::GetLinkerPreference(const std::string& lang) const { std::map::const_iterator it = this->LanguageToLinkerPreference.find(lang); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index b66f01e..2f23fd5 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -77,8 +77,8 @@ public: /** * Set/Get and Clear the enabled languages. */ - void SetLanguageEnabled(const char*, cmMakefile* mf); - bool GetLanguageEnabled(const char*) const; + void SetLanguageEnabled(const std::string&, cmMakefile* mf); + bool GetLanguageEnabled(const std::string&) const; void ClearEnabledLanguages(); void GetEnabledLanguages(std::vector& lang) const; /** @@ -182,13 +182,13 @@ public: bool GetToolSupportsColor() const { return this->ToolSupportsColor; } ///! return the language for the given extension - const char* GetLanguageFromExtension(const char* ext) const; + std::string GetLanguageFromExtension(const char* ext) const; ///! is an extension to be ignored bool IgnoreFile(const char* ext) const; ///! What is the preference for linkers and this language (None or Prefered) - int GetLinkerPreference(const char* lang) const; + int GetLinkerPreference(const std::string& lang) const; ///! What is the object file extension for a given source file? - const char* GetLanguageOutputExtension(cmSourceFile const&) const; + std::string GetLanguageOutputExtension(cmSourceFile const&) const; ///! What is the configurations directory variable called? virtual const char* GetCMakeCFGIntDir() const { return "."; } @@ -332,9 +332,9 @@ protected: bool IsRootOnlyTarget(cmTarget* target) const; void AddTargetDepends(cmTarget const* target, TargetDependSet& projectTargets); - void SetLanguageEnabledFlag(const char* l, cmMakefile* mf); - void SetLanguageEnabledMaps(const char* l, cmMakefile* mf); - void FillExtensionToLanguageMap(const char* l, cmMakefile* mf); + void SetLanguageEnabledFlag(const std::string& l, cmMakefile* mf); + void SetLanguageEnabledMaps(const std::string& l, cmMakefile* mf); + void FillExtensionToLanguageMap(const std::string& l, cmMakefile* mf); virtual bool ComputeTargetDepends(); @@ -420,9 +420,10 @@ private: void WriteSummary(cmTarget* target); void FinalizeTargetCompileInfo(); - virtual void PrintCompilerAdvice(std::ostream& os, std::string lang, + virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang, const char* envVar) const; - void CheckCompilerIdCompatibility(cmMakefile* mf, std::string lang) const; + void CheckCompilerIdCompatibility(cmMakefile* mf, + std::string const& lang) const; cmExternalMakefileProjectGenerator* ExtraGenerator; diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 9186d65..4b73118 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -114,7 +114,8 @@ protected: private: virtual std::string GetVSMakeProgram() = 0; - void PrintCompilerAdvice(std::ostream&, std::string, const char*) const {} + void PrintCompilerAdvice(std::ostream&, std::string const&, + const char*) const {} void ComputeTargetObjects(cmGeneratorTarget* gt) const; void FollowLinkDepends(cmTarget const* target, diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index ab92c6e..3f24167 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -696,12 +696,8 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, flags += flagsBuild.GetString(); } - const char* lang = + std::string lang = this->CurrentLocalGenerator->GetSourceFileLanguage(*sf); - if (!lang) - { - lang = ""; - } cmXCodeObject* buildFile = this->CreateXCodeSourceFileFromPath(sf->GetFullPath(), cmtarget, lang); @@ -906,12 +902,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf, cmTarget& cmtarget) { - const char* lang = + std::string lang = this->CurrentLocalGenerator->GetSourceFileLanguage(*sf); - if (!lang) - { - lang = ""; - } return this->CreateXCodeFileReferenceFromPath( sf->GetFullPath(), cmtarget, lang); @@ -1036,7 +1028,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // Include this file in the build if it has a known language // and has not been listed as an ignored extension for this // generator. - if(this->CurrentLocalGenerator->GetSourceFileLanguage(**i) && + if(!this->CurrentLocalGenerator->GetSourceFileLanguage(**i).empty() && !this->IgnoreFile((*i)->GetExtension().c_str())) { sourceFiles.push_back(xsf); @@ -1241,8 +1233,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) return; } - const char* llang = cmtarget.GetLinkerLanguage("NOCONFIG"); - if(!llang) { return; } + std::string llang = cmtarget.GetLinkerLanguage("NOCONFIG"); + if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. cmTarget::LinkImplementation const* impl = @@ -1270,7 +1262,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) } if(cmSourceFile* sf = mf->GetOrCreateSource(fname.c_str())) { - sf->SetProperty("LANGUAGE", llang); + sf->SetProperty("LANGUAGE", llang.c_str()); cmtarget.AddSourceFile(sf); } } @@ -1714,12 +1706,12 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, (target.GetType() == cmTarget::EXECUTABLE) || shared); - const char* lang = target.GetLinkerLanguage(configName); + std::string lang = target.GetLinkerLanguage(configName); std::string cflags; - if(lang) + if(!lang.empty()) { // for c++ projects get the c flags as well - if(strcmp(lang, "CXX") == 0) + if(lang == "CXX") { this->CurrentLocalGenerator->AddLanguageFlags(cflags, "C", configName); this->CurrentLocalGenerator->AddCMP0018Flags(cflags, &target, @@ -2178,7 +2170,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, const char* debugStr = "YES"; // We can't set the Xcode flag differently depending on the language, // so put them back in this case. - if( (lang && strcmp(lang, "CXX") == 0) && gflag != gflagc ) + if( (lang == "CXX") && gflag != gflagc ) { cflags += " "; cflags += gflagc; @@ -2201,7 +2193,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString("NO")); buildSettings->AddAttribute("GCC_INLINES_ARE_PRIVATE_EXTERN", this->CreateString("NO")); - if(lang && strcmp(lang, "CXX") == 0) + if(lang == "CXX") { flags += " "; flags += defFlags; @@ -3800,12 +3792,13 @@ cmGlobalXCodeGenerator } //---------------------------------------------------------------------------- -std::string cmGlobalXCodeGenerator::LookupFlags(const char* varNamePrefix, - const char* varNameLang, - const char* varNameSuffix, - const char* default_flags) +std::string cmGlobalXCodeGenerator::LookupFlags( + const std::string& varNamePrefix, + const std::string& varNameLang, + const std::string& varNameSuffix, + const std::string& default_flags) { - if(varNameLang) + if(!varNameLang.empty()) { std::string varName = varNamePrefix; varName += varNameLang; diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 31c2cfb..15f1363 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -190,10 +190,10 @@ private: void CreateReRunCMakeFile(cmLocalGenerator* root, std::vector const& gens); - std::string LookupFlags(const char* varNamePrefix, - const char* varNameLang, - const char* varNameSuffix, - const char* default_flags); + std::string LookupFlags(const std::string& varNamePrefix, + const std::string& varNameLang, + const std::string& varNameSuffix, + const std::string& default_flags); class Factory; class BuildObjectListOrString; @@ -215,7 +215,8 @@ protected: std::vector XCodeObjects; cmXCodeObject* RootObject; private: - void PrintCompilerAdvice(std::ostream&, std::string, const char*) const {} + void PrintCompilerAdvice(std::ostream&, std::string const&, + const char*) const {} void ComputeTargetObjects(cmGeneratorTarget* gt) const; std::string GetObjectsNormalDirectory( diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 476c95d..0b4f94b 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -572,7 +572,7 @@ void cmLocalGenerator::GenerateTargetManifest() } void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, - const char* lang, + const std::string& lang, cmSourceFile& source, cmGeneratorTarget& target) { @@ -604,7 +604,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, std::vector commands; cmSystemTools::ExpandList(rules, commands); cmLocalGenerator::RuleVariables vars; - vars.Language = lang; + vars.Language = lang.c_str(); vars.Source = sourceFile.c_str(); vars.Object = objectFile.c_str(); vars.ObjectDir = objectDir.c_str(); @@ -653,7 +653,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, ); } -void cmLocalGenerator::AddBuildTargetRule(const char* llang, +void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, cmGeneratorTarget& target) { cmStdString objs; @@ -703,7 +703,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, &target); linkLibs = frameworkPath + linkPath + linkLibs; cmLocalGenerator::RuleVariables vars; - vars.Language = llang; + vars.Language = llang.c_str(); vars.Objects = objs.c_str(); vars.ObjectDir = "."; vars.Target = targetName.c_str(); @@ -776,8 +776,8 @@ void cmLocalGenerator case cmTarget::MODULE_LIBRARY: case cmTarget::EXECUTABLE: { - const char* llang = target.Target->GetLinkerLanguage(); - if(!llang) + std::string llang = target.Target->GetLinkerLanguage(); + if(llang.empty()) { cmSystemTools::Error ("CMake can not determine linker language for target: ", @@ -1290,10 +1290,11 @@ cmLocalGenerator::ConvertToIncludeReference(std::string const& path, std::string cmLocalGenerator::GetIncludeFlags( const std::vector &includes, cmGeneratorTarget* target, - const char* lang, bool forResponseFile, + const std::string& lang, + bool forResponseFile, const char *config) { - if(!lang) + if(lang.empty()) { return ""; } @@ -1415,7 +1416,7 @@ void cmLocalGenerator::AddCompileDefinitions(std::set& defines, //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileOptions( std::string& flags, cmTarget* target, - const char* lang, const char* config + const std::string& lang, const char* config ) { std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX"; @@ -1463,7 +1464,7 @@ void cmLocalGenerator::AddCompileOptions( //---------------------------------------------------------------------------- void cmLocalGenerator::GetIncludeDirectories(std::vector& dirs, cmGeneratorTarget* target, - const char* lang, + const std::string& lang, const char *config, bool stripImplicitInclDirs ) @@ -1689,8 +1690,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); linkFlags += " "; } - const char* linkLanguage = target->Target->GetLinkerLanguage(); - if(!linkLanguage) + std::string linkLanguage = target->Target->GetLinkerLanguage(); + if(linkLanguage.empty()) { cmSystemTools::Error ("CMake can not determine linker language for target: ", @@ -1813,7 +1814,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, // Collect library linking flags command line options. std::string linkLibs; - const char* linkLanguage = cli.GetLinkLanguage(); + std::string linkLanguage = cli.GetLinkLanguage(); std::string libPathFlag = this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG"); @@ -1943,7 +1944,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, //---------------------------------------------------------------------------- void cmLocalGenerator::AddArchitectureFlags(std::string& flags, cmGeneratorTarget* target, - const char *lang, + const std::string& lang, const char* config) { // Only add Mac OS X specific flags on Darwin platforms (OSX and iphone): @@ -1969,7 +1970,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, std::string("CMAKE_") + lang + "_OSX_DEPLOYMENT_TARGET_FLAG"; const char* deploymentTargetFlag = this->Makefile->GetDefinition(deploymentTargetFlagVar.c_str()); - if(!archs.empty() && lang && (lang[0] =='C' || lang[0] == 'F')) + if(!archs.empty() && !lang.empty() && (lang[0] =='C' || lang[0] == 'F')) { for(std::vector::iterator i = archs.begin(); i != archs.end(); ++i) @@ -2000,7 +2001,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, //---------------------------------------------------------------------------- void cmLocalGenerator::AddLanguageFlags(std::string& flags, - const char* lang, + const std::string& lang, const char* config) { // Add language-specific flags. @@ -2112,7 +2113,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, //---------------------------------------------------------------------------- void cmLocalGenerator::AddSharedFlags(std::string& flags, - const char* lang, + const std::string& lang, bool shared) { std::string flagsVar; @@ -2128,7 +2129,8 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags, } static void AddVisibilityCompileOption(std::string &flags, cmTarget* target, - cmLocalGenerator *lg, const char *lang) + cmLocalGenerator *lg, + const std::string& lang) { std::string l(lang); std::string compileOption = "CMAKE_" + l + "_COMPILE_OPTIONS_VISIBILITY"; @@ -2182,7 +2184,7 @@ static void AddInlineVisibilityCompileOption(std::string &flags, //---------------------------------------------------------------------------- void cmLocalGenerator ::AddVisibilityPresetFlags(std::string &flags, cmTarget* target, - const char *lang) + const std::string& lang) { int targetType = target->GetType(); bool suitableTarget = ((targetType == cmTarget::SHARED_LIBRARY) @@ -2194,13 +2196,13 @@ void cmLocalGenerator return; } - if (!lang) + if (lang.empty()) { return; } AddVisibilityCompileOption(flags, target, this, lang); - if(strcmp(lang, "CXX") == 0) + if(lang == "CXX") { AddInlineVisibilityCompileOption(flags, target, this); } @@ -2396,11 +2398,11 @@ void cmLocalGenerator::AppendDefines(std::set& defines, //---------------------------------------------------------------------------- void cmLocalGenerator::JoinDefines(const std::set& defines, std::string &definesString, - const char* lang) + const std::string& lang) { // Lookup the define flag for the current language. std::string dflag = "-D"; - if(lang) + if(!lang.empty()) { std::string defineFlagVar = "CMAKE_"; defineFlagVar += lang; @@ -2460,7 +2462,7 @@ void cmLocalGenerator::JoinDefines(const std::set& defines, //---------------------------------------------------------------------------- void cmLocalGenerator::AppendFeatureOptions( - std::string& flags, const char* lang, const char* feature) + std::string& flags, const std::string& lang, const char* feature) { std::string optVar = "CMAKE_"; optVar += lang; @@ -3140,7 +3142,8 @@ cmLocalGenerator bool replaceExt = this->NeedBackwardsCompatibility_2_4(); if(!replaceExt) { - if(const char* lang = source.GetLanguage()) + std::string lang = source.GetLanguage(); + if(!lang.empty()) { std::string repVar = "CMAKE_"; repVar += lang; @@ -3174,7 +3177,7 @@ cmLocalGenerator } //---------------------------------------------------------------------------- -const char* +std::string cmLocalGenerator ::GetSourceFileLanguage(const cmSourceFile& source) { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 80a1421..74303f4 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -137,14 +137,14 @@ public: void AddArchitectureFlags(std::string& flags, cmGeneratorTarget* target, - const char *lang, const char* config); + const std::string&lang, const char* config); - void AddLanguageFlags(std::string& flags, const char* lang, + void AddLanguageFlags(std::string& flags, const std::string& lang, const char* config); void AddCMP0018Flags(std::string &flags, cmTarget* target, std::string const& lang, const char *config); void AddVisibilityPresetFlags(std::string &flags, cmTarget* target, - const char *lang); + const std::string& lang); void AddConfigVariableFlags(std::string& flags, const std::string& var, const char* config); ///! Append flags to a string. @@ -153,7 +153,8 @@ public: ///! Get the include flags for the current makefile and language std::string GetIncludeFlags(const std::vector &includes, cmGeneratorTarget* target, - const char* lang, bool forResponseFile = false, + const std::string& lang, + bool forResponseFile = false, const char *config = 0); /** @@ -175,10 +176,10 @@ public: */ void JoinDefines(const std::set& defines, std::string &definesString, - const char* lang); + const std::string& lang); /** Lookup and append options associated with a particular feature. */ - void AppendFeatureOptions(std::string& flags, const char* lang, + void AppendFeatureOptions(std::string& flags, const std::string& lang, const char* feature); /** \brief Get absolute path to dependency \a name @@ -223,16 +224,17 @@ public: /** Get the include flags for the current makefile and language. */ void GetIncludeDirectories(std::vector& dirs, cmGeneratorTarget* target, - const char* lang = "C", const char *config = 0, + const std::string& lang = "C", + const char *config = 0, bool stripImplicitInclDirs = true); void AddCompileOptions(std::string& flags, cmTarget* target, - const char* lang, const char* config); + const std::string& lang, const char* config); void AddCompileDefinitions(std::set& defines, cmTarget const* target, const char* config); /** Compute the language used to compile the given source file. */ - const char* GetSourceFileLanguage(const cmSourceFile& source); + std::string GetSourceFileLanguage(const cmSourceFile& source); // Fill the vector with the target names for the object files, // preprocessed files and assembly files. @@ -389,10 +391,11 @@ protected: /** Convert a target to a utility target for unsupported * languages of a generator */ - void AddBuildTargetRule(const char* llang, cmGeneratorTarget& target); + void AddBuildTargetRule(const std::string& llang, + cmGeneratorTarget& target); ///! add a custom command to build a .o file that is part of a target void AddCustomCommandToCreateObject(const char* ofname, - const char* lang, + const std::string& lang, cmSourceFile& source, cmGeneratorTarget& target); // Create Custom Targets and commands for unsupported languages @@ -473,7 +476,8 @@ private: std::string const& result, OutputFormat format); - void AddSharedFlags(std::string& flags, const char* lang, bool shared); + void AddSharedFlags(std::string& flags, const std::string& lang, + bool shared); bool GetShouldUseOldFlags(bool shared, const std::string &lang) const; void AddPositionIndependentFlags(std::string& flags, std::string const& l, int targetType); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 93722d1..11b89f4 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -2198,7 +2198,7 @@ cmLocalUnixMakefileGenerator3::GetImplicitDepends(cmTarget const& tgt) //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3::AddImplicitDepends(cmTarget const& tgt, - const char* lang, + const std::string& lang, const char* obj, const char* src) { diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 703369e..b0ccf52 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -217,7 +217,7 @@ public: public std::map {}; ImplicitDependLanguageMap const& GetImplicitDepends(cmTarget const& tgt); - void AddImplicitDepends(cmTarget const& tgt, const char* lang, + void AddImplicitDepends(cmTarget const& tgt, const std::string& lang, const char* obj, const char* src); void AppendGlobalTargetDepends(std::vector& depends, @@ -358,7 +358,7 @@ private: cmTarget* Target; std::string Language; LocalObjectEntry(): Target(0), Language() {} - LocalObjectEntry(cmTarget* t, const char* lang): + LocalObjectEntry(cmTarget* t, const std::string& lang): Target(t), Language(lang) {} }; struct LocalObjectInfo: public std::vector diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index a5e8294..ff217c3 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -413,19 +413,16 @@ void cmLocalVisualStudio6Generator compileFlags += cflags; } - const char* lang = this->GetSourceFileLanguage(*(*sf)); - if(lang) + const std::string& lang = this->GetSourceFileLanguage(*(*sf)); + if(lang == "CXX") { - if(strcmp(lang, "CXX") == 0) - { - // force a C++ file type - compileFlags += " /TP "; - } - else if(strcmp(lang, "C") == 0) - { - // force to c file type - compileFlags += " /TC "; - } + // force a C++ file type + compileFlags += " /TP "; + } + else if(lang == "C") + { + // force to c file type + compileFlags += " /TC "; } // Add per-source and per-configuration preprocessor definitions. @@ -469,7 +466,7 @@ void cmLocalVisualStudio6Generator } bool excludedFromBuild = - (lang && (*sf)->GetPropertyAsBool("HEADER_FILE_ONLY")); + (!lang.empty() && (*sf)->GetPropertyAsBool("HEADER_FILE_ONLY")); // Check for extra object-file dependencies. const char* dependsValue = (*sf)->GetProperty("OBJECT_DEPENDS"); @@ -1255,8 +1252,8 @@ void cmLocalVisualStudio6Generator if(targetBuilds) { // Get the language to use for linking. - const char* linkLanguage = target.GetLinkerLanguage(); - if(!linkLanguage) + const std::string& linkLanguage = target.GetLinkerLanguage(); + if(linkLanguage.empty()) { cmSystemTools::Error ("CMake can not determine linker language for target: ", @@ -1677,8 +1674,8 @@ void cmLocalVisualStudio6Generator if(target.GetType() >= cmTarget::EXECUTABLE && target.GetType() <= cmTarget::OBJECT_LIBRARY) { - const char* linkLanguage = target.GetLinkerLanguage(); - if(!linkLanguage) + const std::string& linkLanguage = target.GetLinkerLanguage(); + if(linkLanguage.empty()) { cmSystemTools::Error ("CMake can not determine linker language for target: ", @@ -1745,11 +1742,11 @@ void cmLocalVisualStudio6Generator std::string minsizeDefines = " "; std::string debugrelDefines = " "; - this->JoinDefines(definesSet, defines, 0); - this->JoinDefines(debugDefinesSet, debugDefines, 0); - this->JoinDefines(releaseDefinesSet, releaseDefines, 0); - this->JoinDefines(minsizeDefinesSet, minsizeDefines, 0); - this->JoinDefines(debugrelDefinesSet, debugrelDefines, 0); + this->JoinDefines(definesSet, defines, ""); + this->JoinDefines(debugDefinesSet, debugDefines, ""); + this->JoinDefines(releaseDefinesSet, releaseDefines, ""); + this->JoinDefines(minsizeDefinesSet, minsizeDefines, ""); + this->JoinDefines(debugrelDefinesSet, debugrelDefines, ""); flags += defines; flagsDebug += debugDefines; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index d11bf55..f93a7aa 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -687,17 +687,18 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, std::string flags; if(strcmp(configType, "10") != 0) { - const char* linkLanguage = (this->FortranProject? "Fortran": + const std::string& linkLanguage = (this->FortranProject? + std::string("Fortran"): target.GetLinkerLanguage(configName)); - if(!linkLanguage) + if(linkLanguage.empty()) { cmSystemTools::Error ("CMake can not determine linker language for target: ", target.GetName()); return; } - if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0 - || strcmp(linkLanguage, "Fortran") == 0) + if(linkLanguage == "C" || linkLanguage == "CXX" + || linkLanguage == "Fortran") { std::string baseFlagVar = "CMAKE_"; baseFlagVar += linkLanguage; @@ -709,11 +710,11 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, flags += this->Makefile->GetRequiredDefinition(flagVar.c_str()); } // set the correct language - if(strcmp(linkLanguage, "C") == 0) + if(linkLanguage == "C") { flags += " /TC "; } - if(strcmp(linkLanguage, "CXX") == 0) + if(linkLanguage == "CXX") { flags += " /TP "; } @@ -1081,7 +1082,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, return; } cmComputeLinkInformation& cli = *pcli; - const char* linkLanguage = cli.GetLinkLanguage(); + std::string linkLanguage = cli.GetLinkLanguage(); // Compute the variable name to lookup standard libraries for this // language. @@ -1177,7 +1178,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, return; } cmComputeLinkInformation& cli = *pcli; - const char* linkLanguage = cli.GetLinkLanguage(); + std::string linkLanguage = cli.GetLinkLanguage(); bool isWin32Executable = target.GetPropertyAsBool("WIN32_EXECUTABLE"); @@ -1546,14 +1547,14 @@ cmLocalVisualStudio7GeneratorFCInfo } } - const char* lang = + std::string lang = lg->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); - const char* sourceLang = lg->GetSourceFileLanguage(sf); - const char* linkLanguage = target.GetLinkerLanguage(i->c_str()); + const std::string& sourceLang = lg->GetSourceFileLanguage(sf); + const std::string& linkLanguage = target.GetLinkerLanguage(i->c_str()); bool needForceLang = false; // source file does not match its extension language - if(lang && sourceLang && strcmp(lang, sourceLang) != 0) + if(lang != sourceLang) { needForceLang = true; lang = sourceLang; @@ -1569,16 +1570,15 @@ cmLocalVisualStudio7GeneratorFCInfo // if the source file does not match the linker language // then force c or c++ - if(needForceLang || (linkLanguage && lang - && strcmp(lang, linkLanguage) != 0)) + if(needForceLang || (linkLanguage != lang)) { - if(strcmp(lang, "CXX") == 0) + if(lang == "CXX") { // force a C++ file type fc.CompileFlags += " /TP "; needfc = true; } - else if(strcmp(lang, "C") == 0) + else if(lang == "C") { // force to c fc.CompileFlags += " /TC "; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ff0576e..8274b13 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2361,10 +2361,10 @@ bool cmMakefile::PlatformIs64Bit() const return false; } -const char* cmMakefile::GetSONameFlag(const char* language) const +const char* cmMakefile::GetSONameFlag(const std::string& language) const { std::string name = "CMAKE_SHARED_LIBRARY_SONAME"; - if(language) + if(!language.empty()) { name += "_"; name += language; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 044324e..331a064 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -608,7 +608,7 @@ public: bool PlatformIs64Bit() const; /** Retrieve soname flag for the specified language if supported */ - const char* GetSONameFlag(const char* language) const; + const char* GetSONameFlag(const std::string& language) const; /** * Get a list of preprocessor define flags. diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 1802054..b827363 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -160,11 +160,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) cmLocalGenerator::SHELL); // Get the language to use for linking this executable. - const char* linkLanguage = + std::string linkLanguage = this->Target->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. - if(!linkLanguage) + if(linkLanguage.empty()) { cmSystemTools::Error("Cannot determine link language for target \"", this->Target->GetName(), "\"."); @@ -348,7 +348,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_LINK"; vars.CMTarget = this->Target; - vars.Language = linkLanguage; + vars.Language = linkLanguage.c_str(); vars.Objects = buildObjs.c_str(); std::string objectDir = this->Target->GetSupportDirectory(); objectDir = this->Convert(objectDir.c_str(), diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 10418d0..96159f9 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -131,13 +131,10 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() //---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() { - const char* linkLanguage = + std::string linkLanguage = this->Target->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; - if (linkLanguage) - { - linkRuleVar += linkLanguage; - } + linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_STATIC_LIBRARY"; if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION") && @@ -160,13 +157,10 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) this->WriteFrameworkRules(relink); return; } - const char* linkLanguage = + std::string linkLanguage = this->Target->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; - if (linkLanguage) - { - linkRuleVar += linkLanguage; - } + linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_LIBRARY"; std::string extraFlags; @@ -187,13 +181,10 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) //---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) { - const char* linkLanguage = + std::string linkLanguage = this->Target->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; - if (linkLanguage) - { - linkRuleVar += linkLanguage; - } + linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_MODULE"; std::string extraFlags; @@ -213,13 +204,10 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) //---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) { - const char* linkLanguage = + std::string linkLanguage = this->Target->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; - if (linkLanguage) - { - linkRuleVar += linkLanguage; - } + linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_MACOSX_FRAMEWORK"; std::string extraFlags; @@ -248,11 +236,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules this->AppendLinkDepends(depends); // Get the language to use for linking this library. - const char* linkLanguage = + std::string linkLanguage = this->Target->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. - if(!linkLanguage) + if(linkLanguage.empty()) { cmSystemTools::Error("Cannot determine link language for target \"", this->Target->GetName(), "\"."); @@ -589,7 +577,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules vars.RuleLauncher = "RULE_LAUNCH_LINK"; vars.CMTarget = this->Target; - vars.Language = linkLanguage; + vars.Language = linkLanguage.c_str(); vars.Objects = buildObjs.c_str(); std::string objectDir = this->Target->GetSupportDirectory(); objectDir = this->Convert(objectDir.c_str(), @@ -786,7 +774,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules //---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator -::AppendOSXVerFlag(std::string& flags, const char* lang, +::AppendOSXVerFlag(std::string& flags, const std::string& lang, const char* name, bool so) { // Lookup the flag to specify the version. diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h index 4873516..68980c3 100644 --- a/Source/cmMakefileLibraryTargetGenerator.h +++ b/Source/cmMakefileLibraryTargetGenerator.h @@ -39,7 +39,7 @@ protected: // Store the computd framework version for OS X Frameworks. std::string FrameworkVersion; - void AppendOSXVerFlag(std::string& flags, const char* lang, + void AppendOSXVerFlag(std::string& flags, const std::string& lang, const char* name, bool so); }; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index bf0dc51..3ba5a77 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -422,8 +422,9 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) { // Identify the language of the source file. - const char* lang = this->LocalGenerator->GetSourceFileLanguage(source); - if(!lang) + const std::string& lang = + this->LocalGenerator->GetSourceFileLanguage(source); + if(lang.empty()) { // don't know anything about this file so skip it return; @@ -523,7 +524,7 @@ cmMakefileTargetGenerator void cmMakefileTargetGenerator ::WriteObjectBuildFile(std::string &obj, - const char *lang, + const std::string& lang, cmSourceFile& source, std::vector& depends) { @@ -552,7 +553,7 @@ cmMakefileTargetGenerator cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName); // Add Fortran format flags. - if(strcmp(lang, "Fortran") == 0) + if(lang == "Fortran") { this->AppendFortranFormatFlags(flags, source); } @@ -664,7 +665,7 @@ cmMakefileTargetGenerator cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; vars.CMTarget = this->Target; - vars.Language = lang; + vars.Language = lang.c_str(); vars.Target = targetOutPathReal.c_str(); vars.TargetPDB = targetOutPathPDB.c_str(); vars.TargetCompilePDB = targetOutPathCompilePDB.c_str(); @@ -689,8 +690,7 @@ cmMakefileTargetGenerator vars.Defines = definesString.c_str(); - bool lang_is_c_or_cxx = ((strcmp(lang, "C") == 0) || - (strcmp(lang, "CXX") == 0)); + bool lang_is_c_or_cxx = ((lang == "C") || (lang == "CXX")); // Construct the compile rules. { @@ -1709,8 +1709,8 @@ void cmMakefileTargetGenerator } void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar, - const char* linkLang, - std::string& linkFlags) + const std::string& linkLang, + std::string& linkFlags) { // check for language flags that are not allowed at link time, and // remove them, -w on darwin for gcc -w -dynamiclib sends -w to libtool @@ -1943,7 +1943,7 @@ cmMakefileTargetGenerator //---------------------------------------------------------------------------- void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags, - const char* lang) + const std::string& lang) { std::string responseVar = "CMAKE_"; responseVar += lang; @@ -2113,7 +2113,7 @@ bool cmMakefileTargetGenerator::GetFeatureAsBool(const char* feature) //---------------------------------------------------------------------------- void cmMakefileTargetGenerator::AddFeatureFlags( - std::string& flags, const char* lang + std::string& flags, const std::string& lang ) { // Add language-specific flags. diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index f960afc..8ab65bf 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -93,7 +93,7 @@ protected: // write the build rule for an object void WriteObjectBuildFile(std::string &obj, - const char *lang, + const std::string& lang, cmSourceFile& source, std::vector& depends); @@ -173,10 +173,10 @@ protected: bool useResponseFile, std::string& buildObjs, std::vector& makefile_depends); - void AddIncludeFlags(std::string& flags, const char* lang); + void AddIncludeFlags(std::string& flags, const std::string& lang); virtual void CloseFileStreams(); - void RemoveForbiddenFlags(const char* flagVar, const char* linkLang, + void RemoveForbiddenFlags(const char* flagVar, const std::string& linkLang, std::string& linkFlags); cmTarget *Target; cmGeneratorTarget* GeneratorTarget; @@ -260,7 +260,7 @@ protected: void AddModuleDefinitionFlag(std::string& flags); // Add language feature flags. - void AddFeatureFlags(std::string& flags, const char* lang); + void AddFeatureFlags(std::string& flags, const std::string& lang); // Feature query methods. const char* GetFeature(const char* feature); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 73ba815..b81fbeb 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -35,7 +35,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) , TargetNameReal() , TargetNameImport() , TargetNamePDB() - , TargetLinkLanguage(0) + , TargetLinkLanguage("") { this->TargetLinkLanguage = target->Target ->GetLinkerLanguage(this->GetConfigName()); @@ -72,7 +72,7 @@ cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator() void cmNinjaNormalTargetGenerator::Generate() { - if (!this->TargetLinkLanguage) { + if (this->TargetLinkLanguage.empty()) { cmSystemTools::Error("CMake can not determine linker language for " "target: ", this->GetTarget()->GetName()); @@ -140,7 +140,7 @@ std::string cmNinjaNormalTargetGenerator ::LanguageLinkerRule() const { - return std::string(this->TargetLinkLanguage) + return this->TargetLinkLanguage + "_" + cmTarget::GetTargetTypeName(this->GetTarget()->GetType()) + "_LINKER"; @@ -163,7 +163,7 @@ cmNinjaNormalTargetGenerator cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_LINK"; vars.CMTarget = this->GetTarget(); - vars.Language = this->TargetLinkLanguage; + vars.Language = this->TargetLinkLanguage.c_str(); std::string responseFlag; if (!useResponseFile) { diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h index c7a089c..556ed5e 100644 --- a/Source/cmNinjaNormalTargetGenerator.h +++ b/Source/cmNinjaNormalTargetGenerator.h @@ -47,7 +47,7 @@ private: std::string TargetNameReal; std::string TargetNameImport; std::string TargetNamePDB; - const char *TargetLinkLanguage; + std::string TargetLinkLanguage; }; #endif // ! cmNinjaNormalTargetGenerator_h diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 00b0441..1c43cb3 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -110,7 +110,7 @@ bool cmNinjaTargetGenerator::GetFeatureAsBool(const char* feature) // TODO: Picked up from cmMakefileTargetGenerator. Refactor it. void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags, - const char* lang) + const std::string& lang) { // Add language-specific flags. this->LocalGenerator->AddLanguageFlags(flags, lang, this->GetConfigName()); diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 43f2279..e8ac81c 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -72,7 +72,7 @@ protected: const char* GetFeature(const char* feature); bool GetFeatureAsBool(const char* feature); - void AddFeatureFlags(std::string& flags, const char* lang); + void AddFeatureFlags(std::string& flags, const std::string& lang); /** * Compute the flags for compilation of object files for a given @a language. diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index f052044..0d37205 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -39,7 +39,7 @@ std::string const& cmSourceFile::GetExtension() const } //---------------------------------------------------------------------------- -const char* cmSourceFile::GetLanguage() +std::string cmSourceFile::GetLanguage() { // If the language was set explicitly by the user then use it. if(const char* lang = this->GetProperty("LANGUAGE")) @@ -76,7 +76,7 @@ const char* cmSourceFile::GetLanguage() } //---------------------------------------------------------------------------- -const char* cmSourceFile::GetLanguage() const +std::string cmSourceFile::GetLanguage() const { // If the language was set explicitly by the user then use it. if(const char* lang = this->GetProperty("LANGUAGE")) @@ -87,11 +87,11 @@ const char* cmSourceFile::GetLanguage() const // If the language was determined from the source file extension use it. if(!this->Language.empty()) { - return this->Language.c_str(); + return this->Language; } // The language is not known. - return 0; + return ""; } //---------------------------------------------------------------------------- @@ -267,7 +267,8 @@ void cmSourceFile::CheckLanguage(std::string const& ext) // Try to identify the source file language from the extension. cmMakefile const* mf = this->Location.GetMakefile(); cmGlobalGenerator* gg = mf->GetLocalGenerator()->GetGlobalGenerator(); - if(const char* l = gg->GetLanguageFromExtension(ext.c_str())) + std::string l = gg->GetLanguageFromExtension(ext.c_str()); + if(!l.empty()) { this->Language = l; } diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index b362c98..17c96ac 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -79,8 +79,8 @@ public: /** * Get the language of the compiler to use for this source file. */ - const char* GetLanguage(); - const char* GetLanguage() const; + std::string GetLanguage(); + std::string GetLanguage() const; /** * Return the vector that holds the list of dependencies diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index 832a6a7..30a53cb 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -93,7 +93,7 @@ void cmSourceFileLocation::UpdateExtension(const std::string& name) cmMakefile const* mf = this->Makefile; const std::vector& srcExts = mf->GetSourceExtensions(); const std::vector& hdrExts = mf->GetHeaderExtensions(); - if(gg->GetLanguageFromExtension(ext.c_str()) || + if(!gg->GetLanguageFromExtension(ext.c_str()).empty() || std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end() || std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end()) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 34d92fa..6782822 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2884,13 +2884,11 @@ private: }; //---------------------------------------------------------------------------- -const char* cmTarget::GetLinkerLanguage(const char* config, +std::string cmTarget::GetLinkerLanguage(const char* config, cmTarget const* head) const { cmTarget const* headTarget = head ? head : this; - const char* lang = this->GetLinkClosure(config, headTarget) - ->LinkerLanguage.c_str(); - return *lang? lang : 0; + return this->GetLinkClosure(config, headTarget)->LinkerLanguage; } //---------------------------------------------------------------------------- @@ -2924,7 +2922,7 @@ public: this->Makefile = this->Target->GetMakefile(); this->GG = this->Makefile->GetLocalGenerator()->GetGlobalGenerator(); } - void Consider(const char* lang) + void Consider(const std::string& lang) { int preference = this->GG->GetLinkerPreference(lang); if(preference > this->Preference) @@ -3530,7 +3528,8 @@ void cmTarget::GetFullNameInternal(const char* config, const char* suffixVar = this->GetSuffixVariableInternal(implib); // Check for language-specific default prefix and suffix. - if(const char* ll = this->GetLinkerLanguage(config, this)) + std::string ll = this->GetLinkerLanguage(config, this); + if(!ll.empty()) { if(!targetSuffix && suffixVar && *suffixVar) { @@ -3867,7 +3866,8 @@ bool cmTarget::NeedRelinkBeforeInstall(const char* config) const } // Check for rpath support on this platform. - if(const char* ll = this->GetLinkerLanguage(config, this)) + std::string ll = this->GetLinkerLanguage(config, this); + if(!ll.empty()) { std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; flagVar += ll; @@ -4825,7 +4825,8 @@ void cmTarget::GetLanguages(std::set& languages) const for(std::vector::const_iterator i = this->SourceFiles.begin(); i != this->SourceFiles.end(); ++i) { - if(const char* lang = (*i)->GetLanguage()) + const std::string& lang = (*i)->GetLanguage(); + if(!lang.empty()) { languages.insert(lang); } @@ -4876,7 +4877,8 @@ bool cmTarget::IsChrpathUsed(const char* config) const #if defined(CMAKE_USE_ELF_PARSER) // Enable if the rpath flag uses a separator and the target uses ELF // binaries. - if(const char* ll = this->GetLinkerLanguage(config, this)) + std::string ll = this->GetLinkerLanguage(config, this); + if(!ll.empty()) { std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; sepVar += ll; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9f7b811..205c81c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -347,7 +347,7 @@ public: GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; ///! Return the preferred linker language for this target - const char* GetLinkerLanguage(const char* config = 0, + std::string GetLinkerLanguage(const char* config = 0, cmTarget const* head = 0) const; /** Get the full name of the target according to the settings in its diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2d21a3d..aa721b7 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1012,18 +1012,18 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() si = objectSources.begin(); si != objectSources.end(); ++si) { - const char* lang = (*si)->GetLanguage(); + const std::string& lang = (*si)->GetLanguage(); const char* tool = NULL; - if (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") == 0) + if (lang == "C"|| lang == "CXX") { tool = "ClCompile"; } - else if (strcmp(lang, "ASM_MASM") == 0 && + else if (lang == "ASM_NASM" && this->GlobalGenerator->IsMasmEnabled()) { tool = "MASM"; } - else if (strcmp(lang, "RC") == 0) + else if (lang == "RC") { tool = "ResourceCompile"; } @@ -1108,29 +1108,28 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( { defines += cdefs; } - const char* lang = + std::string lang = this->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); - const char* sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf); - const char* linkLanguage = this->Target->GetLinkerLanguage(); + std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf); + const std::string& linkLanguage = this->Target->GetLinkerLanguage(); bool needForceLang = false; // source file does not match its extension language - if(lang && sourceLang && strcmp(lang, sourceLang) != 0) + if(lang != sourceLang) { needForceLang = true; lang = sourceLang; } // if the source file does not match the linker language // then force c or c++ - if(needForceLang || (linkLanguage && lang - && strcmp(lang, linkLanguage) != 0)) + if(needForceLang || (linkLanguage != lang)) { - if(strcmp(lang, "CXX") == 0) + if(lang == "CXX") { // force a C++ file type flags += " /TP "; } - else if(strcmp(lang, "C") == 0) + else if(lang == "C") { // force to c flags += " /TC "; @@ -1341,17 +1340,17 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( // collect up flags for if(this->Target->GetType() < cmTarget::UTILITY) { - const char* linkLanguage = + const std::string& linkLanguage = this->Target->GetLinkerLanguage(configName.c_str()); - if(!linkLanguage) + if(linkLanguage.empty()) { cmSystemTools::Error ("CMake can not determine linker language for target: ", this->Name.c_str()); return false; } - if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0 - || strcmp(linkLanguage, "Fortran") == 0) + if(linkLanguage == "C" || linkLanguage == "CXX" + || linkLanguage == "Fortran") { std::string baseFlagVar = "CMAKE_"; baseFlagVar += linkLanguage; @@ -1365,11 +1364,11 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str()); } // set the correct language - if(strcmp(linkLanguage, "C") == 0) + if(linkLanguage == "C") { flags += " /TC "; } - if(strcmp(linkLanguage, "CXX") == 0) + if(linkLanguage == "CXX") { flags += " /TP "; } @@ -1525,9 +1524,9 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) cmVSGetLinkFlagTable(this->LocalGenerator), 0, this)); Options& linkOptions = *pOptions; - const char* linkLanguage = + const std::string& linkLanguage = this->Target->GetLinkerLanguage(config.c_str()); - if(!linkLanguage) + if(linkLanguage.empty()) { cmSystemTools::Error ("CMake can not determine linker language for target: ", diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 6aca787..f48c593 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -222,7 +222,7 @@ cmVisualStudioGeneratorOptions ::OutputPreprocessorDefinitions(std::ostream& fout, const char* prefix, const char* suffix, - const char* lang) + const std::string& lang) { if(this->Defines.empty()) { @@ -270,7 +270,7 @@ cmVisualStudioGeneratorOptions { define = cmVisualStudio10GeneratorOptionsEscapeForXML(define.c_str()); - if(0 == strcmp(lang, "RC")) + if(lang == "RC") { cmSystemTools::ReplaceString(define, "\"", "\\\""); } diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index 90f7667..214b893 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -55,7 +55,7 @@ public: void OutputPreprocessorDefinitions(std::ostream& fout, const char* prefix, const char* suffix, - const char* lang); + const std::string& lang); void OutputFlagMap(std::ostream& fout, const char* indent); void OutputAdditionalOptions(std::ostream& fout, const char* prefix, diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index 0761136..ad1533e 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -123,7 +123,7 @@ public: void CopyAttributes(cmXCodeObject* ); void AddDependLibrary(const char* configName, - const char* l) + const std::string& l) { if(!configName) { -- cgit v0.12 From a6ae2ea72bc0d4149c2ff6118fcfd577e95c680d Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 4 Feb 2014 13:31:39 -0500 Subject: stringapi: Use strings in Convert methods in LocalGenerator The C strings were turned into std::strings internally anyways and most callers used .c_str(). --- Source/cmLocalGenerator.cxx | 36 +++++++++++++++++++----------------- Source/cmLocalGenerator.h | 20 +++++++++++--------- Source/cmMakefileTargetGenerator.h | 2 +- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 0b4f94b..e1abfef 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1230,7 +1230,7 @@ void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target, //---------------------------------------------------------------------------- std::string -cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote, +cmLocalGenerator::ConvertToOutputForExistingCommon(const std::string& remote, std::string const& result, OutputFormat format) { @@ -1238,10 +1238,10 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote, // already exists, we can use a short-path to reference it without a // space. if(this->WindowsShell && result.find(' ') != result.npos && - cmSystemTools::FileExists(remote)) + cmSystemTools::FileExists(remote.c_str())) { std::string tmp; - if(cmSystemTools::GetShortPath(remote, tmp)) + if(cmSystemTools::GetShortPath(remote.c_str(), tmp)) { return this->Convert(tmp.c_str(), NONE, format, true); } @@ -1253,7 +1253,7 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote, //---------------------------------------------------------------------------- std::string -cmLocalGenerator::ConvertToOutputForExisting(const char* remote, +cmLocalGenerator::ConvertToOutputForExisting(const std::string& remote, RelativeRoot local, OutputFormat format) { @@ -1267,7 +1267,7 @@ cmLocalGenerator::ConvertToOutputForExisting(const char* remote, //---------------------------------------------------------------------------- std::string cmLocalGenerator::ConvertToOutputForExisting(RelativeRoot remote, - const char* local, + const std::string& local, OutputFormat format) { // Perform standard conversion. @@ -2513,7 +2513,8 @@ cmLocalGenerator::ConstructComment(const cmCustomCommand& cc, //---------------------------------------------------------------------------- std::string -cmLocalGenerator::ConvertToOptionallyRelativeOutputPath(const char* remote) +cmLocalGenerator::ConvertToOptionallyRelativeOutputPath( + const std::string& remote) { return this->Convert(remote, START_OUTPUT, SHELL, true); } @@ -2533,7 +2534,7 @@ const char* cmLocalGenerator::GetRelativeRootPath(RelativeRoot relroot) } //---------------------------------------------------------------------------- -std::string cmLocalGenerator::Convert(const char* source, +std::string cmLocalGenerator::Convert(const std::string& source, RelativeRoot relative, OutputFormat output, bool optional) @@ -2585,7 +2586,7 @@ std::string cmLocalGenerator::Convert(const char* source, } //---------------------------------------------------------------------------- -std::string cmLocalGenerator::ConvertToOutputFormat(const char* source, +std::string cmLocalGenerator::ConvertToOutputFormat(const std::string& source, OutputFormat output) { std::string result = source; @@ -2627,7 +2628,7 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const char* source, //---------------------------------------------------------------------------- std::string cmLocalGenerator::Convert(RelativeRoot remote, - const char* local, + const std::string& local, OutputFormat output, bool optional) { @@ -2636,10 +2637,10 @@ std::string cmLocalGenerator::Convert(RelativeRoot remote, // The relative root must have a path (i.e. not FULL or NONE) assert(remotePath != 0); - if(local && (!optional || this->UseRelativePaths)) + if(!local.empty() && (!optional || this->UseRelativePaths)) { std::vector components; - cmSystemTools::SplitPath(local, components); + cmSystemTools::SplitPath(local.c_str(), components); std::string result = this->ConvertToRelativePath(components, remotePath); return this->ConvertToOutputFormat(result.c_str(), output); } @@ -2722,7 +2723,8 @@ static bool cmLocalGeneratorNotAbove(const char* a, const char* b) //---------------------------------------------------------------------------- std::string cmLocalGenerator::ConvertToRelativePath(const std::vector& local, - const char* in_remote, bool force) + const std::string& in_remote, + bool force) { // The path should never be quoted. assert(in_remote[0] != '\"'); @@ -2731,7 +2733,7 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector& local, assert(local.size() > 0 && !(local[local.size()-1] == "")); // If the path is already relative then just return the path. - if(!cmSystemTools::FileIsFullPath(in_remote)) + if(!cmSystemTools::FileIsFullPath(in_remote.c_str())) { return in_remote; } @@ -2750,11 +2752,11 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector& local, std::string local_path = cmSystemTools::JoinPath(local); if(!((cmLocalGeneratorNotAbove(local_path.c_str(), this->RelativePathTopBinary.c_str()) && - cmLocalGeneratorNotAbove(in_remote, + cmLocalGeneratorNotAbove(in_remote.c_str(), this->RelativePathTopBinary.c_str())) || (cmLocalGeneratorNotAbove(local_path.c_str(), this->RelativePathTopSource.c_str()) && - cmLocalGeneratorNotAbove(in_remote, + cmLocalGeneratorNotAbove(in_remote.c_str(), this->RelativePathTopSource.c_str())))) { return in_remote; @@ -2764,7 +2766,7 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector& local, // Identify the longest shared path component between the remote // path and the local path. std::vector remote; - cmSystemTools::SplitPath(in_remote, remote); + cmSystemTools::SplitPath(in_remote.c_str(), remote); unsigned int common=0; while(common < remote.size() && common < local.size() && @@ -2982,7 +2984,7 @@ bool cmLocalGeneratorCheckObjectName(std::string& objName, //---------------------------------------------------------------------------- std::string& cmLocalGenerator -::CreateSafeUniqueObjectFileName(const char* sin, +::CreateSafeUniqueObjectFileName(const std::string& sin, std::string const& dir_max) { // Look for an existing mapped name for this object file. diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 74303f4..182b783 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -106,11 +106,12 @@ public: */ enum RelativeRoot { NONE, FULL, HOME, START, HOME_OUTPUT, START_OUTPUT }; enum OutputFormat { UNCHANGED, MAKEFILE, SHELL, RESPONSE }; - std::string ConvertToOutputFormat(const char* source, OutputFormat output); - std::string Convert(const char* remote, RelativeRoot local, + std::string ConvertToOutputFormat(const std::string& source, + OutputFormat output); + std::string Convert(const std::string& remote, RelativeRoot local, OutputFormat output = UNCHANGED, bool optional = false); - std::string Convert(RelativeRoot remote, const char* local, + std::string Convert(RelativeRoot remote, const std::string& local, OutputFormat output = UNCHANGED, bool optional = false); @@ -125,7 +126,7 @@ public: * remote path must use forward slashes and not already be escaped * or quoted. */ - std::string ConvertToOptionallyRelativeOutputPath(const char* remote); + std::string ConvertToOptionallyRelativeOutputPath(const std::string& remote); ///! set/get the parent generator cmLocalGenerator* GetParent(){return this->Parent;} @@ -198,14 +199,14 @@ public: std::string& dep); ///! for existing files convert to output path and short path if spaces - std::string ConvertToOutputForExisting(const char* remote, + std::string ConvertToOutputForExisting(const std::string& remote, RelativeRoot local = START_OUTPUT, OutputFormat format = SHELL); /** For existing path identified by RelativeRoot convert to output path and short path if spaces. */ std::string ConvertToOutputForExisting(RelativeRoot remote, - const char* local = 0, + const std::string& local = "", OutputFormat format = SHELL); virtual std::string ConvertToIncludeReference(std::string const& path, @@ -309,7 +310,8 @@ public: * or quoted. */ std::string ConvertToRelativePath(const std::vector& local, - const char* remote, bool force=false); + const std::string& remote, + bool force=false); /** * Get the relative path from the generator output directory to a @@ -410,7 +412,7 @@ protected: std::ostream& os, const char* config, std::vector const& configurationTypes); - std::string& CreateSafeUniqueObjectFileName(const char* sin, + std::string& CreateSafeUniqueObjectFileName(const std::string& sin, std::string const& dir_max); void ComputeObjectMaxPath(); @@ -472,7 +474,7 @@ protected: cmIML_INT_uint64_t BackwardsCompatibility; bool BackwardsCompatibilityFinal; private: - std::string ConvertToOutputForExistingCommon(const char* remote, + std::string ConvertToOutputForExistingCommon(const std::string& remote, std::string const& result, OutputFormat format); diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 8ab65bf..baae2b0 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -269,7 +269,7 @@ protected: //================================================================== // Convenience routines that do nothing more than forward to // implementaitons - std::string Convert(const char* source, + std::string Convert(const std::string& source, cmLocalGenerator::RelativeRoot relative, cmLocalGenerator::OutputFormat output = cmLocalGenerator::UNCHANGED, -- cgit v0.12 From fabf1fbabb4fc67844d5b2210e70a9829a59ff23 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 6 Feb 2014 17:31:47 -0500 Subject: stringapi: Use strings in target name --- Source/CTest/cmCTestBuildCommand.cxx | 3 +- Source/cmBuildCommand.cxx | 6 +-- Source/cmComputeLinkDepends.cxx | 9 ++-- Source/cmComputeLinkDepends.h | 3 +- Source/cmComputeLinkInformation.cxx | 2 +- Source/cmComputeTargetDepends.cxx | 15 +++--- Source/cmComputeTargetDepends.h | 8 +-- Source/cmCoreTryCompile.cxx | 11 +++-- Source/cmCoreTryCompile.h | 2 +- Source/cmExtraCodeBlocksGenerator.cxx | 5 +- Source/cmExtraCodeBlocksGenerator.h | 4 +- Source/cmExtraSublimeTextGenerator.cxx | 5 +- Source/cmExtraSublimeTextGenerator.h | 4 +- Source/cmGeneratorTarget.cxx | 4 +- Source/cmGeneratorTarget.h | 2 +- Source/cmGetPropertyCommand.cxx | 2 +- Source/cmGlobalGenerator.cxx | 24 ++++----- Source/cmGlobalGenerator.h | 19 +++---- Source/cmGlobalNinjaGenerator.cxx | 6 +-- Source/cmGlobalNinjaGenerator.h | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 12 ++--- Source/cmGlobalUnixMakefileGenerator3.h | 2 +- Source/cmGlobalVisualStudio10Generator.cxx | 13 ++--- Source/cmGlobalVisualStudio10Generator.h | 2 +- Source/cmGlobalVisualStudio6Generator.cxx | 11 +++-- Source/cmGlobalVisualStudio6Generator.h | 2 +- Source/cmGlobalVisualStudio7Generator.cxx | 13 ++--- Source/cmGlobalVisualStudio7Generator.h | 2 +- Source/cmGlobalVisualStudio8Generator.cxx | 2 +- Source/cmGlobalVisualStudioGenerator.cxx | 6 +-- Source/cmGlobalVisualStudioGenerator.h | 4 +- Source/cmGlobalXCodeGenerator.cxx | 23 ++++----- Source/cmGlobalXCodeGenerator.h | 4 +- Source/cmGraphVizWriter.cxx | 8 +-- Source/cmGraphVizWriter.h | 8 +-- Source/cmLocalGenerator.cxx | 20 ++++---- Source/cmLocalGenerator.h | 6 +-- Source/cmLocalUnixMakefileGenerator3.cxx | 14 +++--- Source/cmLocalUnixMakefileGenerator3.h | 9 ++-- Source/cmLocalVisualStudio6Generator.cxx | 22 ++++----- Source/cmLocalVisualStudio6Generator.h | 12 ++--- Source/cmLocalVisualStudio7Generator.cxx | 30 ++++++------ Source/cmLocalVisualStudio7Generator.h | 17 ++++--- Source/cmMakefile.cxx | 68 ++++++++++++-------------- Source/cmMakefile.h | 29 +++++------ Source/cmMakefileExecutableTargetGenerator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 4 +- Source/cmMakefileTargetGenerator.cxx | 6 +-- Source/cmMakefileTargetGenerator.h | 2 +- Source/cmMakefileUtilityTargetGenerator.cxx | 2 +- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- Source/cmQtAutoGenerators.cxx | 14 +++--- Source/cmSetPropertyCommand.cxx | 2 +- Source/cmSetTargetPropertiesCommand.cxx | 2 +- Source/cmSetTargetPropertiesCommand.h | 2 +- Source/cmTarget.cxx | 28 ++++++----- Source/cmTarget.h | 18 +++---- Source/cmXCodeObject.h | 2 +- 58 files changed, 287 insertions(+), 274 deletions(-) diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index 12ff718..9738bde 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -130,7 +130,8 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory"); std::string buildCommand = this->GlobalGenerator-> - GenerateCMakeBuildCommand(cmakeBuildTarget, cmakeBuildConfiguration, + GenerateCMakeBuildCommand(cmakeBuildTarget ? cmakeBuildTarget : "", + cmakeBuildConfiguration, cmakeBuildAdditionalFlags, true); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SetMakeCommand:" diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx index c06b8ad..d8e1a2c 100644 --- a/Source/cmBuildCommand.cxx +++ b/Source/cmBuildCommand.cxx @@ -44,7 +44,7 @@ bool cmBuildCommand // Parse remaining arguments. const char* configuration = 0; const char* project_name = 0; - const char* target = 0; + std::string target; enum Doing { DoingNone, DoingConfiguration, DoingProjectName, DoingTarget }; Doing doing = DoingNone; for(unsigned int i=1; i < args.size(); ++i) @@ -74,7 +74,7 @@ bool cmBuildCommand else if(doing == DoingTarget) { doing = DoingNone; - target = args[i].c_str(); + target = args[i]; } else { @@ -136,7 +136,7 @@ bool cmBuildCommand } std::string makecommand = this->Makefile->GetLocalGenerator() - ->GetGlobalGenerator()->GenerateCMakeBuildCommand(0, configType.c_str(), + ->GetGlobalGenerator()->GenerateCMakeBuildCommand("", configType.c_str(), 0, true); if(cacheValue) diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 1be5980..d51e6e6 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -254,7 +254,8 @@ cmComputeLinkDepends::Compute() "---------------------------------------" "---------------------------------------\n"); fprintf(stderr, "Link dependency analysis for target %s, config %s\n", - this->Target->GetName(), this->Config?this->Config:"noconfig"); + this->Target->GetName().c_str(), + this->Config?this->Config:"noconfig"); this->DisplayConstraintGraph(); } @@ -620,7 +621,7 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index, //---------------------------------------------------------------------------- cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, - const char* name) + const std::string& name) { // Look for a target in the scope of the depender. cmMakefile* mf = this->Makefile; @@ -968,14 +969,14 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) //---------------------------------------------------------------------------- void cmComputeLinkDepends::DisplayFinalEntries() { - fprintf(stderr, "target [%s] links to:\n", this->Target->GetName()); + fprintf(stderr, "target [%s] links to:\n", this->Target->GetName().c_str()); for(std::vector::const_iterator lei = this->FinalLinkEntries.begin(); lei != this->FinalLinkEntries.end(); ++lei) { if(lei->Target) { - fprintf(stderr, " target [%s]\n", lei->Target->GetName()); + fprintf(stderr, " target [%s]\n", lei->Target->GetName().c_str()); } else { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 9776f55..26bf6db 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -83,7 +83,8 @@ private: void AddDirectLinkEntries(); void AddLinkEntries(int depender_index, std::vector const& libs); - cmTarget const* FindTargetToLink(int depender_index, const char* name); + cmTarget const* FindTargetToLink(int depender_index, + const std::string& name); // One entry for each unique item. std::vector EntryList; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 716eb4d..23a6671 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -500,7 +500,7 @@ bool cmComputeLinkInformation::Compute() { cmSystemTools:: Error("CMake can not determine linker language for target: ", - this->Target->GetName()); + this->Target->GetName().c_str()); return false; } diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 6511510..83d1e2e 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -298,7 +298,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, //---------------------------------------------------------------------------- void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, - const char* dependee_name, + const std::string& dependee_name, bool linking, std::set &emitted) { @@ -333,7 +333,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, //---------------------------------------------------------------------------- void cmComputeTargetDepends::AddTargetDepend(int depender_index, - const char* dependee_name, + const std::string& dependee_name, bool linking) { // Get the depender. @@ -434,22 +434,23 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, //---------------------------------------------------------------------------- void -cmComputeTargetDepends::DisplayGraph(Graph const& graph, const char* name) +cmComputeTargetDepends::DisplayGraph(Graph const& graph, + const std::string& name) { - fprintf(stderr, "The %s target dependency graph is:\n", name); + fprintf(stderr, "The %s target dependency graph is:\n", name.c_str()); int n = static_cast(graph.size()); for(int depender_index = 0; depender_index < n; ++depender_index) { EdgeList const& nl = graph[depender_index]; cmTarget const* depender = this->Targets[depender_index]; fprintf(stderr, "target %d is [%s]\n", - depender_index, depender->GetName()); + depender_index, depender->GetName().c_str()); for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { int dependee_index = *ni; cmTarget const* dependee = this->Targets[dependee_index]; fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index, - dependee->GetName(), ni->IsStrong()? "strong" : "weak"); + dependee->GetName().c_str(), ni->IsStrong()? "strong" : "weak"); } } fprintf(stderr, "\n"); @@ -471,7 +472,7 @@ cmComputeTargetDepends { int i = *ni; fprintf(stderr, " contains target %d [%s]\n", - i, this->Targets[i]->GetName()); + i, this->Targets[i]->GetName().c_str()); } } fprintf(stderr, "\n"); diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index 6cd6da0..dcb450a 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -45,12 +45,14 @@ private: void CollectTargets(); void CollectDepends(); void CollectTargetDepends(int depender_index); - void AddTargetDepend(int depender_index, const char* dependee_name, + void AddTargetDepend(int depender_index, + const std::string& dependee_name, bool linking); void AddTargetDepend(int depender_index, cmTarget const* dependee, bool linking); bool ComputeFinalDepends(cmComputeComponentGraph const& ccg); - void AddInterfaceDepends(int depender_index, const char* dependee_name, + void AddInterfaceDepends(int depender_index, + const std::string& dependee_name, bool linking, std::set &emitted); void AddInterfaceDepends(int depender_index, cmTarget const* dependee, const char *config, @@ -71,7 +73,7 @@ private: typedef cmGraphAdjacencyList Graph; Graph InitialGraph; Graph FinalGraph; - void DisplayGraph(Graph const& graph, const char* name); + void DisplayGraph(Graph const& graph, const std::string& name); // Deal with connected components. void DisplayComponents(cmComputeComponentGraph const& ccg); diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 1e8e4d0..b0e2b6f 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -28,7 +28,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) const char* sourceDirectory = argv[2].c_str(); const char* projectName = 0; - const char* targetName = 0; + std::string targetName; std::vector cmakeFlags; std::vector compileDefs; std::string outputVariable; @@ -450,7 +450,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n", this->BinaryDirectory.c_str()); /* Create the actual executable. */ - fprintf(fout, "add_executable(%s", targetName); + fprintf(fout, "add_executable(%s", targetName.c_str()); for(std::vector::iterator si = sources.begin(); si != sources.end(); ++si) { @@ -466,12 +466,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) if (useOldLinkLibs) { fprintf(fout, - "target_link_libraries(%s ${LINK_LIBRARIES})\n",targetName); + "target_link_libraries(%s ${LINK_LIBRARIES})\n", + targetName.c_str()); } else { fprintf(fout, "target_link_libraries(%s %s)\n", - targetName, + targetName.c_str(), libsToLink.c_str()); } fclose(fout); @@ -610,7 +611,7 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir) } } -void cmCoreTryCompile::FindOutputFile(const char* targetName) +void cmCoreTryCompile::FindOutputFile(const std::string& targetName) { this->FindErrorMessage = ""; this->OutputFile = ""; diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h index 5c67f13..3272462 100644 --- a/Source/cmCoreTryCompile.h +++ b/Source/cmCoreTryCompile.h @@ -44,7 +44,7 @@ public: TryCompileCode. The result is stored in OutputFile. If nothing is found, the error message is stored in FindErrorMessage. */ - void FindOutputFile(const char* targetName); + void FindOutputFile(const std::string& targetName); cmTypeMacro(cmCoreTryCompile, cmCommand); diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 8d4cf85..1339969 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -537,7 +537,7 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile( // Generate the xml code for one target. void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, - const char* targetName, + const std::string& targetName, cmTarget* target, const char* make, const cmMakefile* makefile, @@ -757,7 +757,8 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmTarget* target) // Create the command line for building the given target using the selected // make std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( - const std::string& make, const char* makefile, const char* target) + const std::string& make, const char* makefile, + const std::string& target) { std::string command = make; if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0) diff --git a/Source/cmExtraCodeBlocksGenerator.h b/Source/cmExtraCodeBlocksGenerator.h index e0a64ca..1cbc3f3 100644 --- a/Source/cmExtraCodeBlocksGenerator.h +++ b/Source/cmExtraCodeBlocksGenerator.h @@ -49,9 +49,9 @@ private: std::string GetCBCompilerId(const cmMakefile* mf); int GetCBTargetType(cmTarget* target); std::string BuildMakeCommand(const std::string& make, const char* makefile, - const char* target); + const std::string& target); void AppendTarget(cmGeneratedFileStream& fout, - const char* targetName, + const std::string& targetName, cmTarget* target, const char* make, const cmMakefile* makefile, diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 1c9ac02..3cfafa7 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -223,7 +223,7 @@ void cmExtraSublimeTextGenerator:: void cmExtraSublimeTextGenerator:: AppendTarget(cmGeneratedFileStream& fout, - const char* targetName, + const std::string& targetName, cmLocalGenerator* lg, cmTarget* target, const char* make, @@ -315,7 +315,8 @@ void cmExtraSublimeTextGenerator:: // Create the command line for building the given target using the selected // make std::string cmExtraSublimeTextGenerator::BuildMakeCommand( - const std::string& make, const char* makefile, const char* target) + const std::string& make, const char* makefile, + const std::string& target) { std::string command = "\""; command += make + "\""; diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h index 7902593..44dfb31 100644 --- a/Source/cmExtraSublimeTextGenerator.h +++ b/Source/cmExtraSublimeTextGenerator.h @@ -60,12 +60,12 @@ private: * specified target. */ std::string BuildMakeCommand(const std::string& make, const char* makefile, - const char* target); + const std::string& target); /** Appends the specified target to the generated project file as a Sublime * Text build system. */ void AppendTarget(cmGeneratedFileStream& fout, - const char* targetName, + const std::string& targetName, cmLocalGenerator* lg, cmTarget* target, const char* make, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4e7c71e..7f22e00 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -228,7 +228,7 @@ int cmGeneratorTarget::GetType() const } //---------------------------------------------------------------------------- -const char *cmGeneratorTarget::GetName() const +std::string cmGeneratorTarget::GetName() const { return this->Target->GetName(); } @@ -988,7 +988,7 @@ void cmGeneratorTarget::GenerateTargetManifest(const char* config) const bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { - int nameResult = strcmp(t1->GetName(), t2->GetName()); + int nameResult = strcmp(t1->GetName().c_str(), t2->GetName().c_str()); if (nameResult == 0) { return strcmp(t1->GetMakefile()->GetStartOutputDirectory(), diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6e19f7d..b15bade 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -27,7 +27,7 @@ public: cmGeneratorTarget(cmTarget*); int GetType() const; - const char *GetName() const; + std::string GetName() const; const char *GetProperty(const std::string& prop) const; bool GetPropertyAsBool(const std::string& prop) const; void GetSourceFiles(std::vector& files) const; diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index 33c43ca..30bec16 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -295,7 +295,7 @@ bool cmGetPropertyCommand::HandleTargetMode() if(cmTarget* target = this->Makefile->FindTargetToUse(this->Name)) { - return this->StoreResult(target->GetName()); + return this->StoreResult(target->GetName().c_str()); } } return this->StoreResult((this->Variable + "-NOTFOUND").c_str()); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 7e93676..795048b 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1616,7 +1616,7 @@ void cmGlobalGenerator::CheckLocalGenerators() int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, const char *projectName, - const char *target, bool fast, + const std::string& target, bool fast, std::string *output, cmMakefile *mf) { // if this is not set, then this is a first time configure @@ -1640,7 +1640,7 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, } std::string newTarget; - if (target && strlen(target)) + if (!target.empty()) { newTarget += target; #if 0 @@ -1664,7 +1664,7 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, void cmGlobalGenerator::GenerateBuildCommand( std::vector& makeCommand, const char*, const char*, const char*, - const char*, const char*, bool, std::vector const&) + const std::string&, const char*, bool, std::vector const&) { makeCommand.push_back( "cmGlobalGenerator::GenerateBuildCommand not implemented"); @@ -1672,7 +1672,7 @@ void cmGlobalGenerator::GenerateBuildCommand( int cmGlobalGenerator::Build( const char *, const char *bindir, - const char *projectName, const char *target, + const char *projectName, const std::string& target, std::string *output, const char *makeCommandCSTR, const char *config, @@ -1787,7 +1787,7 @@ int cmGlobalGenerator::Build( //---------------------------------------------------------------------------- std::string cmGlobalGenerator::GenerateCMakeBuildCommand( - const char* target, const char* config, const char* native, + const std::string& target, const char* config, const char* native, bool ignoreErrors) { std::string makeCommand = cmSystemTools::GetCMakeCommand(); @@ -1799,7 +1799,7 @@ std::string cmGlobalGenerator::GenerateCMakeBuildCommand( makeCommand += config; makeCommand += "\""; } - if(target && *target) + if(!target.empty()) { makeCommand += " --target \""; makeCommand += target; @@ -2041,7 +2041,7 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() ///! Find a local generator by its startdirectory cmLocalGenerator* -cmGlobalGenerator::FindLocalGenerator(const char* start_dir) const +cmGlobalGenerator::FindLocalGenerator(const std::string& start_dir) const { for(std::vector::const_iterator it = this->LocalGenerators.begin(); it != this->LocalGenerators.end(); ++it) @@ -2056,20 +2056,20 @@ cmGlobalGenerator::FindLocalGenerator(const char* start_dir) const } //---------------------------------------------------------------------------- -void cmGlobalGenerator::AddAlias(const char *name, cmTarget *tgt) +void cmGlobalGenerator::AddAlias(const std::string& name, cmTarget *tgt) { this->AliasTargets[name] = tgt; } //---------------------------------------------------------------------------- -bool cmGlobalGenerator::IsAlias(const char *name) const +bool cmGlobalGenerator::IsAlias(const std::string& name) const { return this->AliasTargets.find(name) != this->AliasTargets.end(); } //---------------------------------------------------------------------------- cmTarget* -cmGlobalGenerator::FindTarget(const char* project, const char* name, +cmGlobalGenerator::FindTarget(const char* project, const std::string& name, bool excludeAliases) const { // if project specific @@ -2481,7 +2481,7 @@ void cmGlobalGenerator::EnableMinGWLanguage(cmMakefile *mf) //---------------------------------------------------------------------------- cmTarget cmGlobalGenerator::CreateGlobalTarget( - const char* name, const char* message, + const std::string& name, const char* message, const cmCustomCommandLines* commandLines, std::vector depends, const char* workingDirectory) @@ -2672,7 +2672,7 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets, bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) const { return (target->GetType() == cmTarget::GLOBAL_TARGET || - strcmp(target->GetName(), this->GetAllTargetName()) == 0); + target->GetName() == this->GetAllTargetName()); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 2f23fd5..38d7f58 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -106,7 +106,8 @@ public: * loaded commands, not as part of the usual build process. */ virtual int TryCompile(const char *srcdir, const char *bindir, - const char *projectName, const char *targetName, + const char *projectName, + const std::string& targetName, bool fast, std::string *output, cmMakefile* mf); @@ -117,7 +118,7 @@ public: * done first. */ int Build(const char *srcdir, const char *bindir, - const char *projectName, const char *targetName, + const char *projectName, const std::string& targetName, std::string *output, const char *makeProgram, const char *config, bool clean, bool fast, @@ -130,12 +131,12 @@ public: std::vector& makeCommand, const char* makeProgram, const char *projectName, const char *projectDir, - const char *targetName, const char* config, bool fast, + const std::string& targetName, const char* config, bool fast, std::vector const& makeOptions = std::vector() ); /** Generate a "cmake --build" call for a given target and config. */ - std::string GenerateCMakeBuildCommand(const char* target, + std::string GenerateCMakeBuildCommand(const std::string& target, const char* config, const char* native, bool ignoreErrors); @@ -210,11 +211,11 @@ public: virtual void FindMakeProgram(cmMakefile*); ///! Find a target by name by searching the local generators. - cmTarget* FindTarget(const char* project, const char* name, + cmTarget* FindTarget(const char* project, const std::string& name, bool excludeAliases = false) const; - void AddAlias(const char *name, cmTarget *tgt); - bool IsAlias(const char *name) const; + void AddAlias(const std::string& name, cmTarget *tgt); + bool IsAlias(const std::string& name) const; /** Determine if a name resolves to a framework on disk or a built target that is a framework. */ @@ -224,7 +225,7 @@ public: target in the project */ bool IsDependedOn(const char* project, cmTarget const* target); ///! Find a local generator by its startdirectory - cmLocalGenerator* FindLocalGenerator(const char* start_dir) const; + cmLocalGenerator* FindLocalGenerator(const std::string& start_dir) const; /** Append the subdirectory for the given configuration. If anything is appended the given prefix and suffix will be appended around it, which @@ -355,7 +356,7 @@ protected: bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const; void FillLocalGeneratorToTargetMap(); void CreateDefaultGlobalTargets(cmTargets* targets); - cmTarget CreateGlobalTarget(const char* name, const char* message, + cmTarget CreateGlobalTarget(const std::string& name, const char* message, const cmCustomCommandLines* commandLines, std::vector depends, const char* workingDir); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 731bc00..b027995 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -554,7 +554,7 @@ void cmGlobalNinjaGenerator const char* makeProgram, const char* /*projectName*/, const char* /*projectDir*/, - const char* targetName, + const std::string& targetName, const char* /*config*/, bool /*fast*/, std::vector const& makeOptions) @@ -565,9 +565,9 @@ void cmGlobalNinjaGenerator makeCommand.insert(makeCommand.end(), makeOptions.begin(), makeOptions.end()); - if(targetName && *targetName) + if(!targetName.empty()) { - if(strcmp(targetName, "clean") == 0) + if(targetName == "clean") { makeCommand.push_back("-t"); makeCommand.push_back("clean"); diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 0d5fb44..41d1510 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -196,7 +196,7 @@ public: const char* makeProgram, const char* projectName, const char* projectDir, - const char* targetName, + const std::string& targetName, const char* config, bool fast, std::vector const& makeOptions = std::vector() diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 0b37a07..74b8e98 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -568,7 +568,7 @@ void cmGlobalUnixMakefileGenerator3 const char* makeProgram, const char* /*projectName*/, const char* /*projectDir*/, - const char* targetName, + const std::string& targetName, const char* /*config*/, bool fast, std::vector const& makeOptions) @@ -585,7 +585,7 @@ void cmGlobalUnixMakefileGenerator3 } makeCommand.insert(makeCommand.end(), makeOptions.begin(), makeOptions.end()); - if ( targetName && strlen(targetName)) + if (!targetName.empty()) { cmLocalUnixMakefileGenerator3 *lg; if (this->LocalGenerators.size()) @@ -649,8 +649,7 @@ cmGlobalUnixMakefileGenerator3 } // Don't emit the same rule twice (e.g. two targets with the same // simple name) - if(t->second->GetName() && - strlen(t->second->GetName()) && + if(!t->second->GetName().empty() && emitted.insert(t->second->GetName()).second && // Handle user targets here. Global targets are handled in // the local generator on a per-directory basis. @@ -746,8 +745,7 @@ cmGlobalUnixMakefileGenerator3 { continue; } - if (t->second->GetName() - && strlen(t->second->GetName()) + if (!t->second->GetName().empty() && ((t->second->GetType() == cmTarget::EXECUTABLE) || (t->second->GetType() == cmTarget::STATIC_LIBRARY) || (t->second->GetType() == cmTarget::SHARED_LIBRARY) @@ -975,7 +973,7 @@ cmGlobalUnixMakefileGenerator3::ProgressMapCompare ::operator()(cmTarget const* l, cmTarget const* r) const { // Order by target name. - if(int c = strcmp(l->GetName(), r->GetName())) + if(int c = strcmp(l->GetName().c_str(), r->GetName().c_str())) { return c < 0; } diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 9173751..f97ae9b 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -112,7 +112,7 @@ public: const char* makeProgram, const char* projectName, const char* projectDir, - const char* targetName, + const std::string& targetName, const char* config, bool fast, std::vector const& makeOptions = std::vector() diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 6983ef9..1346e13 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -313,7 +313,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( const char* makeProgram, const char* projectName, const char* projectDir, - const char* targetName, + const std::string& targetName, const char* config, bool fast, std::vector const& makeOptions) @@ -369,25 +369,26 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( makeCommand.push_back(makeProgramSelected); + std::string realTarget = targetName; // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD - if(!targetName || strlen(targetName) == 0) + if(realTarget.empty()) { - targetName = "ALL_BUILD"; + realTarget = "ALL_BUILD"; } - if ( targetName && strcmp(targetName, "clean") == 0 ) + if ( realTarget == "clean" ) { makeCommand.push_back(std::string(projectName)+".sln"); makeCommand.push_back("/t:Clean"); } else { - std::string targetProject(targetName); + std::string targetProject(realTarget); targetProject += ".vcxproj"; if (targetProject.find('/') == std::string::npos) { // it might be in a subdir if (cmSlnProjectEntry const* proj = - slnData.GetProjectByName(targetName)) + slnData.GetProjectByName(realTarget)) { targetProject = proj->GetRelativePath(); cmSystemTools::ConvertToUnixSlashes(targetProject); diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 976d41f..198e113 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -37,7 +37,7 @@ public: const char* makeProgram, const char* projectName, const char* projectDir, - const char* targetName, + const std::string& targetName, const char* config, bool fast, std::vector const& makeOptions = std::vector() diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 6c458c3..534a493 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -119,7 +119,7 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand( const char* makeProgram, const char* projectName, const char* /*projectDir*/, - const char* targetName, + const std::string& targetName, const char* config, bool /*fast*/, std::vector const& makeOptions @@ -134,14 +134,15 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand( makeCommand.push_back("/MAKE"); std::string targetArg; bool clean = false; - if ( targetName && strcmp(targetName, "clean") == 0 ) + std::string realTarget = targetName; + if ( realTarget == "clean" ) { clean = true; - targetName = "ALL_BUILD"; + realTarget = "ALL_BUILD"; } - if (targetName && strlen(targetName)) + if (!realTarget.empty()) { - targetArg += targetName; + targetArg += realTarget; } else { diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 5521410..40b8462 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -57,7 +57,7 @@ public: const char* makeProgram, const char* projectName, const char* projectDir, - const char* targetName, + const std::string& targetName, const char* config, bool fast, std::vector const& makeOptions = std::vector() diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index bb63289..5c7af00 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -186,7 +186,7 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand( const char* makeProgram, const char* projectName, const char* /*projectDir*/, - const char* targetName, + const std::string& targetName, const char* config, bool /*fast*/, std::vector const& makeOptions) @@ -208,11 +208,12 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand( makeCommand.push_back(makeProgramSelected); makeCommand.push_back(std::string(projectName) + ".sln"); + std::string realTarget = targetName; bool clean = false; - if ( targetName && strcmp(targetName, "clean") == 0 ) + if ( realTarget == "clean" ) { clean = true; - targetName = "ALL_BUILD"; + realTarget = "ALL_BUILD"; } if(clean) { @@ -233,9 +234,9 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand( } makeCommand.push_back("/project"); - if (targetName && strlen(targetName)) + if (!realTarget.empty()) { - makeCommand.push_back(targetName); + makeCommand.push_back(realTarget); } else { @@ -381,7 +382,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( std::set allConfigurations(this->Configurations.begin(), this->Configurations.end()); this->WriteProjectConfigurations( - fout, target->GetName(), target->GetType(), + fout, target->GetName().c_str(), target->GetType(), allConfigurations, target->GetProperty("VS_PLATFORM_MAPPING")); } else diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index f69bd84..a7aca60 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -65,7 +65,7 @@ public: const char* makeProgram, const char* projectName, const char* projectDir, - const char* targetName, + const std::string& targetName, const char* config, bool fast, std::vector const& makeOptions = std::vector() diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 12c240b..0453333 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -426,7 +426,7 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends( { continue; } - std::string guid = this->GetGUID((*i)->GetName()); + std::string guid = this->GetGUID((*i)->GetName().c_str()); fout << "\t\t{" << guid << "} = {" << guid << "}\n"; } } diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 0c5f35b..d388034 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -870,15 +870,15 @@ cmGlobalVisualStudioGenerator::TargetCompare ::operator()(cmTarget const* l, cmTarget const* r) const { // Make sure ALL_BUILD is first so it is the default active project. - if(strcmp(r->GetName(), "ALL_BUILD") == 0) + if(r->GetName() == "ALL_BUILD") { return false; } - if(strcmp(l->GetName(), "ALL_BUILD") == 0) + if(l->GetName() == "ALL_BUILD") { return true; } - return strcmp(l->GetName(), r->GetName()) < 0; + return strcmp(l->GetName().c_str(), r->GetName().c_str()) < 0; } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 4b73118..b1fa838 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -104,8 +104,8 @@ protected: VSDependMap VSTargetDepends; void ComputeVSTargetDepends(cmTarget&); - bool CheckTargetLinks(cmTarget& target, const char* name); - std::string GetUtilityForTarget(cmTarget& target, const char*); + bool CheckTargetLinks(cmTarget& target, const std::string& name); + std::string GetUtilityForTarget(cmTarget& target, const std::string&); virtual std::string WriteUtilityDepend(cmTarget const*) = 0; std::string GetUtilityDepend(cmTarget const* target); typedef std::map UtilityDependsMap; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 3f24167..9e1e902 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -263,7 +263,7 @@ cmGlobalXCodeGenerator::GenerateBuildCommand( const char* makeProgram, const char* projectName, const char* /*projectDir*/, - const char* targetName, + const std::string& targetName, const char* config, bool /*fast*/, std::vector const& makeOptions) @@ -283,10 +283,11 @@ cmGlobalXCodeGenerator::GenerateBuildCommand( makeCommand.push_back(projectArg); bool clean = false; - if ( targetName && strcmp(targetName, "clean") == 0 ) + std::string realTarget = targetName; + if ( realTarget == "clean" ) { clean = true; - targetName = "ALL_BUILD"; + realTarget = "ALL_BUILD"; } if(clean) { @@ -302,9 +303,9 @@ cmGlobalXCodeGenerator::GenerateBuildCommand( { config = 0; } - if (targetName && strlen(targetName)) + if (!realTarget.empty()) { - makeCommand.push_back(targetName); + makeCommand.push_back(realTarget); } else { @@ -1737,7 +1738,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { cmSystemTools::Error ("CMake can not determine linker language for target: ", - target.GetName()); + target.GetName().c_str()); return; } @@ -2420,7 +2421,7 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXAggregateTarget); - target->SetComment(cmtarget.GetName()); + target->SetComment(cmtarget.GetName().c_str()); cmXCodeObject* buildPhases = this->CreateObject(cmXCodeObject::OBJECT_LIST); std::vector emptyContentVector; @@ -2621,7 +2622,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, fileRef->AddAttribute("refType", this->CreateString("0")); fileRef->AddAttribute("sourceTree", this->CreateString("BUILT_PRODUCTS_DIR")); - fileRef->SetComment(cmtarget.GetName()); + fileRef->SetComment(cmtarget.GetName().c_str()); target->AddAttribute("productReference", this->CreateObjectReference(fileRef)); if(const char* productType = this->GetTargetProductType(cmtarget)) @@ -2654,8 +2655,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t) } //---------------------------------------------------------------------------- -std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name, - const char* id) +std::string cmGlobalXCodeGenerator::GetOrCreateId(const std::string& name, + const std::string& id) { std::string guidStoreName = name; guidStoreName += "_GUID_CMAKE"; @@ -2668,7 +2669,7 @@ std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name, } this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(), - id, "Stored Xcode object GUID", cmCacheManager::INTERNAL); + id.c_str(), "Stored Xcode object GUID", cmCacheManager::INTERNAL); return id; } diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 15f1363..0cb1758 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -58,7 +58,7 @@ public: const char* makeProgram, const char* projectName, const char* projectDir, - const char* targetName, + const std::string& targetName, const char* config, bool fast, std::vector const& makeOptions = std::vector() @@ -129,7 +129,7 @@ private: ); cmXCodeObject* FindXCodeTarget(cmTarget const*); - std::string GetOrCreateId(const char* name, const char* id); + std::string GetOrCreateId(const std::string& name, const std::string& id); // create cmXCodeObject from these functions so that memory can be managed // correctly. All objects created are stored in this->XCodeObjects. diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index db964a9..6173d21 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -300,7 +300,7 @@ void cmGraphVizWriter::WriteFooter(cmGeneratedFileStream& str) const } -void cmGraphVizWriter::WriteConnections(const char* targetName, +void cmGraphVizWriter::WriteConnections(const std::string& targetName, std::set& insertedNodes, std::set& insertedConnections, cmGeneratedFileStream& str) const @@ -359,7 +359,7 @@ void cmGraphVizWriter::WriteConnections(const char* targetName, } -void cmGraphVizWriter::WriteDependerConnections(const char* targetName, +void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName, std::set& insertedNodes, std::set& insertedConnections, cmGeneratedFileStream& str) const @@ -444,7 +444,7 @@ void cmGraphVizWriter::WriteDependerConnections(const char* targetName, } -void cmGraphVizWriter::WriteNode(const char* targetName, +void cmGraphVizWriter::WriteNode(const std::string& targetName, const cmTarget* target, std::set& insertedNodes, cmGeneratedFileStream& str) const @@ -558,7 +558,7 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt) } -bool cmGraphVizWriter::IgnoreThisTarget(const char* name) +bool cmGraphVizWriter::IgnoreThisTarget(const std::string& name) { for(std::vector::iterator itvIt = this->TargetsToIgnoreRegex.begin(); diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h index 17b97f8..6af460b 100644 --- a/Source/cmGraphVizWriter.h +++ b/Source/cmGraphVizWriter.h @@ -44,23 +44,23 @@ protected: void WriteHeader(cmGeneratedFileStream& str) const; - void WriteConnections(const char* targetName, + void WriteConnections(const std::string& targetName, std::set& insertedNodes, std::set& insertedConnections, cmGeneratedFileStream& str) const; - void WriteDependerConnections(const char* targetName, + void WriteDependerConnections(const std::string& targetName, std::set& insertedNodes, std::set& insertedConnections, cmGeneratedFileStream& str) const; - void WriteNode(const char* targetName, const cmTarget* target, + void WriteNode(const std::string& targetName, const cmTarget* target, std::set& insertedNodes, cmGeneratedFileStream& str) const; void WriteFooter(cmGeneratedFileStream& str) const; - bool IgnoreThisTarget(const char* name); + bool IgnoreThisTarget(const std::string& name); bool GenerateForTargetType(cmTarget::TargetType targetType) const; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index e1abfef..ded4fc6 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -781,7 +781,7 @@ void cmLocalGenerator { cmSystemTools::Error ("CMake can not determine linker language for target: ", - target.Target->GetName()); + target.Target->GetName().c_str()); return; } // if the language is not in the set lang then create custom @@ -1695,7 +1695,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { cmSystemTools::Error ("CMake can not determine linker language for target: ", - target->Target->GetName()); + target->Target->GetName().c_str()); return; } this->AddLanguageFlags(flags, linkLanguage, buildType.c_str()); @@ -2012,7 +2012,7 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, } //---------------------------------------------------------------------------- -bool cmLocalGenerator::GetRealDependency(const char* inName, +bool cmLocalGenerator::GetRealDependency(const std::string& inName, const char* config, std::string& dep) { @@ -2040,7 +2040,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, { // make sure it is not just a coincidence that the target name // found is part of the inName - if(cmSystemTools::FileIsFullPath(inName)) + if(cmSystemTools::FileIsFullPath(inName.c_str())) { std::string tLocation; if(target->GetType() >= cmTarget::EXECUTABLE && @@ -2088,7 +2088,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, } // The name was not that of a CMake target. It must name a file. - if(cmSystemTools::FileIsFullPath(inName)) + if(cmSystemTools::FileIsFullPath(inName.c_str())) { // This is a full path. Return it as given. dep = inName; @@ -3474,7 +3474,7 @@ static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, //---------------------------------------------------------------------------- void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, - const char* targetName, + const std::string& targetName, const char* fname) { // Find the Info.plist template. @@ -3503,7 +3503,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, // back to the directory-level values set by the user. cmMakefile* mf = this->Makefile; mf->PushScope(); - mf->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", targetName); + mf->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", targetName.c_str()); cmLGInfoProp(mf, target, "MACOSX_BUNDLE_INFO_STRING"); cmLGInfoProp(mf, target, "MACOSX_BUNDLE_ICON_FILE"); cmLGInfoProp(mf, target, "MACOSX_BUNDLE_GUI_IDENTIFIER"); @@ -3518,8 +3518,8 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, //---------------------------------------------------------------------------- void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target, - const char* targetName, - const char* fname) + const std::string& targetName, + const char* fname) { // Find the Info.plist template. const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST"); @@ -3547,7 +3547,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target, // back to the directory-level values set by the user. cmMakefile* mf = this->Makefile; mf->PushScope(); - mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName); + mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName.c_str()); cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_ICON_FILE"); cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_IDENTIFIER"); cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_SHORT_VERSION_STRING"); diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 182b783..c1deb09 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -195,7 +195,7 @@ public: * the source directory of this generator. This should only be * used for dependencies of custom commands. */ - bool GetRealDependency(const char* name, const char* config, + bool GetRealDependency(const std::string& name, const char* config, std::string& dep); ///! for existing files convert to output path and short path if spaces @@ -339,14 +339,14 @@ public: /** * Generate a Mac OS X application bundle Info.plist file. */ - void GenerateAppleInfoPList(cmTarget* target, const char* targetName, + void GenerateAppleInfoPList(cmTarget* target, const std::string& targetName, const char* fname); /** * Generate a Mac OS X framework Info.plist file. */ void GenerateFrameworkInfoPList(cmTarget* target, - const char* targetName, + const std::string& targetName, const char* fname); /** Construct a comment for a custom command. */ std::string ConstructComment(const cmCustomCommand& cc, diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 11b89f4..f47ea29 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -550,14 +550,14 @@ void cmLocalUnixMakefileGenerator3 ::WriteMakeRule(std::ostream& os, const char* comment, - const char* target, + const std::string& target, const std::vector& depends, const std::vector& commands, bool symbolic, bool in_help) { // Make sure there is a target. - if(!target || !*target) + if(target.empty()) { cmSystemTools::Error("No target for WriteMakeRule! called with comment: ", comment); @@ -859,11 +859,11 @@ void cmLocalUnixMakefileGenerator3 void cmLocalUnixMakefileGenerator3 ::WriteConvenienceRule(std::ostream& ruleFileStream, - const char* realTarget, - const char* helpTarget) + const std::string& realTarget, + const std::string& helpTarget) { // A rule is only needed if the names are different. - if(strcmp(realTarget, helpTarget) != 0) + if(realTarget != helpTarget) { // The helper target depends on the real target. std::vector depends; @@ -2034,7 +2034,7 @@ void cmLocalUnixMakefileGenerator3::WriteDisclaimer(std::ostream& os) //---------------------------------------------------------------------------- std::string cmLocalUnixMakefileGenerator3 -::GetRecursiveMakeCall(const char *makefile, const char* tgt) +::GetRecursiveMakeCall(const char *makefile, const std::string& tgt) { // Call make on the given file. std::string cmd; @@ -2059,7 +2059,7 @@ cmLocalUnixMakefileGenerator3 } // Add the target. - if (tgt && tgt[0] != '\0') + if (!tgt.empty()) { // The make target is always relative to the top of the build tree. std::string tgt2 = this->Convert(tgt, HOME_OUTPUT); diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index b0ccf52..2ad5250 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -55,7 +55,7 @@ public: // Write out a make rule void WriteMakeRule(std::ostream& os, const char* comment, - const char* target, + const std::string& target, const std::vector& depends, const std::vector& commands, bool symbolic, @@ -168,7 +168,8 @@ public: void WriteDivider(std::ostream& os); /** used to create a recursive make call */ - std::string GetRecursiveMakeCall(const char *makefile, const char* tgt); + std::string GetRecursiveMakeCall(const char *makefile, + const std::string& tgt); // append flags to a string virtual void AppendFlags(std::string& flags, const char* newFlags); @@ -273,8 +274,8 @@ protected: void WriteConvenienceRule(std::ostream& ruleFileStream, - const char* realTarget, - const char* helpTarget); + const std::string& realTarget, + const std::string& helpTarget); void WriteTargetDependRule(std::ostream& ruleFileStream, cmTarget& target); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index ff217c3..88206f1 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -186,7 +186,7 @@ void cmLocalVisualStudio6Generator::OutputDSPFile() // extern std::string GetVS6TargetName(const std::string& targetName); -void cmLocalVisualStudio6Generator::CreateSingleDSP(const char *lname, +void cmLocalVisualStudio6Generator::CreateSingleDSP(const std::string& lname, cmTarget &target) { // add to the list of projects @@ -263,7 +263,7 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt) void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, - const char *libName, + const std::string& libName, cmTarget &target) { // For utility targets need custom command since pre- and post- @@ -372,7 +372,7 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, void cmLocalVisualStudio6Generator ::WriteGroup(const cmSourceGroup *sg, cmTarget& target, - std::ostream &fout, const char *libName) + std::ostream &fout, const std::string& libName) { cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(&target); @@ -572,9 +572,9 @@ cmLocalVisualStudio6Generator { // Create a fake output that forces the rule to run. char* output = new char[(strlen(this->Makefile->GetStartOutputDirectory()) + - strlen(target.GetName()) + 30)]; + target.GetName().size() + 30)]; sprintf(output,"%s/%s_force_%i", this->Makefile->GetStartOutputDirectory(), - target.GetName(), count); + target.GetName().c_str(), count); std::string comment = this->ConstructComment(origCommand, ""); // Add the rule with the given dependencies and commands. @@ -699,7 +699,7 @@ void cmLocalVisualStudio6Generator::WriteDSPEndGroup(std::ostream& fout) void cmLocalVisualStudio6Generator::SetBuildType(BuildType b, - const char* libName, + const std::string& libName, cmTarget& target) { std::string root= this->Makefile->GetRequiredDefinition("CMAKE_ROOT"); @@ -813,8 +813,8 @@ cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target, // look for custom rules on a target and collect them together std::string cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target, - const char* configName, - const char * /* libName */) + const char* configName, + const std::string& /* libName */) { if (target.GetType() >= cmTarget::UTILITY ) { @@ -926,7 +926,7 @@ cmLocalVisualStudio6Generator::GetTargetIncludeOptions(cmTarget &target, void cmLocalVisualStudio6Generator ::WriteDSPHeader(std::ostream& fout, - const char *libName, cmTarget &target, + const std::string& libName, cmTarget &target, std::vector &) { bool targetBuilds = (target.GetType() >= cmTarget::EXECUTABLE && @@ -1257,7 +1257,7 @@ void cmLocalVisualStudio6Generator { cmSystemTools::Error ("CMake can not determine linker language for target: ", - target.GetName()); + target.GetName().c_str()); return; } @@ -1679,7 +1679,7 @@ void cmLocalVisualStudio6Generator { cmSystemTools::Error ("CMake can not determine linker language for target: ", - target.GetName()); + target.GetName().c_str()); return; } // if CXX is on and the target contains cxx code then add the cxx flags diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h index f45bc17..6702111 100644 --- a/Source/cmLocalVisualStudio6Generator.h +++ b/Source/cmLocalVisualStudio6Generator.h @@ -48,7 +48,7 @@ public: /** * Specify the type of the build: static, dll, or executable. */ - void SetBuildType(BuildType, const char* libName, cmTarget&); + void SetBuildType(BuildType, const std::string& libName, cmTarget&); virtual std::string GetTargetDirectory(cmTarget const& target) const; virtual std::string ComputeLongestObjectDirectory(cmTarget&) const; @@ -56,15 +56,15 @@ private: std::string DSPHeaderTemplate; std::string DSPFooterTemplate; - void CreateSingleDSP(const char *lname, cmTarget &tgt); - void WriteDSPFile(std::ostream& fout, const char *libName, + void CreateSingleDSP(const std::string& lname, cmTarget &tgt); + void WriteDSPFile(std::ostream& fout, const std::string& libName, cmTarget &tgt); void WriteDSPBeginGroup(std::ostream& fout, const char* group, const char* filter); void WriteDSPEndGroup(std::ostream& fout); - void WriteDSPHeader(std::ostream& fout, const char *libName, + void WriteDSPHeader(std::ostream& fout, const std::string& libName, cmTarget &tgt, std::vector &sgs); void WriteDSPFooter(std::ostream& fout); @@ -77,14 +77,14 @@ private: std::vector& depends, const cmCustomCommand& origCommand); void WriteGroup(const cmSourceGroup *sg, cmTarget& target, - std::ostream &fout, const char *libName); + std::ostream &fout, const std::string& libName); class EventWriter; friend class EventWriter; cmsys::auto_ptr MaybeCreateOutputDir(cmTarget& target, const char* config); std::string CreateTargetRules(cmTarget &target, const char* configName, - const char *libName); + const std::string& libName); void ComputeLinkOptions(cmTarget& target, const char* configName, const std::string extraOptions, std::string& options); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index f93a7aa..786791c 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -83,7 +83,7 @@ void cmLocalVisualStudio7Generator::AddHelperCommands() if(path) { this->ReadAndStoreExternalGUID( - l->second.GetName(), path); + l->second.GetName().c_str(), path); } else { @@ -334,8 +334,8 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() } void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout, - const char *libName, - cmTarget &target) + const std::string& libName, + cmTarget &target) { std::vector *configs = static_cast @@ -637,9 +637,9 @@ private: //---------------------------------------------------------------------------- void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, - const char* configName, - const char *libName, - cmTarget &target) + const char* configName, + const std::string& libName, + cmTarget &target) { const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG"); if(!mfcFlag) @@ -694,7 +694,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, { cmSystemTools::Error ("CMake can not determine linker language for target: ", - target.GetName()); + target.GetName().c_str()); return; } if(linkLanguage == "C" || linkLanguage == "CXX" @@ -1380,7 +1380,7 @@ cmLocalVisualStudio7Generator } void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, - const char *libName, + const std::string& libName, cmTarget &target) { // get the configurations @@ -1627,7 +1627,7 @@ cmLocalVisualStudio7Generator bool cmLocalVisualStudio7Generator ::WriteGroup(const cmSourceGroup *sg, cmTarget& target, - std::ostream &fout, const char *libName, + std::ostream &fout, const std::string& libName, std::vector *configs) { const std::vector &sourceFiles = @@ -1906,7 +1906,7 @@ void cmLocalVisualStudio7Generator ::OutputTargetRules(std::ostream& fout, const char* configName, cmTarget &target, - const char * /*libName*/) + const std::string& /*libName*/) { if (target.GetType() > cmTarget::GLOBAL_TARGET) { @@ -1966,7 +1966,7 @@ void cmLocalVisualStudio7Generator::WriteProjectSCC(std::ostream& fout, void cmLocalVisualStudio7Generator ::WriteProjectStartFortran(std::ostream& fout, - const char *libName, + const std::string& libName, cmTarget & target) { @@ -2017,7 +2017,7 @@ cmLocalVisualStudio7Generator } this->WriteProjectSCC(fout, target); fout<< "\tKeyword=\"" << keyword << "\">\n" - << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\">\n" + << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\">\n" << "\t\n" << "\t\tPlatformName << "\"/>\n" << "\t\n"; @@ -2026,7 +2026,7 @@ cmLocalVisualStudio7Generator void cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, - const char *libName, + const std::string& libName, cmTarget & target, std::vector &) { @@ -2049,7 +2049,7 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, const char* projLabel = target.GetProperty("PROJECT_LABEL"); if(!projLabel) { - projLabel = libName; + projLabel = libName.c_str(); } const char* keyword = target.GetProperty("VS_KEYWORD"); if(!keyword) @@ -2061,7 +2061,7 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, fout << "\tName=\"" << projLabel << "\"\n"; if(this->Version >= VS8) { - fout << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\"\n"; + fout << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\"\n"; } this->WriteProjectSCC(fout, target); if(const char* targetFrameworkVersion = diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 92e4d3c..4d72747 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -74,29 +74,29 @@ private: const char* configName); void FixGlobalTargets(); void WriteProjectFiles(); - void WriteVCProjHeader(std::ostream& fout, const char *libName, + void WriteVCProjHeader(std::ostream& fout, const std::string& libName, cmTarget &tgt, std::vector &sgs); void WriteVCProjFooter(std::ostream& fout, cmTarget &target); - void WriteVCProjFile(std::ostream& fout, const char *libName, + void WriteVCProjFile(std::ostream& fout, const std::string& libName, cmTarget &tgt); void WriteConfigurations(std::ostream& fout, - const char *libName, cmTarget &tgt); + const std::string& libName, cmTarget &tgt); void WriteConfiguration(std::ostream& fout, const char* configName, - const char* libName, cmTarget &tgt); + const std::string& libName, cmTarget &tgt); std::string EscapeForXML(const char* s); std::string ConvertToXMLOutputPath(const char* path); std::string ConvertToXMLOutputPathSingle(const char* path); void OutputTargetRules(std::ostream& fout, const char* configName, - cmTarget &target, const char *libName); + cmTarget &target, const std::string& libName); void OutputBuildTool(std::ostream& fout, const char* configName, cmTarget& t, const Options& targetOptions); void OutputLibraryDirectories(std::ostream& fout, std::vector const& dirs); void WriteProjectSCC(std::ostream& fout, cmTarget& target); - void WriteProjectStart(std::ostream& fout, const char *libName, + void WriteProjectStart(std::ostream& fout, const std::string& libName, cmTarget &tgt, std::vector &sgs); - void WriteProjectStartFortran(std::ostream& fout, const char *libName, + void WriteProjectStartFortran(std::ostream& fout, const std::string& libName, cmTarget &tgt); void WriteVCProjBeginGroup(std::ostream& fout, const char* group, @@ -111,7 +111,8 @@ private: bool WriteGroup(const cmSourceGroup *sg, cmTarget& target, std::ostream &fout, - const char *libName, std::vector *configs); + const std::string& libName, + std::vector *configs); friend class cmLocalVisualStudio7GeneratorFCInfo; friend class cmLocalVisualStudio7GeneratorInternals; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8274b13..7215e76 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -878,7 +878,7 @@ void cmMakefile::ConfigureFinalPass() //---------------------------------------------------------------------------- void -cmMakefile::AddCustomCommandToTarget(const char* target, +cmMakefile::AddCustomCommandToTarget(const std::string& target, const std::vector& depends, const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, @@ -1120,7 +1120,7 @@ cmMakefile::AddCustomCommandToOutput(const char* output, //---------------------------------------------------------------------------- void -cmMakefile::AddCustomCommandOldStyle(const char* target, +cmMakefile::AddCustomCommandOldStyle(const std::string& target, const std::vector& outputs, const std::vector& depends, const char* source, @@ -1129,7 +1129,7 @@ cmMakefile::AddCustomCommandOldStyle(const char* target, { // Translate the old-style signature to one of the new-style // signatures. - if(strcmp(source, target) == 0) + if(source == target) { // In the old-style signature if the source and target were the // same then it added a post-build rule to the target. Preserve @@ -1179,7 +1179,8 @@ cmMakefile::AddCustomCommandOldStyle(const char* target, else { cmSystemTools::Error("Attempt to add a custom rule to a target " - "that does not exist yet for target ", target); + "that does not exist yet for target ", + target.c_str()); return; } } @@ -1453,7 +1454,7 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove) return true; } -void cmMakefile::AddLinkLibrary(const char* lib, +void cmMakefile::AddLinkLibrary(const std::string& lib, cmTarget::LinkLibraryType llt) { cmTarget::LibraryID tmp; @@ -1462,8 +1463,8 @@ void cmMakefile::AddLinkLibrary(const char* lib, this->LinkLibraries.push_back(tmp); } -void cmMakefile::AddLinkLibraryForTarget(const char *target, - const char* lib, +void cmMakefile::AddLinkLibraryForTarget(const std::string& target, + const std::string& lib, cmTarget::LinkLibraryType llt) { cmTargets::iterator i = this->Targets.find(target); @@ -1500,8 +1501,8 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target, } } -void cmMakefile::AddLinkDirectoryForTarget(const char *target, - const char* d) +void cmMakefile::AddLinkDirectoryForTarget(const std::string& target, + const std::string& d) { cmTargets::iterator i = this->Targets.find(target); if ( i != this->Targets.end()) @@ -1520,46 +1521,37 @@ void cmMakefile::AddLinkDirectoryForTarget(const char *target, { cmSystemTools::Error ("Attempt to add link directories to non-existent target: ", - target, " for directory ", d); + target.c_str(), " for directory ", d.c_str()); } } -void cmMakefile::AddLinkLibrary(const char* lib) +void cmMakefile::AddLinkLibrary(const std::string& lib) { this->AddLinkLibrary(lib,cmTarget::GENERAL); } -void cmMakefile::AddLinkDirectory(const char* dir) +void cmMakefile::AddLinkDirectory(const std::string& dir) { // Don't add a link directory that is already present. Yes, this // linear search results in n^2 behavior, but n won't be getting // much bigger than 20. We cannot use a set because of order // dependency of the link search path. - if(!dir) + if(dir.empty()) { return; } + std::string newdir = dir; // remove trailing slashes - if(dir[strlen(dir)-1] == '/') + if(*dir.rbegin() == '/') { - std::string newdir = dir; - newdir = newdir.substr(0, newdir.size()-1); - if(std::find(this->LinkDirectories.begin(), - this->LinkDirectories.end(), - newdir.c_str()) == this->LinkDirectories.end()) - { - this->LinkDirectories.push_back(newdir); - } + newdir = dir.substr(0, dir.size()-1); } - else + if(std::find(this->LinkDirectories.begin(), + this->LinkDirectories.end(), newdir) + == this->LinkDirectories.end()) { - if(std::find(this->LinkDirectories.begin(), - this->LinkDirectories.end(), dir) - == this->LinkDirectories.end()) - { - this->LinkDirectories.push_back(dir); - } + this->LinkDirectories.push_back(dir); } } @@ -1975,7 +1967,8 @@ void cmMakefile::SetProjectName(const char* p) } -void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target) +void cmMakefile::AddGlobalLinkInformation(const std::string& name, + cmTarget& target) { // for these targets do not add anything switch(target.GetType()) @@ -1996,13 +1989,14 @@ void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target) } -void cmMakefile::AddAlias(const char* lname, cmTarget *tgt) +void cmMakefile::AddAlias(const std::string& lname, cmTarget *tgt) { this->AliasTargets[lname] = tgt; this->LocalGenerator->GetGlobalGenerator()->AddAlias(lname, tgt); } -cmTarget* cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type, +cmTarget* cmMakefile::AddLibrary(const std::string& lname, + cmTarget::TargetType type, const std::vector &srcs, bool excludeFromAll) { @@ -2048,7 +2042,7 @@ cmTarget* cmMakefile::AddExecutable(const char *exeName, //---------------------------------------------------------------------------- cmTarget* -cmMakefile::AddNewTarget(cmTarget::TargetType type, const char* name) +cmMakefile::AddNewTarget(cmTarget::TargetType type, const std::string& name) { cmTargets::iterator it = this->Targets.insert(cmTargets::value_type(name, cmTarget())).first; @@ -3066,7 +3060,8 @@ void cmMakefile::ExpandSourceListArguments( } int cmMakefile::TryCompile(const char *srcdir, const char *bindir, - const char *projectName, const char *targetName, + const char *projectName, + const std::string& targetName, bool fast, const std::vector *cmakeArgs, std::string *output) @@ -4030,7 +4025,8 @@ void cmMakefile::DefineProperties(cmake *cm) //---------------------------------------------------------------------------- cmTarget* -cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type, +cmMakefile::AddImportedTarget(const std::string& name, + cmTarget::TargetType type, bool global) { // Create the target. @@ -4087,7 +4083,7 @@ bool cmMakefile::IsAlias(const std::string& name) const //---------------------------------------------------------------------------- cmGeneratorTarget* -cmMakefile::FindGeneratorTargetToUse(const char* name) const +cmMakefile::FindGeneratorTargetToUse(const std::string& name) const { if (cmTarget *t = this->FindTargetToUse(name)) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 331a064..aa25f09 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -127,7 +127,7 @@ public: * loaded commands, not as part of the usual build process. */ int TryCompile(const char *srcdir, const char *bindir, - const char *projectName, const char *targetName, + const char *projectName, const std::string& targetName, bool fast, const std::vector *cmakeArgs, std::string *output); @@ -168,7 +168,7 @@ public: void Print() const; /** Add a custom command to the build. */ - void AddCustomCommandToTarget(const char* target, + void AddCustomCommandToTarget(const std::string& target, const std::vector& depends, const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, @@ -190,7 +190,7 @@ public: const char* comment, const char* workingDir, bool replace = false, bool escapeOldStyle = true); - void AddCustomCommandOldStyle(const char* target, + void AddCustomCommandOldStyle(const std::string& target, const std::vector& outputs, const std::vector& depends, const char* source, @@ -205,10 +205,11 @@ public: void AddCompileOption(const char* option); /** Create a new imported target with the name and type given. */ - cmTarget* AddImportedTarget(const char* name, cmTarget::TargetType type, + cmTarget* AddImportedTarget(const std::string& name, + cmTarget::TargetType type, bool global); - cmTarget* AddNewTarget(cmTarget::TargetType type, const char* name); + cmTarget* AddNewTarget(cmTarget::TargetType type, const std::string& name); /** * Add an executable to the build. @@ -239,16 +240,16 @@ public: /** * Add a link library to the build. */ - void AddLinkLibrary(const char*); - void AddLinkLibrary(const char*, cmTarget::LinkLibraryType type); - void AddLinkLibraryForTarget(const char *tgt, const char*, + void AddLinkLibrary(const std::string&); + void AddLinkLibrary(const std::string&, cmTarget::LinkLibraryType type); + void AddLinkLibraryForTarget(const std::string& tgt, const std::string&, cmTarget::LinkLibraryType type); - void AddLinkDirectoryForTarget(const char *tgt, const char* d); + void AddLinkDirectoryForTarget(const std::string& tgt, const std::string& d); /** * Add a link directory to the build. */ - void AddLinkDirectory(const char*); + void AddLinkDirectory(const std::string&); const std::vector& GetLinkDirectories() const { @@ -323,10 +324,10 @@ public: /** * Set the name of the library. */ - cmTarget* AddLibrary(const char *libname, cmTarget::TargetType type, + cmTarget* AddLibrary(const std::string& libname, cmTarget::TargetType type, const std::vector &srcs, bool excludeFromAll = false); - void AddAlias(const char *libname, cmTarget *tgt); + void AddAlias(const std::string& libname, cmTarget *tgt); #if defined(CMAKE_BUILD_WITH_CMAKE) /** @@ -534,7 +535,7 @@ public: cmTarget* FindTargetToUse(const std::string& name, bool excludeAliases = false) const; bool IsAlias(const std::string& name) const; - cmGeneratorTarget* FindGeneratorTargetToUse(const char* name) const; + cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const; /** * Mark include directories as system directories. @@ -878,7 +879,7 @@ public: protected: // add link libraries and directories to the target - void AddGlobalLinkInformation(const char* name, cmTarget& target); + void AddGlobalLinkInformation(const std::string& name, cmTarget& target); // Check for a an unused variable void CheckForUnused(const char* reason, const std::string& name) const; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index b827363..ca8ff06 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -167,7 +167,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) if(linkLanguage.empty()) { cmSystemTools::Error("Cannot determine link language for target \"", - this->Target->GetName(), "\"."); + this->Target->GetName().c_str(), "\"."); return; } diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 96159f9..d9425e6 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -125,7 +125,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() depends, commands, true); // Write the main driver rule to build everything in this target. - this->WriteTargetDriverRule(this->Target->GetName(), false); + this->WriteTargetDriverRule(this->Target->GetName().c_str(), false); } //---------------------------------------------------------------------------- @@ -243,7 +243,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules if(linkLanguage.empty()) { cmSystemTools::Error("Cannot determine link language for target \"", - this->Target->GetName(), "\"."); + this->Target->GetName().c_str(), "\"."); return; } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 3ba5a77..fb9b045 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1347,7 +1347,7 @@ cmMakefileTargetGenerator // Write a make variable assignment that lists all objects for the // target. variableName = - this->LocalGenerator->CreateMakeVariable(this->Target->GetName(), + this->LocalGenerator->CreateMakeVariable(this->Target->GetName().c_str(), "_OBJECTS"); *this->BuildFileStream << "# Object files for target " << this->Target->GetName() << "\n" @@ -1382,7 +1382,7 @@ cmMakefileTargetGenerator // Write a make variable assignment that lists all external objects // for the target. variableNameExternal = - this->LocalGenerator->CreateMakeVariable(this->Target->GetName(), + this->LocalGenerator->CreateMakeVariable(this->Target->GetName().c_str(), "_EXTERNAL_OBJECTS"); *this->BuildFileStream << "\n" @@ -1683,7 +1683,7 @@ void cmMakefileTargetGenerator //---------------------------------------------------------------------------- std::string cmMakefileTargetGenerator::GetLinkRule( - const cmStdString& linkRuleVar) + const std::string& linkRuleVar) { std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar); if(this->Target->HasImplibGNUtoMS()) diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index baae2b0..d2cbadd 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -138,7 +138,7 @@ protected: void AppendLinkDepends(std::vector& depends); // Lookup the link rule for this target. - std::string GetLinkRule(const cmStdString& linkRuleVar); + std::string GetLinkRule(const std::string& linkRuleVar); /** In order to support parallel builds for custom commands with multiple outputs the outputs are given a serial order, and only diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index 7751ad9..2066fc2 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -105,7 +105,7 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() depends, commands, true); // Write the main driver rule to build everything in this target. - this->WriteTargetDriverRule(this->Target->GetName(), false); + this->WriteTargetDriverRule(this->Target->GetName().c_str(), false); // Write clean target this->WriteTargetCleanRules(); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index b81fbeb..502127e 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -75,7 +75,7 @@ void cmNinjaNormalTargetGenerator::Generate() if (this->TargetLinkLanguage.empty()) { cmSystemTools::Error("CMake can not determine linker language for " "target: ", - this->GetTarget()->GetName()); + this->GetTarget()->GetName().c_str()); return; } diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index d940fe2..e075c54 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -772,7 +772,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, makefile->AddDefinition("_qt_uic_options_options", cmLocalGenerator::EscapeForCMake(uiFileOptions.c_str()).c_str()); - const char* targetName = target->GetName(); + std::string targetName = target->GetName(); if (strcmp(qtVersion, "5") == 0) { cmTarget *qt5Uic = makefile->FindTargetToUse("Qt5::uic"); @@ -791,7 +791,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, if (!qt4Uic) { cmSystemTools::Error("Qt4::uic target not found ", - targetName); + targetName.c_str()); return; } makefile->AddDefinition("_qt_uic_executable", qt4Uic->GetLocation(0)); @@ -799,7 +799,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, else { cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and " - "Qt 5 ", targetName); + "Qt 5 ", targetName.c_str()); } } @@ -921,14 +921,14 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) makefile->AddDefinition("_qt_rcc_options_options", cmLocalGenerator::EscapeForCMake(rccFileOptions.c_str()).c_str()); - const char* targetName = target->GetName(); + std::string targetName = target->GetName(); if (strcmp(qtVersion, "5") == 0) { cmTarget *qt5Rcc = makefile->FindTargetToUse("Qt5::rcc"); if (!qt5Rcc) { cmSystemTools::Error("Qt5::rcc target not found ", - targetName); + targetName.c_str()); return; } makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation(0)); @@ -939,7 +939,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) if (!qt4Rcc) { cmSystemTools::Error("Qt4::rcc target not found ", - targetName); + targetName.c_str()); return; } makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation(0)); @@ -947,7 +947,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) else { cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and " - "Qt 5 ", targetName); + "Qt 5 ", targetName.c_str()); } } diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 1a6f1d6..e561e36 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -203,7 +203,7 @@ bool cmSetPropertyCommand::HandleDirectoryMode() // Lookup the generator. if(cmLocalGenerator* lg = (this->Makefile->GetLocalGenerator() - ->GetGlobalGenerator()->FindLocalGenerator(dir.c_str()))) + ->GetGlobalGenerator()->FindLocalGenerator(dir))) { // Use the makefile for the directory found. mf = lg->GetMakefile(); diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx index dab4180..fa5aafe 100644 --- a/Source/cmSetTargetPropertiesCommand.cxx +++ b/Source/cmSetTargetPropertiesCommand.cxx @@ -91,7 +91,7 @@ bool cmSetTargetPropertiesCommand } bool cmSetTargetPropertiesCommand -::SetOneTarget(const char *tname, +::SetOneTarget(const std::string& tname, std::vector &propertyPairs, cmMakefile *mf) { diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h index 6221a18..cfe35df 100644 --- a/Source/cmSetTargetPropertiesCommand.h +++ b/Source/cmSetTargetPropertiesCommand.h @@ -37,7 +37,7 @@ public: /** * Used by this command and cmSetPropertiesCommand */ - static bool SetOneTarget(const char *tname, + static bool SetOneTarget(const std::string& tname, std::vector &propertyPairs, cmMakefile *mf); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 6782822..c927a0b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -234,7 +234,7 @@ void cmTarget::DefineProperties(cmake *cm) "", "", true); } -void cmTarget::SetType(TargetType type, const char* name) +void cmTarget::SetType(TargetType type, const std::string& name) { this->Name = name; // only add dependency information for library targets @@ -415,7 +415,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) } //---------------------------------------------------------------------------- -void cmTarget::AddUtility(const char *u, cmMakefile *makefile) +void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { this->Utilities.insert(u); if(makefile) @@ -425,7 +425,8 @@ void cmTarget::AddUtility(const char *u, cmMakefile *makefile) } //---------------------------------------------------------------------------- -cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(const char *u) const +cmListFileBacktrace const* cmTarget::GetUtilityBacktrace( + const std::string& u) const { std::map::const_iterator i = this->UtilityBacktraces.find(u); @@ -657,7 +658,7 @@ void cmTarget::ProcessSourceExpression(std::string const& expr) //---------------------------------------------------------------------------- void cmTarget::MergeLinkLibraries( cmMakefile& mf, - const char *selfname, + const std::string& selfname, const LinkLibraryVectorType& libs ) { // Only add on libraries we haven't added on before. @@ -675,7 +676,7 @@ void cmTarget::MergeLinkLibraries( cmMakefile& mf, } //---------------------------------------------------------------------------- -void cmTarget::AddLinkDirectory(const char* d) +void cmTarget::AddLinkDirectory(const std::string& d) { // Make sure we don't add unnecessary search directories. if(this->LinkDirectoriesEmmitted.insert(d).second) @@ -720,7 +721,7 @@ cmTarget::LinkLibraryType cmTarget::ComputeLinkType(const char* config) const //---------------------------------------------------------------------------- void cmTarget::ClearDependencyInformation( cmMakefile& mf, - const char* target ) + const std::string& target ) { // Clear the dependencies. The cache variable must exist iff we are // recording dependency information for this target. @@ -844,9 +845,9 @@ std::string cmTarget::GetDebugGeneratorExpressions(const std::string &value, } //---------------------------------------------------------------------------- -static std::string targetNameGenex(const char *lib) +static std::string targetNameGenex(const std::string& lib) { - return std::string("$"; + return "$"; } //---------------------------------------------------------------------------- @@ -908,7 +909,8 @@ void cmTarget::GetTllSignatureTraces(cmOStringStream &s, //---------------------------------------------------------------------------- void cmTarget::AddLinkLibrary(cmMakefile& mf, - const char *target, const char* lib, + const std::string& target, + const std::string& lib, LinkLibraryType llt) { cmTarget *tgt = this->Makefile->FindTargetToUse(lib); @@ -917,7 +919,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, const std::string libName = (isNonImportedTarget && llt != GENERAL) ? targetNameGenex(lib) - : std::string(lib); + : lib; this->AppendProperty("LINK_LIBRARIES", this->GetDebugGeneratorExpressions(libName, llt).c_str()); @@ -925,7 +927,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, if (cmGeneratorExpression::Find(lib) != std::string::npos || (tgt && tgt->GetType() == INTERFACE_LIBRARY) - || (strcmp( target, lib ) == 0)) + || (target == lib )) { return; } @@ -1469,7 +1471,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } //---------------------------------------------------------------------------- -const char* cmTarget::GetExportName() const +std::string cmTarget::GetExportName() const { const char *exportName = this->GetProperty("EXPORT_NAME"); @@ -2630,7 +2632,7 @@ const char *cmTarget::GetProperty(const std::string& prop, if (prop == "NAME") { - return this->GetName(); + return this->GetName().c_str(); } // Watch for special "computed" properties that are dependent on diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 205c81c..f73b271 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -93,13 +93,13 @@ public: /** * Set the target type */ - void SetType(TargetType f, const char* name); + void SetType(TargetType f, const std::string& name); void MarkAsImported(); ///! Set/Get the name of the target - const char* GetName() const {return this->Name.c_str();} - const char* GetExportName() const; + const std::string& GetName() const {return this->Name;} + std::string GetExportName() const; ///! Set the cmMakefile that owns this target void SetMakefile(cmMakefile *mf); @@ -168,12 +168,12 @@ public: /** * Clear the dependency information recorded for this target, if any. */ - void ClearDependencyInformation(cmMakefile& mf, const char* target); + void ClearDependencyInformation(cmMakefile& mf, const std::string& target); // Check to see if a library is a framework and treat it different on Mac bool NameResolvesToFramework(const std::string& libname) const; void AddLinkLibrary(cmMakefile& mf, - const char *target, const char* lib, + const std::string& target, const std::string& lib, LinkLibraryType llt); enum TLLSignature { KeywordTLLSignature, @@ -182,12 +182,12 @@ public: bool PushTLLCommandTrace(TLLSignature signature); void GetTllSignatureTraces(cmOStringStream &s, TLLSignature sig) const; - void MergeLinkLibraries( cmMakefile& mf, const char* selfname, + void MergeLinkLibraries( cmMakefile& mf, const std::string& selfname, const LinkLibraryVectorType& libs ); const std::vector& GetLinkDirectories() const; - void AddLinkDirectory(const char* d); + void AddLinkDirectory(const std::string& d); /** * Set the path where this target should be installed. This is relative to @@ -214,10 +214,10 @@ public: * name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE * commands. It is not a full path nor does it have an extension. */ - void AddUtility(const char* u, cmMakefile *makefile = 0); + void AddUtility(const std::string& u, cmMakefile *makefile = 0); ///! Get the utilities used by this target std::setconst& GetUtilities() const { return this->Utilities; } - cmListFileBacktrace const* GetUtilityBacktrace(const char* u) const; + cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const; /** Finalize the target at the end of the Configure step. */ void FinishConfigure(); diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index ad1533e..b4623a0 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -136,7 +136,7 @@ public: return this->DependLibraries; } void AddDependTarget(const char* configName, - const char* tName) + const std::string& tName) { if(!configName) { -- cgit v0.12 From a5996111164a4c4121e7d1fa08dbcd0983bb3589 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 4 Feb 2014 13:35:11 -0500 Subject: FindCUDA: Fix a typo --- Modules/FindCUDA.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 7bc8d49..94f82f6 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -987,7 +987,7 @@ function(CUDA_COMPUTE_BUILD_PATH path build_path) endif() endif() - # This recipie is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the + # This recipe is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the # CMake source. # Remove leading / -- cgit v0.12 From 473ca1ac4a5df336ff09ee2c666e437eabf43bc9 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 7 Feb 2014 15:02:41 -0500 Subject: stringapi: Use string for OS X resource names --- Source/CPack/cmCPackOSXX11Generator.cxx | 6 +++--- Source/CPack/cmCPackOSXX11Generator.h | 5 +++-- Source/CPack/cmCPackPackageMakerGenerator.cxx | 9 +++++---- Source/CPack/cmCPackPackageMakerGenerator.h | 3 ++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 76e15fb..95ffab5 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -227,7 +227,7 @@ int cmCPackOSXX11Generator::InitializeInternal() //---------------------------------------------------------------------- /* -bool cmCPackOSXX11Generator::CopyCreateResourceFile(const char* name) +bool cmCPackOSXX11Generator::CopyCreateResourceFile(const std::string& name) { std::string uname = cmSystemTools::UpperCase(name); std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname; @@ -271,7 +271,7 @@ bool cmCPackOSXX11Generator::CopyCreateResourceFile(const char* name) */ //---------------------------------------------------------------------- -bool cmCPackOSXX11Generator::CopyResourcePlistFile(const char* name, +bool cmCPackOSXX11Generator::CopyResourcePlistFile(const std::string& name, const char* dir, const char* outputFileName /* = 0 */, bool copyOnly /* = false */) { @@ -288,7 +288,7 @@ bool cmCPackOSXX11Generator::CopyResourcePlistFile(const char* name, if ( !outputFileName ) { - outputFileName = name; + outputFileName = name.c_str(); } std::string destFileName = dir; diff --git a/Source/CPack/cmCPackOSXX11Generator.h b/Source/CPack/cmCPackOSXX11Generator.h index b7bd243..7a93f5a 100644 --- a/Source/CPack/cmCPackOSXX11Generator.h +++ b/Source/CPack/cmCPackOSXX11Generator.h @@ -37,8 +37,9 @@ protected: virtual const char* GetPackagingInstallPrefix(); virtual const char* GetOutputExtension() { return ".dmg"; } - //bool CopyCreateResourceFile(const char* name, const char* dir); - bool CopyResourcePlistFile(const char* name, const char* dir, + //bool CopyCreateResourceFile(const std::string& name, + // const std::string& dir); + bool CopyResourcePlistFile(const std::string& name, const char* dir, const char* outputFileName = 0, bool copyOnly = false); std::string InstallPrefix; }; diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index c5b9c6f..69886a1 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -553,8 +553,9 @@ int cmCPackPackageMakerGenerator::InitializeInternal() } //---------------------------------------------------------------------- -bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name, - const char* dirName) +bool cmCPackPackageMakerGenerator::CopyCreateResourceFile( + const std::string& name, + const std::string& dirName) { std::string uname = cmSystemTools::UpperCase(name); std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname; @@ -563,7 +564,7 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name, { cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: " << cpackVar.c_str() << " not specified. It should point to " - << (name ? name : "(NULL)") + << (!name.empty() ? name : "") << ".rtf, " << name << ".html, or " << name << ".txt file" << std::endl); return false; @@ -571,7 +572,7 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name, if ( !cmSystemTools::FileExists(inFileName) ) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find " - << (name ? name : "(NULL)") + << (!name.empty() ? name : "") << " resource file: " << inFileName << std::endl); return false; } diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h index ba3d968..bebb633 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.h +++ b/Source/CPack/cmCPackPackageMakerGenerator.h @@ -51,7 +51,8 @@ protected: // CPACK_RESOURCE_FILE_${NAME} (where ${NAME} is the uppercased // version of name) specifies the input file to use for this file, // which will be configured via ConfigureFile. - bool CopyCreateResourceFile(const char* name, const char *dirName); + bool CopyCreateResourceFile(const std::string& name, + const std::string& dirName); bool CopyResourcePlistFile(const char* name, const char* outName = 0); // Run PackageMaker with the given command line, which will (if -- cgit v0.12 From 77f60392d93f41a8828d3db1d7b76d45f1535d07 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 7 Feb 2014 15:06:13 -0500 Subject: stringapi: Accept strings when MD5 hashing data --- Source/cmCryptoHash.cxx | 10 +++++----- Source/cmCryptoHash.h | 4 ++-- Source/cmSystemTools.cxx | 4 ++-- Source/cmSystemTools.h | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index 7f4b10f..0d3c6bb 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -35,18 +35,18 @@ cmsys::auto_ptr cmCryptoHash::New(const char* algo) } //---------------------------------------------------------------------------- -std::string cmCryptoHash::HashString(const char* input) +std::string cmCryptoHash::HashString(const std::string& input) { this->Initialize(); - this->Append(reinterpret_cast(input), - static_cast(strlen(input))); + this->Append(reinterpret_cast(&input[0]), + static_cast(input.size())); return this->Finalize(); } //---------------------------------------------------------------------------- -std::string cmCryptoHash::HashFile(const char* file) +std::string cmCryptoHash::HashFile(const std::string& file) { - cmsys::ifstream fin(file, std::ios::in | cmsys_ios_binary); + cmsys::ifstream fin(file.c_str(), std::ios::in | cmsys_ios_binary); if(!fin) { return ""; diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h index 1bea9ab..88cd240 100644 --- a/Source/cmCryptoHash.h +++ b/Source/cmCryptoHash.h @@ -21,8 +21,8 @@ class cmCryptoHash public: virtual ~cmCryptoHash() {} static cmsys::auto_ptr New(const char* algo); - std::string HashString(const char* input); - std::string HashFile(const char* file); + std::string HashString(const std::string& input); + std::string HashFile(const std::string& file); protected: virtual void Initialize()=0; virtual void Append(unsigned char const*, int)=0; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 7cc63bb..18eb62e 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -944,7 +944,7 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname) #endif } -bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out) +bool cmSystemTools::ComputeFileMD5(const std::string& source, char* md5out) { #if defined(CMAKE_BUILD_WITH_CMAKE) cmCryptoHashMD5 md5; @@ -959,7 +959,7 @@ bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out) #endif } -std::string cmSystemTools::ComputeStringMD5(const char* input) +std::string cmSystemTools::ComputeStringMD5(const std::string& input) { #if defined(CMAKE_BUILD_WITH_CMAKE) cmCryptoHashMD5 md5; diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 4a5d298..da37ceb 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -185,10 +185,10 @@ public: static bool RenameFile(const char* oldname, const char* newname); ///! Compute the md5sum of a file - static bool ComputeFileMD5(const char* source, char* md5out); + static bool ComputeFileMD5(const std::string& source, char* md5out); /** Compute the md5sum of a string. */ - static std::string ComputeStringMD5(const char* input); + static std::string ComputeStringMD5(const std::string& input); /** * Run a single executable command -- cgit v0.12 From 30bc251b65e9deb39c2cb8a785bd98c8d707d508 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 7 Feb 2014 15:32:48 -0500 Subject: stringapi: Use strings for output names in AddCustomCommandToOutput --- Source/cmMakefile.cxx | 2 +- Source/cmMakefile.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7215e76..8b1f0ba 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1102,7 +1102,7 @@ cmMakefile::UpdateOutputToSourceMap(std::string const& output, //---------------------------------------------------------------------------- cmSourceFile* -cmMakefile::AddCustomCommandToOutput(const char* output, +cmMakefile::AddCustomCommandToOutput(const std::string& output, const std::vector& depends, const char* main_dependency, const cmCustomCommandLines& commandLines, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index aa25f09..e165fd8 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -183,7 +183,7 @@ public: bool replace = false, bool escapeOldStyle = true); cmSourceFile* AddCustomCommandToOutput( - const char* output, + const std::string& output, const std::vector& depends, const char* main_dependency, const cmCustomCommandLines& commandLines, -- cgit v0.12 From adcd812917fe37798a3062bfb3a0932e128faec2 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 7 Feb 2014 15:33:35 -0500 Subject: stringapi: Use strings for AddSubdirectory paths --- Source/cmGlobalGenerator.h | 2 +- Source/cmMakefile.cxx | 9 +++++---- Source/cmMakefile.h | 12 +++++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 38d7f58..4779682 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -287,7 +287,7 @@ public: std::string const& content); /** Return whether the given binary directory is unused. */ - bool BinaryDirectoryIsNew(const char* dir) + bool BinaryDirectoryIsNew(const std::string& dir) { return this->BinaryDirectories.insert(dir).second; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8b1f0ba..1df64dd 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1648,7 +1648,7 @@ void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2) } } -void cmMakefile::AddSubDirectory(const char* sub, +void cmMakefile::AddSubDirectory(const std::string& sub, bool excludeFromAll, bool preorder) { // the source path must be made full if it isn't already @@ -1675,7 +1675,8 @@ void cmMakefile::AddSubDirectory(const char* sub, } -void cmMakefile::AddSubDirectory(const char* srcPath, const char *binPath, +void cmMakefile::AddSubDirectory(const std::string& srcPath, + const std::string& binPath, bool excludeFromAll, bool preorder, bool immediate) { @@ -4185,8 +4186,8 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, } //---------------------------------------------------------------------------- -bool cmMakefile::EnforceUniqueDir(const char* srcPath, - const char* binPath) const +bool cmMakefile::EnforceUniqueDir(const std::string& srcPath, + const std::string& binPath) const { // Make sure the binary directory is unique. cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator(); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index e165fd8..4019372 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -263,9 +263,10 @@ public: /** * Add a subdirectory to the build. */ - void AddSubDirectory(const char*, bool excludeFromAll=false, + void AddSubDirectory(const std::string&, bool excludeFromAll=false, bool preorder = false); - void AddSubDirectory(const char* fullSrcDir,const char *fullBinDir, + void AddSubDirectory(const std::string& fullSrcDir, + const std::string& fullBinDir, bool excludeFromAll, bool preorder, bool immediate); @@ -430,7 +431,7 @@ public: * recursing up the tree starting at the StartDirectory and going up until * it reaches the HomeDirectory. */ - void SetStartDirectory(const char* dir) + void SetStartDirectory(const std::string& dir) { this->cmStartDirectory = dir; cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory); @@ -443,7 +444,7 @@ public: { return this->cmStartDirectory.c_str(); } - void SetStartOutputDirectory(const char* lib) + void SetStartOutputDirectory(const std::string& lib) { this->StartOutputDirectory = lib; cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory); @@ -949,7 +950,8 @@ private: bool ParseDefineFlag(std::string const& definition, bool remove); - bool EnforceUniqueDir(const char* srcPath, const char* binPath) const; + bool EnforceUniqueDir(const std::string& srcPath, + const std::string& binPath) const; friend class cmMakeDepend; // make depend needs direct access // to the Sources array -- cgit v0.12 From f3efa3cd160d9957437168627689720bb953bb2b Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 7 Feb 2014 15:34:39 -0500 Subject: stringapi: Use strings for cache paths as arguments --- Source/cmCacheManager.cxx | 12 ++++++------ Source/cmCacheManager.h | 12 ++++++------ Source/cmMakefile.cxx | 4 ++-- Source/cmMakefile.h | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 7a71482..141fde5 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -82,12 +82,12 @@ bool cmCacheManager::LoadCache(cmMakefile* mf) } -bool cmCacheManager::LoadCache(const char* path) +bool cmCacheManager::LoadCache(const std::string& path) { return this->LoadCache(path,true); } -bool cmCacheManager::LoadCache(const char* path, +bool cmCacheManager::LoadCache(const std::string& path, bool internal) { std::set emptySet; @@ -178,7 +178,7 @@ bool cmCacheManager::ParseEntry(const char* entry, return flag; } -void cmCacheManager::CleanCMakeFiles(const char* path) +void cmCacheManager::CleanCMakeFiles(const std::string& path) { std::string glob = path; glob += cmake::GetCMakeFilesDirectory(); @@ -193,7 +193,7 @@ void cmCacheManager::CleanCMakeFiles(const char* path) } } -bool cmCacheManager::LoadCache(const char* path, +bool cmCacheManager::LoadCache(const std::string& path, bool internal, std::set& excludes, std::set& includes) @@ -428,7 +428,7 @@ bool cmCacheManager::SaveCache(cmMakefile* mf) } -bool cmCacheManager::SaveCache(const char* path) +bool cmCacheManager::SaveCache(const std::string& path) { std::string cacheFile = path; cacheFile += "/CMakeCache.txt"; @@ -578,7 +578,7 @@ bool cmCacheManager::SaveCache(const char* path) return true; } -bool cmCacheManager::DeleteCache(const char* path) +bool cmCacheManager::DeleteCache(const std::string& path) { std::string cacheFile = path; cmSystemTools::ConvertToUnixSlashes(cacheFile); diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 7a61394..14cb1d9 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -108,19 +108,19 @@ public: ///! Load a cache for given makefile. Loads from ouput home. bool LoadCache(cmMakefile*); ///! Load a cache for given makefile. Loads from path/CMakeCache.txt. - bool LoadCache(const char* path); - bool LoadCache(const char* path, bool internal); - bool LoadCache(const char* path, bool internal, + bool LoadCache(const std::string& path); + bool LoadCache(const std::string& path, bool internal); + bool LoadCache(const std::string& path, bool internal, std::set& excludes, std::set& includes); ///! Save cache for given makefile. Saves to ouput home CMakeCache.txt. bool SaveCache(cmMakefile*) ; ///! Save cache for given makefile. Saves to ouput path/CMakeCache.txt - bool SaveCache(const char* path) ; + bool SaveCache(const std::string& path) ; ///! Delete the cache given - bool DeleteCache(const char* path); + bool DeleteCache(const std::string& path); ///! Print the cache to a stream void PrintCache(std::ostream&) const; @@ -159,7 +159,7 @@ protected: ///! Get a cache entry object for a key CacheEntry *GetCacheEntry(const std::string& key); ///! Clean out the CMakeFiles directory if no CMakeCache.txt - void CleanCMakeFiles(const char* path); + void CleanCMakeFiles(const std::string& path); // Cache version info unsigned int CacheMajorVersion; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 1df64dd..e059dd3 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2956,7 +2956,7 @@ cmMakefile::LexicalPushPop::~LexicalPushPop() this->Makefile->PopFunctionBlockerBarrier(this->ReportError); } -void cmMakefile::SetHomeDirectory(const char* dir) +void cmMakefile::SetHomeDirectory(const std::string& dir) { this->cmHomeDirectory = dir; cmSystemTools::ConvertToUnixSlashes(this->cmHomeDirectory); @@ -2967,7 +2967,7 @@ void cmMakefile::SetHomeDirectory(const char* dir) } } -void cmMakefile::SetHomeOutputDirectory(const char* lib) +void cmMakefile::SetHomeOutputDirectory(const std::string& lib) { this->HomeOutputDirectory = lib; cmSystemTools::ConvertToUnixSlashes(this->HomeOutputDirectory); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 4019372..4b9c548 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -401,12 +401,12 @@ public: * CMakeLists files by recursing up the tree starting at the StartDirectory * and going up until it reaches the HomeDirectory. */ - void SetHomeDirectory(const char* dir); + void SetHomeDirectory(const std::string& dir); const char* GetHomeDirectory() const { return this->cmHomeDirectory.c_str(); } - void SetHomeOutputDirectory(const char* lib); + void SetHomeOutputDirectory(const std::string& lib); const char* GetHomeOutputDirectory() const { return this->HomeOutputDirectory.c_str(); -- cgit v0.12 From dddbd2c7faf0a606200d5b03c549d348eceb87d7 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 7 Feb 2014 15:35:10 -0500 Subject: stringapi: Accept strings when setting command errors --- Source/cmCommand.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmCommand.h b/Source/cmCommand.h index e148857..2378ef0 100644 --- a/Source/cmCommand.h +++ b/Source/cmCommand.h @@ -166,7 +166,7 @@ public: /** * Set the error message */ - void SetError(const char* e) + void SetError(const std::string& e) { this->Error = this->GetName(); this->Error += " "; -- cgit v0.12 From 38c7544578f4154dfaaa0a55b118b79b11ec6ae1 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 7 Feb 2014 15:35:30 -0500 Subject: stringapi: Use strings for documentation names --- Source/cmDocumentation.cxx | 4 ++-- Source/cmDocumentation.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 9c27fc1..96b5f04 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -477,9 +477,9 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv, } //---------------------------------------------------------------------------- -void cmDocumentation::SetName(const char* name) +void cmDocumentation::SetName(const std::string& name) { - this->NameString = name?name:""; + this->NameString = name; } //---------------------------------------------------------------------------- diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index d5a7dd5..56a4151 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -56,7 +56,7 @@ public: void SetShowGenerators(bool showGen) { this->ShowGenerators = showGen; } /** Set the program name for standard document generation. */ - void SetName(const char* name); + void SetName(const std::string& name); /** Set a section of the documentation. Typical sections include Name, Usage, Description, Options */ -- cgit v0.12 From d76a6e08d06ef0fa6d52f67e88b0cfe4d96f24d1 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 7 Feb 2014 15:37:02 -0500 Subject: stringapi: Use strings for generated file stream names --- Source/cmGeneratedFileStream.cxx | 7 +------ Source/cmGeneratedFileStream.h | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index 34efc15..78ad4b2 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -249,12 +249,7 @@ int cmGeneratedFileStreamBase::RenameFile(const char* oldname, } //---------------------------------------------------------------------------- -void cmGeneratedFileStream::SetName(const char* fname) +void cmGeneratedFileStream::SetName(const std::string& fname) { - if ( !fname ) - { - this->Name = ""; - return; - } this->Name = fname; } diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h index 99f3b47..7adee7b 100644 --- a/Source/cmGeneratedFileStream.h +++ b/Source/cmGeneratedFileStream.h @@ -140,7 +140,7 @@ public: * Set name of the file that will hold the actual output. This method allows * the output file to be changed during the use of cmGeneratedFileStream. */ - void SetName(const char* fname); + void SetName(const std::string& fname); private: cmGeneratedFileStream(cmGeneratedFileStream const&); // not implemented -- cgit v0.12 From c3833c7da40ccb03fc80bf10f37b77398d7123f8 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 7 Feb 2014 15:40:05 -0500 Subject: stringapi: Use strings for VS project names --- Source/cmGlobalGenerator.cxx | 11 ++++++----- Source/cmGlobalGenerator.h | 8 ++++---- Source/cmGlobalNinjaGenerator.cxx | 2 +- Source/cmGlobalNinjaGenerator.h | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 2 +- Source/cmGlobalUnixMakefileGenerator3.h | 2 +- Source/cmGlobalVisualStudio10Generator.cxx | 2 +- Source/cmGlobalVisualStudio10Generator.h | 2 +- Source/cmGlobalVisualStudio6Generator.cxx | 6 +++--- Source/cmGlobalVisualStudio6Generator.h | 7 ++++--- Source/cmGlobalVisualStudio71Generator.cxx | 8 ++++---- Source/cmGlobalVisualStudio71Generator.h | 8 ++++---- Source/cmGlobalVisualStudio7Generator.cxx | 19 ++++++++++--------- Source/cmGlobalVisualStudio7Generator.h | 14 +++++++------- Source/cmGlobalVisualStudio8Generator.cxx | 4 ++-- Source/cmGlobalVisualStudio8Generator.h | 5 +++-- Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmGlobalXCodeGenerator.h | 2 +- Source/cmLocalVisualStudio7Generator.cxx | 5 ++--- Source/cmLocalVisualStudio7Generator.h | 2 +- Source/cmMakefile.cxx | 2 +- Source/cmMakefile.h | 2 +- 22 files changed, 60 insertions(+), 57 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 795048b..ae9c731 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1007,7 +1007,7 @@ void cmGlobalGenerator::ClearEnabledLanguages() this->LanguageEnabled.clear(); } -bool cmGlobalGenerator::IsDependedOn(const char* project, +bool cmGlobalGenerator::IsDependedOn(const std::string& project, cmTarget const* targetIn) { // Get all local gens for this project @@ -1615,7 +1615,7 @@ void cmGlobalGenerator::CheckLocalGenerators() } int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, - const char *projectName, + const std::string& projectName, const std::string& target, bool fast, std::string *output, cmMakefile *mf) { @@ -1663,8 +1663,9 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, } void cmGlobalGenerator::GenerateBuildCommand( - std::vector& makeCommand, const char*, const char*, const char*, - const std::string&, const char*, bool, std::vector const&) + std::vector& makeCommand, const char*, const std::string&, + const char*, const std::string&, const char*, bool, + std::vector const&) { makeCommand.push_back( "cmGlobalGenerator::GenerateBuildCommand not implemented"); @@ -1672,7 +1673,7 @@ void cmGlobalGenerator::GenerateBuildCommand( int cmGlobalGenerator::Build( const char *, const char *bindir, - const char *projectName, const std::string& target, + const std::string& projectName, const std::string& target, std::string *output, const char *makeCommandCSTR, const char *config, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 4779682..ce285d6 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -106,7 +106,7 @@ public: * loaded commands, not as part of the usual build process. */ virtual int TryCompile(const char *srcdir, const char *bindir, - const char *projectName, + const std::string& projectName, const std::string& targetName, bool fast, std::string *output, cmMakefile* mf); @@ -118,7 +118,7 @@ public: * done first. */ int Build(const char *srcdir, const char *bindir, - const char *projectName, const std::string& targetName, + const std::string& projectName, const std::string& targetName, std::string *output, const char *makeProgram, const char *config, bool clean, bool fast, @@ -130,7 +130,7 @@ public: virtual void GenerateBuildCommand( std::vector& makeCommand, const char* makeProgram, - const char *projectName, const char *projectDir, + const std::string& projectName, const char *projectDir, const std::string& targetName, const char* config, bool fast, std::vector const& makeOptions = std::vector() ); @@ -223,7 +223,7 @@ public: /** If check to see if the target is linked to by any other target in the project */ - bool IsDependedOn(const char* project, cmTarget const* target); + bool IsDependedOn(const std::string& project, cmTarget const* target); ///! Find a local generator by its startdirectory cmLocalGenerator* FindLocalGenerator(const std::string& start_dir) const; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index b027995..954fb17 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -552,7 +552,7 @@ bool cmGlobalNinjaGenerator::UsingMinGW = false; void cmGlobalNinjaGenerator ::GenerateBuildCommand(std::vector& makeCommand, const char* makeProgram, - const char* /*projectName*/, + const std::string& /*projectName*/, const char* /*projectDir*/, const std::string& targetName, const char* /*config*/, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 41d1510..e422e36 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -194,7 +194,7 @@ public: virtual void GenerateBuildCommand( std::vector& makeCommand, const char* makeProgram, - const char* projectName, + const std::string& projectName, const char* projectDir, const std::string& targetName, const char* config, diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 74b8e98..735887e 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -566,7 +566,7 @@ cmGlobalUnixMakefileGenerator3 void cmGlobalUnixMakefileGenerator3 ::GenerateBuildCommand(std::vector& makeCommand, const char* makeProgram, - const char* /*projectName*/, + const std::string& /*projectName*/, const char* /*projectDir*/, const std::string& targetName, const char* /*config*/, diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index f97ae9b..ffdf6fb 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -110,7 +110,7 @@ public: virtual void GenerateBuildCommand( std::vector& makeCommand, const char* makeProgram, - const char* projectName, + const std::string& projectName, const char* projectDir, const std::string& targetName, const char* config, diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 1346e13..a2991e1 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -311,7 +311,7 @@ std::string cmGlobalVisualStudio10Generator::FindDevEnvCommand() void cmGlobalVisualStudio10Generator::GenerateBuildCommand( std::vector& makeCommand, const char* makeProgram, - const char* projectName, + const std::string& projectName, const char* projectDir, const std::string& targetName, const char* config, diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 198e113..97ac9bc 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -35,7 +35,7 @@ public: virtual void GenerateBuildCommand( std::vector& makeCommand, const char* makeProgram, - const char* projectName, + const std::string& projectName, const char* projectDir, const std::string& targetName, const char* config, diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 534a493..214b9ea 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -117,7 +117,7 @@ void cmGlobalVisualStudio6Generator::GenerateBuildCommand( std::vector& makeCommand, const char* makeProgram, - const char* projectName, + const std::string& projectName, const char* /*projectDir*/, const std::string& targetName, const char* config, @@ -271,7 +271,7 @@ void cmGlobalVisualStudio6Generator::OutputDSWFile() // Note, that dependencies from executables to // the libraries it uses are also done here void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout, - const char* dspname, + const std::string& dspname, const char* dir, cmTarget const& target) { @@ -316,7 +316,7 @@ void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout, // Note, that dependencies from executables to // the libraries it uses are also done here void cmGlobalVisualStudio6Generator::WriteExternalProject(std::ostream& fout, - const char* name, + const std::string& name, const char* location, const std::set& dependencies) { diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 40b8462..f1c70e4 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -55,7 +55,7 @@ public: virtual void GenerateBuildCommand( std::vector& makeCommand, const char* makeProgram, - const char* projectName, + const std::string& projectName, const char* projectDir, const std::string& targetName, const char* config, @@ -99,9 +99,10 @@ private: void WriteDSWFile(std::ostream& fout); void WriteDSWHeader(std::ostream& fout); void WriteProject(std::ostream& fout, - const char* name, const char* path, cmTarget const& t); + const std::string& name, const char* path, + cmTarget const& t); void WriteExternalProject(std::ostream& fout, - const char* name, const char* path, + const std::string& name, const char* path, const std::set& dependencies); void WriteDSWFooter(std::ostream& fout); virtual std::string WriteUtilityDepend(cmTarget const* target); diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 22e4f08..af1a5c5 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -155,7 +155,7 @@ cmGlobalVisualStudio71Generator // the libraries it uses are also done here void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, - const char* dspname, + const std::string& dspname, const char* dir, cmTarget const& t) { @@ -208,7 +208,7 @@ cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, void cmGlobalVisualStudio71Generator ::WriteProjectDepends(std::ostream& fout, - const char*, + const std::string&, const char*, cmTarget const& target) { VSDependSet const& depends = this->VSTargetDepends[&target]; @@ -234,7 +234,7 @@ cmGlobalVisualStudio71Generator // executables to the libraries it uses are also done here void cmGlobalVisualStudio71Generator ::WriteExternalProject(std::ostream& fout, - const char* name, + const std::string& name, const char* location, const char* typeGuid, const std::set& depends) @@ -277,7 +277,7 @@ void cmGlobalVisualStudio71Generator // executables to the libraries it uses are also done here void cmGlobalVisualStudio71Generator ::WriteProjectConfigurations( - std::ostream& fout, const char* name, cmTarget::TargetType, + std::ostream& fout, const std::string& name, cmTarget::TargetType, const std::set& configsPartOfDefaultBuild, const char* platformMapping) { diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index 04e3a55..8791468 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -59,17 +59,17 @@ protected: std::vector& generators); virtual void WriteSolutionConfigurations(std::ostream& fout); virtual void WriteProject(std::ostream& fout, - const char* name, const char* path, + const std::string& name, const char* path, cmTarget const& t); virtual void WriteProjectDepends(std::ostream& fout, - const char* name, const char* path, + const std::string& name, const char* path, cmTarget const& t); virtual void WriteProjectConfigurations( - std::ostream& fout, const char* name, cmTarget::TargetType type, + std::ostream& fout, const std::string& name, cmTarget::TargetType type, const std::set& configsPartOfDefaultBuild, const char* platformMapping = NULL); virtual void WriteExternalProject(std::ostream& fout, - const char* name, + const std::string& name, const char* path, const char* typeGuid, const std::set& depends); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 5c7af00..cf84fe3 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -184,7 +184,7 @@ const char* cmGlobalVisualStudio7Generator::ExternalProjectType( void cmGlobalVisualStudio7Generator::GenerateBuildCommand( std::vector& makeCommand, const char* makeProgram, - const char* projectName, + const std::string& projectName, const char* /*projectDir*/, const std::string& targetName, const char* config, @@ -654,7 +654,7 @@ cmGlobalVisualStudio7Generator::ConvertToSolutionPath(const char* path) // Note, that dependencies from executables to // the libraries it uses are also done here void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout, - const char* dspname, + const std::string& dspname, const char* dir, cmTarget const& target) { // check to see if this is a fortran build @@ -694,7 +694,7 @@ void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout, void cmGlobalVisualStudio7Generator ::WriteProjectDepends(std::ostream& fout, - const char* dspname, + const std::string& dspname, const char*, cmTarget const& target) { int depcount = 0; @@ -730,7 +730,7 @@ cmGlobalVisualStudio7Generator // executables to the libraries it uses are also done here void cmGlobalVisualStudio7Generator ::WriteProjectConfigurations( - std::ostream& fout, const char* name, cmTarget::TargetType, + std::ostream& fout, const std::string& name, cmTarget::TargetType, const std::set& configsPartOfDefaultBuild, const char* platformMapping) { @@ -758,7 +758,7 @@ void cmGlobalVisualStudio7Generator // Note, that dependencies from executables to // the libraries it uses are also done here void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout, - const char* name, + const std::string& name, const char* location, const char* typeGuid, const std::set&) @@ -908,7 +908,7 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target) return pname; } -std::string cmGlobalVisualStudio7Generator::GetGUID(const char* name) +std::string cmGlobalVisualStudio7Generator::GetGUID(const std::string& name) { std::string guidStoreName = name; guidStoreName += "_GUID_CMAKE"; @@ -919,7 +919,7 @@ std::string cmGlobalVisualStudio7Generator::GetGUID(const char* name) return std::string(storedGUID); } cmSystemTools::Error("Unknown Target referenced : ", - name); + name.c_str()); return ""; } @@ -975,8 +975,9 @@ cmGlobalVisualStudio7Generator } std::set -cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project, - cmTarget const* target) +cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( + const std::string& project, + cmTarget const* target) { std::set activeConfigs; // if it is a utilitiy target then only make it part of the diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index a7aca60..6fb3731 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -63,7 +63,7 @@ public: virtual void GenerateBuildCommand( std::vector& makeCommand, const char* makeProgram, - const char* projectName, + const std::string& projectName, const char* projectDir, const std::string& targetName, const char* config, @@ -90,7 +90,7 @@ public: ///! Create a GUID or get an existing one. void CreateGUID(const char* name); - std::string GetGUID(const char* name); + std::string GetGUID(const std::string& name); /** Append the subdirectory for the given configuration. */ virtual void AppendDirectoryForConfig(const char* prefix, @@ -123,13 +123,13 @@ protected: virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, std::vector& generators); virtual void WriteProject(std::ostream& fout, - const char* name, const char* path, + const std::string& name, const char* path, cmTarget const& t); virtual void WriteProjectDepends(std::ostream& fout, - const char* name, const char* path, + const std::string& name, const char* path, cmTarget const&t); virtual void WriteProjectConfigurations( - std::ostream& fout, const char* name, cmTarget::TargetType type, + std::ostream& fout, const std::string& name, cmTarget::TargetType type, const std::set& configsPartOfDefaultBuild, const char* platformMapping = NULL); virtual void WriteSLNGlobalSections(std::ostream& fout, @@ -153,7 +153,7 @@ protected: void GenerateConfigurations(cmMakefile* mf); virtual void WriteExternalProject(std::ostream& fout, - const char* name, + const std::string& name, const char* path, const char* typeGuid, const std::set& @@ -161,7 +161,7 @@ protected: std::string ConvertToSolutionPath(const char* path); - std::set IsPartOfDefaultBuild(const char* project, + std::set IsPartOfDefaultBuild(const std::string& project, cmTarget const* target); std::vector Configurations; std::map GUIDMap; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 0453333..1ba74eb 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -372,7 +372,7 @@ cmGlobalVisualStudio8Generator void cmGlobalVisualStudio8Generator ::WriteProjectConfigurations( - std::ostream& fout, const char* name, cmTarget::TargetType type, + std::ostream& fout, const std::string& name, cmTarget::TargetType type, const std::set& configsPartOfDefaultBuild, const char* platformMapping) { @@ -415,7 +415,7 @@ bool cmGlobalVisualStudio8Generator::ComputeTargetDepends() //---------------------------------------------------------------------------- void cmGlobalVisualStudio8Generator::WriteProjectDepends( - std::ostream& fout, const char*, const char*, cmTarget const& t) + std::ostream& fout, const std::string&, const char*, cmTarget const& t) { TargetDependSet const& unordered = this->GetTargetDirectDepends(t); OrderedTargetDependSet depends(unordered); diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 5b952c4..bafb9eb 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -79,11 +79,12 @@ protected: virtual void WriteSLNHeader(std::ostream& fout); virtual void WriteSolutionConfigurations(std::ostream& fout); virtual void WriteProjectConfigurations( - std::ostream& fout, const char* name, cmTarget::TargetType type, + std::ostream& fout, const std::string& name, cmTarget::TargetType type, const std::set& configsPartOfDefaultBuild, const char* platformMapping = NULL); virtual bool ComputeTargetDepends(); - virtual void WriteProjectDepends(std::ostream& fout, const char* name, + virtual void WriteProjectDepends(std::ostream& fout, + const std::string& name, const char* path, cmTarget const& t); std::string Name; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 9e1e902..a1255a0 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -261,7 +261,7 @@ void cmGlobalXCodeGenerator::GenerateBuildCommand( std::vector& makeCommand, const char* makeProgram, - const char* projectName, + const std::string& projectName, const char* /*projectDir*/, const std::string& targetName, const char* config, diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 0cb1758..8e2de9a 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -56,7 +56,7 @@ public: virtual void GenerateBuildCommand( std::vector& makeCommand, const char* makeProgram, - const char* projectName, + const std::string& projectName, const char* projectDir, const std::string& targetName, const char* config, diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 786791c..280320f 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -228,7 +228,7 @@ void cmLocalVisualStudio7Generator::WriteStampFiles() //---------------------------------------------------------------------------- void cmLocalVisualStudio7Generator -::CreateSingleVCProj(const char *lname, cmTarget &target) +::CreateSingleVCProj(const std::string& lname, cmTarget &target) { this->FortranProject = static_cast(this->GlobalGenerator) @@ -245,8 +245,7 @@ void cmLocalVisualStudio7Generator } // add to the list of projects - std::string pname = lname; - target.SetProperty("GENERATOR_FILE_NAME",lname); + target.SetProperty("GENERATOR_FILE_NAME",lname.c_str()); // create the dsp.cmake file std::string fname; fname = this->Makefile->GetStartOutputDirectory(); diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 4d72747..760716e 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -66,7 +66,7 @@ public: const char* path); virtual void AddCMakeListsRules(); protected: - void CreateSingleVCProj(const char *lname, cmTarget &tgt); + void CreateSingleVCProj(const std::string& lname, cmTarget &tgt); private: typedef cmVisualStudioGeneratorOptions Options; typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e059dd3..8584ad8 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3061,7 +3061,7 @@ void cmMakefile::ExpandSourceListArguments( } int cmMakefile::TryCompile(const char *srcdir, const char *bindir, - const char *projectName, + const std::string& projectName, const std::string& targetName, bool fast, const std::vector *cmakeArgs, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 4b9c548..6475c0f 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -127,7 +127,7 @@ public: * loaded commands, not as part of the usual build process. */ int TryCompile(const char *srcdir, const char *bindir, - const char *projectName, const std::string& targetName, + const std::string& projectName, const std::string& targetName, bool fast, const std::vector *cmakeArgs, std::string *output); -- cgit v0.12 From 8455dd0a9a6c766870c7ddcb186e49a8a5db1416 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 7 Feb 2014 15:45:11 -0500 Subject: stringapi: Use strings for search paths --- Source/cmMakeDepend.cxx | 2 +- Source/cmMakeDepend.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx index 615e6f2..03ad37c 100644 --- a/Source/cmMakeDepend.cxx +++ b/Source/cmMakeDepend.cxx @@ -359,7 +359,7 @@ std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath) } // Add a directory to the search path -void cmMakeDepend::AddSearchPath(const char* path) +void cmMakeDepend::AddSearchPath(const std::string& path) { this->IncludeDirectories.push_back(path); } diff --git a/Source/cmMakeDepend.h b/Source/cmMakeDepend.h index b6e3928..2419ae9 100644 --- a/Source/cmMakeDepend.h +++ b/Source/cmMakeDepend.h @@ -94,7 +94,7 @@ public: /** * Add a directory to the search path for include files. */ - virtual void AddSearchPath(const char*); + virtual void AddSearchPath(const std::string&); /** * Generate dependencies for the file given. Returns a pointer to -- cgit v0.12 From 23e9b80f585db1cc68846a54e6e5844f970215ea Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 7 Feb 2014 15:46:27 -0500 Subject: stringapi: Use strings for globbing parameters --- Source/cmSystemTools.cxx | 12 ++++++------ Source/cmSystemTools.h | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 18eb62e..9b35e61 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -971,13 +971,14 @@ std::string cmSystemTools::ComputeStringMD5(const std::string& input) #endif } -void cmSystemTools::Glob(const char *directory, const char *regexp, +void cmSystemTools::Glob(const std::string& directory, + const std::string& regexp, std::vector& files) { cmsys::Directory d; - cmsys::RegularExpression reg(regexp); + cmsys::RegularExpression reg(regexp.c_str()); - if (d.Load(directory)) + if (d.Load(directory.c_str())) { size_t numf; unsigned int i; @@ -994,14 +995,13 @@ void cmSystemTools::Glob(const char *directory, const char *regexp, } -void cmSystemTools::GlobDirs(const char *fullPath, +void cmSystemTools::GlobDirs(const std::string& path, std::vector& files) { - std::string path = fullPath; std::string::size_type pos = path.find("/*"); if(pos == std::string::npos) { - files.push_back(fullPath); + files.push_back(path); return; } std::string startPath = path.substr(0, pos); diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index da37ceb..51c103e 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -158,9 +158,10 @@ public: static std::string FileExistsInParentDirectories(const char* fname, const char* directory, const char* toplevel); - static void Glob(const char *directory, const char *regexp, + static void Glob(const std::string& directory, const std::string& regexp, std::vector& files); - static void GlobDirs(const char *fullPath, std::vector& files); + static void GlobDirs(const std::string& fullPath, + std::vector& files); /** * Try to find a list of files that match the "simple" globbing -- cgit v0.12 From 8d60da0cb56b44815f02ece01e224e1f4eba6c80 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 8 Feb 2014 11:39:22 -0500 Subject: cmTarget: Remove the project argument to FindTarget All callers passed 0 in, so just remove the branch. --- Source/cmExportCommand.cxx | 2 +- Source/cmExportLibraryDependenciesCommand.cxx | 2 +- Source/cmGlobalGenerator.cxx | 51 +++++++++------------------ Source/cmGlobalGenerator.h | 2 +- Source/cmGlobalVisualStudio8Generator.cxx | 2 +- Source/cmLocalVisualStudio6Generator.cxx | 2 +- Source/cmMakefile.cxx | 5 ++- Source/cmTargetLinkLibrariesCommand.cxx | 2 +- Source/cmTargetPropCommandBase.cxx | 2 +- 9 files changed, 25 insertions(+), 45 deletions(-) diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index db56aaf..bda8dda 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -168,7 +168,7 @@ bool cmExportCommand return false; } - if(cmTarget* target = gg->FindTarget(0, currentTarget->c_str())) + if(cmTarget* target = gg->FindTarget(currentTarget->c_str())) { if(target->GetType() == cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index 5d6f094..469a661 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -138,7 +138,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const break; } std::string lib = li->first; - if(cmTarget* libtgt = global->FindTarget(0, lib.c_str())) + if(cmTarget* libtgt = global->FindTarget(lib.c_str())) { // Handle simple output name changes. This command is // deprecated so we do not support full target name diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index ae9c731..ba4cce8 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2070,47 +2070,28 @@ bool cmGlobalGenerator::IsAlias(const std::string& name) const //---------------------------------------------------------------------------- cmTarget* -cmGlobalGenerator::FindTarget(const char* project, const std::string& name, +cmGlobalGenerator::FindTarget(const std::string& name, bool excludeAliases) const { - // if project specific - if(project) + if (!excludeAliases) { - std::map >::const_iterator - gens = this->ProjectMap.find(project); - for(unsigned int i = 0; i < gens->second.size(); ++i) + std::map::const_iterator ai + = this->AliasTargets.find(name); + if (ai != this->AliasTargets.end()) { - cmTarget* ret = (gens->second)[i]->GetMakefile()->FindTarget(name, - excludeAliases); - if(ret) - { - return ret; - } + return ai->second; } } - // if all projects/directories - else + std::map::const_iterator i = + this->TotalTargets.find ( name ); + if ( i != this->TotalTargets.end() ) { - if (!excludeAliases) - { - std::map::const_iterator ai - = this->AliasTargets.find(name); - if (ai != this->AliasTargets.end()) - { - return ai->second; - } - } - std::map::const_iterator i = - this->TotalTargets.find ( name ); - if ( i != this->TotalTargets.end() ) - { - return i->second; - } - i = this->ImportedTargets.find(name); - if ( i != this->ImportedTargets.end() ) - { - return i->second; - } + return i->second; + } + i = this->ImportedTargets.find(name); + if ( i != this->ImportedTargets.end() ) + { + return i->second; } return 0; } @@ -2124,7 +2105,7 @@ cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) const return true; } - if(cmTarget* tgt = this->FindTarget(0, libname.c_str())) + if(cmTarget* tgt = this->FindTarget(libname.c_str())) { if(tgt->IsFrameworkOnApple()) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index ce285d6..746f715 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -211,7 +211,7 @@ public: virtual void FindMakeProgram(cmMakefile*); ///! Find a target by name by searching the local generators. - cmTarget* FindTarget(const char* project, const std::string& name, + cmTarget* FindTarget(const std::string& name, bool excludeAliases = false) const; void AddAlias(const std::string& name, cmTarget *tgt); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 1ba74eb..51825ee 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -440,7 +440,7 @@ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies( target.GetUtilities().begin(); ui != target.GetUtilities().end(); ++ui) { - if(cmTarget* depTarget = this->FindTarget(0, ui->c_str())) + if(cmTarget* depTarget = this->FindTarget(ui->c_str())) { if(depTarget->GetType() != cmTarget::INTERFACE_LIBRARY && depTarget->GetProperty("EXTERNAL_MSPROJECT")) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 88206f1..a5ac629 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1099,7 +1099,7 @@ void cmLocalVisualStudio6Generator // Compute the proper name to use to link this library. std::string lib; std::string libDebug; - cmTarget* tgt = this->GlobalGenerator->FindTarget(0, j->first.c_str()); + cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str()); if(tgt) { lib = cmSystemTools::GetFilenameWithoutExtension diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8584ad8..a94e39c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1471,7 +1471,7 @@ void cmMakefile::AddLinkLibraryForTarget(const std::string& target, if ( i != this->Targets.end()) { cmTarget* tgt = - this->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(0,lib); + this->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(lib); if(tgt) { // if it is not a static or shared library then you can not link to it @@ -4068,8 +4068,7 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name, } // Look for a target built in this project. - return this->LocalGenerator->GetGlobalGenerator()->FindTarget(0, - name.c_str(), + return this->LocalGenerator->GetGlobalGenerator()->FindTarget(name.c_str(), excludeAliases); } diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 02da933..b16f311 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -39,7 +39,7 @@ bool cmTargetLinkLibrariesCommand // Lookup the target for which libraries are specified. this->Target = this->Makefile->GetCMakeInstance() - ->GetGlobalGenerator()->FindTarget(0, args[0].c_str()); + ->GetGlobalGenerator()->FindTarget(args[0].c_str()); if(!this->Target) { cmake::MessageType t = cmake::FATAL_ERROR; // fail by default diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 2a20516..1a1cfa0 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -34,7 +34,7 @@ bool cmTargetPropCommandBase } this->Target = this->Makefile->GetCMakeInstance() - ->GetGlobalGenerator()->FindTarget(0, args[0].c_str()); + ->GetGlobalGenerator()->FindTarget(args[0].c_str()); if(!this->Target) { this->Target = this->Makefile->FindTargetToUse(args[0]); -- cgit v0.12 From 466abd846fdbe17f4cff8a6008396eb1887b70c3 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 8 Feb 2014 21:36:26 -0500 Subject: cmTargetLinkLibrariesCommand: Use a string argument --- Source/cmTargetLinkLibrariesCommand.cxx | 10 +++++----- Source/cmTargetLinkLibrariesCommand.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index b16f311..8dc407b 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -272,7 +272,7 @@ bool cmTargetLinkLibrariesCommand { // The link type was specified by the previous argument. haveLLT = false; - if (!this->HandleLibrary(args[i].c_str(), llt)) + if (!this->HandleLibrary(args[i], llt)) { return false; } @@ -301,7 +301,7 @@ bool cmTargetLinkLibrariesCommand llt = cmTarget::OPTIMIZED; } } - if (!this->HandleLibrary(args[i].c_str(), llt)) + if (!this->HandleLibrary(args[i], llt)) { return false; } @@ -352,7 +352,7 @@ cmTargetLinkLibrariesCommand //---------------------------------------------------------------------------- bool -cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, +cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, cmTarget::LinkLibraryType llt) { if(this->Target->GetType() == cmTarget::INTERFACE_LIBRARY @@ -479,13 +479,13 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, { prop = "LINK_INTERFACE_LIBRARIES_"; prop += *i; - this->Target->AppendProperty(prop.c_str(), lib); + this->Target->AppendProperty(prop.c_str(), lib.c_str()); } } if(llt == cmTarget::OPTIMIZED || llt == cmTarget::GENERAL) { // Put in the non-DEBUG configuration interfaces. - this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", lib); + this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", lib.c_str()); // Make sure the DEBUG configuration interfaces exist so that the // general one will not be used as a fall-back. diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index 6fbf722..e2f3743 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -62,7 +62,7 @@ private: ProcessingState CurrentProcessingState; - bool HandleLibrary(const char* lib, cmTarget::LinkLibraryType llt); + bool HandleLibrary(const std::string& lib, cmTarget::LinkLibraryType llt); }; -- cgit v0.12 From 4c53997f3880785953e3ab6c811626b85ee67510 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 7 Feb 2014 23:55:28 -0500 Subject: stringapi: Take strings for utility command names --- Source/cmMakefile.cxx | 4 ++-- Source/cmMakefile.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index a94e39c..7198523 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1188,7 +1188,7 @@ cmMakefile::AddCustomCommandOldStyle(const std::string& target, } //---------------------------------------------------------------------------- -void cmMakefile::AddUtilityCommand(const char* utilityName, +void cmMakefile::AddUtilityCommand(const std::string& utilityName, bool excludeFromAll, const std::vector& depends, const char* workingDirectory, @@ -1227,7 +1227,7 @@ void cmMakefile::AddUtilityCommand(const char* utilityName, //---------------------------------------------------------------------------- cmTarget* -cmMakefile::AddUtilityCommand(const char* utilityName, +cmMakefile::AddUtilityCommand(const std::string& utilityName, bool excludeFromAll, const char* workingDirectory, const std::vector& depends, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 6475c0f..39635dd 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -222,7 +222,7 @@ public: * Add a utility to the build. A utiltity target is a command that * is run every time the target is built. */ - void AddUtilityCommand(const char* utilityName, bool excludeFromAll, + void AddUtilityCommand(const std::string& utilityName, bool excludeFromAll, const std::vector& depends, const char* workingDirectory, const char* command, @@ -230,7 +230,8 @@ public: const char* arg2=0, const char* arg3=0, const char* arg4=0); - cmTarget* AddUtilityCommand(const char* utilityName, bool excludeFromAll, + cmTarget* AddUtilityCommand(const std::string& utilityName, + bool excludeFromAll, const char* workingDirectory, const std::vector& depends, const cmCustomCommandLines& commandLines, -- cgit v0.12 From 215b1addf09359507281359cd7d478c61c01a9f2 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 8 Feb 2014 00:29:59 -0500 Subject: stringapi: Take strings in escaping functions --- Source/cmLocalGenerator.cxx | 54 +++++++++++++++++--------------- Source/cmLocalGenerator.h | 9 +++--- Source/cmLocalVisualStudio7Generator.cxx | 4 +-- Source/cmLocalVisualStudio7Generator.h | 2 +- Source/cmLocalXCodeGenerator.cxx | 2 +- Source/cmLocalXCodeGenerator.h | 3 +- Source/cmSystemTools.cxx | 7 +++-- Source/cmSystemTools.h | 2 +- 8 files changed, 44 insertions(+), 39 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index ded4fc6..75f2130 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2358,7 +2358,7 @@ void cmLocalGenerator::AppendFlags(std::string& flags, //---------------------------------------------------------------------------- void cmLocalGenerator::AppendFlagEscape(std::string& flags, - const char* rawFlag) + const std::string& rawFlag) { this->AppendFlags(flags, this->EscapeForShell(rawFlag).c_str()); } @@ -3187,7 +3187,7 @@ cmLocalGenerator } //---------------------------------------------------------------------------- -std::string cmLocalGenerator::EscapeForShellOldStyle(const char* str) +std::string cmLocalGenerator::EscapeForShellOldStyle(const std::string& str) { std::string result; #if defined(_WIN32) && !defined(__CYGWIN__) @@ -3203,7 +3203,7 @@ std::string cmLocalGenerator::EscapeForShellOldStyle(const char* str) } return str; #else - for(const char* ch = str; *ch != '\0'; ++ch) + for(const char* ch = str.c_str(); *ch != '\0'; ++ch) { if(*ch == ' ') { @@ -3216,28 +3216,30 @@ std::string cmLocalGenerator::EscapeForShellOldStyle(const char* str) } //---------------------------------------------------------------------------- -static bool cmLocalGeneratorIsShellOperator(const char* str) -{ - if(strcmp(str, "<") == 0 || - strcmp(str, ">") == 0 || - strcmp(str, "<<") == 0 || - strcmp(str, ">>") == 0 || - strcmp(str, "|") == 0 || - strcmp(str, "||") == 0 || - strcmp(str, "&&") == 0 || - strcmp(str, "&>") == 0 || - strcmp(str, "1>") == 0 || - strcmp(str, "2>") == 0 || - strcmp(str, "2>&1") == 0 || - strcmp(str, "1>&2") == 0) +static bool cmLocalGeneratorIsShellOperator(const std::string& str) +{ + static std::set shellOperators; + if(shellOperators.empty()) { - return true; + shellOperators.insert("<"); + shellOperators.insert(">"); + shellOperators.insert("<<"); + shellOperators.insert(">>"); + shellOperators.insert("|"); + shellOperators.insert("||"); + shellOperators.insert("&&"); + shellOperators.insert("&>"); + shellOperators.insert("1>"); + shellOperators.insert("2>"); + shellOperators.insert("2>&1"); + shellOperators.insert("1>&2"); } - return false; + return shellOperators.count(str) > 0; } //---------------------------------------------------------------------------- -std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars, +std::string cmLocalGenerator::EscapeForShell(const std::string& str, + bool makeVars, bool forEcho) { // Do not escape shell operators. @@ -3279,28 +3281,28 @@ std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars, // Compute the buffer size needed. int size = (this->WindowsShell ? - cmsysSystem_Shell_GetArgumentSizeForWindows(str, flags) : - cmsysSystem_Shell_GetArgumentSizeForUnix(str, flags)); + cmsysSystem_Shell_GetArgumentSizeForWindows(str.c_str(), flags) : + cmsysSystem_Shell_GetArgumentSizeForUnix(str.c_str(), flags)); // Compute the shell argument itself. std::vector arg(size); if(this->WindowsShell) { - cmsysSystem_Shell_GetArgumentForWindows(str, &arg[0], flags); + cmsysSystem_Shell_GetArgumentForWindows(str.c_str(), &arg[0], flags); } else { - cmsysSystem_Shell_GetArgumentForUnix(str, &arg[0], flags); + cmsysSystem_Shell_GetArgumentForUnix(str.c_str(), &arg[0], flags); } return std::string(&arg[0]); } //---------------------------------------------------------------------------- -std::string cmLocalGenerator::EscapeForCMake(const char* str) +std::string cmLocalGenerator::EscapeForCMake(const std::string& str) { // Always double-quote the argument to take care of most escapes. std::string result = "\""; - for(const char* c = str; *c; ++c) + for(const char* c = str.c_str(); *c; ++c) { if(*c == '"') { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index c1deb09..633be5d 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -150,7 +150,8 @@ public: const char* config); ///! Append flags to a string. virtual void AppendFlags(std::string& flags, const char* newFlags); - virtual void AppendFlagEscape(std::string& flags, const char* rawFlag); + virtual void AppendFlagEscape(std::string& flags, + const std::string& rawFlag); ///! Get the include flags for the current makefile and language std::string GetIncludeFlags(const std::vector &includes, cmGeneratorTarget* target, @@ -285,14 +286,14 @@ public: system to replace make variable references. Optionally adjust escapes for the special case of passing to the native echo command. */ - std::string EscapeForShell(const char* str, bool makeVars = false, + std::string EscapeForShell(const std::string& str, bool makeVars = false, bool forEcho = false); /** Backwards-compatibility version of EscapeForShell. */ - std::string EscapeForShellOldStyle(const char* str); + std::string EscapeForShellOldStyle(const std::string& str); /** Escape the given string as an argument in a CMake script. */ - static std::string EscapeForCMake(const char* str); + static std::string EscapeForCMake(const std::string& str); enum FortranFormat { diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 280320f..7b921a3 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -2100,7 +2100,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFooter(std::ostream& fout, << "\n"; } -std::string cmLocalVisualStudio7GeneratorEscapeForXML(const char* s) +std::string cmLocalVisualStudio7GeneratorEscapeForXML(const std::string& s) { std::string ret = s; cmSystemTools::ReplaceString(ret, "&", "&"); @@ -2111,7 +2111,7 @@ std::string cmLocalVisualStudio7GeneratorEscapeForXML(const char* s) return ret; } -std::string cmLocalVisualStudio7Generator::EscapeForXML(const char* s) +std::string cmLocalVisualStudio7Generator::EscapeForXML(const std::string& s) { return cmLocalVisualStudio7GeneratorEscapeForXML(s); } diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 760716e..2823a2c 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -84,7 +84,7 @@ private: void WriteConfiguration(std::ostream& fout, const char* configName, const std::string& libName, cmTarget &tgt); - std::string EscapeForXML(const char* s); + std::string EscapeForXML(const std::string& s); std::string ConvertToXMLOutputPath(const char* path); std::string ConvertToXMLOutputPathSingle(const char* path); void OutputTargetRules(std::ostream& fout, const char* configName, diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index a9a27b9..fb8c2d1 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -37,7 +37,7 @@ cmLocalXCodeGenerator::GetTargetDirectory(cmTarget const&) const //---------------------------------------------------------------------------- void cmLocalXCodeGenerator::AppendFlagEscape(std::string& flags, - const char* rawFlag) + const std::string& rawFlag) { cmGlobalXCodeGenerator* gg = static_cast(this->GlobalGenerator); diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index edd2f5b..3bfe3a3 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -28,7 +28,8 @@ public: virtual ~cmLocalXCodeGenerator(); virtual std::string GetTargetDirectory(cmTarget const& target) const; - virtual void AppendFlagEscape(std::string& flags, const char* rawFlag); + virtual void AppendFlagEscape(std::string& flags, + const std::string& rawFlag); virtual void Generate(); virtual void GenerateInstallRules(); private: diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 9b35e61..2b17fba 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -179,10 +179,11 @@ void cmSystemTools::ExpandRegistryValues(std::string& source, KeyWOW64) } #endif -std::string cmSystemTools::EscapeQuotes(const char* str) +std::string cmSystemTools::EscapeQuotes(const std::string& str) { - std::string result = ""; - for(const char* ch = str; *ch != '\0'; ++ch) + std::string result; + result.reserve(str.size()); + for(const char* ch = str.c_str(); *ch != '\0'; ++ch) { if(*ch == '"') { diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 51c103e..4a212c2 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -47,7 +47,7 @@ public: KeyWOW64 view = KeyWOW64_Default); ///! Escape quotes in a string. - static std::string EscapeQuotes(const char* str); + static std::string EscapeQuotes(const std::string& str); /** Map help document name to file name. */ static std::string HelpFileName(std::string); -- cgit v0.12 From 270eb96df05b93023cdd3d3a186b44b4ece1d655 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 10 Feb 2014 00:21:34 -0500 Subject: strings: Remove cmStdString references Casts from std::string -> cmStdString were high on the list of things taking up time. Avoid such implicit casts across function calls by just using std::string everywhere. The comment that the symbol name is too long is no longer relevant since modern debuggers alias the templates anyways and the size is a non-issue since the underlying methods are generated since it's inherited. --- Source/CPack/cmCPackGeneratorFactory.h | 4 +- Source/CPack/cpack.cxx | 2 +- Source/CTest/cmCTestBZR.cxx | 4 +- Source/CTest/cmCTestBuildAndTestHandler.h | 2 +- Source/CTest/cmCTestBuildHandler.cxx | 12 ++-- Source/CTest/cmCTestBuildHandler.h | 14 ++-- Source/CTest/cmCTestCVS.cxx | 6 +- Source/CTest/cmCTestCVS.h | 4 +- Source/CTest/cmCTestCoverageCommand.h | 2 +- Source/CTest/cmCTestCoverageHandler.cxx | 24 +++---- Source/CTest/cmCTestCoverageHandler.h | 12 ++-- Source/CTest/cmCTestGIT.cxx | 4 +- Source/CTest/cmCTestGenericHandler.h | 2 +- Source/CTest/cmCTestGlobalVC.cxx | 2 +- Source/CTest/cmCTestGlobalVC.h | 4 +- Source/CTest/cmCTestHG.cxx | 4 +- Source/CTest/cmCTestLaunch.cxx | 2 +- Source/CTest/cmCTestLaunch.h | 2 +- Source/CTest/cmCTestMemCheckHandler.cxx | 34 +++++----- Source/CTest/cmCTestMemCheckHandler.h | 10 +-- Source/CTest/cmCTestMultiProcessHandler.cxx | 2 +- Source/CTest/cmCTestMultiProcessHandler.h | 10 +-- Source/CTest/cmCTestP4.cxx | 8 +-- Source/CTest/cmCTestSVN.cxx | 8 +-- Source/CTest/cmCTestScriptHandler.cxx | 4 +- Source/CTest/cmCTestScriptHandler.h | 28 ++++---- Source/CTest/cmCTestSubmitCommand.cxx | 6 +- Source/CTest/cmCTestSubmitHandler.cxx | 98 +++++++++++++-------------- Source/CTest/cmCTestSubmitHandler.h | 60 ++++++++-------- Source/CTest/cmCTestTestHandler.cxx | 30 ++++---- Source/CTest/cmCTestTestHandler.h | 18 ++--- Source/CTest/cmCTestUploadCommand.cxx | 2 +- Source/CTest/cmCTestVC.cxx | 4 +- Source/CTest/cmParseGTMCoverage.cxx | 2 +- Source/CTest/cmParseMumpsCoverage.cxx | 2 +- Source/CTest/cmParseMumpsCoverage.h | 2 +- Source/CTest/cmParsePHPCoverage.cxx | 4 +- Source/CTest/cmParsePHPCoverage.h | 2 +- Source/CursesDialog/cmCursesPathWidget.cxx | 2 +- Source/cmCTest.cxx | 22 +++--- Source/cmCTest.h | 20 +++--- Source/cmCacheManager.cxx | 10 +-- Source/cmCacheManager.h | 8 +-- Source/cmCommandArgumentParserHelper.h | 4 +- Source/cmComputeLinkDepends.cxx | 10 +-- Source/cmComputeLinkDepends.h | 4 +- Source/cmComputeLinkInformation.cxx | 8 +-- Source/cmComputeLinkInformation.h | 10 +-- Source/cmComputeTargetDepends.cxx | 16 ++--- Source/cmComputeTargetDepends.h | 4 +- Source/cmCoreTryCompile.cxx | 2 +- Source/cmCustomCommand.h | 2 +- Source/cmDefinitions.cxx | 20 +++--- Source/cmDefinitions.h | 23 ++++--- Source/cmDependsC.cxx | 16 ++--- Source/cmDependsC.h | 16 ++--- Source/cmDependsFortran.cxx | 40 +++++------ Source/cmDependsJavaParserHelper.cxx | 24 +++---- Source/cmDependsJavaParserHelper.h | 20 +++--- Source/cmDynamicLoader.cxx | 8 +-- Source/cmExportFileGenerator.h | 2 +- Source/cmExportInstallFileGenerator.h | 4 +- Source/cmExportLibraryDependenciesCommand.cxx | 12 ++-- Source/cmExprParserHelper.h | 4 +- Source/cmExtraCodeBlocksGenerator.cxx | 4 +- Source/cmExtraCodeLiteGenerator.cxx | 4 +- Source/cmExtraEclipseCDT4Generator.cxx | 2 +- Source/cmExtraSublimeTextGenerator.cxx | 2 +- Source/cmFileTimeComparison.cxx | 4 +- Source/cmFindBase.h | 6 +- Source/cmFindCommon.h | 4 +- Source/cmFindLibraryCommand.cxx | 4 +- Source/cmFindPackageCommand.cxx | 2 +- Source/cmFindPackageCommand.h | 12 ++-- Source/cmFindPathCommand.cxx | 10 +-- Source/cmGeneratorExpression.cxx | 2 +- Source/cmGeneratorExpression.h | 4 +- Source/cmGeneratorExpressionDAGChecker.cxx | 6 +- Source/cmGeneratorExpressionDAGChecker.h | 2 +- Source/cmGeneratorExpressionEvaluator.h | 2 +- Source/cmGeneratorTarget.cxx | 8 +-- Source/cmGetCMakePropertyCommand.cxx | 4 +- Source/cmGlobalGenerator.cxx | 38 +++++------ Source/cmGlobalGenerator.h | 46 ++++++------- Source/cmGlobalKdevelopGenerator.cxx | 6 +- Source/cmGlobalNinjaGenerator.cxx | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 12 ++-- Source/cmGlobalUnixMakefileGenerator3.h | 2 +- Source/cmGlobalVisualStudio6Generator.cxx | 6 +- Source/cmGlobalVisualStudio6Generator.h | 2 +- Source/cmGlobalVisualStudio71Generator.cxx | 4 +- Source/cmGlobalVisualStudio71Generator.h | 2 +- Source/cmGlobalVisualStudio7Generator.cxx | 4 +- Source/cmGlobalVisualStudio7Generator.h | 4 +- Source/cmGlobalVisualStudio8Generator.cxx | 4 +- Source/cmGlobalVisualStudioGenerator.cxx | 8 +-- Source/cmGlobalVisualStudioGenerator.h | 4 +- Source/cmGlobalXCodeGenerator.cxx | 82 +++++++++++----------- Source/cmGlobalXCodeGenerator.h | 16 ++--- Source/cmGraphVizWriter.cxx | 24 +++---- Source/cmGraphVizWriter.h | 12 ++-- Source/cmIDEOptions.cxx | 4 +- Source/cmIDEOptions.h | 4 +- Source/cmIncludeDirectoryCommand.cxx | 2 +- Source/cmInstallCommand.cxx | 2 +- Source/cmInstallExportGenerator.cxx | 2 +- Source/cmInstallTargetGenerator.cxx | 4 +- Source/cmLoadCacheCommand.cxx | 4 +- Source/cmLoadCacheCommand.h | 2 +- Source/cmLocalGenerator.cxx | 20 +++--- Source/cmLocalGenerator.h | 6 +- Source/cmLocalUnixMakefileGenerator3.cxx | 16 ++--- Source/cmLocalUnixMakefileGenerator3.h | 18 ++--- Source/cmLocalVisualStudio6Generator.cxx | 6 +- Source/cmLocalVisualStudio7Generator.cxx | 6 +- Source/cmMakeDepend.h | 6 +- Source/cmMakefile.cxx | 46 ++++++------- Source/cmMakefile.h | 18 ++--- Source/cmMakefileTargetGenerator.cxx | 12 ++-- Source/cmMakefileTargetGenerator.h | 12 ++-- Source/cmNinjaNormalTargetGenerator.cxx | 4 +- Source/cmNinjaTargetGenerator.h | 2 +- Source/cmOSXBundleGenerator.h | 4 +- Source/cmOrderDirectories.cxx | 20 +++--- Source/cmOrderDirectories.h | 10 +-- Source/cmPropertyDefinitionMap.cxx | 6 +- Source/cmPropertyDefinitionMap.h | 8 +-- Source/cmPropertyMap.h | 2 +- Source/cmQtAutoGenerators.cxx | 14 ++-- Source/cmRST.cxx | 4 +- Source/cmRST.h | 4 +- Source/cmSetPropertyCommand.cxx | 12 ++-- Source/cmSetPropertyCommand.h | 2 +- Source/cmSourceGroup.cxx | 2 +- Source/cmSourceGroup.h | 2 +- Source/cmStandardIncludes.h | 4 +- Source/cmSystemTools.cxx | 50 +++----------- Source/cmSystemTools.h | 17 ++--- Source/cmTarget.cxx | 80 +++++++++++----------- Source/cmTarget.h | 24 +++---- Source/cmTest.h | 2 +- Source/cmVariableWatch.h | 2 +- Source/cmVisualStudio10TargetGenerator.h | 4 +- Source/cmVisualStudioGeneratorOptions.cxx | 4 +- Source/cmXCodeObject.cxx | 6 +- Source/cmXCodeObject.h | 20 +++--- Source/cmake.cxx | 2 +- Source/cmake.h | 8 +-- Source/cmcldeps.cxx | 2 +- Source/cmcmd.cxx | 18 ++--- Source/cmcmd.h | 4 +- Tests/CMakeLib/run_compile_commands.cxx | 8 +-- 152 files changed, 808 insertions(+), 844 deletions(-) diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h index e6f74f9..010777f 100644 --- a/Source/CPack/cmCPackGeneratorFactory.h +++ b/Source/CPack/cmCPackGeneratorFactory.h @@ -42,7 +42,7 @@ public: void SetLogger(cmCPackLog* logger) { this->Logger = logger; } - typedef std::map DescriptionsMap; + typedef std::map DescriptionsMap; const DescriptionsMap& GetGeneratorsList() const { return this->GeneratorDescriptions; } @@ -50,7 +50,7 @@ private: cmCPackGenerator* NewGeneratorInternal(const std::string& name); std::vector Generators; - typedef std::map t_GeneratorCreatorsMap; + typedef std::map t_GeneratorCreatorsMap; t_GeneratorCreatorsMap GeneratorCreators; DescriptionsMap GeneratorDescriptions; cmCPackLog* Logger; diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index a19b778..d74c38d 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -68,7 +68,7 @@ int cpackUnknownArgument(const char*, void*) //---------------------------------------------------------------------------- struct cpackDefinitions { - typedef std::map MapType; + typedef std::map MapType; MapType Map; cmCPackLog *Log; }; diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index 381c70c..840ebc9 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -409,7 +409,7 @@ bool cmCTestBZR::UpdateImpl() { opts = this->CTest->GetCTestConfiguration("BZRUpdateOptions"); } - std::vector args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector args = cmSystemTools::ParseArguments(opts.c_str()); // TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY) @@ -418,7 +418,7 @@ bool cmCTestBZR::UpdateImpl() bzr_update.push_back(this->CommandLineTool.c_str()); bzr_update.push_back("pull"); - for(std::vector::const_iterator ai = args.begin(); + for(std::vector::const_iterator ai = args.begin(); ai != args.end(); ++ai) { bzr_update.push_back(ai->c_str()); diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h index ca50c64..d1e9a4d 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.h +++ b/Source/CTest/cmCTestBuildAndTestHandler.h @@ -54,7 +54,7 @@ protected: std::string &cmakeOutString, std::string &cwd, cmake *cm); - cmStdString Output; + std::string Output; std::string BuildGenerator; std::string BuildGeneratorToolset; diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index c5deb96..291c70a 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -380,7 +380,7 @@ int cmCTestBuildHandler::ProcessHandler() // Create lists of regular expression strings for errors, error exceptions, // warnings and warning exceptions. - std::vector::size_type cc; + std::vector::size_type cc; for ( cc = 0; cmCTestErrorMatches[cc]; cc ++ ) { this->CustomErrorMatches.push_back(cmCTestErrorMatches[cc]); @@ -400,7 +400,7 @@ int cmCTestBuildHandler::ProcessHandler() } // Pre-compile regular expressions objects for all regular expressions - std::vector::iterator it; + std::vector::iterator it; #define cmCTestBuildHandlerPopulateRegexVector(strings, regexes) \ regexes.clear(); \ @@ -602,7 +602,7 @@ void cmCTestBuildHandler::GenerateXMLLaunched(std::ostream& os) // Sort XML fragments in chronological order. cmFileTimeComparison ftc; FragmentCompare fragmentCompare(&ftc); - typedef std::set Fragments; + typedef std::set Fragments; Fragments fragments(fragmentCompare); // Identify fragments on disk. @@ -889,7 +889,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, const char* dir, int timeout, std::ostream& ofs) { // First generate the command and arguments - std::vector args = cmSystemTools::ParseArguments(command); + std::vector args = cmSystemTools::ParseArguments(command); if(args.size() < 1) { @@ -897,7 +897,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, } std::vector argv; - for(std::vector::const_iterator a = args.begin(); + for(std::vector::const_iterator a = args.begin(); a != args.end(); ++a) { argv.push_back(a->c_str()); @@ -1133,7 +1133,7 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, errorwarning.PostContext = ""; // Copy pre-context to report - std::deque::iterator pcit; + std::deque::iterator pcit; for ( pcit = this->PreContext.begin(); pcit != this->PreContext.end(); ++pcit ) diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h index ff7cfd6..09346f9 100644 --- a/Source/CTest/cmCTestBuildHandler.h +++ b/Source/CTest/cmCTestBuildHandler.h @@ -97,10 +97,10 @@ private: double StartBuildTime; double EndBuildTime; - std::vector CustomErrorMatches; - std::vector CustomErrorExceptions; - std::vector CustomWarningMatches; - std::vector CustomWarningExceptions; + std::vector CustomErrorMatches; + std::vector CustomErrorExceptions; + std::vector CustomWarningMatches; + std::vector CustomWarningExceptions; std::vector ReallyCustomWarningMatches; std::vector ReallyCustomWarningExceptions; std::vector ErrorWarningFileLineRegex; @@ -121,8 +121,8 @@ private: size_t BuildOutputLogSize; std::vector CurrentProcessingLine; - cmStdString SimplifySourceDir; - cmStdString SimplifyBuildDir; + std::string SimplifySourceDir; + std::string SimplifyBuildDir; size_t OutputLineCounter; typedef std::vector t_ErrorsAndWarningsVector; t_ErrorsAndWarningsVector ErrorsAndWarnings; @@ -130,7 +130,7 @@ private: size_t PostContextCount; size_t MaxPreContext; size_t MaxPostContext; - std::deque PreContext; + std::deque PreContext; int TotalErrors; int TotalWarnings; diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx index 17dbb55..ab363d0 100644 --- a/Source/CTest/cmCTestCVS.cxx +++ b/Source/CTest/cmCTestCVS.cxx @@ -99,7 +99,7 @@ bool cmCTestCVS::UpdateImpl() opts = "-dP"; } } - std::vector args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector args = cmSystemTools::ParseArguments(opts.c_str()); // Specify the start time for nightly testing. if(this->CTest->GetTestModel() == cmCTest::NIGHTLY) @@ -112,7 +112,7 @@ bool cmCTestCVS::UpdateImpl() cvs_update.push_back(this->CommandLineTool.c_str()); cvs_update.push_back("-z3"); cvs_update.push_back("update"); - for(std::vector::const_iterator ai = args.begin(); + for(std::vector::const_iterator ai = args.begin(); ai != args.end(); ++ai) { cvs_update.push_back(ai->c_str()); @@ -308,7 +308,7 @@ bool cmCTestCVS::WriteXMLUpdates(std::ostream& xml) " Gathering version information (one . per updated file):\n" " " << std::flush); - for(std::map::const_iterator + for(std::map::const_iterator di = this->Dirs.begin(); di != this->Dirs.end(); ++di) { this->WriteXMLDirectory(xml, di->first, di->second); diff --git a/Source/CTest/cmCTestCVS.h b/Source/CTest/cmCTestCVS.h index b7fe567..64e1747 100644 --- a/Source/CTest/cmCTestCVS.h +++ b/Source/CTest/cmCTestCVS.h @@ -32,8 +32,8 @@ private: virtual bool WriteXMLUpdates(std::ostream& xml); // Update status for files in each directory. - class Directory: public std::map {}; - std::map Dirs; + class Directory: public std::map {}; + std::map Dirs; std::string ComputeBranchFlag(std::string const& dir); void LoadRevisions(std::string const& file, const char* branchFlag, diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h index 11bb411..3731592 100644 --- a/Source/CTest/cmCTestCoverageCommand.h +++ b/Source/CTest/cmCTestCoverageCommand.h @@ -56,7 +56,7 @@ protected: }; bool LabelsMentioned; - std::set Labels; + std::set Labels; }; diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 0503d94..2e35b75 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -363,7 +363,7 @@ int cmCTestCoverageHandler::ProcessHandler() // setup the regex exclude stuff this->CustomCoverageExcludeRegex.clear(); - std::vector::iterator rexIt; + std::vector::iterator rexIt; for ( rexIt = this->CustomCoverageExclude.begin(); rexIt != this->CustomCoverageExclude.end(); ++ rexIt ) @@ -713,7 +713,7 @@ void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf) this->CustomCoverageExclude); this->CTest->PopulateCustomVector(mf, "CTEST_EXTRA_COVERAGE_GLOB", this->ExtraCoverageGlobs); - std::vector::iterator it; + std::vector::iterator it; for ( it = this->CustomCoverageExclude.begin(); it != this->CustomCoverageExclude.end(); ++ it ) @@ -989,8 +989,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage( << "--------------------------------------------------------------" << std::endl); - std::vector lines; - std::vector::iterator line; + std::vector lines; + std::vector::iterator line; cmSystemTools::Split(output.c_str(), lines); @@ -1504,7 +1504,7 @@ namespace //---------------------------------------------------------------------- int cmCTestCoverageHandler::RunBullseyeCoverageBranch( cmCTestCoverageHandlerContainer* cont, - std::set& coveredFileNames, + std::set& coveredFileNames, std::vector& files, std::vector& filesFullPath) { @@ -1545,7 +1545,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( outputFile.c_str() << std::endl); return 0; } - std::map fileMap; + std::map fileMap; std::vector::iterator fp = filesFullPath.begin(); for(std::vector::iterator f = files.begin(); f != files.end(); ++f, ++fp) @@ -1558,7 +1558,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( std::string lineIn; bool valid = false; // are we in a valid output file int line = 0; // line of the current file - cmStdString file; + std::string file; while(cmSystemTools::GetLineFromStream(fin, lineIn)) { bool startFile = false; @@ -1593,7 +1593,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( } count++; // move on one } - std::map::iterator + std::map::iterator i = fileMap.find(file); // if the file should be covered write out the header for that file if(i != fileMap.end()) @@ -1758,7 +1758,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( outputFile.c_str() << std::endl); return 0; } - std::set coveredFileNames; + std::set coveredFileNames; while(cmSystemTools::GetLineFromStream(fin, stdline)) { // if we have a line of output from stdout @@ -2105,10 +2105,10 @@ void cmCTestCoverageHandler::WriteXMLLabels(std::ostream& os, //---------------------------------------------------------------------------- void -cmCTestCoverageHandler::SetLabelFilter(std::set const& labels) +cmCTestCoverageHandler::SetLabelFilter(std::set const& labels) { this->LabelFilter.clear(); - for(std::set::const_iterator li = labels.begin(); + for(std::set::const_iterator li = labels.begin(); li != labels.end(); ++li) { this->LabelFilter.insert(this->GetLabelId(*li)); @@ -2158,7 +2158,7 @@ std::set cmCTestCoverageHandler::FindUncoveredFiles( { std::set extraMatches; - for(std::vector::iterator i = this->ExtraCoverageGlobs.begin(); + for(std::vector::iterator i = this->ExtraCoverageGlobs.begin(); i != this->ExtraCoverageGlobs.end(); ++i) { cmsys::Glob gl; diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h index 660f501..6a8f55d 100644 --- a/Source/CTest/cmCTestCoverageHandler.h +++ b/Source/CTest/cmCTestCoverageHandler.h @@ -55,7 +55,7 @@ public: void PopulateCustomVectors(cmMakefile *mf); /** Report coverage only for sources with these labels. */ - void SetLabelFilter(std::set const& labels); + void SetLabelFilter(std::set const& labels); private: bool ShouldIDoCoverage(const char* file, const char* srcDir, @@ -81,7 +81,7 @@ private: int HandleBullseyeCoverage(cmCTestCoverageHandlerContainer* cont); int RunBullseyeSourceSummary(cmCTestCoverageHandlerContainer* cont); int RunBullseyeCoverageBranch(cmCTestCoverageHandlerContainer* cont, - std::set& coveredFileNames, + std::set& coveredFileNames, std::vector& files, std::vector& filesFullPath); @@ -112,19 +112,19 @@ private: std::set FindUncoveredFiles( cmCTestCoverageHandlerContainer* cont); - std::vector CustomCoverageExclude; + std::vector CustomCoverageExclude; std::vector CustomCoverageExcludeRegex; - std::vector ExtraCoverageGlobs; + std::vector ExtraCoverageGlobs; // Map from source file to label ids. class LabelSet: public std::set {}; - typedef std::map LabelMapType; + typedef std::map LabelMapType; LabelMapType SourceLabels; LabelMapType TargetDirs; // Map from label name to label id. - typedef std::map LabelIdMapType; + typedef std::map LabelIdMapType; LabelIdMapType LabelIdMap; std::vector Labels; int GetLabelId(std::string const& label); diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 0e0e797..aaa01b2 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -179,8 +179,8 @@ bool cmCTestGIT::UpdateByFetchAndReset() { opts = this->CTest->GetCTestConfiguration("GITUpdateOptions"); } - std::vector args = cmSystemTools::ParseArguments(opts.c_str()); - for(std::vector::const_iterator ai = args.begin(); + std::vector args = cmSystemTools::ParseArguments(opts.c_str()); + for(std::vector::const_iterator ai = args.begin(); ai != args.end(); ++ai) { git_fetch.push_back(ai->c_str()); diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h index d05e230..2788cba 100644 --- a/Source/CTest/cmCTestGenericHandler.h +++ b/Source/CTest/cmCTestGenericHandler.h @@ -71,7 +71,7 @@ public: cmCTestGenericHandler(); virtual ~cmCTestGenericHandler(); - typedef std::map t_StringToString; + typedef std::map t_StringToString; void SetPersistentOption(const std::string& op, const char* value); diff --git a/Source/CTest/cmCTestGlobalVC.cxx b/Source/CTest/cmCTestGlobalVC.cxx index 8c51102..5f570b5 100644 --- a/Source/CTest/cmCTestGlobalVC.cxx +++ b/Source/CTest/cmCTestGlobalVC.cxx @@ -132,7 +132,7 @@ bool cmCTestGlobalVC::WriteXMLUpdates(std::ostream& xml) this->WriteXMLGlobal(xml); - for(std::map::const_iterator + for(std::map::const_iterator di = this->Dirs.begin(); di != this->Dirs.end(); ++di) { this->WriteXMLDirectory(xml, di->first, di->second); diff --git a/Source/CTest/cmCTestGlobalVC.h b/Source/CTest/cmCTestGlobalVC.h index a648a59..cb0d165 100644 --- a/Source/CTest/cmCTestGlobalVC.h +++ b/Source/CTest/cmCTestGlobalVC.h @@ -39,8 +39,8 @@ protected: }; // Update status for files in each directory. - class Directory: public std::map {}; - std::map Dirs; + class Directory: public std::map {}; + std::map Dirs; // Old and new repository revisions. std::string OldRevision; diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index 86a7617..5bf9949 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -149,8 +149,8 @@ bool cmCTestHG::UpdateImpl() { opts = this->CTest->GetCTestConfiguration("HGUpdateOptions"); } - std::vector args = cmSystemTools::ParseArguments(opts.c_str()); - for(std::vector::const_iterator ai = args.begin(); + std::vector args = cmSystemTools::ParseArguments(opts.c_str()); + for(std::vector::const_iterator ai = args.begin(); ai != args.end(); ++ai) { hg_update.push_back(ai->c_str()); diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index cd3bd57..c9f9e9e 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -567,7 +567,7 @@ void cmCTestLaunch::WriteXMLLabels(std::ostream& fxml) fxml << "\n"; fxml << "\t\t\n"; fxml << "\t\t\n"; - for(std::set::const_iterator li = this->Labels.begin(); + for(std::set::const_iterator li = this->Labels.begin(); li != this->Labels.end(); ++li) { fxml << "\t\t\t\n"; diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h index f680d19..bc90d28 100644 --- a/Source/CTest/cmCTestLaunch.h +++ b/Source/CTest/cmCTestLaunch.h @@ -73,7 +73,7 @@ private: bool HaveErr; // Labels associated with the build rule. - std::set Labels; + std::set Labels; void LoadLabels(); bool SourceMatches(std::string const& lhs, std::string const& rhs); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index fdce04d..f2982a4 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -246,8 +246,8 @@ int cmCTestMemCheckHandler::PostProcessHandler() void cmCTestMemCheckHandler::GenerateTestCommand( std::vector& args, int test) { - std::vector::size_type pp; - cmStdString index; + std::vector::size_type pp; + std::string index; cmOStringStream stream; std::string memcheckcommand = cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str()); @@ -255,9 +255,9 @@ void cmCTestMemCheckHandler::GenerateTestCommand( index = stream.str(); for ( pp = 0; pp < this->MemoryTesterDynamicOptions.size(); pp ++ ) { - cmStdString arg = this->MemoryTesterDynamicOptions[pp]; - cmStdString::size_type pos = arg.find("??"); - if (pos != cmStdString::npos) + std::string arg = this->MemoryTesterDynamicOptions[pp]; + std::string::size_type pos = arg.find("??"); + if (pos != std::string::npos) { arg.replace(pos, 2, index); } @@ -580,7 +580,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() return false; } - std::vector::size_type cc; + std::vector::size_type cc; for ( cc = 0; cmCTestMemCheckResultStrings[cc]; cc ++ ) { this->MemoryTesterGlobalResults[cc] = 0; @@ -627,7 +627,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput( const std::string& str, std::string& log, int* results) { - std::vector lines; + std::vector lines; cmSystemTools::Split(str.c_str(), lines); cmOStringStream ostr; log = ""; @@ -636,7 +636,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput( int defects = 0; - for( std::vector::iterator i = lines.begin(); + for( std::vector::iterator i = lines.begin(); i != lines.end(); ++i) { int failure = cmCTestMemCheckHandler::NO_MEMORY_FAULT; @@ -681,7 +681,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( const std::string& str, std::string& log, int* results) { - std::vector lines; + std::vector lines; cmSystemTools::Split(str.c_str(), lines); bool unlimitedOutput = false; if(str.find("CTEST_FULL_OUTPUT") != str.npos || @@ -864,10 +864,10 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput( { log = ""; double sttime = cmSystemTools::GetTime(); - std::vector lines; + std::vector lines; cmSystemTools::Split(str.c_str(), lines); cmCTestLog(this->CTest, DEBUG, "Start test: " << lines.size() << std::endl); - std::vector::size_type cc; + std::vector::size_type cc; for ( cc = 0; cc < lines.size(); cc ++ ) { if(lines[cc] == BOUNDS_CHECKER_MARKER) @@ -923,7 +923,7 @@ cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res, cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "PostProcessBoundsCheckerTest for : " << res.Name.c_str() << std::endl); - cmStdString ofile = testOutputFileName(test); + std::string ofile = testOutputFileName(test); if ( ofile.empty() ) { return; @@ -979,7 +979,7 @@ void cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res, int test) { - cmStdString ofile = testOutputFileName(test); + std::string ofile = testOutputFileName(test); if ( ofile.empty() ) { @@ -1000,15 +1000,15 @@ cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res, } } -cmStdString +std::string cmCTestMemCheckHandler::testOutputFileName(int test) { - cmStdString index; + std::string index; cmOStringStream stream; stream << test; index = stream.str(); - cmStdString ofile = this->MemoryTesterOutputFile; - cmStdString::size_type pos = ofile.find("??"); + std::string ofile = this->MemoryTesterOutputFile; + std::string::size_type pos = ofile.find("??"); ofile.replace(pos, 2, index); if ( !cmSystemTools::FileExists(ofile.c_str()) ) diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h index 040d2e0..0521a48 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -89,8 +89,8 @@ private: std::string BoundsCheckerDPBDFile; std::string BoundsCheckerXMLFile; std::string MemoryTester; - std::vector MemoryTesterDynamicOptions; - std::vector MemoryTesterOptions; + std::vector MemoryTesterDynamicOptions; + std::vector MemoryTesterOptions; int MemoryTesterStyle; std::string MemoryTesterOutputFile; int MemoryTesterGlobalResults[NO_MEMORY_FAULT]; @@ -103,8 +103,8 @@ private: */ void GenerateDartOutput(std::ostream& os); - std::vector CustomPreMemCheck; - std::vector CustomPostMemCheck; + std::vector CustomPreMemCheck; + std::vector CustomPostMemCheck; //! Parse Valgrind/Purify/Bounds Checker result out of the output //string. After running, log holds the output and results hold the @@ -127,7 +127,7 @@ private: int test); ///! generate the output filename for the given test index - cmStdString testOutputFileName(int test); + std::string testOutputFileName(int test); }; #endif diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index ddd1707..c979be3 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -369,7 +369,7 @@ void cmCTestMultiProcessHandler::UpdateCostData() // Write list of failed tests fout << "---\n"; - for(std::vector::iterator i = this->Failed->begin(); + for(std::vector::iterator i = this->Failed->begin(); i != this->Failed->end(); ++i) { fout << i->c_str() << "\n"; diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h index 1b53ec7..605de31 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.h +++ b/Source/CTest/cmCTestMultiProcessHandler.h @@ -41,8 +41,8 @@ public: void PrintTestList(); void PrintLabels(); - void SetPassFailVectors(std::vector* passed, - std::vector* failed) + void SetPassFailVectors(std::vector* passed, + std::vector* failed) { this->Passed = passed; this->Failed = failed; @@ -107,9 +107,9 @@ protected: PropertiesMap Properties; std::map TestRunningMap; std::map TestFinishMap; - std::map TestOutput; - std::vector* Passed; - std::vector* Failed; + std::map TestOutput; + std::vector* Passed; + std::vector* Failed; std::vector LastTestsFailed; std::set LockedResources; std::vector* TestResults; diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index b09d6f5..1ad94bc 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -346,10 +346,10 @@ void cmCTestP4::SetP4Options(std::vector &CommandOptions) //The CTEST_P4_OPTIONS variable adds additional Perforce command line //options before the main command std::string opts = this->CTest->GetCTestConfiguration("P4Options"); - std::vector args = + std::vector args = cmSystemTools::ParseArguments(opts.c_str()); - for(std::vector::const_iterator ai = args.begin(); + for(std::vector::const_iterator ai = args.begin(); ai != args.end(); ++ai) { P4Options.push_back(ai->c_str()); @@ -538,8 +538,8 @@ bool cmCTestP4::UpdateImpl() { opts = this->CTest->GetCTestConfiguration("P4UpdateOptions"); } - std::vector args = cmSystemTools::ParseArguments(opts.c_str()); - for(std::vector::const_iterator ai = args.begin(); + std::vector args = cmSystemTools::ParseArguments(opts.c_str()); + for(std::vector::const_iterator ai = args.begin(); ai != args.end(); ++ai) { p4_sync.push_back(ai->c_str()); diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 2668c8e..89592dd 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -277,7 +277,7 @@ bool cmCTestSVN::UpdateImpl() { opts = this->CTest->GetCTestConfiguration("SVNUpdateOptions"); } - std::vector args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector args = cmSystemTools::ParseArguments(opts.c_str()); // Specify the start time for nightly testing. if(this->CTest->GetTestModel() == cmCTest::NIGHTLY) @@ -287,7 +287,7 @@ bool cmCTestSVN::UpdateImpl() std::vector svn_update; svn_update.push_back("update"); - for(std::vector::const_iterator ai = args.begin(); + for(std::vector::const_iterator ai = args.begin(); ai != args.end(); ++ai) { svn_update.push_back(ai->c_str()); @@ -314,9 +314,9 @@ bool cmCTestSVN::RunSVNCommand(std::vector const& parameters, std::string userOptions = this->CTest->GetCTestConfiguration("SVNOptions"); - std::vector parsedUserOptions = + std::vector parsedUserOptions = cmSystemTools::ParseArguments(userOptions.c_str()); - for(std::vector::iterator i = parsedUserOptions.begin(); + for(std::vector::iterator i = parsedUserOptions.begin(); i != parsedUserOptions.end(); ++i) { args.push_back(i->c_str()); diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 00a0a09..7f13855 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -231,7 +231,7 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg) cmSystemTools::GetCTestCommand() << "\n"); // now pass through all the other arguments - std::vector &initArgs = + std::vector &initArgs = this->CTest->GetInitialCommandLineArguments(); //*** need to make sure this does not have the current script *** for(size_t i=1; i < initArgs.size(); ++i) @@ -766,7 +766,7 @@ int cmCTestScriptHandler::PerformExtraUpdates() // do an initial cvs update as required command = this->UpdateCmd; - std::vector::iterator it; + std::vector::iterator it; for (it = this->ExtraUpdates.begin(); it != this->ExtraUpdates.end(); ++ it ) diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h index 44e9dd0..42c2f20 100644 --- a/Source/CTest/cmCTestScriptHandler.h +++ b/Source/CTest/cmCTestScriptHandler.h @@ -138,26 +138,26 @@ private: // Try to remove the binary directory once static bool TryToRemoveBinaryDirectoryOnce(const std::string& directoryPath); - std::vector ConfigurationScripts; + std::vector ConfigurationScripts; std::vector ScriptProcessScope; bool Backup; bool EmptyBinDir; bool EmptyBinDirOnce; - cmStdString SourceDir; - cmStdString BinaryDir; - cmStdString BackupSourceDir; - cmStdString BackupBinaryDir; - cmStdString CTestRoot; - cmStdString CVSCheckOut; - cmStdString CTestCmd; - cmStdString UpdateCmd; - cmStdString CTestEnv; - cmStdString InitialCache; - cmStdString CMakeCmd; - cmStdString CMOutFile; - std::vector ExtraUpdates; + std::string SourceDir; + std::string BinaryDir; + std::string BackupSourceDir; + std::string BackupBinaryDir; + std::string CTestRoot; + std::string CVSCheckOut; + std::string CTestCmd; + std::string UpdateCmd; + std::string CTestEnv; + std::string InitialCache; + std::string CMakeCmd; + std::string CMOutFile; + std::vector ExtraUpdates; double MinimumInterval; double ContinuousDuration; diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 24974e3..07a994d 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -72,7 +72,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() if (notesFilesVariable) { std::vector notesFiles; - std::vector newNotesFiles; + cmCTest::VectorOfStrings newNotesFiles; cmSystemTools::ExpandListArgument(notesFilesVariable,notesFiles); std::vector::iterator it; for ( it = notesFiles.begin(); @@ -89,7 +89,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() if (extraFilesVariable) { std::vector extraFiles; - std::vector newExtraFiles; + cmCTest::VectorOfStrings newExtraFiles; cmSystemTools::ExpandListArgument(extraFilesVariable,extraFiles); std::vector::iterator it; for ( it = extraFiles.begin(); @@ -222,7 +222,7 @@ bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg) if(this->ArgumentDoing == ArgumentDoingFiles) { - cmStdString filename(arg); + std::string filename(arg); if(cmSystemTools::FileExists(filename.c_str())) { this->Files.insert(filename); diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 139f515..1cd8fc7 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -170,10 +170,10 @@ void cmCTestSubmitHandler::Initialize() } //---------------------------------------------------------------------------- -bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, - const std::set& files, - const cmStdString& remoteprefix, - const cmStdString& url) +bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix, + const std::set& files, + const std::string& remoteprefix, + const std::string& url) { CURL *curl; CURLcode res; @@ -217,12 +217,12 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, ::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); - cmStdString local_file = *file; + std::string local_file = *file; if ( !cmSystemTools::FileExists(local_file.c_str()) ) { local_file = localprefix + "/" + *file; } - cmStdString upload_as + std::string upload_as = url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file); struct stat st; @@ -324,10 +324,10 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, //---------------------------------------------------------------------------- // Uploading files is simpler -bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, - const std::set& files, - const cmStdString& remoteprefix, - const cmStdString& url) +bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, + const std::set& files, + const std::string& remoteprefix, + const std::string& url) { CURL *curl; CURLcode res; @@ -336,8 +336,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, /* In windows, this will init the winsock stuff */ ::curl_global_init(CURL_GLOBAL_ALL); - cmStdString dropMethod(this->CTest->GetCTestConfiguration("DropMethod")); - cmStdString curlopt(this->CTest->GetCTestConfiguration("CurlOptions")); + std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod")); + std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions")); std::vector args; cmSystemTools::ExpandListArgument(curlopt.c_str(), args); bool verifyPeerOff = false; @@ -354,7 +354,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, verifyHostOff = true; } } - cmStdString::size_type kk; + std::string::size_type kk; cmCTest::SetOfStrings::const_iterator file; for ( file = files.begin(); file != files.end(); ++file ) { @@ -414,18 +414,18 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, ::curl_easy_setopt(curl, CURLOPT_PUT, 1); ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); - cmStdString local_file = *file; + std::string local_file = *file; if ( !cmSystemTools::FileExists(local_file.c_str()) ) { local_file = localprefix + "/" + *file; } - cmStdString remote_file + std::string remote_file = remoteprefix + cmSystemTools::GetFilenameName(*file); *this->LogFile << "\tUpload file: " << local_file.c_str() << " to " << remote_file.c_str() << std::endl; - cmStdString ofile = ""; + std::string ofile = ""; for ( kk = 0; kk < remote_file.size(); kk ++ ) { char c = remote_file[kk]; @@ -448,8 +448,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, ofile.append(hexCh); } } - cmStdString upload_as - = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") + std::string upload_as + = url + ((url.find("?",0) == std::string::npos) ? "?" : "&") + "FileName=" + ofile; upload_as += "&MD5="; @@ -666,9 +666,9 @@ void cmCTestSubmitHandler //---------------------------------------------------------------------------- bool cmCTestSubmitHandler::TriggerUsingHTTP( - const std::set& files, - const cmStdString& remoteprefix, - const cmStdString& url) + const std::set& files, + const std::string& remoteprefix, + const std::string& url) { CURL *curl; char error_buffer[1024]; @@ -721,10 +721,10 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP( ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk); ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug); - cmStdString rfile + std::string rfile = remoteprefix + cmSystemTools::GetFilenameName(*file); - cmStdString ofile = ""; - cmStdString::iterator kk; + std::string ofile = ""; + std::string::iterator kk; for ( kk = rfile.begin(); kk < rfile.end(); ++ kk) { char c = *kk; @@ -747,8 +747,8 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP( ofile.append(hexCh); } } - cmStdString turl - = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") + std::string turl + = url + ((url.find("?",0) == std::string::npos) ? "?" : "&") + "xmlfile=" + ofile; *this->LogFile << "Trigger url: " << turl.c_str() << std::endl; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Trigger url: " @@ -805,11 +805,11 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP( //---------------------------------------------------------------------------- bool cmCTestSubmitHandler::SubmitUsingSCP( - const cmStdString& scp_command, - const cmStdString& localprefix, - const std::set& files, - const cmStdString& remoteprefix, - const cmStdString& url) + const std::string& scp_command, + const std::string& localprefix, + const std::set& files, + const std::string& remoteprefix, + const std::string& url) { if ( !scp_command.size() || !localprefix.size() || !files.size() || !remoteprefix.size() || !url.size() ) @@ -906,10 +906,10 @@ bool cmCTestSubmitHandler::SubmitUsingSCP( //---------------------------------------------------------------------------- bool cmCTestSubmitHandler::SubmitUsingCP( - const cmStdString& localprefix, - const std::set& files, - const cmStdString& remoteprefix, - const cmStdString& destination) + const std::string& localprefix, + const std::set& files, + const std::string& remoteprefix, + const std::string& destination) { if ( !localprefix.size() || !files.size() || !remoteprefix.size() || !destination.size() ) @@ -947,17 +947,17 @@ bool cmCTestSubmitHandler::SubmitUsingCP( //---------------------------------------------------------------------------- #if defined(CTEST_USE_XMLRPC) -bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, - const std::set& files, - const cmStdString& remoteprefix, - const cmStdString& url) +bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const std::string& localprefix, + const std::set& files, + const std::string& remoteprefix, + const std::string& url) { xmlrpc_env env; char ctestString[] = "CTest"; std::string ctestVersionString = cmVersion::GetCMakeVersion(); char* ctestVersion = const_cast(ctestVersionString.c_str()); - cmStdString realURL = url + "/" + remoteprefix + "/Command/"; + std::string realURL = url + "/" + remoteprefix + "/Command/"; /* Start up our XML-RPC client library. */ xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, ctestString, ctestVersion); @@ -973,7 +973,7 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, { xmlrpc_value *result; - cmStdString local_file = *file; + std::string local_file = *file; if ( !cmSystemTools::FileExists(local_file.c_str()) ) { local_file = localprefix + "/" + *file; @@ -1045,10 +1045,10 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, return true; } #else -bool cmCTestSubmitHandler::SubmitUsingXMLRPC(cmStdString const&, - std::set const&, - cmStdString const&, - cmStdString const&) +bool cmCTestSubmitHandler::SubmitUsingXMLRPC(std::string const&, + std::set const&, + std::string const&, + std::string const&) { return false; } @@ -1085,7 +1085,7 @@ int cmCTestSubmitHandler::ProcessHandler() } if ( getenv("HTTP_PROXY_TYPE") ) { - cmStdString type = getenv("HTTP_PROXY_TYPE"); + std::string type = getenv("HTTP_PROXY_TYPE"); // HTTP/SOCKS4/SOCKS5 if ( type == "HTTP" ) { @@ -1122,7 +1122,7 @@ int cmCTestSubmitHandler::ProcessHandler() } if ( getenv("FTP_PROXY_TYPE") ) { - cmStdString type = getenv("FTP_PROXY_TYPE"); + std::string type = getenv("FTP_PROXY_TYPE"); // HTTP/SOCKS4/SOCKS5 if ( type == "HTTP" ) { @@ -1178,7 +1178,7 @@ int cmCTestSubmitHandler::ProcessHandler() this->CTest->AddIfExists(cmCTest::PartTest, "Test.xml"); if(this->CTest->AddIfExists(cmCTest::PartCoverage, "Coverage.xml")) { - cmCTest::VectorOfStrings gfiles; + std::vector gfiles; std::string gpath = buildDirectory + "/Testing/" + this->CTest->GetCurrentTag(); std::string::size_type glen = gpath.size() + 1; @@ -1247,7 +1247,7 @@ int cmCTestSubmitHandler::ProcessHandler() } this->SetLogFile(&ofs); - cmStdString dropMethod(this->CTest->GetCTestConfiguration("DropMethod")); + std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod")); if ( dropMethod == "" || dropMethod == "ftp" ) { diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index 14eac80..accabd1 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -47,33 +47,33 @@ private: /** * Submit file using various ways */ - bool SubmitUsingFTP(const cmStdString& localprefix, - const std::set& files, - const cmStdString& remoteprefix, - const cmStdString& url); - bool SubmitUsingHTTP(const cmStdString& localprefix, - const std::set& files, - const cmStdString& remoteprefix, - const cmStdString& url); - bool SubmitUsingSCP(const cmStdString& scp_command, - const cmStdString& localprefix, - const std::set& files, - const cmStdString& remoteprefix, - const cmStdString& url); - - bool SubmitUsingCP( const cmStdString& localprefix, - const std::set& files, - const cmStdString& remoteprefix, - const cmStdString& url); - - bool TriggerUsingHTTP(const std::set& files, - const cmStdString& remoteprefix, - const cmStdString& url); - - bool SubmitUsingXMLRPC(const cmStdString& localprefix, - const std::set& files, - const cmStdString& remoteprefix, - const cmStdString& url); + bool SubmitUsingFTP(const std::string& localprefix, + const std::set& files, + const std::string& remoteprefix, + const std::string& url); + bool SubmitUsingHTTP(const std::string& localprefix, + const std::set& files, + const std::string& remoteprefix, + const std::string& url); + bool SubmitUsingSCP(const std::string& scp_command, + const std::string& localprefix, + const std::set& files, + const std::string& remoteprefix, + const std::string& url); + + bool SubmitUsingCP( const std::string& localprefix, + const std::set& files, + const std::string& remoteprefix, + const std::string& url); + + bool TriggerUsingHTTP(const std::set& files, + const std::string& remoteprefix, + const std::string& url); + + bool SubmitUsingXMLRPC(const std::string& localprefix, + const std::set& files, + const std::string& remoteprefix, + const std::string& url); typedef std::vector cmCTestSubmitHandlerVectorOfChar; @@ -82,10 +82,10 @@ private: std::string GetSubmitResultsPrefix(); class ResponseParser; - cmStdString HTTPProxy; + std::string HTTPProxy; int HTTPProxyType; - cmStdString HTTPProxyAuth; - cmStdString FTPProxy; + std::string HTTPProxyAuth; + std::string FTPProxy; int FTPProxyType; std::ostream* LogFile; bool SubmitPart[cmCTest::PartCount]; diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 3a04b33..b1dddcb 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -540,8 +540,8 @@ int cmCTestTestHandler::ProcessHandler() this->StartLogFile((this->MemCheck ? "DynamicAnalysis" : "Test"), mLogFile); this->LogFile = &mLogFile; - std::vector passed; - std::vector failed; + std::vector passed; + std::vector failed; int total; //start the real time clock @@ -569,7 +569,7 @@ int cmCTestTestHandler::ProcessHandler() { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl << "The following tests passed:" << std::endl); - for(std::vector::iterator j = passed.begin(); + for(std::vector::iterator j = passed.begin(); j != passed.end(); ++j) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "\t" << *j @@ -661,8 +661,8 @@ void cmCTestTestHandler::PrintLabelSummary() cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin(); cmCTestTestHandler::TestResultsVector::iterator ri = this->TestResults.begin(); - std::map labelTimes; - std::set labels; + std::map labelTimes; + std::set labels; // initialize maps std::string::size_type maxlen = 0; for(; it != this->TestList.end(); ++it) @@ -702,7 +702,7 @@ void cmCTestTestHandler::PrintLabelSummary() { cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nLabel Time Summary:"); } - for(std::set::const_iterator i = labels.begin(); + for(std::set::const_iterator i = labels.begin(); i != labels.end(); ++i) { std::string label = *i; @@ -1050,8 +1050,8 @@ bool cmCTestTestHandler::GetValue(const char* tag, } //--------------------------------------------------------------------- -void cmCTestTestHandler::ProcessDirectory(std::vector &passed, - std::vector &failed) +void cmCTestTestHandler::ProcessDirectory(std::vector &passed, + std::vector &failed) { this->ComputeTestList(); this->StartTest = this->CTest->CurrentTime(); @@ -1216,7 +1216,7 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os) << "name=\"Command Line\">" << cmXMLSafe(result->FullCommandLine) << "\n"; - std::map::iterator measureIt; + std::map::iterator measureIt; for ( measureIt = result->Properties->Measurements.begin(); measureIt != result->Properties->Measurements.end(); ++ measureIt ) @@ -1328,9 +1328,9 @@ void cmCTestTestHandler::AttachFiles(std::ostream& os, } //---------------------------------------------------------------------- -int cmCTestTestHandler::ExecuteCommands(std::vector& vec) +int cmCTestTestHandler::ExecuteCommands(std::vector& vec) { - std::vector::iterator it; + std::vector::iterator it; for ( it = vec.begin(); it != vec.end(); ++it ) { int retVal = 0; @@ -2112,7 +2112,7 @@ bool cmCTestTestHandler::SetTestsProperties( const std::vector& args) { std::vector::const_iterator it; - std::vector tests; + std::vector tests; bool found = false; for ( it = args.begin(); it != args.end(); ++ it ) { @@ -2137,7 +2137,7 @@ bool cmCTestTestHandler::SetTestsProperties( break; } std::string val = *it; - std::vector::const_iterator tit; + std::vector::const_iterator tit; for ( tit = tests.begin(); tit != tests.end(); ++ tit ) { cmCTestTestHandler::ListOfTests::iterator rtit; @@ -2319,7 +2319,7 @@ bool cmCTestTestHandler::AddTest(const std::vector& args) } if ( this->MemCheck ) { - std::vector::iterator it; + std::vector::iterator it; bool found = false; for ( it = this->CustomTestsIgnore.begin(); it != this->CustomTestsIgnore.end(); ++ it ) @@ -2339,7 +2339,7 @@ bool cmCTestTestHandler::AddTest(const std::vector& args) } else { - std::vector::iterator it; + std::vector::iterator it; bool found = false; for ( it = this->CustomTestsIgnore.begin(); it != this->CustomTestsIgnore.end(); ++ it ) diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 63f9c93..fe43bb8 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -87,8 +87,8 @@ public: // ctest -j N will break for that feature struct cmCTestTestProperties { - cmStdString Name; - cmStdString Directory; + std::string Name; + std::string Directory; std::vector Args; std::vector RequiredFiles; std::vector Depends; @@ -98,7 +98,7 @@ public: std::string> > ErrorRegularExpressions; std::vector > RequiredRegularExpressions; - std::map Measurements; + std::map Measurements; bool IsInBasedOnREOptions; bool WillFail; float Cost; @@ -162,7 +162,7 @@ protected: virtual int PreProcessHandler(); virtual int PostProcessHandler(); virtual void GenerateTestCommand(std::vector& args, int test); - int ExecuteCommands(std::vector& vec); + int ExecuteCommands(std::vector& vec); void WriteTestResultHeader(std::ostream& os, cmCTestTestResult* result); void WriteTestResultFooter(std::ostream& os, cmCTestTestResult* result); @@ -177,7 +177,7 @@ protected: typedef std::vector TestResultsVector; TestResultsVector TestResults; - std::vector CustomTestsIgnore; + std::vector CustomTestsIgnore; std::string StartTest; std::string EndTest; unsigned int StartTestTime; @@ -210,8 +210,8 @@ private: /** * Run the tests for a directory and any subdirectories */ - void ProcessDirectory(std::vector &passed, - std::vector &failed); + void ProcessDirectory(std::vector &passed, + std::vector &failed); /** * Get the list of tests in directory and subdirectories. @@ -251,8 +251,8 @@ private: void ExpandTestsToRunInformation(size_t numPossibleTests); void ExpandTestsToRunInformationForRerunFailed(); - std::vector CustomPreTest; - std::vector CustomPostTest; + std::vector CustomPreTest; + std::vector CustomPostTest; std::vector TestsToRun; diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx index 731c1c7..f7de294 100644 --- a/Source/CTest/cmCTestUploadCommand.cxx +++ b/Source/CTest/cmCTestUploadCommand.cxx @@ -47,7 +47,7 @@ bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg) { if(this->ArgumentDoing == ArgumentDoingFiles) { - cmStdString filename(arg); + std::string filename(arg); if(cmSystemTools::FileExists(filename.c_str())) { this->Files.insert(filename); diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx index fbee227..f89fa2b 100644 --- a/Source/CTest/cmCTestVC.cxx +++ b/Source/CTest/cmCTestVC.cxx @@ -63,9 +63,9 @@ bool cmCTestVC::InitialCheckout(const char* command) } // Construct the initial checkout command line. - std::vector args = cmSystemTools::ParseArguments(command); + std::vector args = cmSystemTools::ParseArguments(command); std::vector vc_co; - for(std::vector::const_iterator ai = args.begin(); + for(std::vector::const_iterator ai = args.begin(); ai != args.end(); ++ai) { vc_co.push_back(ai->c_str()); diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx index 528d0db..5bcfeac 100644 --- a/Source/CTest/cmParseGTMCoverage.cxx +++ b/Source/CTest/cmParseGTMCoverage.cxx @@ -182,7 +182,7 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line, // ( file , entry ) = "number_executed:timing_info" // ^COVERAGE("%RSEL","init",8,"FOR_LOOP",1)=1 // ( file , entry, line, IGNORE ) =number_executed - std::vector args; + std::vector args; std::string::size_type pos = line.find('(', 0); // if no ( is found, then return line has no coverage if(pos == std::string::npos) diff --git a/Source/CTest/cmParseMumpsCoverage.cxx b/Source/CTest/cmParseMumpsCoverage.cxx index 6226feb..fe98964 100644 --- a/Source/CTest/cmParseMumpsCoverage.cxx +++ b/Source/CTest/cmParseMumpsCoverage.cxx @@ -140,7 +140,7 @@ bool cmParseMumpsCoverage::LoadPackages(const char* d) bool cmParseMumpsCoverage::FindMumpsFile(std::string const& routine, std::string& filepath) { - std::map::iterator i = + std::map::iterator i = this->RoutineToDirectory.find(routine); if(i != this->RoutineToDirectory.end()) { diff --git a/Source/CTest/cmParseMumpsCoverage.h b/Source/CTest/cmParseMumpsCoverage.h index c1effa7..bc71891 100644 --- a/Source/CTest/cmParseMumpsCoverage.h +++ b/Source/CTest/cmParseMumpsCoverage.h @@ -44,7 +44,7 @@ protected: bool FindMumpsFile(std::string const& routine, std::string& filepath); protected: - std::map RoutineToDirectory; + std::map RoutineToDirectory; cmCTestCoverageHandlerContainer& Coverage; cmCTest* CTest; }; diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx index 1c26c1c..3b7f968 100644 --- a/Source/CTest/cmParsePHPCoverage.cxx +++ b/Source/CTest/cmParsePHPCoverage.cxx @@ -34,7 +34,7 @@ bool cmParsePHPCoverage::ReadUntil(std::istream& in, char until) return true; } bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in, - cmStdString const& fileName) + std::string const& fileName) { cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector = this->Coverage.TotalCoverage[fileName]; @@ -166,7 +166,7 @@ bool cmParsePHPCoverage::ReadFileInformation(std::istream& in) // read the string data in.read(s, size-1); s[size-1] = 0; - cmStdString fileName = s; + std::string fileName = s; delete [] s; // read close quote if(in.get(c) && c != '"') diff --git a/Source/CTest/cmParsePHPCoverage.h b/Source/CTest/cmParsePHPCoverage.h index 035a093..92a7634 100644 --- a/Source/CTest/cmParsePHPCoverage.h +++ b/Source/CTest/cmParsePHPCoverage.h @@ -35,7 +35,7 @@ private: bool ReadArraySize(std::istream& in, int& size); bool ReadFileInformation(std::istream& in); bool ReadInt(std::istream& in, int& v); - bool ReadCoverageArray(std::istream& in, cmStdString const&); + bool ReadCoverageArray(std::istream& in, std::string const&); bool ReadUntil(std::istream& in, char until); cmCTestCoverageHandlerContainer& Coverage; cmCTest* CTest; diff --git a/Source/CursesDialog/cmCursesPathWidget.cxx b/Source/CursesDialog/cmCursesPathWidget.cxx index 14c325b..893ca99 100644 --- a/Source/CursesDialog/cmCursesPathWidget.cxx +++ b/Source/CursesDialog/cmCursesPathWidget.cxx @@ -57,7 +57,7 @@ void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w) { glob = cstr + "*"; } - std::vector dirs; + std::vector dirs; cmSystemTools::SimpleGlob(glob.c_str(), dirs, (this->Type == cmCacheManager::PATH?-1:0)); if ( this->CurrentIndex < dirs.size() ) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 72bb7fd..ee9b664 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1153,7 +1153,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output, int* retVal, const char* dir, int timeout, std::ostream& ofs) { // First generate the command and arguments - std::vector args = cmSystemTools::ParseArguments(command); + std::vector args = cmSystemTools::ParseArguments(command); if(args.size() < 1) { @@ -1161,7 +1161,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output, } std::vector argv; - for(std::vector::const_iterator a = args.begin(); + for(std::vector::const_iterator a = args.begin(); a != args.end(); ++a) { argv.push_back(a->c_str()); @@ -1637,7 +1637,7 @@ int cmCTest::GenerateCTestNotesOutput(std::ostream& os, } //---------------------------------------------------------------------- -int cmCTest::GenerateNotesFile(const std::vector &files) +int cmCTest::GenerateNotesFile(const VectorOfStrings &files) { cmGeneratedFileStream ofs; if ( !this->OpenOutputFile(this->CurrentTag, "Notes.xml", ofs) ) @@ -1658,7 +1658,7 @@ int cmCTest::GenerateNotesFile(const char* cfiles) return 1; } - std::vector files; + VectorOfStrings files; cmCTestLog(this, OUTPUT, "Create notes file" << std::endl); @@ -1675,7 +1675,7 @@ int cmCTest::GenerateNotesFile(const char* cfiles) std::string cmCTest::Base64GzipEncodeFile(std::string file) { std::string tarFile = file + "_temp.tar.gz"; - std::vector files; + std::vector files; files.push_back(file); if(!cmSystemTools::CreateTar(tarFile.c_str(), files, true, false, false)) @@ -1722,9 +1722,9 @@ std::string cmCTest::Base64EncodeFile(std::string file) //---------------------------------------------------------------------- -bool cmCTest::SubmitExtraFiles(const std::vector &files) +bool cmCTest::SubmitExtraFiles(const VectorOfStrings &files) { - std::vector::const_iterator it; + VectorOfStrings::const_iterator it; for ( it = files.begin(); it != files.end(); ++ it ) @@ -1749,7 +1749,7 @@ bool cmCTest::SubmitExtraFiles(const char* cfiles) return 1; } - std::vector files; + VectorOfStrings files; cmCTestLog(this, OUTPUT, "Submit extra files" << std::endl); @@ -2594,7 +2594,7 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) //---------------------------------------------------------------------- void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def, - VectorOfStrings& vec) + std::vector& vec) { const char* dval = mf->GetDefinition(def); if ( !dval ) @@ -2892,7 +2892,7 @@ bool cmCTest::RunCommand( const char* dir, double timeout) { - std::vector args = cmSystemTools::ParseArguments(command); + std::vector args = cmSystemTools::ParseArguments(command); if(args.size() < 1) { @@ -2900,7 +2900,7 @@ bool cmCTest::RunCommand( } std::vector argv; - for(std::vector::const_iterator a = args.begin(); + for(std::vector::const_iterator a = args.begin(); a != args.end(); ++a) { argv.push_back(a->c_str()); diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 1eb0e01..836e41d 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -101,8 +101,8 @@ public: if the string does not name a valid part. */ Part GetPartFromName(const char* name); - typedef std::vector VectorOfStrings; - typedef std::set SetOfStrings; + typedef std::vector VectorOfStrings; + typedef std::set SetOfStrings; ///! Process Command line arguments int Run(std::vector &, std::string* output = 0); @@ -186,7 +186,7 @@ public: void SetNotesFiles(const char* notes); void PopulateCustomVector(cmMakefile* mf, const std::string& definition, - VectorOfStrings& vec); + std::vector& vec); void PopulateCustomInteger(cmMakefile* mf, const std::string& def, int& val); @@ -352,11 +352,11 @@ public: void AddCTestConfigurationOverwrite(const std::string& encstr); //! Create XML file that contains all the notes specified - int GenerateNotesFile(const std::vector &files); + int GenerateNotesFile(const VectorOfStrings &files); //! Submit extra files to the server bool SubmitExtraFiles(const char* files); - bool SubmitExtraFiles(const std::vector &files); + bool SubmitExtraFiles(const VectorOfStrings &files); //! Set the output log file name void SetOutputLogFileName(const char* name); @@ -391,7 +391,7 @@ public: //! Read the custom configuration files and apply them to the current ctest int ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf); - std::vector &GetInitialCommandLineArguments() + std::vector &GetInitialCommandLineArguments() { return this->InitialCommandLineArguments; }; //! Set the track to submit to @@ -447,13 +447,13 @@ private: void DetermineNextDayStop(); // these are helper classes - typedef std::map t_TestingHandlers; + typedef std::map t_TestingHandlers; t_TestingHandlers TestingHandlers; bool ShowOnly; //! Map of configuration properties - typedef std::map CTestConfigurationMap; + typedef std::map CTestConfigurationMap; std::string CTestConfigFile; // TODO: The ctest configuration should be a hierarchy of @@ -463,7 +463,7 @@ private: CTestConfigurationMap CTestConfiguration; CTestConfigurationMap CTestConfigurationOverwrites; PartInfo Parts[PartCount]; - typedef std::map PartMapType; + typedef std::map PartMapType; PartMapType PartMap; std::string CurrentTag; @@ -556,7 +556,7 @@ private: int DartVersion; bool DropSiteCDash; - std::vector InitialCommandLineArguments; + std::vector InitialCommandLineArguments; int SubmitIndex; diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 141fde5..39b9ae5 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -90,7 +90,7 @@ bool cmCacheManager::LoadCache(const std::string& path) bool cmCacheManager::LoadCache(const std::string& path, bool internal) { - std::set emptySet; + std::set emptySet; return this->LoadCache(path, internal, emptySet, emptySet); } @@ -195,8 +195,8 @@ void cmCacheManager::CleanCMakeFiles(const std::string& path) bool cmCacheManager::LoadCache(const std::string& path, bool internal, - std::set& excludes, - std::set& includes) + std::set& excludes, + std::set& includes) { std::string cacheFile = path; cacheFile += "/CMakeCache.txt"; @@ -500,7 +500,7 @@ bool cmCacheManager::SaveCache(const std::string& path) fout << "########################\n"; fout << "\n"; - for( std::map::const_iterator i = + for( std::map::const_iterator i = this->Cache.begin(); i != this->Cache.end(); ++i) { const CacheEntry& ce = (*i).second; @@ -693,7 +693,7 @@ void cmCacheManager::PrintCache(std::ostream& out) const { out << "=================================================" << std::endl; out << "CMakeCache Contents:" << std::endl; - for(std::map::const_iterator i = + for(std::map::const_iterator i = this->Cache.begin(); i != this->Cache.end(); ++i) { if((*i).second.Type != INTERNAL) diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 14cb1d9..573f828 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -72,7 +72,7 @@ public: void SetType(CacheEntryType ty) { this->GetEntry().Type = ty; } bool Initialized() { return this->GetEntry().Initialized; } cmCacheManager &Container; - std::map::iterator Position; + std::map::iterator Position; CacheIterator(cmCacheManager &cm) : Container(cm) { this->Begin(); } @@ -111,8 +111,8 @@ public: bool LoadCache(const std::string& path); bool LoadCache(const std::string& path, bool internal); bool LoadCache(const std::string& path, bool internal, - std::set& excludes, - std::set& includes); + std::set& excludes, + std::set& includes); ///! Save cache for given makefile. Saves to ouput home CMakeCache.txt. bool SaveCache(cmMakefile*) ; @@ -166,7 +166,7 @@ protected: unsigned int CacheMinorVersion; private: cmake* CMakeInstance; - typedef std::map CacheEntryMap; + typedef std::map CacheEntryMap; static void OutputHelpString(std::ostream& fout, const std::string& helpString); static void OutputKey(std::ostream& fout, std::string const& key); diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h index da00124..d375ae6 100644 --- a/Source/cmCommandArgumentParserHelper.h +++ b/Source/cmCommandArgumentParserHelper.h @@ -77,8 +77,8 @@ public: char BSLASHVariable[3]; private: - cmStdString::size_type InputBufferPos; - cmStdString InputBuffer; + std::string::size_type InputBufferPos; + std::string InputBuffer; std::vector OutputBuffer; int CurrentLine; int Verbose; diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index d51e6e6..6c1c1de 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -279,12 +279,12 @@ cmComputeLinkDepends::Compute() } //---------------------------------------------------------------------------- -std::map::iterator +std::map::iterator cmComputeLinkDepends::AllocateLinkEntry(std::string const& item) { - std::map::value_type + std::map::value_type index_entry(item, static_cast(this->EntryList.size())); - std::map::iterator + std::map::iterator lei = this->LinkEntryIndex.insert(index_entry).first; this->EntryList.push_back(LinkEntry()); this->InferredDependSets.push_back(0); @@ -297,7 +297,7 @@ int cmComputeLinkDepends::AddLinkEntry(int depender_index, std::string const& item) { // Check if the item entry has already been added. - std::map::iterator lei = this->LinkEntryIndex.find(item); + std::map::iterator lei = this->LinkEntryIndex.find(item); if(lei != this->LinkEntryIndex.end()) { // Yes. We do not need to follow the item's dependencies again. @@ -423,7 +423,7 @@ cmComputeLinkDepends void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) { // Check if the target already has an entry. - std::map::iterator lei = + std::map::iterator lei = this->LinkEntryIndex.find(dep.Item); if(lei == this->LinkEntryIndex.end()) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 26bf6db..ac5e368 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -76,7 +76,7 @@ private: typedef cmTarget::LinkLibraryVectorType LinkLibraryVectorType; - std::map::iterator + std::map::iterator AllocateLinkEntry(std::string const& item); int AddLinkEntry(int depender_index, std::string const& item); void AddVarLinkEntries(int depender_index, const char* value); @@ -88,7 +88,7 @@ private: // One entry for each unique item. std::vector EntryList; - std::map LinkEntryIndex; + std::map LinkEntryIndex; // BFS of initial dependencies. struct BFSEntry diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 23a6671..32b23b8 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -902,7 +902,7 @@ void cmComputeLinkInformation::ComputeItemParserInfo() // be the library name. Match index 3 will be the library // extension. reg = "^("; - for(std::set::iterator p = this->LinkPrefixes.begin(); + for(std::set::iterator p = this->LinkPrefixes.begin(); p != this->LinkPrefixes.end(); ++p) { reg += *p; @@ -1640,7 +1640,7 @@ void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os) // List the paths old behavior is adding. os << "and other libraries with known full path:\n"; - std::set emitted; + std::set emitted; for(std::vector::const_iterator i = this->OldLinkDirItems.begin(); i != this->OldLinkDirItems.end(); ++i) @@ -1856,7 +1856,7 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath) //---------------------------------------------------------------------------- static void cmCLI_ExpandListUnique(const char* str, std::vector& out, - std::set& emitted) + std::set& emitted) { std::vector tmp; cmSystemTools::ExpandListArgument(str, tmp); @@ -1894,7 +1894,7 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. - std::set emitted; + std::set emitted; if(use_install_rpath) { const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH"); diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 26ee8f0..b5a8bec 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -126,7 +126,7 @@ private: std::vector StaticLinkExtensions; std::vector SharedLinkExtensions; std::vector LinkExtensions; - std::set LinkPrefixes; + std::set LinkPrefixes; cmsys::RegularExpression ExtractStaticLibraryName; cmsys::RegularExpression ExtractSharedLibraryName; cmsys::RegularExpression ExtractAnyLibraryName; @@ -153,7 +153,7 @@ private: // Framework info. void ComputeFrameworkInfo(); void AddFrameworkPath(std::string const& p); - std::set FrameworkPathsEmmitted; + std::set FrameworkPathsEmmitted; cmsys::RegularExpression SplitFramework; // Linker search path computation. @@ -165,14 +165,14 @@ private: void LoadImplicitLinkInfo(); void AddImplicitLinkInfo(); void AddImplicitLinkInfo(std::string const& lang); - std::set ImplicitLinkDirs; - std::set ImplicitLinkLibs; + std::set ImplicitLinkDirs; + std::set ImplicitLinkLibs; // Additional paths configured by the runtime linker std::vector RuntimeLinkDirs; // Linker search path compatibility mode. - std::set OldLinkDirMask; + std::set OldLinkDirMask; std::vector OldLinkDirItems; std::vector OldUserFlagItems; bool OldLinkDirMode; diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 83d1e2e..405643e 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -211,7 +211,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // dependencies in all targets, because the generated build-systems can't // deal with config-specific dependencies. { - std::set emitted; + std::set emitted; { std::vector tlibs; depender->GetDirectLinkLibraries(0, tlibs, depender); @@ -255,11 +255,11 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // Loop over all utility dependencies. { - std::set const& tutils = depender->GetUtilities(); - std::set emitted; + std::set const& tutils = depender->GetUtilities(); + std::set emitted; // A target should not depend on itself. emitted.insert(depender->GetName()); - for(std::set::const_iterator util = tutils.begin(); + for(std::set::const_iterator util = tutils.begin(); util != tutils.end(); ++util) { // Don't emit the same utility twice for this target. @@ -275,7 +275,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, cmTarget const* dependee, const char *config, - std::set &emitted) + std::set &emitted) { cmTarget const* depender = this->Targets[depender_index]; if(cmTarget::LinkInterface const* iface = @@ -300,7 +300,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, const std::string& dependee_name, bool linking, - std::set &emitted) + std::set &emitted) { cmTarget const* depender = this->Targets[depender_index]; cmTarget const* dependee = @@ -406,8 +406,8 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, if(dependee->IsImported()) { // Skip imported targets but follow their utility dependencies. - std::set const& utils = dependee->GetUtilities(); - for(std::set::const_iterator i = utils.begin(); + std::set const& utils = dependee->GetUtilities(); + for(std::set::const_iterator i = utils.begin(); i != utils.end(); ++i) { if(cmTarget const* transitive_dependee = diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index dcb450a..db76a18 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -53,10 +53,10 @@ private: bool ComputeFinalDepends(cmComputeComponentGraph const& ccg); void AddInterfaceDepends(int depender_index, const std::string& dependee_name, - bool linking, std::set &emitted); + bool linking, std::set &emitted); void AddInterfaceDepends(int depender_index, cmTarget const* dependee, const char *config, - std::set &emitted); + std::set &emitted); cmGlobalGenerator* GlobalGenerator; bool DebugMode; bool NoCycles; diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index b0e2b6f..ea3e814 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -566,7 +566,7 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir) cmsys::Directory dir; dir.Load(binDir); size_t fileNum; - std::set deletedFiles; + std::set deletedFiles; for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) { if (strcmp(dir.GetFile(static_cast(fileNum)),".") && diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index 6851105..67c305e 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -72,7 +72,7 @@ public: /** Backtrace of the command that created this custom command. */ cmListFileBacktrace const& GetBacktrace() const; - typedef std::pair ImplicitDependsPair; + typedef std::pair ImplicitDependsPair; class ImplicitDependsList: public std::vector {}; void SetImplicitDepends(ImplicitDependsList const&); void AppendImplicitDepends(ImplicitDependsList const&); diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 5fa3877..babf1c4 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -85,9 +85,9 @@ const char* cmDefinitions::Set(const std::string& key, const char* value) } //---------------------------------------------------------------------------- -std::set cmDefinitions::LocalKeys() const +std::set cmDefinitions::LocalKeys() const { - std::set keys; + std::set keys; // Consider local definitions. for(MapType::const_iterator mi = this->Map.begin(); mi != this->Map.end(); ++mi) @@ -110,12 +110,12 @@ cmDefinitions cmDefinitions::Closure() const cmDefinitions::cmDefinitions(ClosureTag const&, cmDefinitions const* root): Up(0) { - std::set undefined; + std::set undefined; this->ClosureImpl(undefined, root); } //---------------------------------------------------------------------------- -void cmDefinitions::ClosureImpl(std::set& undefined, +void cmDefinitions::ClosureImpl(std::set& undefined, cmDefinitions const* defs) { // Consider local definitions. @@ -145,17 +145,17 @@ void cmDefinitions::ClosureImpl(std::set& undefined, } //---------------------------------------------------------------------------- -std::set cmDefinitions::ClosureKeys() const +std::set cmDefinitions::ClosureKeys() const { - std::set defined; - std::set undefined; + std::set defined; + std::set undefined; this->ClosureKeys(defined, undefined); return defined; } //---------------------------------------------------------------------------- -void cmDefinitions::ClosureKeys(std::set& defined, - std::set& undefined) const +void cmDefinitions::ClosureKeys(std::set& defined, + std::set& undefined) const { // Consider local definitions. for(MapType::const_iterator mi = this->Map.begin(); @@ -165,7 +165,7 @@ void cmDefinitions::ClosureKeys(std::set& defined, if(defined.find(mi->first) == defined.end() && undefined.find(mi->first) == undefined.end()) { - std::set& m = mi->second.Exists? defined : undefined; + std::set& m = mi->second.Exists? defined : undefined; m.insert(mi->first); } } diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 24dad29..4c1ad0a 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -41,22 +41,25 @@ public: const char* Set(const std::string& key, const char* value); /** Get the set of all local keys. */ - std::set LocalKeys() const; + std::set LocalKeys() const; /** Compute the closure of all defined keys with values. This flattens the scope. The result has no parent. */ cmDefinitions Closure() const; /** Compute the set of all defined keys. */ - std::set ClosureKeys() const; + std::set ClosureKeys() const; private: // String with existence boolean. - struct Def: public cmStdString + struct Def: public std::string { - Def(): cmStdString(), Exists(false) {} - Def(const char* v): cmStdString(v?v:""), Exists(v?true:false) {} - Def(Def const& d): cmStdString(d), Exists(d.Exists) {} + private: + typedef std::string std_string; + public: + Def(): std_string(), Exists(false) {} + Def(const char* v): std_string(v?v:""), Exists(v?true:false) {} + Def(Def const& d): std_string(d), Exists(d.Exists) {} bool Exists; }; static Def NoDef; @@ -65,7 +68,7 @@ private: cmDefinitions* Up; // Local definitions, set or unset. - typedef std::map MapType; + typedef std::map MapType; MapType Map; // Internal query and update methods. @@ -75,12 +78,12 @@ private: // Implementation of Closure() method. struct ClosureTag {}; cmDefinitions(ClosureTag const&, cmDefinitions const* root); - void ClosureImpl(std::set& undefined, + void ClosureImpl(std::set& undefined, cmDefinitions const* defs); // Implementation of ClosureKeys() method. - void ClosureKeys(std::set& defined, - std::set& undefined) const; + void ClosureKeys(std::set& defined, + std::set& undefined) const; }; #endif diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 585f959..57a66da 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -91,7 +91,7 @@ cmDependsC::~cmDependsC() { this->WriteCacheFile(); - for (std::map::iterator it= + for (std::map::iterator it= this->FileCache.begin(); it!=this->FileCache.end(); ++it) { delete it->second; @@ -116,7 +116,7 @@ bool cmDependsC::WriteDependencies(const std::set& sources, return false; } - std::set dependencies; + std::set dependencies; bool haveDeps = false; if (this->ValidDeps != 0) @@ -149,7 +149,7 @@ bool cmDependsC::WriteDependencies(const std::set& sources, this->Encountered.insert(*srcIt); } - std::set scanned; + std::set scanned; // Use reserve to allocate enough memory for tempPathStr // so that during the loops no memory is allocated or freed @@ -182,7 +182,7 @@ bool cmDependsC::WriteDependencies(const std::set& sources, } else { - std::map::iterator + std::map::iterator headerLocationIt=this->HeaderLocationCache.find(current.FileName); if (headerLocationIt!=this->HeaderLocationCache.end()) { @@ -224,7 +224,7 @@ bool cmDependsC::WriteDependencies(const std::set& sources, scanned.insert(fullName); // Check whether this file is already in the cache - std::map::iterator fileIt= + std::map::iterator fileIt= this->FileCache.find(fullName); if (fileIt!=this->FileCache.end()) { @@ -270,7 +270,7 @@ bool cmDependsC::WriteDependencies(const std::set& sources, // convert the dependencies to paths relative to the home output // directory. We must do the same here. internalDepends << obj << std::endl; - for(std::set::const_iterator i=dependencies.begin(); + for(std::set::const_iterator i=dependencies.begin(); i != dependencies.end(); ++i) { makeDepends << obj << ": " << @@ -392,7 +392,7 @@ void cmDependsC::WriteCacheFile() const cacheOut << this->IncludeRegexComplainString << "\n\n"; cacheOut << this->IncludeRegexTransformString << "\n\n"; - for (std::map::const_iterator fileIt= + for (std::map::const_iterator fileIt= this->FileCache.begin(); fileIt!=this->FileCache.end(); ++fileIt) { @@ -421,7 +421,7 @@ void cmDependsC::WriteCacheFile() const //---------------------------------------------------------------------------- void cmDependsC::Scan(std::istream& is, const char* directory, - const cmStdString& fullName) + const std::string& fullName) { cmIncludeLines* newCacheEntry=new cmIncludeLines; newCacheEntry->Used=true; diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h index cd1e7a4..07d3c21 100644 --- a/Source/cmDependsC.h +++ b/Source/cmDependsC.h @@ -41,7 +41,7 @@ protected: // Method to scan a single file. void Scan(std::istream& is, const char* directory, - const cmStdString& fullName); + const std::string& fullName); // Regular expression to identify C preprocessor include directives. cmsys::RegularExpression IncludeRegexLine; @@ -57,7 +57,7 @@ protected: // Regex to transform #include lines. std::string IncludeRegexTransformString; cmsys::RegularExpression IncludeRegexTransform; - typedef std::map TransformRulesType; + typedef std::map TransformRulesType; TransformRulesType TransformRules; void SetupTransforms(); void ParseTransform(std::string const& xform); @@ -67,8 +67,8 @@ public: // Data structures for dependency graph walk. struct UnscannedEntry { - cmStdString FileName; - cmStdString QuotedLocation; + std::string FileName; + std::string QuotedLocation; }; struct cmIncludeLines @@ -79,13 +79,13 @@ public: }; protected: const std::map* ValidDeps; - std::set Encountered; + std::set Encountered; std::queue Unscanned; - std::map FileCache; - std::map HeaderLocationCache; + std::map FileCache; + std::map HeaderLocationCache; - cmStdString CacheFileName; + std::string CacheFileName; void WriteCacheFile() const; void ReadCacheFile(); diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index d5472a1..b3fbaa2 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -34,11 +34,11 @@ public: std::string Source; // Set of provided and required modules. - std::set Provides; - std::set Requires; + std::set Provides; + std::set Requires; // Set of files included in the translation unit. - std::set Includes; + std::set Includes; }; //---------------------------------------------------------------------------- @@ -98,24 +98,24 @@ class cmDependsFortranInternals { public: // The set of modules provided by this target. - std::set TargetProvides; + std::set TargetProvides; // Map modules required by this target to locations. - typedef std::map TargetRequiresMap; + typedef std::map TargetRequiresMap; TargetRequiresMap TargetRequires; // Information about each object file. - typedef std::map ObjectInfoMap; + typedef std::map ObjectInfoMap; ObjectInfoMap ObjectInfo; cmDependsFortranSourceInfo& CreateObjectInfo(const char* obj, const char* src) { - std::map::iterator i = + std::map::iterator i = this->ObjectInfo.find(obj); if(i == this->ObjectInfo.end()) { - std::map::value_type + std::map::value_type entry(obj, cmDependsFortranSourceInfo()); i = this->ObjectInfo.insert(entry).first; i->second.Source = src; @@ -260,8 +260,8 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, cmGeneratedFileStream fiStream(fiName.c_str()); fiStream << "# The fortran modules provided by this target.\n"; fiStream << "provides\n"; - std::set const& provides = this->Internal->TargetProvides; - for(std::set::const_iterator i = provides.begin(); + std::set const& provides = this->Internal->TargetProvides; + for(std::set::const_iterator i = provides.begin(); i != provides.end(); ++i) { fiStream << " " << *i << "\n"; @@ -275,7 +275,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, cmGeneratedFileStream fcStream(fcName.c_str()); fcStream << "# Remove fortran modules provided by this target.\n"; fcStream << "FILE(REMOVE"; - for(std::set::const_iterator i = provides.begin(); + for(std::set::const_iterator i = provides.begin(); i != provides.end(); ++i) { std::string mod_upper = mod_dir; @@ -319,14 +319,14 @@ void cmDependsFortran::LocateModules() infoI != objInfo.end(); ++infoI) { cmDependsFortranSourceInfo const& info = infoI->second; - for(std::set::const_iterator i = info.Provides.begin(); + for(std::set::const_iterator i = info.Provides.begin(); i != info.Provides.end(); ++i) { // Include this module in the set provided by this target. this->Internal->TargetProvides.insert(*i); } - for(std::set::const_iterator i = info.Requires.begin(); + for(std::set::const_iterator i = info.Requires.begin(); i != info.Requires.end(); ++i) { // Include this module in the set required by this target. @@ -368,8 +368,8 @@ void cmDependsFortran::LocateModules() void cmDependsFortran::MatchLocalModules() { const char* stampDir = this->TargetDirectory.c_str(); - std::set const& provides = this->Internal->TargetProvides; - for(std::set::const_iterator i = provides.begin(); + std::set const& provides = this->Internal->TargetProvides; + for(std::set::const_iterator i = provides.begin(); i != provides.end(); ++i) { this->ConsiderModule(i->c_str(), stampDir); @@ -445,7 +445,7 @@ cmDependsFortran // Write the include dependencies to the output stream. internalDepends << obj << std::endl; internalDepends << " " << src << std::endl; - for(std::set::const_iterator i = info.Includes.begin(); + for(std::set::const_iterator i = info.Includes.begin(); i != info.Includes.end(); ++i) { makeDepends << obj << ": " << @@ -458,11 +458,11 @@ cmDependsFortran makeDepends << std::endl; // Write module requirements to the output stream. - for(std::set::const_iterator i = info.Requires.begin(); + for(std::set::const_iterator i = info.Requires.begin(); i != info.Requires.end(); ++i) { // Require only modules not provided in the same source. - if(std::set::const_iterator(info.Provides.find(*i)) != + if(std::set::const_iterator(info.Provides.find(*i)) != info.Provides.end()) { continue; @@ -519,7 +519,7 @@ cmDependsFortran } // Write provided modules to the output stream. - for(std::set::const_iterator i = info.Provides.begin(); + for(std::set::const_iterator i = info.Provides.begin(); i != info.Provides.end(); ++i) { std::string proxy = stamp_dir; @@ -538,7 +538,7 @@ cmDependsFortran // Create a target to copy the module after the object file // changes. makeDepends << obj << ".provides.build:\n"; - for(std::set::const_iterator i = info.Provides.begin(); + for(std::set::const_iterator i = info.Provides.begin(); i != info.Provides.end(); ++i) { // Include this module in the set provided by this target. diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx index c30d4bd..e23e4b7 100644 --- a/Source/cmDependsJavaParserHelper.cxx +++ b/Source/cmDependsJavaParserHelper.cxx @@ -36,10 +36,10 @@ cmDependsJavaParserHelper::~cmDependsJavaParserHelper() } void cmDependsJavaParserHelper::CurrentClass -::AddFileNamesForPrinting(std::vector *files, +::AddFileNamesForPrinting(std::vector *files, const char* prefix, const char* sep) { - cmStdString rname = ""; + std::string rname = ""; if ( prefix ) { rname += prefix; @@ -76,7 +76,7 @@ void cmDependsJavaParserHelper::AddClassFound(const char* sclass) { return; } - std::vector::iterator it; + std::vector::iterator it; for ( it = this->ClassesFound.begin(); it != this->ClassesFound.end(); it ++ ) @@ -91,7 +91,7 @@ void cmDependsJavaParserHelper::AddClassFound(const char* sclass) void cmDependsJavaParserHelper::AddPackagesImport(const char* sclass) { - std::vector::iterator it; + std::vector::iterator it; for ( it = this->PackagesImport.begin(); it != this->PackagesImport.end(); it ++ ) @@ -256,8 +256,8 @@ void cmDependsJavaParserHelper::PrintClasses() std::cerr << "Error when parsing. No classes on class stack" << std::endl; abort(); } - std::vector files = this->GetFilesProduced(); - std::vector::iterator sit; + std::vector files = this->GetFilesProduced(); + std::vector::iterator sit; for ( sit = files.begin(); sit != files.end(); ++ sit ) @@ -266,9 +266,9 @@ void cmDependsJavaParserHelper::PrintClasses() } } -std::vector cmDependsJavaParserHelper::GetFilesProduced() +std::vector cmDependsJavaParserHelper::GetFilesProduced() { - std::vector files; + std::vector files; CurrentClass* toplevel = &(*(this->ClassStack.begin())); std::vector::iterator it; for ( it = toplevel->NestedClasses->begin(); @@ -313,7 +313,7 @@ int cmDependsJavaParserHelper::ParseString(const char* str, int verb) std::cout << "Imports packages:"; if ( this->PackagesImport.size() > 0 ) { - std::vector::iterator it; + std::vector::iterator it; for ( it = this->PackagesImport.begin(); it != this->PackagesImport.end(); ++ it ) @@ -325,7 +325,7 @@ int cmDependsJavaParserHelper::ParseString(const char* str, int verb) std::cout << "Depends on:"; if ( this->ClassesFound.size() > 0 ) { - std::vector::iterator it; + std::vector::iterator it; for ( it = this->ClassesFound.begin(); it != this->ClassesFound.end(); ++ it ) @@ -419,8 +419,8 @@ int cmDependsJavaParserHelper::ParseFile(const char* file) return 0; } - cmStdString fullfile = ""; - cmStdString line; + std::string fullfile = ""; + std::string line; while ( cmSystemTools::GetLineFromStream(ifs, line) ) { fullfile += line + "\n"; diff --git a/Source/cmDependsJavaParserHelper.h b/Source/cmDependsJavaParserHelper.h index 9807a04..5542018 100644 --- a/Source/cmDependsJavaParserHelper.h +++ b/Source/cmDependsJavaParserHelper.h @@ -59,15 +59,15 @@ public: const char* GetCurrentCombine() { return this->CurrentCombine.c_str(); } void UpdateCombine(const char* str1, const char* str2); - std::vector& GetClassesFound() { return this->ClassesFound; } + std::vector& GetClassesFound() { return this->ClassesFound; } - std::vector GetFilesProduced(); + std::vector GetFilesProduced(); private: class CurrentClass { public: - cmStdString Name; + std::string Name; std::vector* NestedClasses; CurrentClass() { @@ -93,16 +93,16 @@ private: { (*this) = c; } - void AddFileNamesForPrinting(std::vector *files, + void AddFileNamesForPrinting(std::vector *files, const char* prefix, const char* sep); }; - cmStdString CurrentPackage; - cmStdString::size_type InputBufferPos; - cmStdString InputBuffer; + std::string CurrentPackage; + std::string::size_type InputBufferPos; + std::string InputBuffer; std::vector OutputBuffer; - std::vector ClassesFound; - std::vector PackagesImport; - cmStdString CurrentCombine; + std::vector ClassesFound; + std::vector PackagesImport; + std::string CurrentCombine; std::vector ClassStack; diff --git a/Source/cmDynamicLoader.cxx b/Source/cmDynamicLoader.cxx index 6a0ab7b..944a000 100644 --- a/Source/cmDynamicLoader.cxx +++ b/Source/cmDynamicLoader.cxx @@ -23,7 +23,7 @@ public: static cmDynamicLoaderCache* GetInstance(); private: - std::map CacheMap; + std::map CacheMap; static cmDynamicLoaderCache* Instance; }; @@ -47,7 +47,7 @@ void cmDynamicLoaderCache::CacheFile(const char* path, bool cmDynamicLoaderCache::GetCacheFile(const char* path, cmsys::DynamicLoader::LibraryHandle& p) { - std::map::iterator it + std::map::iterator it = this->CacheMap.find(path); if ( it != this->CacheMap.end() ) { @@ -59,7 +59,7 @@ bool cmDynamicLoaderCache::GetCacheFile(const char* path, bool cmDynamicLoaderCache::FlushCache(const char* path) { - std::map::iterator it + std::map::iterator it = this->CacheMap.find(path); bool ret = false; if ( it != this->CacheMap.end() ) @@ -73,7 +73,7 @@ bool cmDynamicLoaderCache::FlushCache(const char* path) void cmDynamicLoaderCache::FlushCache() { - for ( std::map::iterator it = this->CacheMap.begin(); it != this->CacheMap.end(); it++ ) diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index f93e72a..9e3ce0b 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -63,7 +63,7 @@ public: bool GenerateImportFile(); protected: - typedef std::map ImportPropertyMap; + typedef std::map ImportPropertyMap; // Generate per-configuration target information to the given output // stream. diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index 7c634a4..5ee2a78 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -41,7 +41,7 @@ public: /** Get the per-config file generated for each configuraiton. This maps from the configuration name to the file temporary location for installation. */ - std::map const& GetConfigImportFiles() + std::map const& GetConfigImportFiles() { return this->ConfigImportFiles; } /** Compute the globbing expression used to load per-config import @@ -92,7 +92,7 @@ protected: std::string ImportPrefix; // The import file generated for each configuration. - std::map ConfigImportFiles; + std::map ConfigImportFiles; }; #endif diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index 469a661..b04b937 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -83,9 +83,9 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const cmake* cm = this->Makefile->GetCMakeInstance(); cmGlobalGenerator* global = cm->GetGlobalGenerator(); const std::vector& locals = global->GetLocalGenerators(); - std::map libDepsOld; - std::map libDepsNew; - std::map libTypes; + std::map libDepsOld; + std::map libDepsNew; + std::map libTypes; for(std::vector::const_iterator i = locals.begin(); i != locals.end(); ++i) { @@ -175,7 +175,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const fout << "# Generated by CMake " << cmVersion::GetCMakeVersion() << "\n\n"; fout << "if(" << vertest << ")\n"; fout << " # Information for CMake 2.6 and above.\n"; - for(std::map::const_iterator + for(std::map::const_iterator i = libDepsNew.begin(); i != libDepsNew.end(); ++i) { @@ -186,7 +186,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const } fout << "else()\n"; fout << " # Information for CMake 2.4 and lower.\n"; - for(std::map::const_iterator + for(std::map::const_iterator i = libDepsOld.begin(); i != libDepsOld.end(); ++i) { @@ -195,7 +195,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const fout << " set(\"" << i->first << "\" \"" << i->second << "\")\n"; } } - for(std::map::const_iterator i = libTypes.begin(); + for(std::map::const_iterator i = libTypes.begin(); i != libTypes.end(); ++i) { if(i->second != "general") diff --git a/Source/cmExprParserHelper.h b/Source/cmExprParserHelper.h index 4b76b33..8d6b2cd 100644 --- a/Source/cmExprParserHelper.h +++ b/Source/cmExprParserHelper.h @@ -49,8 +49,8 @@ public: const char* GetError() { return this->ErrorString.c_str(); } private: - cmStdString::size_type InputBufferPos; - cmStdString InputBuffer; + std::string::size_type InputBufferPos; + std::string InputBuffer; std::vector OutputBuffer; int CurrentLine; int Verbose; diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 1339969..01d1155 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -61,7 +61,7 @@ cmExtraCodeBlocksGenerator::cmExtraCodeBlocksGenerator() void cmExtraCodeBlocksGenerator::Generate() { // for each sub project in the project create a codeblocks project - for (std::map >::const_iterator + for (std::map >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); it!= this->GlobalGenerator->GetProjectMap().end(); ++it) @@ -243,7 +243,7 @@ void cmExtraCodeBlocksGenerator Tree tree; // build tree of virtual folders - for (std::map >::const_iterator + for (std::map >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); it != this->GlobalGenerator->GetProjectMap().end(); ++it) diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 028d3d5..1e34fe0 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -60,7 +60,7 @@ void cmExtraCodeLiteGenerator::Generate() // loop projects and locate the root project. // and extract the information for creating the worspace - for (std::map >::const_iterator + for (std::map >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); it!= this->GlobalGenerator->GetProjectMap().end(); ++it) @@ -85,7 +85,7 @@ void cmExtraCodeLiteGenerator::Generate() } // for each sub project in the workspace create a codelite project - for (std::map >::const_iterator + for (std::map >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); it!= this->GlobalGenerator->GetProjectMap().end(); ++it) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 74ba9a6..38a2470 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -624,7 +624,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects( this->AppendLinkedResource(fout, "[Subprojects]", "virtual:/virtual", VirtualFolder); - for (std::map >::const_iterator + for (std::map >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); it != this->GlobalGenerator->GetProjectMap().end(); ++it) diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 3cfafa7..9c2849c 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -64,7 +64,7 @@ cmExtraSublimeTextGenerator::cmExtraSublimeTextGenerator() void cmExtraSublimeTextGenerator::Generate() { // for each sub project in the project create a sublime text 2 project - for (std::map >::const_iterator + for (std::map >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); it!= this->GlobalGenerator->GetProjectMap().end(); ++it) diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx index 02f10c0..5727470 100644 --- a/Source/cmFileTimeComparison.cxx +++ b/Source/cmFileTimeComparison.cxx @@ -43,13 +43,13 @@ private: class HashString { public: - size_t operator()(const cmStdString& s) const + size_t operator()(const std::string& s) const { return h(s.c_str()); } cmsys::hash h; }; - typedef cmsys::hash_map FileStatsMap; FileStatsMap Files; #endif diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h index e590d6e..42d9bc1 100644 --- a/Source/cmFindBase.h +++ b/Source/cmFindBase.h @@ -42,14 +42,14 @@ protected: bool CheckForVariableInCache(); // use by command during find - cmStdString VariableDocumentation; - cmStdString VariableName; + std::string VariableDocumentation; + std::string VariableName; std::vector Names; bool NamesPerDir; bool NamesPerDirAllowed; // CMAKE_*_PATH CMAKE_SYSTEM_*_PATH FRAMEWORK|LIBRARY|INCLUDE|PROGRAM - cmStdString EnvironmentPath; // LIB,INCLUDE + std::string EnvironmentPath; // LIB,INCLUDE bool AlreadyInCache; bool AlreadyInCacheWithoutMetaInfo; diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h index ba90a84..5a905cd 100644 --- a/Source/cmFindCommon.h +++ b/Source/cmFindCommon.h @@ -56,7 +56,7 @@ protected: /** Compute the current default bundle/framework search policy. */ void SelectDefaultMacMode(); - cmStdString CMakePathName; + std::string CMakePathName; RootPathMode FindRootPathMode; bool CheckCommonArgument(std::string const& arg); @@ -81,7 +81,7 @@ protected: std::vector UserPaths; std::vector UserHints; std::vector SearchPaths; - std::set SearchPathsEmitted; + std::set SearchPathsEmitted; bool SearchFrameworkFirst; bool SearchFrameworkOnly; diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index de52df7..9345d15 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -368,8 +368,8 @@ bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path, // Search for a file matching the library name regex. std::string dir = path; cmSystemTools::ConvertToUnixSlashes(dir); - std::set const& files = this->GG->GetDirectoryContent(dir); - for(std::set::const_iterator fi = files.begin(); + std::set const& files = this->GG->GetDirectoryContent(dir); + for(std::set::const_iterator fi = files.begin(); fi != files.end(); ++fi) { std::string const& origName = *fi; diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index d557fba..7a4e7f4 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -553,7 +553,7 @@ void cmFindPackageCommand::AddFindDefinition(const std::string& var, //---------------------------------------------------------------------------- void cmFindPackageCommand::RestoreFindDefinitions() { - for(std::map::iterator + for(std::map::iterator i = this->OriginalDefs.begin(); i != this->OriginalDefs.end(); ++i) { OriginalDef const& od = i->second; diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 9819d4f..72c1e3c 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -96,19 +96,19 @@ private: friend class cmFindPackageFileList; struct OriginalDef { bool exists; std::string value; }; - std::map OriginalDefs; + std::map OriginalDefs; - cmStdString Name; - cmStdString Variable; - cmStdString Version; + std::string Name; + std::string Variable; + std::string Version; unsigned int VersionMajor; unsigned int VersionMinor; unsigned int VersionPatch; unsigned int VersionTweak; unsigned int VersionCount; bool VersionExact; - cmStdString FileFound; - cmStdString VersionFound; + std::string FileFound; + std::string VersionFound; unsigned int VersionFoundMajor; unsigned int VersionFoundMinor; unsigned int VersionFoundPatch; diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 8459995..caaf1d3 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -89,9 +89,9 @@ std::string cmFindPathCommand::FindHeaderInFramework(std::string const& file, std::string const& dir) { - cmStdString fileName = file; - cmStdString frameWorkName; - cmStdString::size_type pos = fileName.find("/"); + std::string fileName = file; + std::string frameWorkName; + std::string::size_type pos = fileName.find("/"); // if there is a / in the name try to find the header as a framework // For example bar/foo.h would look for: // bar.framework/Headers/foo.h @@ -128,7 +128,7 @@ cmFindPathCommand::FindHeaderInFramework(std::string const& file, } // if it is not found yet or not a framework header, then do a glob search // for all frameworks in the directory: dir/*.framework/Headers/ - cmStdString glob = dir; + std::string glob = dir; glob += "*.framework/Headers/"; glob += file; cmsys::Glob globIt; @@ -136,7 +136,7 @@ cmFindPathCommand::FindHeaderInFramework(std::string const& file, std::vector files = globIt.GetFiles(); if(files.size()) { - cmStdString fheader = cmSystemTools::CollapseFullPath(files[0].c_str()); + std::string fheader = cmSystemTools::CollapseFullPath(files[0].c_str()); if(this->IncludeFileInPath) { return fheader; diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index cd30546..3ebb1b6 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -97,7 +97,7 @@ const char *cmCompiledGeneratorExpression::Evaluate( { this->Output += (*it)->Evaluate(&context, dagChecker); - for(std::set::const_iterator + for(std::set::const_iterator p = context.SeenTargetProperties.begin(); p != context.SeenTargetProperties.end(); ++p) { diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 4992e93..58abf14 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -92,7 +92,7 @@ public: std::set const& GetTargets() const { return this->DependTargets; } - std::set const& GetSeenTargetProperties() const + std::set const& GetSeenTargetProperties() const { return this->SeenTargetProperties; } std::set const& GetAllTargetsSeen() const @@ -130,7 +130,7 @@ private: mutable std::set DependTargets; mutable std::set AllTargetsSeen; - mutable std::set SeenTargetProperties; + mutable std::set SeenTargetProperties; mutable std::string Output; mutable bool HadContextSensitiveCondition; }; diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index e7e1d34..04f36b4 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -42,12 +42,12 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( ) #undef TEST_TRANSITIVE_PROPERTY_METHOD { - std::map >::const_iterator it + std::map >::const_iterator it = top->Seen.find(target); if (it != top->Seen.end()) { - const std::set &propSet = it->second; - const std::set::const_iterator i = propSet.find(property); + const std::set &propSet = it->second; + const std::set::const_iterator i = propSet.find(property); if (i != propSet.end()) { this->CheckResult = ALREADY_SEEN; diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index b6effa1..6cbbd2a 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -77,7 +77,7 @@ private: const cmGeneratorExpressionDAGChecker * const Parent; const std::string Target; const std::string Property; - std::map > Seen; + std::map > Seen; const GeneratorExpressionContent * const Content; const cmListFileBacktrace Backtrace; Result CheckResult; diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h index 49e52df..0c8a9cf 100644 --- a/Source/cmGeneratorExpressionEvaluator.h +++ b/Source/cmGeneratorExpressionEvaluator.h @@ -25,7 +25,7 @@ struct cmGeneratorExpressionContext cmListFileBacktrace Backtrace; std::set DependTargets; std::set AllTargets; - std::set SeenTargetProperties; + std::set SeenTargetProperties; cmMakefile *Makefile; const char *Config; cmTarget const* HeadTarget; // The target whose property is being evaluated. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 7f22e00..a7b2efa 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -422,7 +422,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, = this->Target->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED"); std::vector result; - for (std::set::const_iterator + for (std::set::const_iterator it = this->Target->GetSystemIncludeDirectories().begin(); it != this->Target->GetSystemIncludeDirectories().end(); ++it) { @@ -462,7 +462,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, } } } - std::set unique; + std::set unique; for(std::vector::iterator li = result.begin(); li != result.end(); ++li) { @@ -470,7 +470,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, unique.insert(*li); } result.clear(); - for(std::set::iterator li = unique.begin(); + for(std::set::iterator li = unique.begin(); li != unique.end(); ++li) { result.push_back(*li); @@ -594,7 +594,7 @@ private: SourceEntry* CurrentEntry; std::queue SourceQueue; std::set SourcesQueued; - typedef std::map NameMapType; + typedef std::map NameMapType; NameMapType NameMap; void QueueSource(cmSourceFile* sf); diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx index e7ad91a..5aaf1c6 100644 --- a/Source/cmGetCMakePropertyCommand.cxx +++ b/Source/cmGetCMakePropertyCommand.cxx @@ -49,10 +49,10 @@ bool cmGetCMakePropertyCommand } else if ( args[1] == "COMPONENTS" ) { - const std::set* components + const std::set* components = this->Makefile->GetLocalGenerator()->GetGlobalGenerator() ->GetInstallComponents(); - std::set::const_iterator compIt; + std::set::const_iterator compIt; output = ""; for (compIt = components->begin(); compIt != components->end(); ++compIt) { diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index ba4cce8..9748c61 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -432,8 +432,8 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, fpath += "/CMakeSystem.cmake"; mf->ReadListFile(0,fpath.c_str()); } - std::map needTestLanguage; - std::map needSetLanguageEnabledMaps; + std::map needTestLanguage; + std::map needSetLanguageEnabledMaps; // foreach language // load the CMakeDetermine(LANG)Compiler.cmake file to find // the compiler @@ -823,7 +823,7 @@ cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const const std::string& lang = source.GetLanguage(); if(!lang.empty()) { - std::map::const_iterator it = + std::map::const_iterator it = this->LanguageToOutputExtension.find(lang); if(it != this->LanguageToOutputExtension.end()) @@ -857,7 +857,7 @@ std::string cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const { ++ext; } - std::map::const_iterator it + std::map::const_iterator it = this->ExtensionToLanguage.find(ext); if(it != this->ExtensionToLanguage.end()) { @@ -1011,7 +1011,7 @@ bool cmGlobalGenerator::IsDependedOn(const std::string& project, cmTarget const* targetIn) { // Get all local gens for this project - std::map >::const_iterator it = + std::map >::const_iterator it = this->ProjectMap.find(project); if (it == this->ProjectMap.end()) { @@ -1516,8 +1516,8 @@ void cmGlobalGenerator::ComputeTargetObjects(cmGeneratorTarget*) const void cmGlobalGenerator::CheckLocalGenerators() { - std::map notFoundMap; -// std::set notFoundMap; + std::map notFoundMap; +// std::set notFoundMap; // after it is all done do a ConfigureFinalPass cmCacheManager* manager = 0; for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) @@ -1597,7 +1597,7 @@ void cmGlobalGenerator::CheckLocalGenerators() if(notFoundMap.size()) { std::string notFoundVars; - for(std::map::const_iterator + for(std::map::const_iterator ii = notFoundMap.begin(); ii != notFoundMap.end(); ++ii) @@ -1956,7 +1956,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, void cmGlobalGenerator::GetEnabledLanguages(std::vector& lang) const { - for(std::map::const_iterator i = + for(std::map::const_iterator i = this->LanguageEnabled.begin(); i != this->LanguageEnabled.end(); ++i) { lang.push_back(i->first); @@ -1965,7 +1965,7 @@ cmGlobalGenerator::GetEnabledLanguages(std::vector& lang) const int cmGlobalGenerator::GetLinkerPreference(const std::string& lang) const { - std::map::const_iterator it = + std::map::const_iterator it = this->LanguageToLinkerPreference.find(lang); if (it != this->LanguageToLinkerPreference.end()) { @@ -2075,14 +2075,14 @@ cmGlobalGenerator::FindTarget(const std::string& name, { if (!excludeAliases) { - std::map::const_iterator ai + std::map::const_iterator ai = this->AliasTargets.find(name); if (ai != this->AliasTargets.end()) { return ai->second; } } - std::map::const_iterator i = + std::map::const_iterator i = this->TotalTargets.find ( name ); if ( i != this->TotalTargets.end() ) { @@ -2294,7 +2294,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) { if(!cmakeCfgIntDir || !*cmakeCfgIntDir || cmakeCfgIntDir[0] == '.') { - std::set* componentsSet = &this->InstallComponents; + std::set* componentsSet = &this->InstallComponents; cpackCommandLines.erase(cpackCommandLines.begin(), cpackCommandLines.end()); depends.erase(depends.begin(), depends.end()); @@ -2302,7 +2302,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) if ( componentsSet->size() > 0 ) { ostr << "Available install components are:"; - std::set::iterator it; + std::set::iterator it; for ( it = componentsSet->begin(); it != componentsSet->end(); @@ -2516,7 +2516,7 @@ cmGlobalGenerator::GenerateRuleFile(std::string const& output) const std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage( std::string const& l) const { - std::map::const_iterator it = + std::map::const_iterator it = this->LanguageToOriginalSharedLibFlags.find(l); if(it != this->LanguageToOriginalSharedLibFlags.end()) { @@ -2690,7 +2690,7 @@ void cmGlobalGenerator::AddToManifest(const char* config, } //---------------------------------------------------------------------------- -std::set const& +std::set const& cmGlobalGenerator::GetDirectoryContent(std::string const& dir, bool needDisk) { DirectoryContent& dc = this->DirectoryContentMap[dir]; @@ -2796,7 +2796,7 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile, fname = line.substr(33, line.npos); // Look for a hash for this file's rule. - std::map::const_iterator rhi = + std::map::const_iterator rhi = this->RuleHashes.find(fname); if(rhi != this->RuleHashes.end()) { @@ -2841,7 +2841,7 @@ void cmGlobalGenerator::WriteRuleHashes(std::string const& pfile) { cmGeneratedFileStream fout(pfile.c_str()); fout << "# Hashes of file build rules.\n"; - for(std::map::const_iterator + for(std::map::const_iterator rhi = this->RuleHashes.begin(); rhi != this->RuleHashes.end(); ++rhi) { fout.write(rhi->second.Data, 32); @@ -2862,7 +2862,7 @@ void cmGlobalGenerator::WriteSummary() cmGeneratedFileStream fout(fname.c_str()); // Generate summary information files for each target. - for(std::map::const_iterator ti = + for(std::map::const_iterator ti = this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti) { if ((ti->second)->GetType() == cmTarget::INTERFACE_LIBRARY) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 746f715..f06162c 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -167,7 +167,7 @@ public: void AddInstallComponent(const char* component); - const std::set* GetInstallComponents() const + const std::set* GetInstallComponents() const { return &this->InstallComponents; } cmExportSetMap& GetExportSets() {return this->ExportSets;} @@ -244,7 +244,7 @@ public: from disk at most once and cached. During the generation step the content will include the target files to be built even if they do not yet exist. */ - std::set const& GetDirectoryContent(std::string const& dir, + std::set const& GetDirectoryContent(std::string const& dir, bool needDisk = true); void AddTarget(cmTarget* t); @@ -276,7 +276,7 @@ public: /** Get per-target generator information. */ cmGeneratorTarget* GetGeneratorTarget(cmTarget const*) const; - const std::map >& GetProjectMap() + const std::map >& GetProjectMap() const {return this->ProjectMap;} // track files replaced during a Generate @@ -364,18 +364,18 @@ protected: bool UseLinkScript; bool ForceUnixPaths; bool ToolSupportsColor; - cmStdString FindMakeProgramFile; - cmStdString ConfiguredFilesPath; + std::string FindMakeProgramFile; + std::string ConfiguredFilesPath; cmake *CMakeInstance; std::vector LocalGenerators; cmLocalGenerator* CurrentLocalGenerator; // map from project name to vector of local generators in that project - std::map > ProjectMap; + std::map > ProjectMap; std::map > LocalGeneratorToTargetMap; // Set of named installation components requested by the project. - std::set InstallComponents; + std::set InstallComponents; bool InstallTargetEnabled; // Sets of named target exports cmExportSetMap ExportSets; @@ -387,9 +387,9 @@ protected: cmTargetManifest TargetManifest; // All targets in the entire project. - std::map TotalTargets; - std::map AliasTargets; - std::map ImportedTargets; + std::map TotalTargets; + std::map AliasTargets; + std::map ImportedTargets; std::vector EvaluationFiles; virtual const char* GetPredefinedTargetsFolder(); @@ -401,18 +401,18 @@ private: float FirstTimeProgress; // If you add a new map here, make sure it is copied // in EnableLanguagesFromGenerator - std::map IgnoreExtensions; - std::map LanguageEnabled; - std::set LanguagesReady; // Ready for try_compile - std::map OutputExtensions; - std::map LanguageToOutputExtension; - std::map ExtensionToLanguage; - std::map LanguageToLinkerPreference; - std::map LanguageToOriginalSharedLibFlags; + std::map IgnoreExtensions; + std::map LanguageEnabled; + std::set LanguagesReady; // Ready for try_compile + std::map OutputExtensions; + std::map LanguageToOutputExtension; + std::map ExtensionToLanguage; + std::map LanguageToLinkerPreference; + std::map LanguageToOriginalSharedLibFlags; // Record hashes for rules and outputs. struct RuleHash { char Data[32]; }; - std::map RuleHashes; + std::map RuleHashes; void CheckRuleHashes(); void CheckRuleHashes(std::string const& pfile, std::string const& home); void WriteRuleHashes(std::string const& pfile); @@ -448,18 +448,18 @@ private: virtual const char* GetBuildIgnoreErrorsFlag() const { return 0; } // Cache directory content and target files to be built. - struct DirectoryContent: public std::set + struct DirectoryContent: public std::set { - typedef std::set derived; + typedef std::set derived; bool LoadedFromDisk; DirectoryContent(): LoadedFromDisk(false) {} DirectoryContent(DirectoryContent const& dc): derived(dc), LoadedFromDisk(dc.LoadedFromDisk) {} }; - std::map DirectoryContentMap; + std::map DirectoryContentMap; // Set of binary directories on disk. - std::set BinaryDirectories; + std::set BinaryDirectories; // track targets to issue CMP0042 warning for. std::set CMP0042WarnTargets; diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index ed0e15b..25df953 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -44,7 +44,7 @@ void cmGlobalKdevelopGenerator::Generate() { // for each sub project in the project create // a kdevelop project - for (std::map >::const_iterator + for (std::map >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); it!= this->GlobalGenerator->GetProjectMap().end(); ++it) @@ -103,7 +103,7 @@ bool cmGlobalKdevelopGenerator std::string projectDir = projectDirIn + "/"; std::string filename = outputDir+ "/" + projectname +".kdevelop.filelist"; - std::set files; + std::set files; std::string tmp; for (std::vector::const_iterator it=lgs.begin(); @@ -217,7 +217,7 @@ bool cmGlobalKdevelopGenerator } fileToOpen=""; - for (std::set::const_iterator it=files.begin(); + for (std::set::const_iterator it=files.begin(); it!=files.end(); it++) { // get the full path to the file diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 954fb17..977b3a1 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -886,7 +886,7 @@ cmGlobalNinjaGenerator if (target->GetType() == cmTarget::GLOBAL_TARGET) { // Global targets only depend on other utilities, which may not appear in // the TargetDepends set (e.g. "all"). - std::set const& utils = target->GetUtilities(); + std::set const& utils = target->GetUtilities(); std::copy(utils.begin(), utils.end(), std::back_inserter(outputs)); } else { cmTargetDependSet const& targetDeps = diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 735887e..a392aa6 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -624,7 +624,7 @@ void cmGlobalUnixMakefileGenerator3 void cmGlobalUnixMakefileGenerator3 ::WriteConvenienceRules(std::ostream& ruleFileStream, - std::set &emitted) + std::set &emitted) { std::vector depends; std::vector commands; @@ -1049,7 +1049,7 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule lg->AppendEcho(commands,"... depend"); // Keep track of targets already listed. - std::set emittedTargets; + std::set emittedTargets; // for each local generator unsigned int i; @@ -1084,8 +1084,8 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule } } } - std::vector const& localHelp = lg->GetLocalHelp(); - for(std::vector::const_iterator o = localHelp.begin(); + std::vector const& localHelp = lg->GetLocalHelp(); + for(std::vector::const_iterator o = localHelp.begin(); o != localHelp.end(); ++o) { path = "... "; @@ -1102,9 +1102,9 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule bool cmGlobalUnixMakefileGenerator3 ::NeedRequiresStep(cmTarget const& target) { - std::set languages; + std::set languages; target.GetLanguages(languages); - for(std::set::const_iterator l = languages.begin(); + for(std::set::const_iterator l = languages.begin(); l != languages.end(); ++l) { std::string var = "CMAKE_NEEDS_REQUIRES_STEP_"; diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index ffdf6fb..b61619d 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -96,7 +96,7 @@ public: // write the top level target rules void WriteConvenienceRules(std::ostream& ruleFileStream, - std::set &emitted); + std::set &emitted); /** Get the command to use for a target that has no rule. This is used for multiple output dependencies and for cmake_force. */ diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 214b9ea..a7f6587 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -260,7 +260,7 @@ void cmGlobalVisualStudio6Generator // output the DSW file void cmGlobalVisualStudio6Generator::OutputDSWFile() { - std::map >::iterator it; + std::map >::iterator it; for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) { this->OutputDSWFile(it->second[0], it->second); @@ -318,7 +318,7 @@ void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout, void cmGlobalVisualStudio6Generator::WriteExternalProject(std::ostream& fout, const std::string& name, const char* location, - const std::set& dependencies) + const std::set& dependencies) { fout << "#########################################################" "######################\n\n"; @@ -329,7 +329,7 @@ void cmGlobalVisualStudio6Generator::WriteExternalProject(std::ostream& fout, fout << "{{{\n"; - std::set::const_iterator i, end; + std::set::const_iterator i, end; // write dependencies. i = dependencies.begin(); end = dependencies.end(); diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index f1c70e4..3665f7b 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -103,7 +103,7 @@ private: cmTarget const& t); void WriteExternalProject(std::ostream& fout, const std::string& name, const char* path, - const std::set& dependencies); + const std::set& dependencies); void WriteDSWFooter(std::ostream& fout); virtual std::string WriteUtilityDepend(cmTarget const* target); std::string MSDevCommand; diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index af1a5c5..08bcc5b 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -237,7 +237,7 @@ void cmGlobalVisualStudio71Generator const std::string& name, const char* location, const char* typeGuid, - const std::set& depends) + const std::set& depends) { fout << "Project(\"{" << (typeGuid ? typeGuid : this->ExternalProjectType(location)) @@ -252,7 +252,7 @@ void cmGlobalVisualStudio71Generator if(!depends.empty()) { fout << "\tProjectSection(ProjectDependencies) = postProject\n"; - std::set::const_iterator it; + std::set::const_iterator it; for(it = depends.begin(); it != depends.end(); ++it) { if(it->size() > 0) diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index 8791468..75cc6ae 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -72,7 +72,7 @@ protected: const std::string& name, const char* path, const char* typeGuid, - const std::set& depends); + const std::set& depends); virtual void WriteSLNHeader(std::ostream& fout); std::string ProjectConfigurationSectionName; diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index cf84fe3..2a97edc 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -353,7 +353,7 @@ void cmGlobalVisualStudio7Generator // output the SLN file void cmGlobalVisualStudio7Generator::OutputSLNFile() { - std::map >::iterator it; + std::map >::iterator it; for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) { this->OutputSLNFile(it->second[0], it->second); @@ -761,7 +761,7 @@ void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout, const std::string& name, const char* location, const char* typeGuid, - const std::set&) + const std::set&) { std::string d = cmSystemTools::ConvertToOutputPath(location); fout << "Project(" diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 6fb3731..2e58f6c 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -156,7 +156,7 @@ protected: const std::string& name, const char* path, const char* typeGuid, - const std::set& + const std::set& dependencies); std::string ConvertToSolutionPath(const char* path); @@ -164,7 +164,7 @@ protected: std::set IsPartOfDefaultBuild(const std::string& project, cmTarget const* target); std::vector Configurations; - std::map GUIDMap; + std::map GUIDMap; virtual void WriteFolders(std::ostream& fout); virtual void WriteFoldersContent(std::ostream& fout); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 51825ee..2ae1bbc 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -338,7 +338,7 @@ void cmGlobalVisualStudio8Generator::Generate() if(this->AddCheckTarget()) { // All targets depend on the build-system check target. - for(std::map::const_iterator + for(std::map::const_iterator ti = this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti) { @@ -436,7 +436,7 @@ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies( cmTarget& target) { // Look for utility dependencies that magically link. - for(std::set::const_iterator ui = + for(std::set::const_iterator ui = target.GetUtilities().begin(); ui != target.GetUtilities().end(); ++ui) { diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index d388034..b2a705e 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -53,7 +53,7 @@ void cmGlobalVisualStudioGenerator::Generate() const char* no_working_dir = 0; std::vector no_depends; cmCustomCommandLines no_commands; - std::map >::iterator it; + std::map >::iterator it; for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) { std::vector& gen = it->second; @@ -128,7 +128,7 @@ cmGlobalVisualStudioGenerator // Count the number of object files with each name. Note that // windows file names are not case sensitive. - std::map counts; + std::map counts; std::vector objectSources; gt->GetObjectSources(objectSources); for(std::vector::const_iterator @@ -380,7 +380,7 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends() { return false; } - std::map >::iterator it; + std::map >::iterator it; for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) { std::vector& gen = it->second; @@ -852,7 +852,7 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) { // check to see if this is a fortran build - std::set languages; + std::set languages; target.GetLanguages(languages); if(languages.size() == 1) { diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index b1fa838..dc0f9c7 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -99,7 +99,7 @@ protected: virtual void AddPlatformDefinitions(cmMakefile* mf); virtual bool ComputeTargetDepends(); - class VSDependSet: public std::set {}; + class VSDependSet: public std::set {}; class VSDependMap: public std::map {}; VSDependMap VSTargetDepends; void ComputeVSTargetDepends(cmTarget&); @@ -108,7 +108,7 @@ protected: std::string GetUtilityForTarget(cmTarget& target, const std::string&); virtual std::string WriteUtilityDepend(cmTarget const*) = 0; std::string GetUtilityDepend(cmTarget const* target); - typedef std::map UtilityDependsMap; + typedef std::map UtilityDependsMap; UtilityDependsMap UtilityDepends; const char* AdditionalPlatformDefinition; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index a1255a0..08e9adf 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -337,7 +337,7 @@ cmLocalGenerator *cmGlobalXCodeGenerator::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::Generate() { - std::map >::iterator it; + std::map >::iterator it; // make sure extra targets are added before calling // the parent generate which will call trace depends for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) @@ -570,7 +570,7 @@ void cmGlobalXCodeGenerator::addObject(cmXCodeObject *obj) { if(obj->GetType() == cmXCodeObject::OBJECT) { - cmStdString id = obj->GetId(); + std::string id = obj->GetId(); // If this is a duplicate id, it's an error: // @@ -631,17 +631,17 @@ cmXCodeObject* cmGlobalXCodeGenerator } //---------------------------------------------------------------------------- -cmStdString +std::string GetGroupMapKeyFromPath(cmTarget& cmtarget, const std::string& fullpath) { - cmStdString key(cmtarget.GetName()); + std::string key(cmtarget.GetName()); key += "-"; key += fullpath; return key; } //---------------------------------------------------------------------------- -cmStdString +std::string GetGroupMapKey(cmTarget& cmtarget, cmSourceFile* sf) { return GetGroupMapKeyFromPath(cmtarget, sf->GetFullPath()); @@ -844,7 +844,7 @@ cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath( fileRef->SetComment(fname.c_str()); this->FileRefs[fname] = fileRef; } - cmStdString key = GetGroupMapKeyFromPath(cmtarget, fullpath); + std::string key = GetGroupMapKeyFromPath(cmtarget, fullpath); cmXCodeObject* group = this->GroupMap[key]; cmXCodeObject* children = group->GetObject("children"); if (!children->HasObject(fileRef)) @@ -1127,7 +1127,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, std::vector contentBuildPhases; if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) { - typedef std::map > + typedef std::map > mapOfVectorOfSourceFiles; mapOfVectorOfSourceFiles bundleFiles; for(std::vector::const_iterator i = classes.begin(); @@ -1216,7 +1216,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, void cmGlobalXCodeGenerator::ForceLinkerLanguages() { // This makes sure all targets link using the proper language. - for(std::map::const_iterator + for(std::map::const_iterator ti = this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti) { this->ForceLinkerLanguage(*ti->second); @@ -1477,7 +1477,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, // collect multiple outputs of custom commands into a set // which will be used for every configuration - std::map multipleOutputPairs; + std::map multipleOutputPairs; for(std::vector::const_iterator i = commands.begin(); i != commands.end(); ++i) { @@ -1548,8 +1548,8 @@ void cmGlobalXCodeGenerator std::vector const & commands, const char* configName, - const std::map& multipleOutputPairs + const std::map& multipleOutputPairs ) { std::string makefileName=makefileBasename; @@ -1571,7 +1571,7 @@ void cmGlobalXCodeGenerator // have all depend on all outputs makefileStream << "all: "; - std::map tname; + std::map tname; int count = 0; for(std::vector::const_iterator i = commands.begin(); i != commands.end(); ++i) @@ -1669,7 +1669,7 @@ void cmGlobalXCodeGenerator makefileStream << "\n# Dependencies of multiple outputs to their primary outputs \n"; - for(std::map::const_iterator o = + for(std::map::const_iterator o = multipleOutputPairs.begin(); o != multipleOutputPairs.end(); ++o) { makefileStream << o->first << ": " << o->second << "\n"; @@ -1678,7 +1678,7 @@ void cmGlobalXCodeGenerator makefileStream << "\n" "cmake_check_multiple_outputs:\n"; - for(std::map::const_iterator o = + for(std::map::const_iterator o = multipleOutputPairs.begin(); o != multipleOutputPairs.end(); ++o) { makefileStream << "\t@if [ ! -f " @@ -2088,7 +2088,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::vector includes; this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, "C", configName); - std::set emitted; + std::set emitted; emitted.insert("/System/Library/Frameworks"); for(std::vector::iterator i = includes.begin(); i != includes.end(); ++i) @@ -2357,18 +2357,18 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { if(i->first.find("XCODE_ATTRIBUTE_") == 0) { - cmStdString attribute = i->first.substr(16); + std::string attribute = i->first.substr(16); // Handle [variant=] condition explicitly here. - cmStdString::size_type beginVariant = + std::string::size_type beginVariant = attribute.find("[variant="); - if (beginVariant != cmStdString::npos) + if (beginVariant != std::string::npos) { - cmStdString::size_type endVariant = + std::string::size_type endVariant = attribute.find("]", beginVariant+9); - if (endVariant != cmStdString::npos) + if (endVariant != std::string::npos) { // Compare the variant to the configuration. - cmStdString variant = + std::string variant = attribute.substr(beginVariant+9, endVariant-beginVariant-9); if (variant == configName) { @@ -2969,7 +2969,7 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, mf->FindSourceGroup(source.c_str(), sourceGroups); cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(cmtarget, sourceGroup); - cmStdString key = GetGroupMapKey(cmtarget, sf); + std::string key = GetGroupMapKey(cmtarget, sf); this->GroupMap[key] = pbxgroup; } @@ -2984,7 +2984,7 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, mf->FindSourceGroup(source.c_str(), sourceGroups); cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(cmtarget, sourceGroup); - cmStdString key = GetGroupMapKeyFromPath(cmtarget, source); + std::string key = GetGroupMapKeyFromPath(cmtarget, source); this->GroupMap[key] = pbxgroup; } } @@ -2992,7 +2992,7 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, } cmXCodeObject *cmGlobalXCodeGenerator -::CreatePBXGroup(cmXCodeObject *parent, cmStdString name) +::CreatePBXGroup(cmXCodeObject *parent, std::string name) { cmXCodeObject* parentChildren = NULL; if(parent) @@ -3016,8 +3016,8 @@ cmXCodeObject *cmGlobalXCodeGenerator cmXCodeObject* cmGlobalXCodeGenerator ::CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg) { - cmStdString s; - cmStdString target; + std::string s; + std::string target; const char *targetFolder= cmtarget.GetProperty("FOLDER"); if(targetFolder) { target = targetFolder; @@ -3026,7 +3026,7 @@ cmXCodeObject* cmGlobalXCodeGenerator target += cmtarget.GetName(); s = target + "/"; s += sg->GetFullName(); - std::map::iterator it = + std::map::iterator it = this->GroupNameMap.find(s); if(it != this->GroupNameMap.end()) { @@ -3043,7 +3043,7 @@ cmXCodeObject* cmGlobalXCodeGenerator { std::vector tgt_folders = cmSystemTools::tokenize(target, "/"); - cmStdString curr_tgt_folder; + std::string curr_tgt_folder; for(std::vector::size_type i = 0; i < tgt_folders.size();i++) { if (i != 0) @@ -3070,7 +3070,7 @@ cmXCodeObject* cmGlobalXCodeGenerator // If it's the default source group (empty name) then put the source file // directly in the tgroup... // - if (cmStdString(sg->GetFullName()) == "") + if (std::string(sg->GetFullName()) == "") { this->GroupNameMap[s] = tgroup; return tgroup; @@ -3081,12 +3081,12 @@ cmXCodeObject* cmGlobalXCodeGenerator { std::vector folders = cmSystemTools::tokenize(sg->GetFullName(), "\\"); - cmStdString curr_folder = target; + std::string curr_folder = target; curr_folder += "/"; for(std::vector::size_type i = 0; i < folders.size();i++) { curr_folder += folders[i]; - std::map::iterator i_folder = + std::map::iterator i_folder = this->GroupNameMap.find(curr_folder); //Create new folder if(i_folder == this->GroupNameMap.end()) @@ -3466,14 +3466,14 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( makefileStream << "# For each target create a dummy rule " "so the target does not have to exist\n"; - std::set emitted; + std::set emitted; for(std::vector::iterator i = targets.begin(); i != targets.end(); ++i) { cmXCodeObject* target = *i; - std::map const& deplibs = + std::map const& deplibs = target->GetDependLibraries(); - for(std::map::const_iterator ci + for(std::map::const_iterator ci = deplibs.begin(); ci != deplibs.end(); ++ci) { for(cmXCodeObject::StringVec::const_iterator d = ci->second.begin(); @@ -3529,12 +3529,12 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::string trel = this->ConvertToRelativeForMake(tfull.c_str()); // Add this target to the post-build phases of its dependencies. - std::map::const_iterator + std::map::const_iterator y = target->GetDependTargets().find(*ct); if(y != target->GetDependTargets().end()) { - std::vector const& deptgts = y->second; - for(std::vector::const_iterator d = deptgts.begin(); + std::vector const& deptgts = y->second; + for(std::vector::const_iterator d = deptgts.begin(); d != deptgts.end(); ++d) { makefileStream << this->PostBuildMakeTarget(*d, *ct) << ": " @@ -3546,12 +3546,12 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( makefileStream << trel << ":"; // List dependencies if any exist. - std::map::const_iterator + std::map::const_iterator x = target->GetDependLibraries().find(*ct); if(x != target->GetDependLibraries().end()) { - std::vector const& deplibs = x->second; - for(std::vector::const_iterator d = deplibs.begin(); + std::vector const& deplibs = x->second; + for(std::vector::const_iterator d = deplibs.begin(); d != deplibs.end(); ++d) { makefileStream << "\\\n\t" << @@ -3960,7 +3960,7 @@ cmGlobalXCodeGenerator // names since Xcode names them uniquely automatically with a numeric suffix // to avoid exact duplicate file names. Note that Mac file names are not // typically case sensitive, hence the LowerCase. - std::map counts; + std::map counts; std::vector objectSources; gt->GetObjectSources(objectSources); for(std::vector::const_iterator diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 8e2de9a..d2dd491 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -95,7 +95,7 @@ private: cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg); cmXCodeObject* CreatePBXGroup(cmXCodeObject *parent, - cmStdString name); + std::string name); void CreateGroups(cmLocalGenerator* root, std::vector& generators); @@ -124,7 +124,7 @@ private: cmTarget& target, std::vector const & commands, const char* configName, - const std::map& + const std::map& multipleOutputPairs ); @@ -211,7 +211,7 @@ protected: unsigned int XcodeVersion; std::string VersionString; - std::set XCodeObjectIDs; + std::set XCodeObjectIDs; std::vector XCodeObjects; cmXCodeObject* RootObject; private: @@ -236,14 +236,14 @@ private: std::string CurrentReRunCMakeMakefile; std::string CurrentXCodeHackMakefile; std::string CurrentProject; - std::set TargetDoneSet; + std::set TargetDoneSet; std::vector CurrentOutputDirectoryComponents; std::vector ProjectSourceDirectoryComponents; std::vector ProjectOutputDirectoryComponents; - std::map GroupMap; - std::map GroupNameMap; - std::map TargetGroup; - std::map FileRefs; + std::map GroupMap; + std::map GroupNameMap; + std::map TargetGroup; + std::map FileRefs; std::vector Architectures; std::string PlatformToolset; }; diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 6173d21..22cba89 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -121,7 +121,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, __set_bool_if_set(this->GeneratePerTarget, "GRAPHVIZ_GENERATE_PER_TARGET"); __set_bool_if_set(this->GenerateDependers, "GRAPHVIZ_GENERATE_DEPENDERS"); - cmStdString ignoreTargetsRegexes; + std::string ignoreTargetsRegexes; __set_if_set(ignoreTargetsRegexes, "GRAPHVIZ_IGNORE_TARGETS"); this->TargetsToIgnoreRegex.clear(); @@ -135,7 +135,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, itvIt != ignoreTargetsRegExVector.end(); ++ itvIt ) { - cmStdString currentRegexString(*itvIt); + std::string currentRegexString(*itvIt); cmsys::RegularExpression currentRegex; if (!currentRegex.compile(currentRegexString.c_str())) { @@ -160,7 +160,7 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName) this->CollectTargetsAndLibs(); - for(std::map::const_iterator ptrIt = + for(std::map::const_iterator ptrIt = this->TargetPtrs.begin(); ptrIt != this->TargetPtrs.end(); ++ptrIt) @@ -211,7 +211,7 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName) this->CollectTargetsAndLibs(); - for(std::map::const_iterator ptrIt = + for(std::map::const_iterator ptrIt = this->TargetPtrs.begin(); ptrIt != this->TargetPtrs.end(); ++ptrIt) @@ -265,7 +265,7 @@ void cmGraphVizWriter::WriteGlobalFile(const char* fileName) std::set insertedConnections; std::set insertedNodes; - for(std::map::const_iterator ptrIt = + for(std::map::const_iterator ptrIt = this->TargetPtrs.begin(); ptrIt != this->TargetPtrs.end(); ++ptrIt) @@ -305,7 +305,7 @@ void cmGraphVizWriter::WriteConnections(const std::string& targetName, std::set& insertedConnections, cmGeneratedFileStream& str) const { - std::map::const_iterator targetPtrIt = + std::map::const_iterator targetPtrIt = this->TargetPtrs.find(targetName); if (targetPtrIt == this->TargetPtrs.end()) // not found at all @@ -331,7 +331,7 @@ void cmGraphVizWriter::WriteConnections(const std::string& targetName, ++ llit ) { const char* libName = llit->first.c_str(); - std::map::const_iterator libNameIt = + std::map::const_iterator libNameIt = this->TargetNamesNodes.find(libName); // can happen e.g. if GRAPHVIZ_TARGET_IGNORE_REGEX is used @@ -364,7 +364,7 @@ void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName, std::set& insertedConnections, cmGeneratedFileStream& str) const { - std::map::const_iterator targetPtrIt = + std::map::const_iterator targetPtrIt = this->TargetPtrs.find(targetName); if (targetPtrIt == this->TargetPtrs.end()) // not found at all @@ -383,7 +383,7 @@ void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName, std::string myNodeName = this->TargetNamesNodes.find(targetName)->second; // now search who links against me - for(std::map::const_iterator dependerIt = + for(std::map::const_iterator dependerIt = this->TargetPtrs.begin(); dependerIt != this->TargetPtrs.end(); ++dependerIt) @@ -411,7 +411,7 @@ void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName, if (libName == targetName) { // So this target links against targetName. - std::map::const_iterator dependerNodeNameIt = + std::map::const_iterator dependerNodeNameIt = this->TargetNamesNodes.find(dependerIt->first); if(dependerNodeNameIt != this->TargetNamesNodes.end()) @@ -452,7 +452,7 @@ void cmGraphVizWriter::WriteNode(const std::string& targetName, if (insertedNodes.find(targetName) == insertedNodes.end()) { insertedNodes.insert(targetName); - std::map::const_iterator nameIt = + std::map::const_iterator nameIt = this->TargetNamesNodes.find(targetName); str << " \"" << nameIt->second.c_str() << "\" [ label=\"" @@ -540,7 +540,7 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt) continue; } - std::map::const_iterator tarIt = + std::map::const_iterator tarIt = this->TargetPtrs.find(libName); if ( tarIt == this->TargetPtrs.end() ) { diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h index 6af460b..a7acd0e 100644 --- a/Source/cmGraphVizWriter.h +++ b/Source/cmGraphVizWriter.h @@ -64,10 +64,10 @@ protected: bool GenerateForTargetType(cmTarget::TargetType targetType) const; - cmStdString GraphType; - cmStdString GraphName; - cmStdString GraphHeader; - cmStdString GraphNodePrefix; + std::string GraphType; + std::string GraphName; + std::string GraphHeader; + std::string GraphNodePrefix; bool GenerateForExecutables; bool GenerateForStaticLibs; @@ -81,9 +81,9 @@ protected: const std::vector& LocalGenerators; - std::map TargetPtrs; + std::map TargetPtrs; // maps from the actual target names to node names in dot: - std::map TargetNamesNodes; + std::map TargetNamesNodes; bool HaveTargetsAndLibs; }; diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index 34a9c7c..e03223f 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -108,7 +108,7 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table, { const char *new_value = flag+1+n; - std::map::iterator itr; + std::map::iterator itr; itr = this->FlagMap.find(entry->IDEName); if(itr != this->FlagMap.end()) { @@ -186,7 +186,7 @@ void cmIDEOptions::RemoveFlag(const char* flag) //---------------------------------------------------------------------------- const char* cmIDEOptions::GetFlag(const char* flag) { - std::map::iterator i = this->FlagMap.find(flag); + std::map::iterator i = this->FlagMap.find(flag); if(i != this->FlagMap.end()) { return i->second.c_str(); diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index e78af3e..691893f 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -40,13 +40,13 @@ protected: // Then parse the command line flags specified in CMAKE_CXX_FLAGS // and CMAKE_C_FLAGS // and overwrite or add new values to this map - std::map FlagMap; + std::map FlagMap; // Preprocessor definitions. std::vector Defines; // Unrecognized flags that get no special handling. - cmStdString FlagString; + std::string FlagString; bool DoingDefine; bool AllowDefine; diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx index e20fe02..df5508e 100644 --- a/Source/cmIncludeDirectoryCommand.cxx +++ b/Source/cmIncludeDirectoryCommand.cxx @@ -38,7 +38,7 @@ bool cmIncludeDirectoryCommand std::vector beforeIncludes; std::vector afterIncludes; - std::set systemIncludes; + std::set systemIncludes; for(; i != args.end(); ++i) { diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 0878aae..94d2091 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -97,7 +97,7 @@ bool cmInstallCommand::InitialPass(std::vector const& args, } // Unknown mode. - cmStdString e = "called with unknown mode "; + std::string e = "called with unknown mode "; e += args[0]; this->SetError(e.c_str()); return false; diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 1287ea6..045cff6 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -177,7 +177,7 @@ cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os, // Now create a configuration-specific install rule for the import // file of each configuration. std::vector files; - for(std::map::const_iterator + for(std::map::const_iterator i = this->EFGen->GetConfigImportFiles().begin(); i != this->EFGen->GetConfigImportFiles().end(); ++i) { diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 7a39f45..5df6e4b 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -513,7 +513,7 @@ cmInstallTargetGenerator // Build a map of build-tree install_name to install-tree install_name for // shared libraries linked to this target. - std::map install_name_remap; + std::map install_name_remap; if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { std::set const& sharedLibs @@ -590,7 +590,7 @@ cmInstallTargetGenerator { os << "\n" << indent << " -id \"" << new_id << "\""; } - for(std::map::const_iterator + for(std::map::const_iterator i = install_name_remap.begin(); i != install_name_remap.end(); ++i) { diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx index dfd98fa..806d821 100644 --- a/Source/cmLoadCacheCommand.cxx +++ b/Source/cmLoadCacheCommand.cxx @@ -33,7 +33,7 @@ bool cmLoadCacheCommand // and they can not be overridden. bool excludeFiles=false; unsigned int i; - std::set excludes; + std::set excludes; for(i=0; i includes; + std::set includes; for(i=0; i VariablesToRead; + std::set VariablesToRead; std::string Prefix; bool ReadWithPrefix(std::vector const& args); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 75f2130..e36266a 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -617,8 +617,8 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, // Parse the string to get the custom command line. cmCustomCommandLine commandLine; - std::vector cmd = cmSystemTools::ParseArguments(i->c_str()); - for(std::vector::iterator a = cmd.begin(); + std::vector cmd = cmSystemTools::ParseArguments(i->c_str()); + for(std::vector::iterator a = cmd.begin(); a != cmd.end(); ++a) { commandLine.push_back(*a); @@ -656,7 +656,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, cmGeneratorTarget& target) { - cmStdString objs; + std::string objs; std::vector objVector; // Add all the sources outputs to the depends of the target std::vector classes; @@ -728,8 +728,8 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, this->ExpandRuleVariables(*i, vars); // Parse the string to get the custom command line. cmCustomCommandLine commandLine; - std::vector cmd = cmSystemTools::ParseArguments(i->c_str()); - for(std::vector::iterator a = cmd.begin(); + std::vector cmd = cmSystemTools::ParseArguments(i->c_str()); + for(std::vector::iterator a = cmd.begin(); a != cmd.end(); ++a) { commandLine.push_back(*a); @@ -758,7 +758,7 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, void cmLocalGenerator -::CreateCustomTargetsAndCommands(std::set const& lang) +::CreateCustomTargetsAndCommands(std::set const& lang) { cmGeneratorTargetsType tgts = this->Makefile->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator l = tgts.begin(); @@ -1344,7 +1344,7 @@ std::string cmLocalGenerator::GetIncludeFlags( this->Makefile->GetDefinition(fwSearchFlagVar.c_str()); bool flagUsed = false; - std::set emitted; + std::set emitted; #ifdef __APPLE__ emitted.insert("/System/Library/Frameworks"); #endif @@ -1488,7 +1488,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector& dirs, } // Do not repeat an include path. - std::set emitted; + std::set emitted; // Store the automatic include paths. if(includeBinaryDir) @@ -2988,7 +2988,7 @@ cmLocalGenerator std::string const& dir_max) { // Look for an existing mapped name for this object file. - std::map::iterator it = + std::map::iterator it = this->UniqueObjectNamesMap.find(sin); // If no entry exists create one. @@ -3071,7 +3071,7 @@ cmLocalGenerator #endif // Insert the newly mapped object file name. - std::map::value_type e(sin, ssin); + std::map::value_type e(sin, ssin); it = this->UniqueObjectNamesMap.insert(e).first; } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 633be5d..3fe6a26 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -406,7 +406,7 @@ protected: // generator directly. Any targets containing files that are not // of the types listed will be compiled as custom commands and added // to a custom target. - void CreateCustomTargetsAndCommands(std::set const&); + void CreateCustomTargetsAndCommands(std::set const&); // Handle old-style install rules stored in the targets. void GenerateTargetInstallRules( @@ -443,9 +443,9 @@ protected: std::vector StartOutputDirectoryComponents; cmLocalGenerator* Parent; std::vector Children; - std::map UniqueObjectNamesMap; + std::map UniqueObjectNamesMap; std::string::size_type ObjectPathMax; - std::set ObjectMaxPathViolations; + std::set ObjectMaxPathViolations; bool WindowsShell; bool WindowsVSIDE; bool WatcomWMake; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index f47ea29..2516613 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -190,7 +190,7 @@ void cmLocalUnixMakefileGenerator3::AddLocalObjectFile( void cmLocalUnixMakefileGenerator3::GetIndividualFileTargets (std::vector& targets) { - for (std::map::iterator lo = + for (std::map::iterator lo = this->LocalObjectFiles.begin(); lo != this->LocalObjectFiles.end(); ++lo) { @@ -235,7 +235,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() // only write local targets unless at the top Keep track of targets already // listed. - std::set emittedTargets; + std::set emittedTargets; if (this->Parent) { // write our targets, and while doing it collect up the object @@ -256,7 +256,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() // now write out the object rules // for each object file name - for (std::map::iterator lo = + for (std::map::iterator lo = this->LocalObjectFiles.begin(); lo != this->LocalObjectFiles.end(); ++lo) { @@ -371,7 +371,7 @@ cmLocalUnixMakefileGenerator3 //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 ::WriteLocalMakefileTargets(std::ostream& ruleFileStream, - std::set &emitted) + std::set &emitted) { std::vector depends; std::vector commands; @@ -1196,12 +1196,12 @@ cmLocalUnixMakefileGenerator3 if(!filename) { // Get the set of source languages in the target. - std::set languages; + std::set languages; target.GetLanguages(languages); fout << "\n" << "# Per-language clean rules from dependency scanning.\n" << "foreach(lang"; - for(std::set::const_iterator l = languages.begin(); + for(std::set::const_iterator l = languages.begin(); l != languages.end(); ++l) { fout << " " << *l; @@ -1317,7 +1317,7 @@ cmLocalUnixMakefileGenerator3 // see if the variable has been defined before and return // the modified version of the variable - std::map::iterator i = + std::map::iterator i = this->MakeVariableMap.find(unmodified); if(i != this->MakeVariableMap.end()) { @@ -1721,7 +1721,7 @@ void cmLocalUnixMakefileGenerator3 { text = "Running external command ..."; } - std::set::const_iterator dit; + std::set::const_iterator dit; for ( dit = glIt->second.GetUtilities().begin(); dit != glIt->second.GetUtilities().end(); ++ dit ) diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 2ad5250..37ee874 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -211,11 +211,11 @@ public: // File pairs for implicit dependency scanning. The key of the map // is the depender and the value is the explicit dependee. struct ImplicitDependFileMap: - public std::map {}; + public std::map {}; struct ImplicitDependLanguageMap: - public std::map {}; + public std::map {}; struct ImplicitDependTargetMap: - public std::map {}; + public std::map {}; ImplicitDependLanguageMap const& GetImplicitDepends(cmTarget const& tgt); void AddImplicitDepends(cmTarget const& tgt, const std::string& lang, @@ -231,7 +231,7 @@ public: std::string objNoTargetDir, bool hasSourceExtension); - std::vector const& GetLocalHelp() { return this->LocalHelp; } + std::vector const& GetLocalHelp() { return this->LocalHelp; } /** Get whether to create rules to generate preprocessed and assembly sources. This could be converted to a variable lookup @@ -256,7 +256,7 @@ protected: // write the target rules for the local Makefile into the stream void WriteLocalMakefileTargets(std::ostream& ruleFileStream, - std::set &emitted); + std::set &emitted); // this method Writes the Directory information files void WriteDirectoryInformationFile(); @@ -370,16 +370,16 @@ private: LocalObjectInfo():HasSourceExtension(false), HasPreprocessRule(false), HasAssembleRule(false) {} }; - std::map LocalObjectFiles; + std::map LocalObjectFiles; void WriteObjectConvenienceRule(std::ostream& ruleFileStream, const char* comment, const char* output, LocalObjectInfo const& info); - std::vector LocalHelp; + std::vector LocalHelp; /* does the work for each target */ - std::map MakeVariableMap; - std::map ShortMakeVariableMap; + std::map MakeVariableMap; + std::map ShortMakeVariableMap; }; #endif diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index a5ac629..b0c577e 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -80,7 +80,7 @@ private: void cmLocalVisualStudio6Generator::AddHelperCommands() { - std::set lang; + std::set lang; lang.insert("C"); lang.insert("CXX"); this->CreateCustomTargetsAndCommands(lang); @@ -426,7 +426,7 @@ void cmLocalVisualStudio6Generator } // Add per-source and per-configuration preprocessor definitions. - std::map cdmap; + std::map cdmap; { std::set targetCompileDefinitions; @@ -526,7 +526,7 @@ void cmLocalVisualStudio6Generator { fout << "\n# ADD CPP " << compileFlags << "\n\n"; } - std::map::iterator cdi = + std::map::iterator cdi = cdmap.find(cmSystemTools::UpperCase(config)); if(cdi != cdmap.end() && !cdi->second.empty()) { diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 7b921a3..6ad5e04 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -59,7 +59,7 @@ cmLocalVisualStudio7Generator::~cmLocalVisualStudio7Generator() void cmLocalVisualStudio7Generator::AddHelperCommands() { - std::set lang; + std::set lang; lang.insert("C"); lang.insert("CXX"); lang.insert("RC"); @@ -1468,7 +1468,7 @@ public: cmTarget& target, cmSourceFile const& sf, std::vector* configs); - std::map FileConfigMap; + std::map FileConfigMap; }; cmLocalVisualStudio7GeneratorFCInfo @@ -1712,7 +1712,7 @@ bool cmLocalVisualStudio7Generator aCompilerTool = "VFCustomBuildTool"; } } - for(std::map::const_iterator + for(std::map::const_iterator fci = fcinfo.FileConfigMap.begin(); fci != fcinfo.FileConfigMap.end(); ++fci) { diff --git a/Source/cmMakeDepend.h b/Source/cmMakeDepend.h index 2419ae9..2c9d515 100644 --- a/Source/cmMakeDepend.h +++ b/Source/cmMakeDepend.h @@ -138,10 +138,10 @@ protected: cmsys::RegularExpression IncludeFileRegularExpression; cmsys::RegularExpression ComplainFileRegularExpression; std::vector IncludeDirectories; - typedef std::map FileToPathMapType; - typedef std::map + typedef std::map FileToPathMapType; + typedef std::map DirectoryToFileToPathMapType; - typedef std::map + typedef std::map DependInformationMapType; DependInformationMapType DependInformationMap; DirectoryToFileToPathMapType DirectoryToFileToPathMap; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7198523..d107ddf 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -45,8 +45,8 @@ class cmMakefile::Internals { public: std::stack > VarStack; - std::stack > VarInitStack; - std::stack > VarUsageStack; + std::stack > VarInitStack; + std::stack > VarUsageStack; bool IsSourceFileTryCompile; }; @@ -54,7 +54,7 @@ public: cmMakefile::cmMakefile(): Internal(new Internals) { const cmDefinitions& defs = cmDefinitions(); - const std::set globalKeys = defs.LocalKeys(); + const std::set globalKeys = defs.LocalKeys(); this->Internal->VarStack.push(defs); this->Internal->VarInitStack.push(globalKeys); this->Internal->VarUsageStack.push(globalKeys); @@ -203,7 +203,7 @@ cmMakefile::~cmMakefile() { delete *i; } - for(std::map::iterator i = this->Tests.begin(); + for(std::map::iterator i = this->Tests.begin(); i != this->Tests.end(); ++i) { delete i->second; @@ -247,10 +247,10 @@ void cmMakefile::PrintStringVector(const char* s, void cmMakefile ::PrintStringVector(const char* s, - const std::vector >& v) const + const std::vector >& v) const { std::cout << s << ": ( \n"; - for(std::vector >::const_iterator i + for(std::vector >::const_iterator i = v.begin(); i != v.end(); ++i) { std::cout << i->first.c_str() << " " << i->second; @@ -1746,9 +1746,9 @@ void cmMakefile::AddIncludeDirectories(const std::vector &incs, //---------------------------------------------------------------------------- void -cmMakefile::AddSystemIncludeDirectories(const std::set &incs) +cmMakefile::AddSystemIncludeDirectories(const std::set &incs) { - for(std::set::const_iterator li = incs.begin(); + for(std::set::const_iterator li = incs.begin(); li != incs.end(); ++li) { this->SystemIncludeDirectories.insert(*li); @@ -1865,8 +1865,8 @@ void cmMakefile::CheckForUnusedVariables() const return; } const cmDefinitions& defs = this->Internal->VarStack.top(); - const std::set& locals = defs.LocalKeys(); - std::set::const_iterator it = locals.begin(); + const std::set& locals = defs.LocalKeys(); + std::set::const_iterator it = locals.begin(); for (; it != locals.end(); ++it) { this->CheckForUnused("out of scope", it->c_str()); @@ -1903,7 +1903,7 @@ void cmMakefile::CheckForUnused(const char* reason, { if (this->WarnUnused && !this->VariableUsed(name)) { - cmStdString path; + std::string path; cmListFileBacktrace bt; if (this->CallStack.size()) { @@ -2487,7 +2487,7 @@ const char* cmMakefile::GetSafeDefinition(const std::string& def) const std::vector cmMakefile ::GetDefinitions(int cacheonly /* = 0 */) const { - std::set definitions; + std::set definitions; if ( !cacheonly ) { definitions = this->Internal->VarStack.top().ClosureKeys(); @@ -2501,7 +2501,7 @@ std::vector cmMakefile std::vector res; - std::set::iterator fit; + std::set::iterator fit; for ( fit = definitions.begin(); fit != definitions.end(); fit ++ ) { res.push_back(*fit); @@ -3679,7 +3679,7 @@ const char *cmMakefile::GetProperty(const std::string& prop, } else if (prop == "LISTFILE_STACK") { - for (std::deque::const_iterator + for (std::deque::const_iterator i = this->ListFileStack.begin(); i != this->ListFileStack.end(); ++i) { @@ -3864,7 +3864,7 @@ cmTest* cmMakefile::CreateTest(const std::string& testName) //---------------------------------------------------------------------------- cmTest* cmMakefile::GetTest(const std::string& testName) const { - std::map::const_iterator + std::map::const_iterator mi = this->Tests.find(testName); if(mi != this->Tests.end()) { @@ -3903,7 +3903,7 @@ std::string cmMakefile::GetListFileStack() const size_t depth = this->ListFileStack.size(); if (depth > 0) { - std::deque::const_iterator it = this->ListFileStack.end(); + std::deque::const_iterator it = this->ListFileStack.end(); do { if (depth != this->ListFileStack.size()) @@ -3926,8 +3926,8 @@ std::string cmMakefile::GetListFileStack() const void cmMakefile::PushScope() { cmDefinitions* parent = &this->Internal->VarStack.top(); - const std::set& init = this->Internal->VarInitStack.top(); - const std::set& usage = this->Internal->VarUsageStack.top(); + const std::set& init = this->Internal->VarInitStack.top(); + const std::set& usage = this->Internal->VarUsageStack.top(); this->Internal->VarStack.push(cmDefinitions(parent)); this->Internal->VarInitStack.push(init); this->Internal->VarUsageStack.push(usage); @@ -3936,12 +3936,12 @@ void cmMakefile::PushScope() void cmMakefile::PopScope() { cmDefinitions* current = &this->Internal->VarStack.top(); - std::set init = this->Internal->VarInitStack.top(); - std::set usage = this->Internal->VarUsageStack.top(); - const std::set& locals = current->LocalKeys(); + std::set init = this->Internal->VarInitStack.top(); + std::set usage = this->Internal->VarUsageStack.top(); + const std::set& locals = current->LocalKeys(); // Remove initialization and usage information for variables in the local // scope. - std::set::const_iterator it = locals.begin(); + std::set::const_iterator it = locals.begin(); for (; it != locals.end(); ++it) { init.erase(*it); @@ -4054,7 +4054,7 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name, { // Look for an imported target. These take priority because they // are more local in scope and do not have to be globally unique. - std::map::const_iterator + std::map::const_iterator imported = this->ImportedTargets.find(name); if(imported != this->ImportedTargets.end()) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 39635dd..86cedb0 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -542,7 +542,7 @@ public: /** * Mark include directories as system directories. */ - void AddSystemIncludeDirectories(const std::set &incs); + void AddSystemIncludeDirectories(const std::set &incs); /** Expand out any arguements in the vector that have ; separated * strings into multiple arguements. A new vector is created @@ -876,7 +876,7 @@ public: void AddQtUiFileWithOptions(cmSourceFile *sf); std::vector GetQtUiFilesWithOptions() const; - std::set const & GetSystemIncludeDirectories() const + std::set const & GetSystemIncludeDirectories() const { return this->SystemIncludeDirectories; } protected: @@ -904,14 +904,14 @@ protected: std::vector SourceFiles; // Tests - std::map Tests; + std::map Tests; // The link-library paths. Order matters, use std::vector (not std::set). std::vector LinkDirectories; // The set of include directories that are marked as system include // directories. - std::set SystemIncludeDirectories; + std::set SystemIncludeDirectories; std::vector ListFiles; // list of command files loaded std::vector OutputFiles; // list of command files loaded @@ -957,7 +957,7 @@ private: friend class cmMakeDepend; // make depend needs direct access // to the Sources array void PrintStringVector(const char* s, const - std::vector >& v) const; + std::vector >& v) const; void PrintStringVector(const char* s, const std::vector& v) const; @@ -968,10 +968,10 @@ private: void PushFunctionBlockerBarrier(); void PopFunctionBlockerBarrier(bool reportError = true); - typedef std::map StringStringMap; + typedef std::map StringStringMap; StringStringMap MacrosMap; - std::map SubDirectoryOrder; + std::map SubDirectoryOrder; mutable cmsys::RegularExpression cmDefineRegex; mutable cmsys::RegularExpression cmDefine01Regex; @@ -987,7 +987,7 @@ private: bool CheckSystemVars; // stack of list files being read - std::deque ListFileStack; + std::deque ListFileStack; // stack of commands being invoked. struct CallStackEntry @@ -1000,7 +1000,7 @@ private: friend class cmMakefileCall; std::vector ImportedTargetsOwned; - std::map ImportedTargets; + std::map ImportedTargets; // Internal policy stack management. void PushPolicy(bool weak = false, diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index fb9b045..0a836a5 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -342,21 +342,21 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) void cmMakefileTargetGenerator::WriteTargetLanguageFlags() { // write language flags for target - std::set languages; + std::set languages; this->Target->GetLanguages(languages); // put the compiler in the rules.make file so that if it changes // things rebuild - for(std::set::const_iterator l = languages.begin(); + for(std::set::const_iterator l = languages.begin(); l != languages.end(); ++l) { - cmStdString compiler = "CMAKE_"; + std::string compiler = "CMAKE_"; compiler += *l; compiler += "_COMPILER"; *this->FlagFileStream << "# compile " << l->c_str() << " with " << this->Makefile->GetSafeDefinition(compiler.c_str()) << "\n"; } - for(std::set::const_iterator l = languages.begin(); + for(std::set::const_iterator l = languages.begin(); l != languages.end(); ++l) { *this->FlagFileStream << *l << "_FLAGS = " << this->GetFlags(*l) << "\n\n"; @@ -1531,7 +1531,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output, } // Make sure the extra files are built. - for(std::set::const_iterator i = this->ExtraFiles.begin(); + for(std::set::const_iterator i = this->ExtraFiles.begin(); i != this->ExtraFiles.end(); ++i) { depends.push_back(*i); @@ -1561,7 +1561,7 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l) return std::string(); } - std::set emitted; + std::set emitted; #ifdef __APPLE__ /* don't insert this when crosscompiling e.g. to iphone */ emitted.insert("/System/Library/Frameworks"); #endif diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index d2cbadd..5f697a5 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -208,7 +208,7 @@ protected: std::string FlagFileNameFull; cmGeneratedFileStream *FlagFileStream; class StringList: public std::vector {}; - std::map FlagFileDepends; + std::map FlagFileDepends; // the stream for the info file std::string InfoFileNameFull; @@ -222,12 +222,12 @@ protected: std::vector ExternalObjects; // Set of object file names that will be built in this directory. - std::set ObjectFiles; + std::set ObjectFiles; // Set of extra output files to be driven by the build. - std::set ExtraFiles; + std::set ExtraFiles; - typedef std::map MultipleOutputPairsType; + typedef std::map MultipleOutputPairsType; MultipleOutputPairsType MultipleOutputPairs; // Target name info. @@ -238,11 +238,11 @@ protected: std::string TargetNamePDB; // Mac OS X content info. - std::set MacContentFolders; + std::set MacContentFolders; cmOSXBundleGenerator* OSXBundleGenerator; MacOSXContentGeneratorType* MacOSXContentGenerator; - typedef std::map ByLanguageMap; + typedef std::map ByLanguageMap; std::string GetFlags(const std::string &l); ByLanguageMap FlagsByLanguage; std::string GetDefines(const std::string &l); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 502127e..a49fc2d 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -109,9 +109,9 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules() << "\n\n"; #endif - std::set languages; + std::set languages; this->GetTarget()->GetLanguages(languages); - for(std::set::const_iterator l = languages.begin(); + for(std::set::const_iterator l = languages.begin(); l != languages.end(); ++l) this->WriteLanguageRules(*l); diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index e8ac81c..b3b37a4 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -140,7 +140,7 @@ protected: MacOSXContentGeneratorType* MacOSXContentGenerator; // Properly initialized by sub-classes. cmOSXBundleGenerator* OSXBundleGenerator; - std::set MacContentFolders; + std::set MacContentFolders; void addPoolNinjaVariable(const char* pool_property, cmTarget* target, diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h index 2f36394..97ae731 100644 --- a/Source/cmOSXBundleGenerator.h +++ b/Source/cmOSXBundleGenerator.h @@ -52,7 +52,7 @@ public: MacOSXContentGeneratorType* generator); std::string InitMacOSXContentDirectory(const char* pkgloc); - void SetMacContentFolders(std::set* macContentFolders) + void SetMacContentFolders(std::set* macContentFolders) { this->MacContentFolders = macContentFolders; } private: @@ -63,7 +63,7 @@ private: cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; const char* ConfigName; - std::set* MacContentFolders; + std::set* MacContentFolders; }; diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 86beb97..79677e3 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -138,9 +138,9 @@ bool cmOrderDirectoriesConstraint::FileMayConflict(std::string const& dir, } // Check if the file will be built by cmake. - std::set const& files = + std::set const& files = (this->GlobalGenerator->GetDirectoryContent(dir, false)); - std::set::const_iterator fi = files.find(name); + std::set::const_iterator fi = files.find(name); return fi != files.end(); } @@ -200,7 +200,7 @@ bool cmOrderDirectoriesConstraintSOName::FindConflict(std::string const& dir) { // We do not have the soname. Look for files in the directory // that may conflict. - std::set const& files = + std::set const& files = (this->GlobalGenerator ->GetDirectoryContent(dir, true)); @@ -208,9 +208,9 @@ bool cmOrderDirectoriesConstraintSOName::FindConflict(std::string const& dir) // know the soname just look at all files that start with the // file name. Usually the soname starts with the library name. std::string base = this->FileName; - std::set::const_iterator first = files.lower_bound(base); + std::set::const_iterator first = files.lower_bound(base); ++base[base.size()-1]; - std::set::const_iterator last = files.upper_bound(base); + std::set::const_iterator last = files.upper_bound(base); if(first != last) { return true; @@ -251,8 +251,8 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) if(!this->OD->LinkExtensions.empty() && this->OD->RemoveLibraryExtension.find(this->FileName)) { - cmStdString lib = this->OD->RemoveLibraryExtension.match(1); - cmStdString ext = this->OD->RemoveLibraryExtension.match(2); + std::string lib = this->OD->RemoveLibraryExtension.match(1); + std::string ext = this->OD->RemoveLibraryExtension.match(2); for(std::vector::iterator i = this->OD->LinkExtensions.begin(); i != this->OD->LinkExtensions.end(); ++i) @@ -407,7 +407,7 @@ cmOrderDirectories //---------------------------------------------------------------------------- void cmOrderDirectories -::SetImplicitDirectories(std::set const& implicitDirs) +::SetImplicitDirectories(std::set const& implicitDirs) { this->ImplicitDirectories = implicitDirs; } @@ -444,11 +444,11 @@ void cmOrderDirectories::CollectOriginalDirectories() int cmOrderDirectories::AddOriginalDirectory(std::string const& dir) { // Add the runtime directory with a unique index. - std::map::iterator i = + std::map::iterator i = this->DirectoryIndex.find(dir); if(i == this->DirectoryIndex.end()) { - std::map::value_type + std::map::value_type entry(dir, static_cast(this->OriginalDirectories.size())); i = this->DirectoryIndex.insert(entry).first; this->OriginalDirectories.push_back(dir); diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index 76bf429..07c85dd 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -34,7 +34,7 @@ public: void AddLinkLibrary(std::string const& fullPath); void AddUserDirectories(std::vector const& extra); void AddLanguageDirectories(std::vector const& dirs); - void SetImplicitDirectories(std::set const& implicitDirs); + void SetImplicitDirectories(std::set const& implicitDirs); void SetLinkExtensionInfo(std::vector const& linkExtensions, std::string const& removeExtRegex); @@ -54,11 +54,11 @@ private: std::vector LanguageDirectories; cmsys::RegularExpression RemoveLibraryExtension; std::vector LinkExtensions; - std::set ImplicitDirectories; - std::set EmmittedConstraintSOName; - std::set EmmittedConstraintLibrary; + std::set ImplicitDirectories; + std::set EmmittedConstraintSOName; + std::set EmmittedConstraintLibrary; std::vector OriginalDirectories; - std::map DirectoryIndex; + std::map DirectoryIndex; std::vector DirectoryVisited; void CollectOriginalDirectories(); int AddOriginalDirectory(std::string const& dir); diff --git a/Source/cmPropertyDefinitionMap.cxx b/Source/cmPropertyDefinitionMap.cxx index 9ebbaa4..3875318 100644 --- a/Source/cmPropertyDefinitionMap.cxx +++ b/Source/cmPropertyDefinitionMap.cxx @@ -14,7 +14,7 @@ #include "cmDocumentationSection.h" void cmPropertyDefinitionMap -::DefineProperty(const cmStdString& name, cmProperty::ScopeType scope, +::DefineProperty(const std::string& name, cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, bool chain) @@ -29,7 +29,7 @@ void cmPropertyDefinitionMap } } -bool cmPropertyDefinitionMap::IsPropertyDefined(const cmStdString& name) +bool cmPropertyDefinitionMap::IsPropertyDefined(const std::string& name) { cmPropertyDefinitionMap::iterator it = this->find(name); if (it == this->end()) @@ -40,7 +40,7 @@ bool cmPropertyDefinitionMap::IsPropertyDefined(const cmStdString& name) return true; } -bool cmPropertyDefinitionMap::IsPropertyChained(const cmStdString& name) +bool cmPropertyDefinitionMap::IsPropertyChained(const std::string& name) { cmPropertyDefinitionMap::iterator it = this->find(name); if (it == this->end()) diff --git a/Source/cmPropertyDefinitionMap.h b/Source/cmPropertyDefinitionMap.h index 68c3ff3..00c7328 100644 --- a/Source/cmPropertyDefinitionMap.h +++ b/Source/cmPropertyDefinitionMap.h @@ -17,20 +17,20 @@ class cmDocumentationSection; class cmPropertyDefinitionMap : -public std::map +public std::map { public: // define the property - void DefineProperty(const cmStdString& name, cmProperty::ScopeType scope, + void DefineProperty(const std::string& name, cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, bool chain); // has a named property been defined - bool IsPropertyDefined(const cmStdString& name); + bool IsPropertyDefined(const std::string& name); // is a named property set to chain - bool IsPropertyChained(const cmStdString& name); + bool IsPropertyChained(const std::string& name); }; #endif diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index a13ac35..fa33848 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -16,7 +16,7 @@ class cmake; -class cmPropertyMap : public std::map +class cmPropertyMap : public std::map { public: cmProperty *GetOrCreateProperty(const std::string& name); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index e075c54..17b2424 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -697,7 +697,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, { cmMakefile *makefile = target->GetMakefile(); - std::set skipped; + std::set skipped; std::vector skipVec; cmSystemTools::ExpandListArgument(this->SkipUic.c_str(), skipVec); @@ -1895,7 +1895,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, |cmsysTerminal_Color_ForegroundBold, msg.c_str(), true, this->ColorOutput); - std::vector command; + std::vector command; command.push_back(this->MocExecutable); for (std::list::const_iterator it = this->MocIncludes.begin(); it != this->MocIncludes.end(); @@ -1924,7 +1924,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, if (this->Verbose) { - for(std::vector::const_iterator cmdIt = command.begin(); + for(std::vector::const_iterator cmdIt = command.begin(); cmdIt != command.end(); ++cmdIt) { @@ -1971,7 +1971,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& path, |cmsysTerminal_Color_ForegroundBold, msg.c_str(), true, this->ColorOutput); - std::vector command; + std::vector command; command.push_back(this->UicExecutable); std::vector opts = this->UicTargetOptions; @@ -1996,7 +1996,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& path, if (this->Verbose) { - for(std::vector::const_iterator cmdIt = command.begin(); + for(std::vector::const_iterator cmdIt = command.begin(); cmdIt != command.end(); ++cmdIt) { @@ -2034,7 +2034,7 @@ bool cmQtAutoGenerators::GenerateQrc() { continue; } - std::vector command; + std::vector command; command.push_back(this->RccExecutable); std::string basename = cmsys::SystemTools:: @@ -2068,7 +2068,7 @@ bool cmQtAutoGenerators::GenerateQrc() if (this->Verbose) { - for(std::vector::const_iterator cmdIt = command.begin(); + for(std::vector::const_iterator cmdIt = command.begin(); cmdIt != command.end(); ++cmdIt) { diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx index 11a9913..7ff12dd 100644 --- a/Source/cmRST.cxx +++ b/Source/cmRST.cxx @@ -326,11 +326,11 @@ std::string cmRST::ReplaceSubstitutions(std::string const& line) std::string::size_type start = this->Substitution.start(2); std::string::size_type end = this->Substitution.end(2); std::string substitute = this->Substitution.match(3); - std::map::iterator + std::map::iterator replace = this->Replace.find(substitute); if(replace != this->Replace.end()) { - std::pair::iterator, bool> replaced = + std::pair::iterator, bool> replaced = this->Replaced.insert(substitute); if(replaced.second) { diff --git a/Source/cmRST.h b/Source/cmRST.h index 3356008..b9b2366 100644 --- a/Source/cmRST.h +++ b/Source/cmRST.h @@ -92,8 +92,8 @@ private: std::vector MarkupLines; std::string DocDir; - std::map Replace; - std::set Replaced; + std::map Replace; + std::set Replaced; std::string ReplaceName; }; diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index e561e36..84c7610 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -241,7 +241,7 @@ bool cmSetPropertyCommand::HandleDirectoryMode() //---------------------------------------------------------------------------- bool cmSetPropertyCommand::HandleTargetMode() { - for(std::set::const_iterator ni = this->Names.begin(); + for(std::set::const_iterator ni = this->Names.begin(); ni != this->Names.end(); ++ni) { if (this->Makefile->IsAlias(*ni)) @@ -297,7 +297,7 @@ bool cmSetPropertyCommand::HandleTarget(cmTarget* target) //---------------------------------------------------------------------------- bool cmSetPropertyCommand::HandleSourceMode() { - for(std::set::const_iterator ni = this->Names.begin(); + for(std::set::const_iterator ni = this->Names.begin(); ni != this->Names.end(); ++ni) { // Get the source file. @@ -345,8 +345,8 @@ bool cmSetPropertyCommand::HandleSource(cmSourceFile* sf) bool cmSetPropertyCommand::HandleTestMode() { // Look for tests with all names given. - std::set::iterator next; - for(std::set::iterator ni = this->Names.begin(); + std::set::iterator next; + for(std::set::iterator ni = this->Names.begin(); ni != this->Names.end(); ni = next) { next = ni; @@ -369,7 +369,7 @@ bool cmSetPropertyCommand::HandleTestMode() { cmOStringStream e; e << "given TEST names that do not exist:\n"; - for(std::set::const_iterator ni = this->Names.begin(); + for(std::set::const_iterator ni = this->Names.begin(); ni != this->Names.end(); ++ni) { e << " " << *ni << "\n"; @@ -440,7 +440,7 @@ bool cmSetPropertyCommand::HandleCacheMode() return false; } - for(std::set::const_iterator ni = this->Names.begin(); + for(std::set::const_iterator ni = this->Names.begin(); ni != this->Names.end(); ++ni) { // Get the source file. diff --git a/Source/cmSetPropertyCommand.h b/Source/cmSetPropertyCommand.h index 5470314..5757d21 100644 --- a/Source/cmSetPropertyCommand.h +++ b/Source/cmSetPropertyCommand.h @@ -44,7 +44,7 @@ public: cmTypeMacro(cmSetPropertyCommand, cmCommand); private: - std::set Names; + std::set Names; std::string PropertyName; std::string PropertyValue; bool Remove; diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx index 195feb5..8fed95e 100644 --- a/Source/cmSourceGroup.cxx +++ b/Source/cmSourceGroup.cxx @@ -99,7 +99,7 @@ bool cmSourceGroup::MatchesRegex(const char* name) //---------------------------------------------------------------------------- bool cmSourceGroup::MatchesFiles(const char* name) { - std::set::const_iterator i = this->GroupFiles.find(name); + std::set::const_iterator i = this->GroupFiles.find(name); if(i != this->GroupFiles.end()) { return true; diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h index 2d891d1..e8cf519 100644 --- a/Source/cmSourceGroup.h +++ b/Source/cmSourceGroup.h @@ -118,7 +118,7 @@ private: /** * Set of file names explicitly added to this group. */ - std::set GroupFiles; + std::set GroupFiles; /** * Vector of all source files that have been assigned to diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index 04e1bc8..ed8efcc 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -241,7 +241,7 @@ inline bool operator==(std::string const& a, const char* b) // std::string is really basic_string<....lots of stuff....> // when combined with a map or set, the symbols can be > 2000 chars! #include -typedef cmsys::String cmStdString; +//typedef cmsys::String std::string; // Define cmOStringStream and cmIStringStream wrappers to hide // differences between std::stringstream and the old strstream. @@ -468,7 +468,7 @@ struct cmStrCmp { } private: - const cmStdString m_test; + const std::string m_test; }; #endif diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 2b17fba..39b53bf 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -477,13 +477,6 @@ public: args.push_back(*arg); } } - void Store(std::vector& args) const - { - for(char** arg = this->ArgV; arg && *arg; ++arg) - { - args.push_back(*arg); - } - } }; //---------------------------------------------------------------------------- @@ -495,15 +488,6 @@ void cmSystemTools::ParseUnixCommandLine(const char* command, argv.Store(args); } -//---------------------------------------------------------------------------- -void cmSystemTools::ParseUnixCommandLine(const char* command, - std::vector& args) -{ - // Invoke the underlying parser. - cmSystemToolsArgV argv = cmsysSystem_Parse_CommandForUnix(command, 0); - argv.Store(args); -} - std::string cmSystemTools::EscapeWindowsShellArgument(const char* arg, int shell_flags) { @@ -523,9 +507,9 @@ std::string cmSystemTools::EscapeWindowsShellArgument(const char* arg, return result; } -std::vector cmSystemTools::ParseArguments(const char* command) +std::vector cmSystemTools::ParseArguments(const char* command) { - std::vector args; + std::vector args; std::string arg; bool win_path = false; @@ -606,22 +590,6 @@ std::vector cmSystemTools::ParseArguments(const char* command) } -bool cmSystemTools::RunSingleCommand(std::vectorconst& command, - std::string* output , - int* retVal , const char* dir , - OutputOption outputflag , - double timeout ) -{ - std::vector cmd; - for(std::vector::const_iterator i = command.begin(); - i != command.end(); ++i) - { - cmd.push_back(*i); - } - return cmSystemTools::RunSingleCommand(cmd, output, retVal, dir, - outputflag, timeout); -} - bool cmSystemTools::RunSingleCommand(std::vectorconst& command, std::string* output , int* retVal , const char* dir , @@ -781,7 +749,7 @@ bool cmSystemTools::RunSingleCommand( outputflag = OUTPUT_NONE; } - std::vector args = cmSystemTools::ParseArguments(command); + std::vector args = cmSystemTools::ParseArguments(command); if(args.size() < 1) { @@ -1114,8 +1082,8 @@ void cmSystemTools::ExpandListArgument(const std::string& arg, } } -bool cmSystemTools::SimpleGlob(const cmStdString& glob, - std::vector& files, +bool cmSystemTools::SimpleGlob(const std::string& glob, + std::vector& files, int type /* = 0 */) { files.clear(); @@ -1233,7 +1201,7 @@ cmSystemTools::FileFormat cmSystemTools::GetFileFormat(const char* cext) return cmSystemTools::UNKNOWN_FILE_FORMAT; } -bool cmSystemTools::Split(const char* s, std::vector& l) +bool cmSystemTools::Split(const char* s, std::vector& l) { std::vector temp; bool res = Superclass::Split(s, temp); @@ -1445,7 +1413,7 @@ bool cmSystemTools::IsPathToFramework(const char* path) } bool cmSystemTools::CreateTar(const char* outFileName, - const std::vector& files, + const std::vector& files, bool gzip, bool bzip2, bool verbose) { #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -1465,7 +1433,7 @@ bool cmSystemTools::CreateTar(const char* outFileName, cmArchiveWrite::CompressNone)), cmArchiveWrite::TypeTAR); a.SetVerbose(verbose); - for(std::vector::const_iterator i = files.begin(); + for(std::vector::const_iterator i = files.begin(); i != files.end(); ++i) { std::string path = *i; @@ -2317,7 +2285,7 @@ bool cmSystemTools::GuessLibrarySOName(std::string const& fullPath, bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath, std::string& soname) { - std::vector cmds; + std::vector cmds; cmds.push_back("otool"); cmds.push_back("-D"); cmds.push_back(fullPath.c_str()); diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 4a212c2..27b4bce 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -172,8 +172,8 @@ public: * want to find. 0 means all files, -1 means directories, 1 means * files only. This method returns true if search was succesfull. */ - static bool SimpleGlob(const cmStdString& glob, - std::vector& files, + static bool SimpleGlob(const std::string& glob, + std::vector& files, int type = 0); ///! Copy a file. @@ -234,18 +234,13 @@ public: int* retVal = 0, const char* dir = 0, OutputOption outputflag = OUTPUT_MERGE, double timeout = 0.0); - static bool RunSingleCommand(std::vector const& command, - std::string* output = 0, - int* retVal = 0, const char* dir = 0, - OutputOption outputflag = OUTPUT_MERGE, - double timeout = 0.0); static std::string PrintSingleCommand(std::vector const&); /** * Parse arguments out of a single string command */ - static std::vector ParseArguments(const char* command); + static std::vector ParseArguments(const char* command); /** Parse arguments out of a windows command line string. */ static void ParseWindowsCommandLine(const char* command, @@ -254,8 +249,6 @@ public: /** Parse arguments out of a unix command line string. */ static void ParseUnixCommandLine(const char* command, std::vector& args); - static void ParseUnixCommandLine(const char* command, - std::vector& args); /** Compute an escaped version of the given argument for use in a windows shell. See kwsys/System.h.in for details. */ @@ -321,7 +314,7 @@ public: /** Split a string on its newlines into multiple lines. Returns false only if the last line stored had no newline. */ - static bool Split(const char* s, std::vector& l); + static bool Split(const char* s, std::vector& l); static void SetForceUnixPaths(bool v) { s_ForceUnixPaths = v; @@ -390,7 +383,7 @@ public: static bool ListTar(const char* outFileName, bool gzip, bool verbose); static bool CreateTar(const char* outFileName, - const std::vector& files, bool gzip, + const std::vector& files, bool gzip, bool bzip2, bool verbose); static bool ExtractTar(const char* inFileName, bool gzip, bool verbose); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c927a0b..99f2c1f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -118,7 +118,7 @@ public: LinkInterfaceMapType LinkInterfaceMap; bool PolicyWarnedCMP0022; - typedef std::map OutputInfoMapType; + typedef std::map OutputInfoMapType; OutputInfoMapType OutputInfoMap; typedef std::map @@ -356,10 +356,10 @@ void cmTarget::SetMakefile(cmMakefile* mf) { this->InsertInclude(*it); } - const std::set parentSystemIncludes = + const std::set parentSystemIncludes = this->Makefile->GetSystemIncludeDirectories(); - for (std::set::const_iterator it + for (std::set::const_iterator it = parentSystemIncludes.begin(); it != parentSystemIncludes.end(); ++it) { @@ -428,7 +428,7 @@ void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) cmListFileBacktrace const* cmTarget::GetUtilityBacktrace( const std::string& u) const { - std::map::const_iterator i = + std::map::const_iterator i = this->UtilityBacktraces.find(u); if(i == this->UtilityBacktraces.end()) return 0; @@ -776,8 +776,8 @@ void cmTarget::GetDirectLinkLibraries(const char *config, &dagChecker), libs); - std::set seenProps = cge->GetSeenTargetProperties(); - for (std::set::const_iterator it = seenProps.begin(); + std::set seenProps = cge->GetSeenTargetProperties(); + for (std::set::const_iterator it = seenProps.begin(); it != seenProps.end(); ++it) { if (!this->GetProperty(it->c_str())) @@ -887,7 +887,7 @@ void cmTarget::GetTllSignatureTraces(cmOStringStream &s, = (sig == cmTarget::KeywordTLLSignature ? "keyword" : "plain"); s << "The uses of the " << sigString << " signature are here:\n"; - std::set emitted; + std::set emitted; for(std::vector::const_iterator it = sigs.begin(); it != sigs.end(); ++it) { @@ -981,9 +981,9 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, //---------------------------------------------------------------------------- void -cmTarget::AddSystemIncludeDirectories(const std::set &incs) +cmTarget::AddSystemIncludeDirectories(const std::set &incs) { - for(std::set::const_iterator li = incs.begin(); + for(std::set::const_iterator li = incs.begin(); li != incs.end(); ++li) { this->SystemIncludeDirectories.insert(*li); @@ -1574,7 +1574,7 @@ static void processIncludeDirectories(cmTarget const* tgt, { bool testIsOff = true; bool cacheIncludes = false; - std::vector entryIncludes = (*it)->CachedEntries; + std::vector& entryIncludes = (*it)->CachedEntries; if(!entryIncludes.empty()) { testIsOff = false; @@ -2806,7 +2806,7 @@ class cmTargetCollectLinkLanguages { public: cmTargetCollectLinkLanguages(cmTarget const* target, const char* config, - std::set& languages, + std::set& languages, cmTarget const* head): Config(config), Languages(languages), HeadTarget(head), Makefile(target->GetMakefile()), Target(target) @@ -2878,7 +2878,7 @@ public: } private: const char* Config; - std::set& Languages; + std::set& Languages; cmTarget const* HeadTarget; cmMakefile* Makefile; const cmTarget* Target; @@ -2917,7 +2917,7 @@ class cmTargetSelectLinker cmTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator* GG; - std::set Preferred; + std::set Preferred; public: cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target) { @@ -2949,7 +2949,7 @@ public: e << "Target " << this->Target->GetName() << " contains multiple languages with the highest linker preference" << " (" << this->Preference << "):\n"; - for(std::set::const_iterator + for(std::set::const_iterator li = this->Preferred.begin(); li != this->Preferred.end(); ++li) { e << " " << *li << "\n"; @@ -2968,7 +2968,7 @@ void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc, cmTarget const* head) const { // Get languages built in this target. - std::set languages; + std::set languages; LinkImplementation const* impl = this->GetLinkImplementation(config, head); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) @@ -2985,7 +2985,7 @@ void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc, } // Store the transitive closure of languages. - for(std::set::const_iterator li = languages.begin(); + for(std::set::const_iterator li = languages.begin(); li != languages.end(); ++li) { lc.Languages.push_back(*li); @@ -3013,7 +3013,7 @@ void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc, } // Now consider languages that propagate from linked targets. - for(std::set::const_iterator sit = languages.begin(); + for(std::set::const_iterator sit = languages.begin(); sit != languages.end(); ++sit) { std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; @@ -4822,7 +4822,7 @@ bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, } //---------------------------------------------------------------------------- -void cmTarget::GetLanguages(std::set& languages) const +void cmTarget::GetLanguages(std::set& languages) const { for(std::vector::const_iterator i = this->SourceFiles.begin(); i != this->SourceFiles.end(); ++i) @@ -5662,7 +5662,7 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, { // Shared libraries may have runtime implementation dependencies // on other shared libraries that are not in the interface. - std::set emitted; + std::set emitted; for(std::vector::const_iterator li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) { @@ -5891,7 +5891,7 @@ void cmTarget::ComputeLinkImplementationLanguages(LinkImplementation& impl) const { // This target needs runtime libraries for its source languages. - std::set languages; + std::set languages; // Get languages used in our source files. this->GetLanguages(languages); // Get languages used in object library sources. @@ -5908,7 +5908,7 @@ cmTarget::ComputeLinkImplementationLanguages(LinkImplementation& impl) const } } // Copy the set of langauges to the link implementation. - for(std::set::iterator li = languages.begin(); + for(std::set::iterator li = languages.begin(); li != languages.end(); ++li) { impl.Languages.push_back(*li); @@ -6017,8 +6017,8 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, template void checkPropertyConsistency(cmTarget const* depender, cmTarget const* dependee, - const cmStdString& propName, - std::set &emitted, + const std::string& propName, + std::set &emitted, const char *config, CompatibleType t, PropertyType *) @@ -6062,10 +6062,10 @@ void checkPropertyConsistency(cmTarget const* depender, } } -static cmStdString intersect(const std::set &s1, - const std::set &s2) +static std::string intersect(const std::set &s1, + const std::set &s2) { - std::set intersect; + std::set intersect; std::set_intersection(s1.begin(),s1.end(), s2.begin(),s2.end(), std::inserter(intersect,intersect.begin())); @@ -6075,11 +6075,11 @@ static cmStdString intersect(const std::set &s1, } return ""; } -static cmStdString intersect(const std::set &s1, - const std::set &s2, - const std::set &s3) +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3) { - cmStdString result; + std::string result; result = intersect(s1, s2); if (!result.empty()) return result; @@ -6088,12 +6088,12 @@ static cmStdString intersect(const std::set &s1, return result; return intersect(s2, s3); } -static cmStdString intersect(const std::set &s1, - const std::set &s2, - const std::set &s3, - const std::set &s4) +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3, + const std::set &s4) { - cmStdString result; + std::string result; result = intersect(s1, s2); if (!result.empty()) return result; @@ -6112,10 +6112,10 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, { const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); - std::set emittedBools; - std::set emittedStrings; - std::set emittedMinNumbers; - std::set emittedMaxNumbers; + std::set emittedBools; + std::set emittedStrings; + std::set emittedMinNumbers; + std::set emittedMaxNumbers; for(cmComputeLinkInformation::ItemVector::const_iterator li = deps.begin(); @@ -6167,7 +6167,7 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, if (!prop.empty()) { std::set props; - std::set::const_iterator i = emittedBools.find(prop); + std::set::const_iterator i = emittedBools.find(prop); if (i != emittedBools.end()) { props.insert("COMPATIBLE_INTERFACE_BOOL"); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f73b271..ec74e05 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -148,7 +148,7 @@ public: enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED}; //* how we identify a library, by name and type - typedef std::pair LibraryID; + typedef std::pair LibraryID; typedef std::vector LinkLibraryVectorType; const LinkLibraryVectorType &GetLinkLibraries() const { @@ -216,7 +216,7 @@ public: */ void AddUtility(const std::string& u, cmMakefile *makefile = 0); ///! Get the utilities used by this target - std::setconst& GetUtilities() const { return this->Utilities; } + std::setconst& GetUtilities() const { return this->Utilities; } cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const; /** Finalize the target at the end of the Configure step. */ @@ -455,7 +455,7 @@ public: // when source file properties are changed and we do not have enough // information to forward these property changes to the targets // until we have per-target object file properties. - void GetLanguages(std::set& languages) const; + void GetLanguages(std::set& languages) const; /** Return whether this target is an executable with symbol exports enabled. */ @@ -552,9 +552,9 @@ public: std::string GetDebugGeneratorExpressions(const std::string &value, cmTarget::LinkLibraryType llt) const; - void AddSystemIncludeDirectories(const std::set &incs); + void AddSystemIncludeDirectories(const std::set &incs); void AddSystemIncludeDirectories(const std::vector &incs); - std::set const & GetSystemIncludeDirectories() const + std::set const & GetSystemIncludeDirectories() const { return this->SystemIncludeDirectories; } bool LinkLanguagePropagatesToDependents() const @@ -570,7 +570,7 @@ private: // The set of include directories that are marked as system include // directories. - std::set SystemIncludeDirectories; + std::set SystemIncludeDirectories; std::vector > TLLCommands; @@ -675,13 +675,13 @@ private: LinkLibraryVectorType PrevLinkedLibraries; bool LinkLibrariesAnalyzed; std::vector LinkDirectories; - std::set LinkDirectoriesEmmitted; + std::set LinkDirectoriesEmmitted; bool HaveInstallRule; std::string InstallPath; std::string RuntimeInstallPath; mutable std::string ExportMacro; - std::set Utilities; - std::map UtilityBacktraces; + std::set Utilities; + std::map UtilityBacktraces; bool RecordDependencies; mutable cmPropertyMap Properties; LinkLibraryVectorType OriginalLinkLibraries; @@ -762,9 +762,9 @@ private: const char* version) const; }; -typedef std::map cmTargets; +typedef std::map cmTargets; -class cmTargetSet: public std::set {}; -class cmTargetManifest: public std::map {}; +class cmTargetSet: public std::set {}; +class cmTargetManifest: public std::map {}; #endif diff --git a/Source/cmTest.h b/Source/cmTest.h index a5795c3..b3785f6 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -65,7 +65,7 @@ public: private: cmPropertyMap Properties; - cmStdString Name; + std::string Name; std::vector Command; bool OldStyle; diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h index 790c75a..c86fad0 100644 --- a/Source/cmVariableWatch.h +++ b/Source/cmVariableWatch.h @@ -81,7 +81,7 @@ protected: }; typedef std::vector< Pair* > VectorOfPairs; - typedef std::map StringToVectorOfPairs; + typedef std::map StringToVectorOfPairs; StringToVectorOfPairs WatchMap; }; diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index d1f3d19..8d69254 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -98,7 +98,7 @@ private: private: typedef cmVisualStudioGeneratorOptions Options; - typedef std::map OptionsMap; + typedef std::map OptionsMap; OptionsMap ClOptions; OptionsMap LinkOptions; std::string PathToVcxproj; @@ -113,7 +113,7 @@ private: cmLocalVisualStudio7Generator* LocalGenerator; std::set SourcesVisited; - typedef std::map ToolSourceMap; + typedef std::map ToolSourceMap; ToolSourceMap Tools; }; diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index f48c593..81adb56 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -300,7 +300,7 @@ cmVisualStudioGeneratorOptions { if(this->Version >= cmLocalVisualStudioGenerator::VS10) { - for(std::map::iterator m = this->FlagMap.begin(); + for(std::map::iterator m = this->FlagMap.begin(); m != this->FlagMap.end(); ++m) { fout << indent; @@ -326,7 +326,7 @@ cmVisualStudioGeneratorOptions } else { - for(std::map::iterator m = this->FlagMap.begin(); + for(std::map::iterator m = this->FlagMap.begin(); m != this->FlagMap.end(); ++m) { fout << indent << m->first << "=\"" << m->second << "\"\n"; diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 3b9035f..3302a8d 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -108,7 +108,7 @@ void cmXCodeObject::Print(std::ostream& out) { out << separator; } - std::map::iterator i; + std::map::iterator i; cmXCodeObject::Indent(3*indentFactor, out); out << "isa = " << PBXTypeNames[this->IsA] << ";" << separator; for(i = this->ObjectAttributes.begin(); @@ -138,7 +138,7 @@ void cmXCodeObject::Print(std::ostream& out) } else if(object->TypeValue == ATTRIBUTE_GROUP) { - std::map::iterator j; + std::map::iterator j; out << i->first << " = {" << separator; for(j = object->ObjectAttributes.begin(); j != object->ObjectAttributes.end(); ++j) @@ -236,7 +236,7 @@ void cmXCodeObject::CopyAttributes(cmXCodeObject* copy) } //---------------------------------------------------------------------------- -void cmXCodeObject::PrintString(std::ostream& os,cmStdString String) +void cmXCodeObject::PrintString(std::ostream& os,std::string String) { // The string needs to be quoted if it contains any characters // considered special by the Xcode project file parser. diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index b4623a0..8eaf2aa 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -30,7 +30,7 @@ public: PBXCopyFilesBuildPhase, None }; - class StringVec: public std::vector {}; + class StringVec: public std::vector {}; static const char* PBXTypeNames[]; virtual ~cmXCodeObject(); cmXCodeObject(PBXType ptype, Type type); @@ -131,7 +131,7 @@ public: } this->DependLibraries[configName].push_back(l); } - std::map const& GetDependLibraries() + std::map const& GetDependLibraries() { return this->DependLibraries; } @@ -144,27 +144,27 @@ public: } this->DependTargets[configName].push_back(tName); } - std::map const& GetDependTargets() + std::map const& GetDependTargets() { return this->DependTargets; } std::vector const& GetObjectList() { return this->List;} void SetComment(const char* c) { this->Comment = c;} - static void PrintString(std::ostream& os,cmStdString String); + static void PrintString(std::ostream& os,std::string String); protected: void PrintString(std::ostream& os) const; cmTarget* Target; Type TypeValue; - cmStdString Id; + std::string Id; PBXType IsA; int Version; - cmStdString Comment; - cmStdString String; + std::string Comment; + std::string String; cmXCodeObject* Object; std::vector List; - std::map DependLibraries; - std::map DependTargets; - std::map ObjectAttributes; + std::map DependLibraries; + std::map DependTargets; + std::map ObjectAttributes; }; #endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index ad1d0fa..bdba9c2 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2701,7 +2701,7 @@ void cmake::RunCheckForUnusedVariables() bool haveUnused = false; cmOStringStream msg; msg << "Manually-specified variables were not used by the project:"; - for(std::map::const_iterator + for(std::map::const_iterator it = this->UsedCliVariables.begin(); it != this->UsedCliVariables.end(); ++it) { diff --git a/Source/cmake.h b/Source/cmake.h index 2d78e8f..1b81520 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -91,7 +91,7 @@ class cmake */ FIND_PACKAGE_MODE }; - typedef std::map RegisteredCommandsMap; + typedef std::map RegisteredCommandsMap; /// Default constructor cmake(); @@ -364,14 +364,14 @@ protected: void InitializeProperties(); int HandleDeleteCacheVariables(const std::string& var); cmPropertyMap Properties; - std::set > AccessedProperties; + std::set > AccessedProperties; std::map PropertyDefinitions; typedef cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)(); - typedef std::map RegisteredExtraGeneratorsMap; typedef std::vector RegisteredGeneratorsVector; RegisteredCommandsMap Commands; @@ -432,7 +432,7 @@ private: bool WarnUnused; bool WarnUnusedCli; bool CheckSystemVars; - std::map UsedCliVariables; + std::map UsedCliVariables; std::string CMakeEditCommand; std::string CXXEnvironment; std::string CCEnvironment; diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx index faa5fa7..55fc633 100644 --- a/Source/cmcldeps.cxx +++ b/Source/cmcldeps.cxx @@ -198,7 +198,7 @@ static int process( const std::string& srcfilename, std::vector args; cmSystemTools::ParseWindowsCommandLine(cmd.c_str(), args); // convert to correct vector type for RunSingleCommand - std::vector command; + std::vector command; for(std::vector::iterator i = args.begin(); i != args.end(); ++i) { diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 4ac1986..603b6d0 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -677,7 +677,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) { std::string flags = args[2]; std::string outFile = args[3]; - std::vector files; + std::vector files; for (std::string::size_type cc = 4; cc < args.size(); cc ++) { files.push_back(args[cc]); @@ -1143,7 +1143,7 @@ int cmcmd::VisualStudioLink(std::vector& args, int type) } int cmcmd::ParseVisualStudioLinkCommand(std::vector& args, - std::vector& command, + std::vector& command, std::string& targetName) { std::vector::iterator i = args.begin(); @@ -1171,14 +1171,14 @@ int cmcmd::ParseVisualStudioLinkCommand(std::vector& args, } bool cmcmd::RunCommand(const char* comment, - std::vector& command, + std::vector& command, bool verbose, int* retCodeOut) { if(verbose) { std::cout << comment << ":\n"; - for(std::vector::iterator i = command.begin(); + for(std::vector::iterator i = command.begin(); i != command.end(); ++i) { std::cout << i->c_str() << " "; @@ -1239,16 +1239,16 @@ int cmcmd::VisualStudioLinkIncremental(std::vector& args, // 7. Finally, the Linker does another incremental link, but since the // only thing that has changed is the *.res file that contains the // manifest it is a short link. - std::vector linkCommand; + std::vector linkCommand; std::string targetName; if(cmcmd::ParseVisualStudioLinkCommand(args, linkCommand, targetName) == -1) { return -1; } std::string manifestArg = "/MANIFESTFILE:"; - std::vector rcCommand; + std::vector rcCommand; rcCommand.push_back(cmSystemTools::FindProgram("rc.exe")); - std::vector mtCommand; + std::vector mtCommand; mtCommand.push_back(cmSystemTools::FindProgram("mt.exe")); std::string tempManifest; tempManifest = targetName; @@ -1349,7 +1349,7 @@ int cmcmd::VisualStudioLinkNonIncremental(std::vector& args, bool hasManifest, bool verbose) { - std::vector linkCommand; + std::vector linkCommand; std::string targetName; if(cmcmd::ParseVisualStudioLinkCommand(args, linkCommand, targetName) == -1) { @@ -1368,7 +1368,7 @@ int cmcmd::VisualStudioLinkNonIncremental(std::vector& args, { return 0; } - std::vector mtCommand; + std::vector mtCommand; mtCommand.push_back(cmSystemTools::FindProgram("mt.exe")); mtCommand.push_back("/nologo"); mtCommand.push_back("/manifest"); diff --git a/Source/cmcmd.h b/Source/cmcmd.h index 4517ebf..2bfbae7 100644 --- a/Source/cmcmd.h +++ b/Source/cmcmd.h @@ -43,10 +43,10 @@ protected: bool hasManifest, bool verbose); static int ParseVisualStudioLinkCommand(std::vector& args, - std::vector& command, + std::vector& command, std::string& targetName); static bool RunCommand(const char* comment, - std::vector& command, + std::vector& command, bool verbose, int* retCodeOut = 0); }; diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx index dc1ce24..279bcd5 100644 --- a/Tests/CMakeLib/run_compile_commands.cxx +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -2,14 +2,14 @@ class CompileCommandParser { public: - class CommandType: public std::map + class CommandType: public std::map { public: - cmStdString const& at(cmStdString const& k) const + std::string const& at(std::string const& k) const { const_iterator i = this->find(k); if(i != this->end()) { return i->second; } - static cmStdString emptyString; + static std::string emptyString; return emptyString; } }; @@ -127,7 +127,7 @@ int main () it = parser.GetTranslationUnits().begin(), end = parser.GetTranslationUnits().end(); it != end; ++it) { - std::vector command; + std::vector command; cmSystemTools::ParseUnixCommandLine(it->at("command").c_str(), command); if (!cmSystemTools::RunSingleCommand( command, 0, 0, it->at("directory").c_str())) -- cgit v0.12 From f0ad6631adb7cd364e2bcf5e8738c697c902e0ad Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 7 Feb 2014 15:24:15 -0500 Subject: Directories: Take strings when setting directories --- Source/cmake.cxx | 4 ++-- Source/cmake.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index bdba9c2..5ada30e 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1069,13 +1069,13 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name) return generator; } -void cmake::SetHomeDirectory(const char* dir) +void cmake::SetHomeDirectory(const std::string& dir) { this->cmHomeDirectory = dir; cmSystemTools::ConvertToUnixSlashes(this->cmHomeDirectory); } -void cmake::SetHomeOutputDirectory(const char* lib) +void cmake::SetHomeOutputDirectory(const std::string& lib) { this->HomeOutputDirectory = lib; cmSystemTools::ConvertToUnixSlashes(this->HomeOutputDirectory); diff --git a/Source/cmake.h b/Source/cmake.h index 1b81520..933502a 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -110,12 +110,12 @@ class cmake * CMakeLists files by recursing up the tree starting at the StartDirectory * and going up until it reaches the HomeDirectory. */ - void SetHomeDirectory(const char* dir); + void SetHomeDirectory(const std::string& dir); const char* GetHomeDirectory() const { return this->cmHomeDirectory.c_str(); } - void SetHomeOutputDirectory(const char* lib); + void SetHomeOutputDirectory(const std::string& lib); const char* GetHomeOutputDirectory() const { return this->HomeOutputDirectory.c_str(); @@ -130,7 +130,7 @@ class cmake * recursing up the tree starting at the StartDirectory and going up until * it reaches the HomeDirectory. */ - void SetStartDirectory(const char* dir) + void SetStartDirectory(const std::string& dir) { this->cmStartDirectory = dir; cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory); @@ -139,7 +139,7 @@ class cmake { return this->cmStartDirectory.c_str(); } - void SetStartOutputDirectory(const char* lib) + void SetStartOutputDirectory(const std::string& lib) { this->StartOutputDirectory = lib; cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory); -- cgit v0.12 From cfc2cf9559eacbf45d04249ee1dd7f75bb0cdff0 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 8 Feb 2014 12:01:01 -0500 Subject: cmGeneratorExpression: Tokenize over strings --- Source/cmGeneratorExpression.cxx | 16 ++++++++-------- Source/cmGeneratorExpression.h | 4 ++-- Source/cmGeneratorExpressionLexer.cxx | 6 ++---- Source/cmGeneratorExpressionLexer.h | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 3ebb1b6..433adcf 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -33,17 +33,17 @@ cmGeneratorExpression::cmGeneratorExpression( cmsys::auto_ptr cmGeneratorExpression::Parse(std::string const& input) { - return this->Parse(input.c_str()); + return cmsys::auto_ptr( + new cmCompiledGeneratorExpression( + this->Backtrace, + input)); } //---------------------------------------------------------------------------- cmsys::auto_ptr cmGeneratorExpression::Parse(const char* input) { - return cmsys::auto_ptr( - new cmCompiledGeneratorExpression( - this->Backtrace, - input)); + return this->Parse(std::string(input ? input : "")); } cmGeneratorExpression::~cmGeneratorExpression() @@ -122,13 +122,13 @@ const char *cmCompiledGeneratorExpression::Evaluate( cmCompiledGeneratorExpression::cmCompiledGeneratorExpression( cmListFileBacktrace const& backtrace, - const char *input) - : Backtrace(backtrace), Input(input ? input : ""), + const std::string& input) + : Backtrace(backtrace), Input(input), HadContextSensitiveCondition(false) { cmGeneratorExpressionLexer l; std::vector tokens = - l.Tokenize(this->Input.c_str()); + l.Tokenize(this->Input); this->NeedsEvaluation = l.GetSawGeneratorExpression(); if (this->NeedsEvaluation) diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 58abf14..9aa590d 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -100,7 +100,7 @@ public: ~cmCompiledGeneratorExpression(); - std::string GetInput() const + std::string const& GetInput() const { return this->Input; } @@ -116,7 +116,7 @@ public: private: cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace, - const char *input); + const std::string& input); friend class cmGeneratorExpression; diff --git a/Source/cmGeneratorExpressionLexer.cxx b/Source/cmGeneratorExpressionLexer.cxx index 117a24e..1c83466 100644 --- a/Source/cmGeneratorExpressionLexer.cxx +++ b/Source/cmGeneratorExpressionLexer.cxx @@ -32,13 +32,11 @@ static void InsertText(const char *upto, const char *c, //---------------------------------------------------------------------------- std::vector -cmGeneratorExpressionLexer::Tokenize(const char *input) +cmGeneratorExpressionLexer::Tokenize(const std::string& input) { std::vector result; - if (!input) - return result; - const char *c = input; + const char *c = input.c_str(); const char *upto = c; for ( ; *c; ++c) diff --git a/Source/cmGeneratorExpressionLexer.h b/Source/cmGeneratorExpressionLexer.h index 83d661d..1e2e8c2 100644 --- a/Source/cmGeneratorExpressionLexer.h +++ b/Source/cmGeneratorExpressionLexer.h @@ -43,7 +43,7 @@ class cmGeneratorExpressionLexer public: cmGeneratorExpressionLexer(); - std::vector Tokenize(const char *input); + std::vector Tokenize(const std::string& input); bool GetSawGeneratorExpression() const { -- cgit v0.12 From f154475b65738444414312d7d5a255f3220d90c6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Sat, 8 Mar 2014 07:55:46 -0500 Subject: cmTarget: Refactor GetLocation API When given a non-NULL configuration the GetLocation returned the location for the given configuration. When given a NULL configuration the GetLocation method returned a location with the build-system placeholder for the configuration name. Split the latter use case out into a separate GetLocationForBuild method and update call sites accordingly. --- Source/cmGeneratorTarget.cxx | 2 +- Source/cmGlobalKdevelopGenerator.cxx | 2 +- Source/cmQtAutoGenerators.cxx | 12 ++++++------ Source/cmTarget.cxx | 25 +++++++++---------------- Source/cmTarget.h | 11 ++++++----- 5 files changed, 23 insertions(+), 29 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a7b2efa..f7f6feb 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -742,7 +742,7 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) { // This is really only for compatibility so we do not need to // worry about configuration names and output names. - std::string tLocation = t->GetLocation(0); + std::string tLocation = t->GetLocationForBuild(); tLocation = cmSystemTools::GetFilenamePath(tLocation); std::string depLocation = cmSystemTools::GetFilenamePath(dep); depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str()); diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 25df953..2d485f6 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -76,7 +76,7 @@ void cmGlobalKdevelopGenerator::Generate() { if (ti->second.GetType()==cmTarget::EXECUTABLE) { - executable = ti->second.GetLocation(0); + executable = ti->second.GetLocation(""); break; } } diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 17b2424..fbb3b1c 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -610,7 +610,7 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, autogenTargetName.c_str()); return; } - makefile->AddDefinition("_qt_moc_executable", qt5Moc->GetLocation(0)); + makefile->AddDefinition("_qt_moc_executable", qt5Moc->GetLocation("")); } else if (strcmp(qtVersion, "4") == 0) { @@ -621,7 +621,7 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, autogenTargetName.c_str()); return; } - makefile->AddDefinition("_qt_moc_executable", qt4Moc->GetLocation(0)); + makefile->AddDefinition("_qt_moc_executable", qt4Moc->GetLocation("")); } else { @@ -782,7 +782,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, } else { - makefile->AddDefinition("_qt_uic_executable", qt5Uic->GetLocation(0)); + makefile->AddDefinition("_qt_uic_executable", qt5Uic->GetLocation("")); } } else if (strcmp(qtVersion, "4") == 0) @@ -794,7 +794,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, targetName.c_str()); return; } - makefile->AddDefinition("_qt_uic_executable", qt4Uic->GetLocation(0)); + makefile->AddDefinition("_qt_uic_executable", qt4Uic->GetLocation("")); } else { @@ -931,7 +931,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) targetName.c_str()); return; } - makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation(0)); + makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation("")); } else if (strcmp(qtVersion, "4") == 0) { @@ -942,7 +942,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) targetName.c_str()); return; } - makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation(0)); + makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation("")); } else { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 99f2c1f..3273437 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2458,32 +2458,25 @@ std::string cmTarget::GetCompilePDBDirectory(const char* config) const //---------------------------------------------------------------------------- const char* cmTarget::GetLocation(const char* config) const { + static std::string location; if (this->IsImported()) { - return this->ImportedGetLocation(config); + location = this->ImportedGetFullPath(config, false); } else { - return this->NormalGetLocation(config); + location = this->GetFullPath(config, false); } -} - -//---------------------------------------------------------------------------- -const char* cmTarget::ImportedGetLocation(const char* config) const -{ - static std::string location; - location = this->ImportedGetFullPath(config, false); return location.c_str(); } //---------------------------------------------------------------------------- -const char* cmTarget::NormalGetLocation(const char* config) const +const char* cmTarget::GetLocationForBuild() const { static std::string location; - // Handle the configuration-specific case first. - if(config) + if(this->IsImported()) { - location = this->GetFullPath(config, false); + location = this->ImportedGetFullPath("", false); return location.c_str(); } @@ -2503,7 +2496,7 @@ const char* cmTarget::NormalGetLocation(const char* config) const if(this->IsAppBundleOnApple()) { - std::string macdir = this->BuildMacContentDirectory("", config, false); + std::string macdir = this->BuildMacContentDirectory("", "", false); if(!macdir.empty()) { location += "/"; @@ -2511,7 +2504,7 @@ const char* cmTarget::NormalGetLocation(const char* config) const } } location += "/"; - location += this->GetFullName(config, false); + location += this->GetFullName("", false); return location.c_str(); } @@ -2659,7 +2652,7 @@ const char *cmTarget::GetProperty(const std::string& prop, // cannot take into account the per-configuration name of the // target because the configuration type may not be known at // CMake time. - this->Properties.SetProperty("LOCATION", this->GetLocation(0), + this->Properties.SetProperty("LOCATION", this->GetLocationForBuild(), cmProperty::TARGET); } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index ec74e05..41f84a6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -331,10 +331,14 @@ public: std::string GetCompilePDBDirectory(const char* config = 0) const; /** Get the location of the target in the build tree for the given - configuration. This location is suitable for use as the LOCATION - target property. */ + configuration. */ const char* GetLocation(const char* config) const; + /** Get the location of the target in the build tree with a placeholder + referencing the configuration in the native build system. This + location is suitable for use as the LOCATION target property. */ + const char* GetLocationForBuild() const; + /** Get the target major and minor version numbers interpreted from the VERSION property. Version 0 is returned if the property is not set or cannot be parsed. */ @@ -643,9 +647,6 @@ private: // Get the target base name. std::string GetOutputName(const char* config, bool implib) const; - const char* ImportedGetLocation(const char* config) const; - const char* NormalGetLocation(const char* config) const; - std::string GetFullNameImported(const char* config, bool implib) const; std::string ImportedGetFullPath(const char* config, bool implib) const; -- cgit v0.12 From 84fdc9921cab35addba8c57cd201778de2cf87a4 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 9 Feb 2014 22:48:34 -0500 Subject: stringapi: Pass configuration names as strings --- Source/CPack/cmCPackGenerator.cxx | 7 +- Source/cmComputeLinkDepends.cxx | 7 +- Source/cmComputeLinkDepends.h | 5 +- Source/cmComputeLinkInformation.cxx | 7 +- Source/cmComputeLinkInformation.h | 4 +- Source/cmComputeTargetDepends.cxx | 6 +- Source/cmComputeTargetDepends.h | 2 +- Source/cmCoreTryCompile.cxx | 2 +- Source/cmCustomCommandGenerator.cxx | 2 +- Source/cmCustomCommandGenerator.h | 5 +- Source/cmExportBuildFileGenerator.cxx | 8 +- Source/cmExportBuildFileGenerator.h | 4 +- Source/cmExportFileGenerator.cxx | 25 +-- Source/cmExportFileGenerator.h | 16 +- Source/cmExportInstallFileGenerator.cxx | 11 +- Source/cmExportInstallFileGenerator.h | 6 +- Source/cmExportTryCompileFileGenerator.h | 6 +- Source/cmExtraSublimeTextGenerator.cxx | 4 +- Source/cmGeneratorExpression.cxx | 4 +- Source/cmGeneratorExpression.h | 4 +- Source/cmGeneratorExpressionEvaluationFile.cxx | 4 +- Source/cmGeneratorExpressionEvaluationFile.h | 2 +- Source/cmGeneratorExpressionEvaluator.cxx | 6 +- Source/cmGeneratorExpressionEvaluator.h | 2 +- Source/cmGeneratorTarget.cxx | 30 +-- Source/cmGeneratorTarget.h | 10 +- Source/cmGlobalGenerator.cxx | 17 +- Source/cmGlobalGenerator.h | 10 +- Source/cmGlobalNinjaGenerator.cxx | 6 +- Source/cmGlobalNinjaGenerator.h | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 2 +- Source/cmGlobalUnixMakefileGenerator3.h | 2 +- Source/cmGlobalVisualStudio10Generator.cxx | 4 +- Source/cmGlobalVisualStudio10Generator.h | 2 +- Source/cmGlobalVisualStudio6Generator.cxx | 8 +- Source/cmGlobalVisualStudio6Generator.h | 4 +- Source/cmGlobalVisualStudio7Generator.cxx | 8 +- Source/cmGlobalVisualStudio7Generator.h | 4 +- Source/cmGlobalXCodeGenerator.cxx | 27 +-- Source/cmGlobalXCodeGenerator.h | 11 +- Source/cmInstallExportGenerator.cxx | 2 +- Source/cmInstallFilesGenerator.cxx | 4 +- Source/cmInstallFilesGenerator.h | 2 +- Source/cmInstallGenerator.cxx | 2 +- Source/cmInstallGenerator.h | 2 +- Source/cmInstallTargetGenerator.cxx | 29 +-- Source/cmInstallTargetGenerator.h | 25 ++- Source/cmLocalGenerator.cxx | 38 ++-- Source/cmLocalGenerator.h | 20 +- Source/cmLocalVisualStudio6Generator.cxx | 16 +- Source/cmLocalVisualStudio6Generator.h | 9 +- Source/cmLocalVisualStudio7Generator.cxx | 16 +- Source/cmLocalVisualStudio7Generator.h | 8 +- Source/cmLocalVisualStudioGenerator.cxx | 4 +- Source/cmLocalVisualStudioGenerator.h | 5 +- Source/cmLocalXCodeGenerator.cxx | 4 +- Source/cmMakefile.cxx | 13 +- Source/cmMakefile.h | 4 +- Source/cmMakefileTargetGenerator.cxx | 15 +- Source/cmMakefileTargetGenerator.h | 2 +- Source/cmOSXBundleGenerator.cxx | 2 +- Source/cmOSXBundleGenerator.h | 4 +- Source/cmQtAutoGenerators.cxx | 21 +- Source/cmQtAutoGenerators.h | 4 +- Source/cmScriptGenerator.cxx | 21 +- Source/cmScriptGenerator.h | 10 +- Source/cmTarget.cxx | 277 +++++++++++++------------ Source/cmTarget.h | 147 +++++++------ Source/cmTestGenerator.cxx | 2 +- Source/cmTestGenerator.h | 2 +- Source/cmVisualStudio10TargetGenerator.cxx | 2 +- Source/cmVisualStudio10TargetGenerator.h | 2 +- Source/cmXCodeObject.h | 12 +- Source/cmcmd.cxx | 2 +- 74 files changed, 539 insertions(+), 485 deletions(-) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index bed3891..4c52c96 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -623,7 +623,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( componentsVector.push_back(installComponent); } - const char* buildConfig = this->GetOption("CPACK_BUILD_CONFIG"); + const char* buildConfigCstr = this->GetOption("CPACK_BUILD_CONFIG"); + std::string buildConfig = buildConfigCstr ? buildConfigCstr : ""; cmGlobalGenerator* globalGenerator = this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator( cmakeGenerator); @@ -822,9 +823,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( << "'" << std::endl); } - if ( buildConfig && *buildConfig ) + if (!buildConfig.empty()) { - mf->AddDefinition("BUILD_TYPE", buildConfig); + mf->AddDefinition("BUILD_TYPE", buildConfig.c_str()); } std::string installComponentLowerCase = cmSystemTools::LowerCase(installComponent); diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 6c1c1de..2d1da55 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -172,7 +172,7 @@ satisfy dependencies. //---------------------------------------------------------------------------- cmComputeLinkDepends -::cmComputeLinkDepends(cmTarget const* target, const char* config, +::cmComputeLinkDepends(cmTarget const* target, const std::string& config, cmTarget const* head) { // Store context information. @@ -184,7 +184,8 @@ cmComputeLinkDepends this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // The configuration being linked. - this->Config = (config && *config)? config : 0; + this->HasConfig = !config.empty(); + this->Config = (this->HasConfig)? config : std::string(); this->LinkType = this->Target->ComputeLinkType(this->Config); // Enable debug mode if requested. @@ -255,7 +256,7 @@ cmComputeLinkDepends::Compute() "---------------------------------------\n"); fprintf(stderr, "Link dependency analysis for target %s, config %s\n", this->Target->GetName().c_str(), - this->Config?this->Config:"noconfig"); + this->HasConfig?this->Config.c_str():"noconfig"); this->DisplayConstraintGraph(); } diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index ac5e368..13fc993 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -32,7 +32,7 @@ class cmake; class cmComputeLinkDepends { public: - cmComputeLinkDepends(cmTarget const* target, const char* config, + cmComputeLinkDepends(cmTarget const* target, const std::string& config, cmTarget const* head); ~cmComputeLinkDepends(); @@ -68,7 +68,8 @@ private: bool DebugMode; // Configuration information. - const char* Config; + bool HasConfig; + std::string Config; cmTarget::LinkLibraryType LinkType; // Output information. diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 32b23b8..e4e2047 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -239,7 +239,7 @@ because this need be done only for shared libraries without soname-s. //---------------------------------------------------------------------------- cmComputeLinkInformation -::cmComputeLinkInformation(cmTarget const* target, const char* config, +::cmComputeLinkInformation(cmTarget const* target, const std::string& config, cmTarget const* headTarget) { // Store context information. @@ -505,7 +505,8 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target, this->Config, this->HeadTarget); + cmComputeLinkDepends cld(this->Target, this->Config.c_str(), + this->HeadTarget); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); @@ -624,7 +625,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget const* tgt) { // Compute the proper name to use to link this library. - const char* config = this->Config; + const std::string& config = this->Config; bool impexe = (tgt && tgt->IsExecutableWithExports()); if(impexe && !this->UseImportLibrary && !this->LoaderFlag) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index b5a8bec..e345fe2 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -29,7 +29,7 @@ class cmOrderDirectories; class cmComputeLinkInformation { public: - cmComputeLinkInformation(cmTarget const* target, const char* config, + cmComputeLinkInformation(cmTarget const* target, const std::string& config, cmTarget const* headTarget); ~cmComputeLinkInformation(); bool Compute(); @@ -82,7 +82,7 @@ private: cmake* CMakeInstance; // Configuration information. - const char* Config; + std::string Config; std::string LinkLanguage; bool LinkDependsNoShared; diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 405643e..10041db 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -214,7 +214,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) std::set emitted; { std::vector tlibs; - depender->GetDirectLinkLibraries(0, tlibs, depender); + depender->GetDirectLinkLibraries("", tlibs, depender); // A target should not depend on itself. emitted.insert(depender->GetName()); for(std::vector::const_iterator lib = tlibs.begin(); @@ -274,7 +274,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) //---------------------------------------------------------------------------- void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, cmTarget const* dependee, - const char *config, + const std::string& config, std::set &emitted) { cmTarget const* depender = this->Targets[depender_index]; @@ -317,7 +317,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, if(dependee) { - this->AddInterfaceDepends(depender_index, dependee, 0, emitted); + this->AddInterfaceDepends(depender_index, dependee, "", emitted); std::vector configs; depender->GetMakefile()->GetConfigurations(configs); for (std::vector::const_iterator it = configs.begin(); diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index db76a18..7553816 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -55,7 +55,7 @@ private: const std::string& dependee_name, bool linking, std::set &emitted); void AddInterfaceDepends(int depender_index, cmTarget const* dependee, - const char *config, + const std::string& config, std::set &emitted); cmGlobalGenerator* GlobalGenerator; bool DebugMode; diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index ea3e814..ab7b024 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -357,7 +357,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) cmExportTryCompileFileGenerator tcfg; tcfg.SetExportFile((this->BinaryDirectory + fname).c_str()); tcfg.SetExports(targets); - tcfg.SetConfig(this->Makefile->GetDefinition( + tcfg.SetConfig(this->Makefile->GetSafeDefinition( "CMAKE_TRY_COMPILE_CONFIGURATION")); if(!tcfg.GenerateImportFile()) diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index f24dfa2..d8a756d 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -18,7 +18,7 @@ //---------------------------------------------------------------------------- cmCustomCommandGenerator::cmCustomCommandGenerator( - cmCustomCommand const& cc, const char* config, cmMakefile* mf): + cmCustomCommand const& cc, const std::string& config, cmMakefile* mf): CC(cc), Config(config), Makefile(mf), LG(mf->GetLocalGenerator()), OldStyle(cc.GetEscapeOldStyle()), MakeVars(cc.GetEscapeAllowMakeVars()), GE(new cmGeneratorExpression(cc.GetBacktrace())) diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h index 4e89f27..17d644a 100644 --- a/Source/cmCustomCommandGenerator.h +++ b/Source/cmCustomCommandGenerator.h @@ -22,14 +22,15 @@ class cmGeneratorExpression; class cmCustomCommandGenerator { cmCustomCommand const& CC; - const char* Config; + std::string Config; cmMakefile* Makefile; cmLocalGenerator* LG; bool OldStyle; bool MakeVars; cmGeneratorExpression* GE; public: - cmCustomCommandGenerator(cmCustomCommand const& cc, const char* config, + cmCustomCommandGenerator(cmCustomCommand const& cc, + const std::string& config, cmMakefile* mf); ~cmCustomCommandGenerator(); unsigned int GetNumberOfCommands() const; diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 308956a..f991f45 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -118,8 +118,9 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) void cmExportBuildFileGenerator ::GenerateImportTargetsConfig(std::ostream& os, - const char* config, std::string const& suffix, - std::vector &missingTargets) + const std::string& config, + std::string const& suffix, + std::vector &missingTargets) { for(std::vector::const_iterator tei = this->Exports.begin(); @@ -166,7 +167,8 @@ void cmExportBuildFileGenerator::SetExportSet(cmExportSet *exportSet) //---------------------------------------------------------------------------- void cmExportBuildFileGenerator -::SetImportLocationProperty(const char* config, std::string const& suffix, +::SetImportLocationProperty(const std::string& config, + std::string const& suffix, cmTarget* target, ImportPropertyMap& properties) { // Get the makefile in which to lookup target information. diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index cea2099..c1bdb5b 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -52,7 +52,7 @@ protected: // Implement virtual methods from the superclass. virtual bool GenerateMainFile(std::ostream& os); virtual void GenerateImportTargetsConfig(std::ostream& os, - const char* config, + const std::string& config, std::string const& suffix, std::vector &missingTargets); virtual void HandleMissingTarget(std::string& link_libs, @@ -66,7 +66,7 @@ protected: int occurrences); /** Fill in properties indicating built file locations. */ - void SetImportLocationProperty(const char* config, + void SetImportLocationProperty(const std::string& config, std::string const& suffix, cmTarget* target, ImportPropertyMap& properties); diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index c06f889..3c3c6df 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -35,7 +35,7 @@ cmExportFileGenerator::cmExportFileGenerator() } //---------------------------------------------------------------------------- -void cmExportFileGenerator::AddConfiguration(const char* config) +void cmExportFileGenerator::AddConfiguration(const std::string& config) { this->Configurations.push_back(config); } @@ -117,12 +117,12 @@ bool cmExportFileGenerator::GenerateImportFile() //---------------------------------------------------------------------------- void cmExportFileGenerator::GenerateImportConfig(std::ostream& os, - const char* config, + const std::string& config, std::vector &missingTargets) { // Construct the property configuration suffix. std::string suffix = "_"; - if(config && *config) + if(!config.empty()) { suffix += cmSystemTools::UpperCase(config); } @@ -345,7 +345,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( true); this->ReplaceInstallPrefix(dirs); cmsys::auto_ptr cge = ge.Parse(dirs); - std::string exportDirs = cge->Evaluate(target->GetMakefile(), 0, + std::string exportDirs = cge->Evaluate(target->GetMakefile(), "", false, target); if (cge->GetHadContextSensitiveCondition()) @@ -426,7 +426,7 @@ void getPropertyContents(cmTarget const* tgt, const std::string& prop, //---------------------------------------------------------------------------- void getCompatibleInterfaceProperties(cmTarget *target, std::set &ifaceProperties, - const char *config) + const std::string& config) { cmComputeLinkInformation *info = target->GetLinkInformation(config); @@ -490,7 +490,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( if (target->GetType() != cmTarget::INTERFACE_LIBRARY) { - getCompatibleInterfaceProperties(target, ifaceProperties, 0); + getCompatibleInterfaceProperties(target, ifaceProperties, ""); std::vector configNames; target->GetMakefile()->GetConfigurations(configNames); @@ -687,7 +687,7 @@ cmExportFileGenerator::ReplaceInstallPrefix(std::string &) //---------------------------------------------------------------------------- void cmExportFileGenerator -::SetImportLinkInterface(const char* config, std::string const& suffix, +::SetImportLinkInterface(const std::string& config, std::string const& suffix, cmGeneratorExpression::PreprocessContext preprocessRule, cmTarget* target, ImportPropertyMap& properties, std::vector& missingTargets) @@ -762,7 +762,8 @@ cmExportFileGenerator //---------------------------------------------------------------------------- void cmExportFileGenerator -::SetImportDetailProperties(const char* config, std::string const& suffix, +::SetImportDetailProperties(const std::string& config, + std::string const& suffix, cmTarget* target, ImportPropertyMap& properties, std::vector& missingTargets ) @@ -864,11 +865,11 @@ cmExportFileGenerator //---------------------------------------------------------------------------- void cmExportFileGenerator::GenerateImportHeaderCode(std::ostream& os, - const char* config) + const std::string& config) { os << "#----------------------------------------------------------------\n" << "# Generated CMake target import file"; - if(config) + if(!config.empty()) { os << " for configuration \"" << config << "\".\n"; } @@ -999,7 +1000,7 @@ cmExportFileGenerator //---------------------------------------------------------------------------- void cmExportFileGenerator -::GenerateImportPropertyCode(std::ostream& os, const char* config, +::GenerateImportPropertyCode(std::ostream& os, const std::string& config, cmTarget const* target, ImportPropertyMap const& properties) { @@ -1013,7 +1014,7 @@ cmExportFileGenerator << config << "\"\n"; os << "set_property(TARGET " << targetName << " APPEND PROPERTY IMPORTED_CONFIGURATIONS "; - if(config && *config) + if(!config.empty()) { os << cmSystemTools::UpperCase(config); } diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 9e3ce0b..cf91c69 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -56,7 +56,7 @@ public: void SetExportOld(bool exportOld) { this->ExportOld = exportOld; } /** Add a configuration to be exported. */ - void AddConfiguration(const char* config); + void AddConfiguration(const std::string& config); /** Actually generate the export file. Returns whether there was an error. */ @@ -67,15 +67,16 @@ protected: // Generate per-configuration target information to the given output // stream. - void GenerateImportConfig(std::ostream& os, const char* config, + void GenerateImportConfig(std::ostream& os, const std::string& config, std::vector &missingTargets); // Methods to implement export file code generation. - void GenerateImportHeaderCode(std::ostream& os, const char* config = 0); + void GenerateImportHeaderCode(std::ostream& os, + const std::string& config = ""); void GenerateImportFooterCode(std::ostream& os); void GenerateImportVersionCode(std::ostream& os); void GenerateImportTargetCode(std::ostream& os, cmTarget const* target); - void GenerateImportPropertyCode(std::ostream& os, const char* config, + void GenerateImportPropertyCode(std::ostream& os, const std::string& config, cmTarget const* target, ImportPropertyMap const& properties); void GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target, @@ -90,7 +91,7 @@ protected: // Collect properties with detailed information about targets beyond // their location on disk. - void SetImportDetailProperties(const char* config, + void SetImportDetailProperties(const std::string& config, std::string const& suffix, cmTarget* target, ImportPropertyMap& properties, std::vector& missingTargets); @@ -105,7 +106,7 @@ protected: /** Each subclass knows where the target files are located. */ virtual void GenerateImportTargetsConfig(std::ostream& os, - const char* config, + const std::string& config, std::string const& suffix, std::vector &missingTargets) = 0; @@ -137,7 +138,8 @@ protected: ImportPropertyMap &properties, std::vector &missingTargets); - void SetImportLinkInterface(const char* config, std::string const& suffix, + void SetImportLinkInterface(const std::string& config, + std::string const& suffix, cmGeneratorExpression::PreprocessContext preprocessRule, cmTarget* target, ImportPropertyMap& properties, std::vector& missingTargets); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index b579963..5e7d5e4 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -240,7 +240,8 @@ cmExportInstallFileGenerator::ReplaceInstallPrefix(std::string &input) //---------------------------------------------------------------------------- bool -cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config, +cmExportInstallFileGenerator::GenerateImportFileConfig( + const std::string& config, std::vector &missingTargets) { // Skip configurations not enabled for this export. @@ -254,7 +255,7 @@ cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config, fileName += "/"; fileName += this->FileBase; fileName += "-"; - if(config && *config) + if(!config.empty()) { fileName += cmSystemTools::LowerCase(config); } @@ -296,7 +297,8 @@ cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config, void cmExportInstallFileGenerator ::GenerateImportTargetsConfig(std::ostream& os, - const char* config, std::string const& suffix, + const std::string& config, + std::string const& suffix, std::vector &missingTargets) { // Add each target in the set to the export. @@ -355,7 +357,8 @@ cmExportInstallFileGenerator //---------------------------------------------------------------------------- void cmExportInstallFileGenerator -::SetImportLocationProperty(const char* config, std::string const& suffix, +::SetImportLocationProperty(const std::string& config, + std::string const& suffix, cmInstallTargetGenerator* itgen, ImportPropertyMap& properties, std::set& importedLocations diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index 5ee2a78..b851ad5 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -52,7 +52,7 @@ protected: // Implement virtual methods from the superclass. virtual bool GenerateMainFile(std::ostream& os); virtual void GenerateImportTargetsConfig(std::ostream& os, - const char* config, + const std::string& config, std::string const& suffix, std::vector &missingTargets); virtual void HandleMissingTarget(std::string& link_libs, @@ -72,11 +72,11 @@ protected: /** Generate a per-configuration file for the targets. */ - bool GenerateImportFileConfig(const char* config, + bool GenerateImportFileConfig(const std::string& config, std::vector &missingTargets); /** Fill in properties indicating installed file locations. */ - void SetImportLocationProperty(const char* config, + void SetImportLocationProperty(const std::string& config, std::string const& suffix, cmInstallTargetGenerator* itgen, ImportPropertyMap& properties, diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index a16fe6b..ec70d81 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -23,14 +23,14 @@ public: /** Set the list of targets to export. */ void SetExports(const std::vector &exports) { this->Exports = exports; } - void SetConfig(const char *config) { this->Config = config; } + void SetConfig(const std::string& config) { this->Config = config; } protected: // Implement virtual methods from the superclass. virtual bool GenerateMainFile(std::ostream& os); virtual void GenerateImportTargetsConfig(std::ostream&, - const char*, + const std::string&, std::string const&, std::vector&) {} virtual void HandleMissingTarget(std::string&, @@ -51,7 +51,7 @@ private: std::vector Exports; - const char *Config; + std::string Config; }; #endif diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 9c2849c..03c7c92 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -375,7 +375,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source, { language = "C"; } - const char* config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); + const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); // Add language-specific flags. lg->AddLanguageFlags(flags, language, config); @@ -425,7 +425,7 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target, std::set defines; cmMakefile *makefile = lg->GetMakefile(); const std::string& language = source->GetLanguage(); - const char* config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); + const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); // Add the export symbol definition for shared library objects. if(const char* exportMacro = target->GetExportMacro()) diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 433adcf..e4187d2 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -52,7 +52,7 @@ cmGeneratorExpression::~cmGeneratorExpression() //---------------------------------------------------------------------------- const char *cmCompiledGeneratorExpression::Evaluate( - cmMakefile* mf, const char* config, bool quiet, + cmMakefile* mf, const std::string& config, bool quiet, cmTarget const* headTarget, cmGeneratorExpressionDAGChecker *dagChecker) const { @@ -66,7 +66,7 @@ const char *cmCompiledGeneratorExpression::Evaluate( //---------------------------------------------------------------------------- const char *cmCompiledGeneratorExpression::Evaluate( - cmMakefile* mf, const char* config, bool quiet, + cmMakefile* mf, const std::string& config, bool quiet, cmTarget const* headTarget, cmTarget const* currentTarget, cmGeneratorExpressionDAGChecker *dagChecker) const diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 9aa590d..5b97e8b 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -78,12 +78,12 @@ private: class cmCompiledGeneratorExpression { public: - const char* Evaluate(cmMakefile* mf, const char* config, + const char* Evaluate(cmMakefile* mf, const std::string& config, bool quiet = false, cmTarget const* headTarget = 0, cmTarget const* currentTarget = 0, cmGeneratorExpressionDAGChecker *dagChecker = 0) const; - const char* Evaluate(cmMakefile* mf, const char* config, + const char* Evaluate(cmMakefile* mf, const std::string& config, bool quiet, cmTarget const* headTarget, cmGeneratorExpressionDAGChecker *dagChecker) const; diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index bf85870..90ce27c 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -33,7 +33,7 @@ cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile( } //---------------------------------------------------------------------------- -void cmGeneratorExpressionEvaluationFile::Generate(const char *config, +void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, cmCompiledGeneratorExpression* inputExpression, std::map &outputFiles) { @@ -135,7 +135,7 @@ void cmGeneratorExpressionEvaluationFile::Generate() if (allConfigs.empty()) { - this->Generate(0, inputExpression.get(), outputFiles); + this->Generate("", inputExpression.get(), outputFiles); } else { diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h index 20ee5cb..f939916 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.h +++ b/Source/cmGeneratorExpressionEvaluationFile.h @@ -32,7 +32,7 @@ public: std::vector GetFiles() const { return this->Files; } private: - void Generate(const char *config, + void Generate(const std::string& config, cmCompiledGeneratorExpression* inputExpression, std::map &outputFiles); diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index d12a66d..43c1794 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -689,7 +689,7 @@ static const struct ConfigurationNode : public cmGeneratorExpressionNode cmGeneratorExpressionDAGChecker *) const { context->HadContextSensitiveCondition = true; - return context->Config ? context->Config : ""; + return context->Config; } } configurationNode; @@ -718,13 +718,13 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode return std::string(); } context->HadContextSensitiveCondition = true; - if (!context->Config) + if (context->Config.empty()) { return parameters.front().empty() ? "1" : "0"; } if (cmsysString_strcasecmp(parameters.begin()->c_str(), - context->Config) == 0) + context->Config.c_str()) == 0) { return "1"; } diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h index 0c8a9cf..a7099cb 100644 --- a/Source/cmGeneratorExpressionEvaluator.h +++ b/Source/cmGeneratorExpressionEvaluator.h @@ -27,7 +27,7 @@ struct cmGeneratorExpressionContext std::set AllTargets; std::set SeenTargetProperties; cmMakefile *Makefile; - const char *Config; + std::string Config; cmTarget const* HeadTarget; // The target whose property is being evaluated. cmTarget const* CurrentTarget; // The dependent of HeadTarget which appears // directly or indirectly in the property. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index f7f6feb..eb67f91 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -252,7 +252,8 @@ cmGeneratorTarget::GetSourceDepends(cmSourceFile* sf) const } static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt, - const char *config, cmTarget *headTarget, + const std::string& config, + cmTarget *headTarget, cmGeneratorExpressionDAGChecker *dagChecker, std::vector& result, bool excludeImported) @@ -390,12 +391,12 @@ void cmGeneratorTarget::GetResxSources(std::vector& srcs) const } //---------------------------------------------------------------------------- -bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, - const char *config) const +bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, + const std::string& config) const { assert(this->GetType() != cmTarget::INTERFACE_LIBRARY); std::string config_upper; - if(config && *config) + if(!config.empty()) { config_upper = cmSystemTools::UpperCase(config); } @@ -802,7 +803,7 @@ cmTargetTraceDependencies { const cmsys::auto_ptr cge = ge.Parse(*cli); - cge->Evaluate(this->Makefile, 0, true); + cge->Evaluate(this->Makefile, "", true); std::set geTargets = cge->GetTargets(); for(std::set::const_iterator it = geTargets.begin(); it != geTargets.end(); ++it) @@ -863,11 +864,11 @@ void cmGeneratorTarget::TraceDependencies() } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetAppleArchs(const char* config, +void cmGeneratorTarget::GetAppleArchs(const std::string& config, std::vector& archVec) const { const char* archs = 0; - if(config && *config) + if(!config.empty()) { std::string defVarName = "OSX_ARCHITECTURES_"; defVarName += cmSystemTools::UpperCase(config); @@ -904,13 +905,14 @@ const char* cmGeneratorTarget::GetCreateRuleVariable() const //---------------------------------------------------------------------------- std::vector -cmGeneratorTarget::GetIncludeDirectories(const char *config) const +cmGeneratorTarget::GetIncludeDirectories(const std::string& config) const { return this->Target->GetIncludeDirectories(config); } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GenerateTargetManifest(const char* config) const +void cmGeneratorTarget::GenerateTargetManifest( + const std::string& config) const { if (this->Target->IsImported()) { @@ -953,35 +955,35 @@ void cmGeneratorTarget::GenerateTargetManifest(const char* config) const f = dir; f += "/"; f += name; - gg->AddToManifest(config? config:"", f); + gg->AddToManifest(config, f); } if(!soName.empty()) { f = dir; f += "/"; f += soName; - gg->AddToManifest(config? config:"", f); + gg->AddToManifest(config, f); } if(!realName.empty()) { f = dir; f += "/"; f += realName; - gg->AddToManifest(config? config:"", f); + gg->AddToManifest(config, f); } if(!pdbName.empty()) { f = dir; f += "/"; f += pdbName; - gg->AddToManifest(config? config:"", f); + gg->AddToManifest(config, f); } if(!impName.empty()) { f = this->Target->GetDirectory(config, true); f += "/"; f += impName; - gg->AddToManifest(config? config:"", f); + gg->AddToManifest(config, f); } } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index b15bade..81a447f 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -61,7 +61,7 @@ public: void UseObjectLibraries(std::vector& objs) const; - void GetAppleArchs(const char* config, + void GetAppleArchs(const std::string& config, std::vector& archVec) const; ///! Return the rule variable used to create this type of target, @@ -69,12 +69,14 @@ public: const char* GetCreateRuleVariable() const; /** Get the include directories for this target. */ - std::vector GetIncludeDirectories(const char *config) const; + std::vector GetIncludeDirectories( + const std::string& config) const; - bool IsSystemIncludeDirectory(const char *dir, const char *config) const; + bool IsSystemIncludeDirectory(const std::string& dir, + const std::string& config) const; /** Add the target output files to the global generator manifest. */ - void GenerateTargetManifest(const char* config) const; + void GenerateTargetManifest(const std::string& config) const; /** * Trace through the source files in this target and add al source files diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 9748c61..70cc16f 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1655,7 +1655,8 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, #endif // WIN32 #endif } - const char* config = mf->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION"); + std::string config = + mf->GetSafeDefinition("CMAKE_TRY_COMPILE_CONFIGURATION"); return this->Build(srcdir,bindir,projectName, newTarget.c_str(), output,0,config,false,fast, @@ -1664,7 +1665,7 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, void cmGlobalGenerator::GenerateBuildCommand( std::vector& makeCommand, const char*, const std::string&, - const char*, const std::string&, const char*, bool, + const char*, const std::string&, const std::string&, bool, std::vector const&) { makeCommand.push_back( @@ -1676,7 +1677,7 @@ int cmGlobalGenerator::Build( const std::string& projectName, const std::string& target, std::string *output, const char *makeCommandCSTR, - const char *config, + const std::string& config, bool clean, bool fast, double timeout, cmSystemTools::OutputOption outputflag, @@ -1788,13 +1789,14 @@ int cmGlobalGenerator::Build( //---------------------------------------------------------------------------- std::string cmGlobalGenerator::GenerateCMakeBuildCommand( - const std::string& target, const char* config, const char* native, + const std::string& target, const std::string& config, + const char* native, bool ignoreErrors) { std::string makeCommand = cmSystemTools::GetCMakeCommand(); makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str()); makeCommand += " --build ."; - if(config && *config) + if(!config.empty()) { makeCommand += " --config \""; makeCommand += config; @@ -2526,7 +2528,8 @@ std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage( } //---------------------------------------------------------------------------- -void cmGlobalGenerator::AppendDirectoryForConfig(const char*, const char*, +void cmGlobalGenerator::AppendDirectoryForConfig(const char*, + const std::string&, const char*, std::string&) { // Subclasses that support multiple configurations should implement @@ -2677,7 +2680,7 @@ void cmGlobalGenerator::AddTargetDepends(cmTarget const* target, //---------------------------------------------------------------------------- -void cmGlobalGenerator::AddToManifest(const char* config, +void cmGlobalGenerator::AddToManifest(const std::string& config, std::string const& f) { // Add to the main manifest for this configuration. diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index f06162c..e9a1b47 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -120,7 +120,7 @@ public: int Build(const char *srcdir, const char *bindir, const std::string& projectName, const std::string& targetName, std::string *output, - const char *makeProgram, const char *config, + const char *makeProgram, const std::string& config, bool clean, bool fast, double timeout, cmSystemTools::OutputOption outputflag=cmSystemTools::OUTPUT_NONE, @@ -131,13 +131,13 @@ public: std::vector& makeCommand, const char* makeProgram, const std::string& projectName, const char *projectDir, - const std::string& targetName, const char* config, bool fast, + const std::string& targetName, const std::string& config, bool fast, std::vector const& makeOptions = std::vector() ); /** Generate a "cmake --build" call for a given target and config. */ std::string GenerateCMakeBuildCommand(const std::string& target, - const char* config, + const std::string& config, const char* native, bool ignoreErrors); @@ -173,7 +173,7 @@ public: cmExportSetMap& GetExportSets() {return this->ExportSets;} /** Add a file to the manifest of generated targets for a configuration. */ - void AddToManifest(const char* config, std::string const& f); + void AddToManifest(const std::string& config, std::string const& f); void EnableInstallTarget(); @@ -231,7 +231,7 @@ public: appended the given prefix and suffix will be appended around it, which is useful for leading or trailing slashes. */ virtual void AppendDirectoryForConfig(const char* prefix, - const char* config, + const std::string& config, const char* suffix, std::string& dir); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 977b3a1..16e9788 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -555,7 +555,7 @@ void cmGlobalNinjaGenerator const std::string& /*projectName*/, const char* /*projectDir*/, const std::string& targetName, - const char* /*config*/, + const std::string& /*config*/, bool /*fast*/, std::vector const& makeOptions) { @@ -834,8 +834,8 @@ void cmGlobalNinjaGenerator ::AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs) { - const char* configName = - target->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE"); + std::string configName = + target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); cmLocalNinjaGenerator *ng = static_cast(this->LocalGenerators[0]); diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index e422e36..86c2912 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -197,7 +197,7 @@ public: const std::string& projectName, const char* projectDir, const std::string& targetName, - const char* config, + const std::string& config, bool fast, std::vector const& makeOptions = std::vector() ); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index a392aa6..d947150 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -569,7 +569,7 @@ void cmGlobalUnixMakefileGenerator3 const std::string& /*projectName*/, const char* /*projectDir*/, const std::string& targetName, - const char* /*config*/, + const std::string& /*config*/, bool fast, std::vector const& makeOptions) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index b61619d..8924fa8 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -113,7 +113,7 @@ public: const std::string& projectName, const char* projectDir, const std::string& targetName, - const char* config, + const std::string& config, bool fast, std::vector const& makeOptions = std::vector() ); diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index a2991e1..0bc572b 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -314,7 +314,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( const std::string& projectName, const char* projectDir, const std::string& targetName, - const char* config, + const std::string& config, bool fast, std::vector const& makeOptions) { @@ -397,7 +397,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( makeCommand.push_back(targetProject); } std::string configArg = "/p:Configuration="; - if(config && strlen(config)) + if(!config.empty()) { configArg += config; } diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 97ac9bc..085f2d2 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -38,7 +38,7 @@ public: const std::string& projectName, const char* projectDir, const std::string& targetName, - const char* config, + const std::string& config, bool fast, std::vector const& makeOptions = std::vector() ); diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index a7f6587..f69bcfd 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -120,7 +120,7 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand( const std::string& projectName, const char* /*projectDir*/, const std::string& targetName, - const char* config, + const std::string& config, bool /*fast*/, std::vector const& makeOptions ) @@ -149,7 +149,7 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand( targetArg += "ALL_BUILD"; } targetArg += " - "; - if(config && strlen(config)) + if(!config.empty()) { targetArg += config; } @@ -419,11 +419,11 @@ void cmGlobalVisualStudio6Generator void cmGlobalVisualStudio6Generator ::AppendDirectoryForConfig(const char* prefix, - const char* config, + const std::string& config, const char* suffix, std::string& dir) { - if(config) + if(!config.empty()) { dir += prefix; dir += config; diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 3665f7b..22ec926 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -58,7 +58,7 @@ public: const std::string& projectName, const char* projectDir, const std::string& targetName, - const char* config, + const std::string& config, bool fast, std::vector const& makeOptions = std::vector() ); @@ -82,7 +82,7 @@ public: /** Append the subdirectory for the given configuration. */ virtual void AppendDirectoryForConfig(const char* prefix, - const char* config, + const std::string& config, const char* suffix, std::string& dir); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 2a97edc..18f7f19 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -187,7 +187,7 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand( const std::string& projectName, const char* /*projectDir*/, const std::string& targetName, - const char* config, + const std::string& config, bool /*fast*/, std::vector const& makeOptions) { @@ -224,7 +224,7 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand( makeCommand.push_back("/build"); } - if(config && strlen(config)) + if(!config.empty()) { makeCommand.push_back(config); } @@ -962,11 +962,11 @@ void cmGlobalVisualStudio7Generator void cmGlobalVisualStudio7Generator ::AppendDirectoryForConfig(const char* prefix, - const char* config, + const std::string& config, const char* suffix, std::string& dir) { - if(config) + if(!config.empty()) { dir += prefix; dir += config; diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 2e58f6c..009f002 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -66,7 +66,7 @@ public: const std::string& projectName, const char* projectDir, const std::string& targetName, - const char* config, + const std::string& config, bool fast, std::vector const& makeOptions = std::vector() ); @@ -94,7 +94,7 @@ public: /** Append the subdirectory for the given configuration. */ virtual void AppendDirectoryForConfig(const char* prefix, - const char* config, + const std::string& config, const char* suffix, std::string& dir); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 08e9adf..c0077b9 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -264,7 +264,7 @@ cmGlobalXCodeGenerator::GenerateBuildCommand( const std::string& projectName, const char* /*projectDir*/, const std::string& targetName, - const char* config, + const std::string& config, bool /*fast*/, std::vector const& makeOptions) { @@ -298,11 +298,6 @@ cmGlobalXCodeGenerator::GenerateBuildCommand( makeCommand.push_back("build"); } makeCommand.push_back("-target"); - // if it is a null string for config don't use it - if(config && *config == 0) - { - config = 0; - } if (!realTarget.empty()) { makeCommand.push_back(realTarget); @@ -319,7 +314,7 @@ cmGlobalXCodeGenerator::GenerateBuildCommand( else { makeCommand.push_back("-configuration"); - makeCommand.push_back(config?config:"Debug"); + makeCommand.push_back(!config.empty()?config:"Debug"); } makeCommand.insert(makeCommand.end(), makeOptions.begin(), makeOptions.end()); @@ -1547,7 +1542,7 @@ void cmGlobalXCodeGenerator cmTarget& target, std::vector const & commands, - const char* configName, + const std::string& configName, const std::map& multipleOutputPairs ) @@ -1690,8 +1685,8 @@ void cmGlobalXCodeGenerator //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, - cmXCodeObject* buildSettings, - const char* configName) + cmXCodeObject* buildSettings, + const std::string& configName) { if(target.GetType() == cmTarget::INTERFACE_LIBRARY) { @@ -1804,7 +1799,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CurrentLocalGenerator-> AppendFlags(extraLinkOptions, targetLinkFlags); } - if(configName && *configName) + if(!configName.empty()) { std::string linkFlagsVar = "LINK_FLAGS_"; linkFlagsVar += cmSystemTools::UpperCase(configName); @@ -2738,7 +2733,7 @@ void cmGlobalXCodeGenerator ::AppendBuildSettingAttribute(cmXCodeObject* target, const char* attribute, const char* value, - const char* configName) + const std::string& configName) { if(this->XcodeVersion < 21) { @@ -2761,9 +2756,9 @@ void cmGlobalXCodeGenerator for(std::vector::iterator i = list.begin(); i != list.end(); ++i) { - if(configName) + if(!configName.empty()) { - if(strcmp((*i)->GetObject("name")->GetString(), configName) == 0) + if((*i)->GetObject("name")->GetString() == configName) { cmXCodeObject* settings = (*i)->GetObject("buildSettings"); this->AppendOrAddBuildSetting(settings, attribute, value); @@ -3777,13 +3772,13 @@ std::string cmGlobalXCodeGenerator::XCodeEscapePath(const char* p) void cmGlobalXCodeGenerator ::AppendDirectoryForConfig(const char* prefix, - const char* config, + const std::string& config, const char* suffix, std::string& dir) { if(this->XcodeVersion > 20) { - if(config) + if(!config.empty()) { dir += prefix; dir += config; diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index d2dd491..03e75c4 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -59,7 +59,7 @@ public: const std::string& projectName, const char* projectDir, const std::string& targetName, - const char* config, + const std::string& config, bool fast, std::vector const& makeOptions = std::vector() ); @@ -73,7 +73,7 @@ public: /** Append the subdirectory for the given configuration. */ virtual void AppendDirectoryForConfig(const char* prefix, - const char* config, + const std::string& config, const char* suffix, std::string& dir); @@ -123,7 +123,7 @@ private: void CreateCustomRulesMakefile(const char* makefileBasename, cmTarget& target, std::vector const & commands, - const char* configName, + const std::string& configName, const std::map& multipleOutputPairs ); @@ -147,12 +147,13 @@ private: void AppendOrAddBuildSetting(cmXCodeObject* settings, const char* attr, const char* value); void AppendBuildSettingAttribute(cmXCodeObject* target, const char* attr, - const char* value, const char* configName); + const char* value, + const std::string& configName); cmXCodeObject* CreateUtilityTarget(cmTarget& target); void AddDependAndLinkInformation(cmXCodeObject* target); void CreateBuildSettings(cmTarget& target, cmXCodeObject* buildSettings, - const char* buildType); + const std::string& buildType); std::string ExtractFlag(const char* flag, std::string& flags); // delete all objects in the this->XCodeObjects vector. void ClearXCodeObjects(); diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 045cff6..d2737a1 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -142,7 +142,7 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os) this->EFGen->SetExportOld(this->ExportOld); if(this->ConfigurationTypes->empty()) { - if(this->ConfigurationName && *this->ConfigurationName) + if(!this->ConfigurationName.empty()) { this->EFGen->AddConfiguration(this->ConfigurationName); } diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index ec15044..6594218 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -80,8 +80,8 @@ void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os, //---------------------------------------------------------------------------- void cmInstallFilesGenerator::GenerateScriptForConfig(std::ostream& os, - const char* config, - Indent const& indent) + const std::string& config, + Indent const& indent) { std::vector files; cmListFileBacktrace lfbt; diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h index 9dea296..23bf935 100644 --- a/Source/cmInstallFilesGenerator.h +++ b/Source/cmInstallFilesGenerator.h @@ -35,7 +35,7 @@ public: protected: virtual void GenerateScriptActions(std::ostream& os, Indent const& indent); virtual void GenerateScriptForConfig(std::ostream& os, - const char* config, + const std::string& config, Indent const& indent); void AddFilesInstallRule(std::ostream& os, Indent const& indent, std::vector const& files); diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index d105a0c..0fad9d6 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -163,7 +163,7 @@ void cmInstallGenerator::GenerateScript(std::ostream& os) } //---------------------------------------------------------------------------- -bool cmInstallGenerator::InstallsForConfig(const char* config) +bool cmInstallGenerator::InstallsForConfig(const std::string& config) { return this->GeneratesForConfig(config); } diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index c89ab8a..c72e9e9 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -48,7 +48,7 @@ public: std::string GetInstallDestination() const; /** Test if this generator installs something for a given configuration. */ - bool InstallsForConfig(const char*); + bool InstallsForConfig(const std::string& config); protected: virtual void GenerateScript(std::ostream& os); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 5df6e4b..ec2b518 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -59,8 +59,8 @@ void cmInstallTargetGenerator::GenerateScript(std::ostream& os) //---------------------------------------------------------------------------- void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, - const char* config, - Indent const& indent) + const std::string& config, + Indent const& indent) { // Compute the build tree directory from which to copy the target. std::string fromDirConfig; @@ -319,7 +319,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, //---------------------------------------------------------------------------- std::string -cmInstallTargetGenerator::GetInstallFilename(const char* config) const +cmInstallTargetGenerator::GetInstallFilename(const std::string& config) const { NameType nameType = this->ImportLibrary? NameImplib : NameNormal; return @@ -330,7 +330,7 @@ cmInstallTargetGenerator::GetInstallFilename(const char* config) const //---------------------------------------------------------------------------- std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, - const char* config, + const std::string& config, NameType nameType) { std::string fname; @@ -405,7 +405,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, //---------------------------------------------------------------------------- void cmInstallTargetGenerator -::AddTweak(std::ostream& os, Indent const& indent, const char* config, +::AddTweak(std::ostream& os, Indent const& indent, const std::string& config, std::string const& file, TweakMethod tweak) { cmOStringStream tw; @@ -423,7 +423,7 @@ cmInstallTargetGenerator //---------------------------------------------------------------------------- void cmInstallTargetGenerator -::AddTweak(std::ostream& os, Indent const& indent, const char* config, +::AddTweak(std::ostream& os, Indent const& indent, const std::string& config, std::vector const& files, TweakMethod tweak) { if(files.size() == 1) @@ -470,7 +470,7 @@ std::string cmInstallTargetGenerator::GetDestDirPath(std::string const& file) //---------------------------------------------------------------------------- void cmInstallTargetGenerator::PreReplacementTweaks(std::ostream& os, Indent const& indent, - const char* config, + const std::string& config, std::string const& file) { this->AddRPathCheckRule(os, indent, config, file); @@ -478,9 +478,9 @@ void cmInstallTargetGenerator::PreReplacementTweaks(std::ostream& os, //---------------------------------------------------------------------------- void cmInstallTargetGenerator::PostReplacementTweaks(std::ostream& os, - Indent const& indent, - const char* config, - std::string const& file) + Indent const& indent, + const std::string& config, + std::string const& file) { this->AddInstallNamePatchRule(os, indent, config, file); this->AddChrpathPatchRule(os, indent, config, file); @@ -492,7 +492,8 @@ void cmInstallTargetGenerator::PostReplacementTweaks(std::ostream& os, void cmInstallTargetGenerator ::AddInstallNamePatchRule(std::ostream& os, Indent const& indent, - const char* config, std::string const& toDestDirPath) + const std::string& config, + std::string const& toDestDirPath) { if(this->ImportLibrary || !(this->Target->GetType() == cmTarget::SHARED_LIBRARY || @@ -605,7 +606,8 @@ cmInstallTargetGenerator void cmInstallTargetGenerator ::AddRPathCheckRule(std::ostream& os, Indent const& indent, - const char* config, std::string const& toDestDirPath) + const std::string& config, + std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) @@ -642,7 +644,8 @@ cmInstallTargetGenerator void cmInstallTargetGenerator ::AddChrpathPatchRule(std::ostream& os, Indent const& indent, - const char* config, std::string const& toDestDirPath) + const std::string& config, + std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 18c3957..0f21da7 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -43,7 +43,7 @@ public: void SetNamelinkMode(NamelinkModeType mode) { this->NamelinkMode = mode; } NamelinkModeType GetNamelinkMode() const { return this->NamelinkMode; } - std::string GetInstallFilename(const char* config) const; + std::string GetInstallFilename(const std::string& config) const; enum NameType { @@ -54,7 +54,7 @@ public: }; static std::string GetInstallFilename(cmTarget const* target, - const char* config, + const std::string& config, NameType nameType = NameNormal); cmTarget* GetTarget() const { return this->Target; } @@ -63,30 +63,33 @@ public: protected: virtual void GenerateScript(std::ostream& os); virtual void GenerateScriptForConfig(std::ostream& os, - const char* config, + const std::string& config, Indent const& indent); typedef void (cmInstallTargetGenerator::*TweakMethod)( - std::ostream&, Indent const&, const char*, std::string const& + std::ostream&, Indent const&, const std::string&, std::string const& ); void AddTweak(std::ostream& os, Indent const& indent, - const char* config, std::string const& file, + const std::string& config, std::string const& file, TweakMethod tweak); void AddTweak(std::ostream& os, Indent const& indent, - const char* config, std::vector const& files, + const std::string& config, + std::vector const& files, TweakMethod tweak); std::string GetDestDirPath(std::string const& file); void PreReplacementTweaks(std::ostream& os, Indent const& indent, - const char* config, std::string const& file); + const std::string& config, + std::string const& file); void PostReplacementTweaks(std::ostream& os, Indent const& indent, - const char* config, std::string const& file); + const std::string& config, + std::string const& file); void AddInstallNamePatchRule(std::ostream& os, Indent const& indent, - const char* config, + const std::string& config, const std::string& toDestDirPath); void AddChrpathPatchRule(std::ostream& os, Indent const& indent, - const char* config, + const std::string& config, std::string const& toDestDirPath); void AddRPathCheckRule(std::ostream& os, Indent const& indent, - const char* config, + const std::string& config, std::string const& toDestDirPath); void AddStripRule(std::ostream& os, Indent const& indent, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index e36266a..cd9f9bd 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -280,7 +280,7 @@ void cmLocalGenerator::GenerateTestFiles() // Compute the set of configurations. std::vector configurationTypes; - const char* config = + const std::string& config = this->Makefile->GetConfigurations(configurationTypes, false); std::string file = this->Makefile->GetStartOutputDirectory(); @@ -384,11 +384,11 @@ void cmLocalGenerator::GenerateInstallRules() // Compute the set of configurations. std::vector configurationTypes; - const char* config = + const std::string& config = this->Makefile->GetConfigurations(configurationTypes, false); // Choose a default install configuration. - const char* default_config = config; + const char* default_config = config.c_str(); const char* default_order[] = {"RELEASE", "MINSIZEREL", "RELWITHDEBINFO", "DEBUG", 0}; for(const char** c = default_order; *c && !default_config; ++c) @@ -557,7 +557,7 @@ void cmLocalGenerator::GenerateTargetManifest() } if(configNames.empty()) { - target.GenerateTargetManifest(0); + target.GenerateTargetManifest(""); } else { @@ -712,8 +712,8 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, vars.LinkFlags = linkFlags.c_str(); std::string langFlags; - this->AddLanguageFlags(langFlags, llang, 0); - this->AddArchitectureFlags(langFlags, &target, llang, 0); + this->AddLanguageFlags(langFlags, llang, ""); + this->AddArchitectureFlags(langFlags, &target, llang, ""); vars.LanguageCompileFlags = langFlags.c_str(); cmCustomCommandLines commandLines; @@ -1292,7 +1292,7 @@ std::string cmLocalGenerator::GetIncludeFlags( cmGeneratorTarget* target, const std::string& lang, bool forResponseFile, - const char *config) + const std::string& config) { if(lang.empty()) { @@ -1370,7 +1370,7 @@ std::string cmLocalGenerator::GetIncludeFlags( if(!flagUsed || repeatFlag) { if(sysIncludeFlag && target && - target->IsSystemIncludeDirectory(i->c_str(), config)) + target->IsSystemIncludeDirectory(*i, config)) { includeFlags << sysIncludeFlag; } @@ -1405,7 +1405,7 @@ std::string cmLocalGenerator::GetIncludeFlags( //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileDefinitions(std::set& defines, cmTarget const* target, - const char* config) + const std::string& config) { std::vector targetDefines; target->GetCompileDefinitions(targetDefines, @@ -1416,7 +1416,7 @@ void cmLocalGenerator::AddCompileDefinitions(std::set& defines, //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileOptions( std::string& flags, cmTarget* target, - const std::string& lang, const char* config + const std::string& lang, const std::string& config ) { std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX"; @@ -1465,7 +1465,7 @@ void cmLocalGenerator::AddCompileOptions( void cmLocalGenerator::GetIncludeDirectories(std::vector& dirs, cmGeneratorTarget* target, const std::string& lang, - const char *config, + const std::string& config, bool stripImplicitInclDirs ) { @@ -1698,7 +1698,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, target->Target->GetName().c_str()); return; } - this->AddLanguageFlags(flags, linkLanguage, buildType.c_str()); + this->AddLanguageFlags(flags, linkLanguage, buildType); this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, *target, false, false); if(cmSystemTools::IsOn @@ -1945,7 +1945,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, void cmLocalGenerator::AddArchitectureFlags(std::string& flags, cmGeneratorTarget* target, const std::string& lang, - const char* config) + const std::string& config) { // Only add Mac OS X specific flags on Darwin platforms (OSX and iphone): if(!this->Makefile->IsOn("APPLE")) @@ -2002,7 +2002,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, //---------------------------------------------------------------------------- void cmLocalGenerator::AddLanguageFlags(std::string& flags, const std::string& lang, - const char* config) + const std::string& config) { // Add language-specific flags. std::string flagsVar = "CMAKE_"; @@ -2013,7 +2013,7 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, //---------------------------------------------------------------------------- bool cmLocalGenerator::GetRealDependency(const std::string& inName, - const char* config, + const std::string& config, std::string& dep) { // Older CMake code may specify the dependency using the target @@ -2211,7 +2211,7 @@ void cmLocalGenerator //---------------------------------------------------------------------------- void cmLocalGenerator::AddCMP0018Flags(std::string &flags, cmTarget* target, std::string const& lang, - const char *config) + const std::string& config) { int targetType = target->GetType(); @@ -2327,13 +2327,13 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags, //---------------------------------------------------------------------------- void cmLocalGenerator::AddConfigVariableFlags(std::string& flags, const std::string& var, - const char* config) + const std::string& config) { // Add the flags from the variable itself. std::string flagsVar = var; this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str())); // Add the flags from the build-type specific variable. - if(config && *config) + if(!config.empty()) { flagsVar += "_"; flagsVar += cmSystemTools::UpperCase(config); @@ -2837,7 +2837,7 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector& local, void cmLocalGenerator ::GenerateTargetInstallRules( - std::ostream& os, const char* config, + std::ostream& os, const std::string& config, std::vector const& configurationTypes) { // Convert the old-style install specification from each target to diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 3fe6a26..4d62833 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -138,16 +138,16 @@ public: void AddArchitectureFlags(std::string& flags, cmGeneratorTarget* target, - const std::string&lang, const char* config); + const std::string&lang, const std::string& config); void AddLanguageFlags(std::string& flags, const std::string& lang, - const char* config); + const std::string& config); void AddCMP0018Flags(std::string &flags, cmTarget* target, - std::string const& lang, const char *config); + std::string const& lang, const std::string& config); void AddVisibilityPresetFlags(std::string &flags, cmTarget* target, const std::string& lang); void AddConfigVariableFlags(std::string& flags, const std::string& var, - const char* config); + const std::string& config); ///! Append flags to a string. virtual void AppendFlags(std::string& flags, const char* newFlags); virtual void AppendFlagEscape(std::string& flags, @@ -157,7 +157,7 @@ public: cmGeneratorTarget* target, const std::string& lang, bool forResponseFile = false, - const char *config = 0); + const std::string& config = ""); /** * Encode a list of preprocessor definitions for the compiler @@ -196,7 +196,7 @@ public: * the source directory of this generator. This should only be * used for dependencies of custom commands. */ - bool GetRealDependency(const std::string& name, const char* config, + bool GetRealDependency(const std::string& name, const std::string& config, std::string& dep); ///! for existing files convert to output path and short path if spaces @@ -227,13 +227,13 @@ public: void GetIncludeDirectories(std::vector& dirs, cmGeneratorTarget* target, const std::string& lang = "C", - const char *config = 0, + const std::string& config = "", bool stripImplicitInclDirs = true); void AddCompileOptions(std::string& flags, cmTarget* target, - const std::string& lang, const char* config); + const std::string& lang, const std::string& config); void AddCompileDefinitions(std::set& defines, cmTarget const* target, - const char* config); + const std::string& config); /** Compute the language used to compile the given source file. */ std::string GetSourceFileLanguage(const cmSourceFile& source); @@ -410,7 +410,7 @@ protected: // Handle old-style install rules stored in the targets. void GenerateTargetInstallRules( - std::ostream& os, const char* config, + std::ostream& os, const std::string& config, std::vector const& configurationTypes); std::string& CreateSafeUniqueObjectFileName(const std::string& sin, diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index b0c577e..0e246a5 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -38,7 +38,7 @@ class cmLocalVisualStudio6Generator::EventWriter { public: EventWriter(cmLocalVisualStudio6Generator* lg, - const char* config, std::string& code): + const std::string& config, std::string& code): LG(lg), Config(config), Code(code), First(true) {} void Start(const char* event) { @@ -72,7 +72,7 @@ public: } private: cmLocalVisualStudio6Generator* LG; - const char* Config; + std::string Config; std::string& Code; bool First; std::string Event; @@ -785,7 +785,7 @@ void cmLocalVisualStudio6Generator::SetBuildType(BuildType b, //---------------------------------------------------------------------------- cmsys::auto_ptr cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target, - const char* config) + const std::string& config) { cmsys::auto_ptr pcc; @@ -813,7 +813,7 @@ cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target, // look for custom rules on a target and collect them together std::string cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target, - const char* configName, + const std::string& configName, const std::string& /* libName */) { if (target.GetType() >= cmTarget::UTILITY ) @@ -863,7 +863,7 @@ inline std::string removeQuotes(const std::string& s) std::string cmLocalVisualStudio6Generator::GetTargetIncludeOptions(cmTarget &target, - const char *config) + const std::string& config) { std::string includeOptions; @@ -1704,7 +1704,7 @@ void cmLocalVisualStudio6Generator flagsRelWithDebInfo = this->Makefile->GetSafeDefinition(flagVar.c_str()); flagsRelWithDebInfo += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" "; - this->AddCompileOptions(flags, &target, linkLanguage, 0); + this->AddCompileOptions(flags, &target, linkLanguage, ""); this->AddCompileOptions(flagsDebug, &target, linkLanguage, "Debug"); this->AddCompileOptions(flagsRelease, &target, linkLanguage, "Release"); this->AddCompileOptions(flagsMinSizeRel, &target, linkLanguage, @@ -1730,7 +1730,7 @@ void cmLocalVisualStudio6Generator std::set minsizeDefinesSet; std::set debugrelDefinesSet; - this->AddCompileDefinitions(definesSet, &target, 0); + this->AddCompileDefinitions(definesSet, &target, ""); this->AddCompileDefinitions(debugDefinesSet, &target, "DEBUG"); this->AddCompileDefinitions(releaseDefinesSet, &target, "RELEASE"); this->AddCompileDefinitions(minsizeDefinesSet, &target, "MINSIZEREL"); @@ -1800,7 +1800,7 @@ void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout) //---------------------------------------------------------------------------- void cmLocalVisualStudio6Generator ::ComputeLinkOptions(cmTarget& target, - const char* configName, + const std::string& configName, const std::string extraOptions, std::string& options) { diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h index 6702111..4771833 100644 --- a/Source/cmLocalVisualStudio6Generator.h +++ b/Source/cmLocalVisualStudio6Generator.h @@ -81,16 +81,17 @@ private: class EventWriter; friend class EventWriter; cmsys::auto_ptr - MaybeCreateOutputDir(cmTarget& target, const char* config); + MaybeCreateOutputDir(cmTarget& target, const std::string& config); std::string CreateTargetRules(cmTarget &target, - const char* configName, + const std::string& configName, const std::string& libName); - void ComputeLinkOptions(cmTarget& target, const char* configName, + void ComputeLinkOptions(cmTarget& target, const std::string& configName, const std::string extraOptions, std::string& options); void OutputObjects(cmTarget& target, const char* tool, std::string& options); - std::string GetTargetIncludeOptions(cmTarget &target, const char *config); + std::string GetTargetIncludeOptions(cmTarget &target, + const std::string& config); std::vector Configurations; std::string GetConfigName(std::string const& configuration) const; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 6ad5e04..5f98a71 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -588,7 +588,7 @@ class cmLocalVisualStudio7Generator::EventWriter { public: EventWriter(cmLocalVisualStudio7Generator* lg, - const char* config, std::ostream& os): + const std::string& config, std::ostream& os): LG(lg), Config(config), Stream(os), First(true) {} void Start(const char* tool) { @@ -629,14 +629,14 @@ public: } private: cmLocalVisualStudio7Generator* LG; - const char* Config; + std::string Config; std::ostream& Stream; bool First; }; //---------------------------------------------------------------------------- void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, - const char* configName, + const std::string& configName, const std::string& libName, cmTarget &target) { @@ -745,7 +745,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, table, this->ExtraFlagTable); targetOptions.FixExceptionHandlingDefault(); - std::string asmLocation = std::string(configName) + "/"; + std::string asmLocation = configName + "/"; targetOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str()); targetOptions.Parse(flags.c_str()); targetOptions.Parse(defineFlags.c_str()); @@ -944,7 +944,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, //---------------------------------------------------------------------------- std::string cmLocalVisualStudio7Generator -::GetBuildTypeLinkerFlags(std::string rootLinkerFlags, const char* configName) +::GetBuildTypeLinkerFlags(std::string rootLinkerFlags, + const std::string& configName) { std::string configTypeUpper = cmSystemTools::UpperCase(configName); std::string extraLinkOptionsBuildTypeDef = @@ -958,7 +959,8 @@ cmLocalVisualStudio7Generator } void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, - const char* configName, cmTarget &target, const Options& targetOptions) + const std::string& configName, cmTarget &target, + const Options& targetOptions) { cmGlobalVisualStudio7Generator* gg = static_cast(this->GlobalGenerator); @@ -1903,7 +1905,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjEndGroup(std::ostream& fout) // look for custom rules on a target and collect them together void cmLocalVisualStudio7Generator ::OutputTargetRules(std::ostream& fout, - const char* configName, + const std::string& configName, cmTarget &target, const std::string& /*libName*/) { diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 2823a2c..f9bb6e1 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -71,7 +71,7 @@ private: typedef cmVisualStudioGeneratorOptions Options; typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo; std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags, - const char* configName); + const std::string& configName); void FixGlobalTargets(); void WriteProjectFiles(); void WriteVCProjHeader(std::ostream& fout, const std::string& libName, @@ -82,14 +82,14 @@ private: void WriteConfigurations(std::ostream& fout, const std::string& libName, cmTarget &tgt); void WriteConfiguration(std::ostream& fout, - const char* configName, + const std::string& configName, const std::string& libName, cmTarget &tgt); std::string EscapeForXML(const std::string& s); std::string ConvertToXMLOutputPath(const char* path); std::string ConvertToXMLOutputPathSingle(const char* path); - void OutputTargetRules(std::ostream& fout, const char* configName, + void OutputTargetRules(std::ostream& fout, const std::string& configName, cmTarget &target, const std::string& libName); - void OutputBuildTool(std::ostream& fout, const char* configName, + void OutputBuildTool(std::ostream& fout, const std::string& configName, cmTarget& t, const Options& targetOptions); void OutputLibraryDirectories(std::ostream& fout, std::vector const& dirs); diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index ef2bb1d..11b0387 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -33,7 +33,7 @@ cmLocalVisualStudioGenerator::~cmLocalVisualStudioGenerator() //---------------------------------------------------------------------------- cmsys::auto_ptr cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target, - const char* config, + const std::string& config, bool isFortran) { cmsys::auto_ptr pcc; @@ -80,7 +80,7 @@ const char* cmLocalVisualStudioGenerator::GetReportErrorLabel() const std::string cmLocalVisualStudioGenerator ::ConstructScript(cmCustomCommand const& cc, - const char* configName, + const std::string& configName, const char* newline_text) { bool useLocal = this->CustomCommandUseLocal(); diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index 1a3499a..2297072 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -47,7 +47,7 @@ public: /** Construct a script from the given list of command lines. */ std::string ConstructScript(cmCustomCommand const& cc, - const char* configName, + const std::string& configName, const char* newline = "\n"); /** Label to which to jump in a batch file after a failed step in a @@ -67,7 +67,8 @@ protected: /** Construct a custom command to make exe import lib dir. */ cmsys::auto_ptr - MaybeCreateImplibDir(cmTarget& target, const char* config, bool isFortran); + MaybeCreateImplibDir(cmTarget& target, const std::string& config, + bool isFortran); VSVersion Version; }; diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index fb8c2d1..5857aef 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -54,7 +54,7 @@ void cmLocalXCodeGenerator::Generate() iter != targets.end(); ++iter) { cmTarget* t = &iter->second; - t->HasMacOSXRpathInstallNameDir(NULL); + t->HasMacOSXRpathInstallNameDir(""); } } @@ -68,6 +68,6 @@ void cmLocalXCodeGenerator::GenerateInstallRules() iter != targets.end(); ++iter) { cmTarget* t = &iter->second; - t->HasMacOSXRpathInstallNameDir(NULL); + t->HasMacOSXRpathInstallNameDir(""); } } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index d107ddf..1ef4d46 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2734,7 +2734,7 @@ void cmMakefile::AddDefaultDefinitions() } //---------------------------------------------------------------------------- -const char* +std::string cmMakefile::GetConfigurations(std::vector& configs, bool single) const { @@ -2745,12 +2745,12 @@ cmMakefile::GetConfigurations(std::vector& configs, { cmSystemTools::ExpandListArgument(configTypes, configs); } - return 0; + return ""; } else { - const char* buildType = this->GetDefinition("CMAKE_BUILD_TYPE"); - if(single && buildType && *buildType) + const std::string& buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE"); + if(single && !buildType.empty()) { configs.push_back(buildType); } @@ -3801,11 +3801,12 @@ bool cmMakefile::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -const char* cmMakefile::GetFeature(const char* feature, const char* config) +const char* cmMakefile::GetFeature(const char* feature, + const std::string& config) { // TODO: Define accumulation policy for features (prepend, append, replace). // Currently we always replace. - if(config && *config) + if(!config.empty()) { std::string featureConfig = feature; featureConfig += "_"; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 86cedb0..1c3ad73 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -320,7 +320,7 @@ public: } /** Get the configurations to be generated. */ - const char* GetConfigurations(std::vector& configs, + std::string GetConfigurations(std::vector& configs, bool single = true) const; /** @@ -811,7 +811,7 @@ public: cmProperty::ScopeType scope) const; bool GetPropertyAsBool(const std::string& prop) const; - const char* GetFeature(const char* feature, const char* config); + const char* GetFeature(const char* feature, const std::string& config); // Get the properties cmPropertyMap &GetProperties() { return this->Properties; }; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 0a836a5..1af5d6c 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -133,7 +133,8 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() this->Makefile->GetProperty ("ADDITIONAL_MAKE_CLEAN_FILES")) { - const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); + const std::string& config = + this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); cmListFileBacktrace lfbt; cmGeneratorExpression ge(lfbt); cmsys::auto_ptr cge = @@ -1070,7 +1071,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() << "set(CMAKE_C_TARGET_INCLUDE_PATH\n"; std::vector includes; - const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); + const std::string& config = + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, "C", config); @@ -1567,7 +1569,8 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l) #endif std::vector includes; - const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); + const std::string& config = + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, "C", config); @@ -1952,7 +1955,8 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags, std::vector includes; - const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); + const std::string& config = + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, lang, config); @@ -2059,7 +2063,8 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags) this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG")) { std::vector includes; - const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); + const std::string& config = + this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, "C", config); diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 5f697a5..21eece4 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -183,7 +183,7 @@ protected: cmLocalUnixMakefileGenerator3 *LocalGenerator; cmGlobalUnixMakefileGenerator3 *GlobalGenerator; cmMakefile *Makefile; - const char *ConfigName; + std::string ConfigName; enum CustomCommandDriveType { OnBuild, OnDepends, OnUtility }; CustomCommandDriveType CustomCommandDriver; diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 78b59b3..449f923 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -19,7 +19,7 @@ //---------------------------------------------------------------------------- cmOSXBundleGenerator:: cmOSXBundleGenerator(cmGeneratorTarget* target, - const char* configName) + const std::string& configName) : GT(target) , Makefile(target->Target->GetMakefile()) , LocalGenerator(Makefile->GetLocalGenerator()) diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h index 97ae731..95b4aef 100644 --- a/Source/cmOSXBundleGenerator.h +++ b/Source/cmOSXBundleGenerator.h @@ -27,7 +27,7 @@ class cmOSXBundleGenerator { public: cmOSXBundleGenerator(cmGeneratorTarget* target, - const char* configName); + const std::string& configName); // create an app bundle at a given root, and return // the directory within the bundle that contains the executable @@ -62,7 +62,7 @@ private: cmGeneratorTarget* GT; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; - const char* ConfigName; + std::string ConfigName; std::set* MacContentFolders; }; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index fbb3b1c..8eee991 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -306,7 +306,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) } static void GetCompileDefinitionsAndDirectories(cmTarget const* target, - const char * config, + const std::string& config, std::string &incs, std::string &defs) { @@ -366,7 +366,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", 0)) + target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } @@ -563,7 +563,7 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, std::string _moc_incs; std::string _moc_compile_defs; std::vector configs; - const char *config = makefile->GetConfigurations(configs); + const std::string& config = makefile->GetConfigurations(configs); GetCompileDefinitionsAndDirectories(target, config, _moc_incs, _moc_compile_defs); @@ -675,7 +675,7 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector &opts, opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } -static void GetUicOpts(cmTarget const* target, const char * config, +static void GetUicOpts(cmTarget const* target, const std::string& config, std::string &optString) { std::vector opts; @@ -717,7 +717,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, std::string _uic_opts; std::vector configs; - const char *config = makefile->GetConfigurations(configs); + const std::string& config = makefile->GetConfigurations(configs); GetUicOpts(target, config, _uic_opts); if (!_uic_opts.empty()) @@ -967,7 +967,8 @@ static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, return gg; } -bool cmQtAutoGenerators::Run(const char* targetDirectory, const char *config) +bool cmQtAutoGenerators::Run(const char* targetDirectory, + const std::string& config) { bool success = true; cmake cm; @@ -994,7 +995,7 @@ bool cmQtAutoGenerators::Run(const char* targetDirectory, const char *config) bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, const char* targetDirectory, - const char *config) + const std::string& config) { std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); cmSystemTools::ConvertToUnixSlashes(filename); @@ -1027,7 +1028,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, { std::string compileDefsPropOrig = "AM_MOC_COMPILE_DEFINITIONS"; std::string compileDefsProp = compileDefsPropOrig; - if(config) + if(!config.empty()) { compileDefsProp += "_"; compileDefsProp += config; @@ -1039,7 +1040,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, { std::string includesPropOrig = "AM_MOC_INCLUDES"; std::string includesProp = includesPropOrig; - if(config) + if(!config.empty()) { includesProp += "_"; includesProp += config; @@ -1058,7 +1059,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, = makefile->GetSafeDefinition("AM_UIC_OPTIONS_FILES"); std::string uicOptionsPropOrig = "AM_UIC_TARGET_OPTIONS"; std::string uicOptionsProp = uicOptionsPropOrig; - if(config) + if(!config.empty()) { uicOptionsProp += "_"; uicOptionsProp += config; diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index 2840fbf..af4ceb9 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -21,7 +21,7 @@ class cmQtAutoGenerators { public: cmQtAutoGenerators(); - bool Run(const char* targetDirectory, const char *config); + bool Run(const char* targetDirectory, const std::string& config); bool InitializeAutogenTarget(cmTarget* target); void SetupAutoGenerateTarget(cmTarget const* target); @@ -38,7 +38,7 @@ private: bool ReadAutogenInfoFile(cmMakefile* makefile, const char* targetDirectory, - const char *config); + const std::string& config); bool ReadOldMocDefinitionsFile(cmMakefile* makefile, const char* targetDirectory); void WriteOldMocDefinitionsFile(const char* targetDirectory); diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx index 7a8efc1..7685d40 100644 --- a/Source/cmScriptGenerator.cxx +++ b/Source/cmScriptGenerator.cxx @@ -19,7 +19,7 @@ cmScriptGenerator std::vector const& configurations): RuntimeConfigVariable(config_var), Configurations(configurations), - ConfigurationName(0), + ConfigurationName(""), ConfigurationTypes(0), ActionsPerConfig(false) { @@ -34,21 +34,21 @@ cmScriptGenerator //---------------------------------------------------------------------------- void cmScriptGenerator -::Generate(std::ostream& os, const char* config, +::Generate(std::ostream& os, const std::string& config, std::vector const& configurationTypes) { this->ConfigurationName = config; this->ConfigurationTypes = &configurationTypes; this->GenerateScript(os); - this->ConfigurationName = 0; + this->ConfigurationName = ""; this->ConfigurationTypes = 0; } //---------------------------------------------------------------------------- -static void cmScriptGeneratorEncodeConfig(const char* config, +static void cmScriptGeneratorEncodeConfig(const std::string& config, std::string& result) { - for(const char* c = config; *c; ++c) + for(const char* c = config.c_str(); *c; ++c) { if(*c >= 'a' && *c <= 'z') { @@ -73,12 +73,12 @@ static void cmScriptGeneratorEncodeConfig(const char* config, //---------------------------------------------------------------------------- std::string -cmScriptGenerator::CreateConfigTest(const char* config) +cmScriptGenerator::CreateConfigTest(const std::string& config) { std::string result = "\"${"; result += this->RuntimeConfigVariable; result += "}\" MATCHES \"^("; - if(config && *config) + if(!config.empty()) { cmScriptGeneratorEncodeConfig(config, result); } @@ -142,14 +142,15 @@ void cmScriptGenerator::GenerateScriptActions(std::ostream& os, } //---------------------------------------------------------------------------- -void cmScriptGenerator::GenerateScriptForConfig(std::ostream&, const char*, +void cmScriptGenerator::GenerateScriptForConfig(std::ostream&, + const std::string&, Indent const&) { // No actions for this generator. } //---------------------------------------------------------------------------- -bool cmScriptGenerator::GeneratesForConfig(const char* config) +bool cmScriptGenerator::GeneratesForConfig(const std::string& config) { // If this is not a configuration-specific rule then we install. if(this->Configurations.empty()) @@ -159,7 +160,7 @@ bool cmScriptGenerator::GeneratesForConfig(const char* config) // This is a configuration-specific rule. Check if the config // matches this rule. - std::string config_upper = cmSystemTools::UpperCase(config?config:""); + std::string config_upper = cmSystemTools::UpperCase(config); for(std::vector::const_iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h index 3515e20..9ab04f1 100644 --- a/Source/cmScriptGenerator.h +++ b/Source/cmScriptGenerator.h @@ -51,7 +51,7 @@ public: std::vector const& configurations); virtual ~cmScriptGenerator(); - void Generate(std::ostream& os, const char* config, + void Generate(std::ostream& os, const std::string& config, std::vector const& configurationTypes); const std::vector& GetConfigurations() const @@ -63,15 +63,15 @@ protected: virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent); virtual void GenerateScriptActions(std::ostream& os, Indent const& indent); virtual void GenerateScriptForConfig(std::ostream& os, - const char* config, + const std::string& config, Indent const& indent); virtual void GenerateScriptNoConfig(std::ostream&, Indent const&) {} virtual bool NeedsScriptNoConfig() const { return false; } // Test if this generator does something for a given configuration. - bool GeneratesForConfig(const char*); + bool GeneratesForConfig(const std::string&); - std::string CreateConfigTest(const char* config); + std::string CreateConfigTest(const std::string& config); std::string CreateConfigTest(std::vector const& configs); std::string CreateComponentTest(const char* component); @@ -80,7 +80,7 @@ protected: std::vector const Configurations; // Information used during generation. - const char* ConfigurationName; + std::string ConfigurationName; std::vector const* ConfigurationTypes; // True if the subclass needs to generate an explicit rule for each diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 3273437..b8e662a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -109,7 +109,8 @@ public: const char* ExplicitLibraries; }; void ComputeLinkInterface(cmTarget const* thisTarget, - const char* config, OptionalLinkInterface& iface, + const std::string& config, + OptionalLinkInterface& iface, cmTarget const* head, const char *explicitLibraries) const; @@ -692,10 +693,11 @@ const std::vector& cmTarget::GetLinkDirectories() const } //---------------------------------------------------------------------------- -cmTarget::LinkLibraryType cmTarget::ComputeLinkType(const char* config) const +cmTarget::LinkLibraryType cmTarget::ComputeLinkType( + const std::string& config) const { // No configuration is always optimized. - if(!(config && *config)) + if(config.empty()) { return cmTarget::OPTIMIZED; } @@ -755,7 +757,7 @@ bool cmTarget::NameResolvesToFramework(const std::string& libname) const } //---------------------------------------------------------------------------- -void cmTarget::GetDirectLinkLibraries(const char *config, +void cmTarget::GetDirectLinkLibraries(const std::string& config, std::vector &libs, cmTarget const* head) const { @@ -789,7 +791,7 @@ void cmTarget::GetDirectLinkLibraries(const char *config, } //---------------------------------------------------------------------------- -void cmTarget::GetInterfaceLinkLibraries(const char *config, +void cmTarget::GetInterfaceLinkLibraries(const std::string& config, std::vector &libs, cmTarget const* head) const { @@ -1565,7 +1567,7 @@ static void processIncludeDirectories(cmTarget const* tgt, std::vector &includes, std::set &uniqueIncludes, cmGeneratorExpressionDAGChecker *dagChecker, - const char *config, bool debugIncludes) + const std::string& config, bool debugIncludes) { cmMakefile *mf = tgt->GetMakefile(); @@ -1730,7 +1732,7 @@ static void processIncludeDirectories(cmTarget const* tgt, //---------------------------------------------------------------------------- std::vector -cmTarget::GetIncludeDirectories(const char *config) const +cmTarget::GetIncludeDirectories(const std::string& config) const { std::vector includes; std::set uniqueIncludes; @@ -1767,8 +1769,7 @@ cmTarget::GetIncludeDirectories(const char *config) const config, debugIncludes); - std::string configString = config ? config : ""; - if (!this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[configString]) + if (!this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[config]) { for (std::vector::const_iterator it = this->Internal->LinkImplementationPropertyEntries.begin(), @@ -1805,7 +1806,7 @@ cmTarget::GetIncludeDirectories(const char *config) const includeGenex); this->Internal - ->CachedLinkInterfaceIncludeDirectoriesEntries[configString].push_back( + ->CachedLinkInterfaceIncludeDirectoriesEntries[config].push_back( new cmTargetInternals::TargetPropertyEntry(cge, it->Value)); } @@ -1833,14 +1834,14 @@ cmTarget::GetIncludeDirectories(const char *config) const cmsys::auto_ptr cge = ge.Parse(libDir.c_str()); this->Internal - ->CachedLinkInterfaceIncludeDirectoriesEntries[configString] + ->CachedLinkInterfaceIncludeDirectoriesEntries[config] .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); } } } processIncludeDirectories(this, - this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries[configString], + this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries[config], includes, uniqueIncludes, &dagChecker, @@ -1854,7 +1855,7 @@ cmTarget::GetIncludeDirectories(const char *config) const } else { - this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[configString] + this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[config] = true; } @@ -1867,7 +1868,7 @@ static void processCompileOptionsInternal(cmTarget const* tgt, std::vector &options, std::set &uniqueOptions, cmGeneratorExpressionDAGChecker *dagChecker, - const char *config, bool debugOptions, const char *logName) + const std::string& config, bool debugOptions, const char *logName) { cmMakefile *mf = tgt->GetMakefile(); @@ -1926,7 +1927,7 @@ static void processCompileOptions(cmTarget const* tgt, std::vector &options, std::set &uniqueOptions, cmGeneratorExpressionDAGChecker *dagChecker, - const char *config, bool debugOptions) + const std::string& config, bool debugOptions) { processCompileOptionsInternal(tgt, entries, options, uniqueOptions, dagChecker, config, debugOptions, "options"); @@ -1934,7 +1935,7 @@ static void processCompileOptions(cmTarget const* tgt, //---------------------------------------------------------------------------- void cmTarget::GetAutoUicOptions(std::vector &result, - const char *config) const + const std::string& config) const { const char *prop = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", @@ -1960,7 +1961,7 @@ void cmTarget::GetAutoUicOptions(std::vector &result, //---------------------------------------------------------------------------- void cmTarget::GetCompileOptions(std::vector &result, - const char *config) const + const std::string& config) const { std::set uniqueOptions; cmListFileBacktrace lfbt; @@ -1996,8 +1997,7 @@ void cmTarget::GetCompileOptions(std::vector &result, config, debugOptions); - std::string configString = config ? config : ""; - if (!this->Internal->CacheLinkInterfaceCompileOptionsDone[configString]) + if (!this->Internal->CacheLinkInterfaceCompileOptionsDone[config]) { for (std::vector::const_iterator it = this->Internal->LinkImplementationPropertyEntries.begin(), @@ -2034,14 +2034,14 @@ void cmTarget::GetCompileOptions(std::vector &result, optionGenex); this->Internal - ->CachedLinkInterfaceCompileOptionsEntries[configString].push_back( + ->CachedLinkInterfaceCompileOptionsEntries[config].push_back( new cmTargetInternals::TargetPropertyEntry(cge, it->Value)); } } processCompileOptions(this, - this->Internal->CachedLinkInterfaceCompileOptionsEntries[configString], + this->Internal->CachedLinkInterfaceCompileOptionsEntries[config], result, uniqueOptions, &dagChecker, @@ -2054,7 +2054,7 @@ void cmTarget::GetCompileOptions(std::vector &result, } else { - this->Internal->CacheLinkInterfaceCompileOptionsDone[configString] = true; + this->Internal->CacheLinkInterfaceCompileOptionsDone[config] = true; } } @@ -2064,7 +2064,7 @@ static void processCompileDefinitions(cmTarget const* tgt, std::vector &options, std::set &uniqueOptions, cmGeneratorExpressionDAGChecker *dagChecker, - const char *config, bool debugOptions) + const std::string& config, bool debugOptions) { processCompileOptionsInternal(tgt, entries, options, uniqueOptions, dagChecker, config, debugOptions, @@ -2073,7 +2073,7 @@ static void processCompileDefinitions(cmTarget const* tgt, //---------------------------------------------------------------------------- void cmTarget::GetCompileDefinitions(std::vector &list, - const char *config) const + const std::string& config) const { std::set uniqueOptions; cmListFileBacktrace lfbt; @@ -2109,8 +2109,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, config, debugDefines); - std::string configString = config ? config : ""; - if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString]) + if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[config]) { for (std::vector::const_iterator it = this->Internal->LinkImplementationPropertyEntries.begin(), @@ -2147,11 +2146,11 @@ void cmTarget::GetCompileDefinitions(std::vector &list, defsGenex); this->Internal - ->CachedLinkInterfaceCompileDefinitionsEntries[configString].push_back( + ->CachedLinkInterfaceCompileDefinitionsEntries[config].push_back( new cmTargetInternals::TargetPropertyEntry(cge, it->Value)); } - if (config) + if (!config.empty()) { std::string configPropName = "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config); @@ -2174,7 +2173,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, cmsys::auto_ptr cge = ge.Parse(configProp); this->Internal - ->CachedLinkInterfaceCompileDefinitionsEntries[configString] + ->CachedLinkInterfaceCompileDefinitionsEntries[config] .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); } break; @@ -2189,7 +2188,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, } processCompileDefinitions(this, - this->Internal->CachedLinkInterfaceCompileDefinitionsEntries[configString], + this->Internal->CachedLinkInterfaceCompileDefinitionsEntries[config], list, uniqueOptions, &dagChecker, @@ -2203,7 +2202,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, } else { - this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString] + this->Internal->CacheLinkInterfaceCompileDefinitionsDone[config] = true; } } @@ -2333,7 +2332,8 @@ bool cmTarget::HaveWellDefinedOutputFiles() const } //---------------------------------------------------------------------------- -cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const +cmTarget::OutputInfo const* cmTarget::GetOutputInfo( + const std::string& config) const { // There is no output information for imported targets. if(this->IsImported()) @@ -2355,7 +2355,7 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const // Lookup/compute/cache the output information for this configuration. std::string config_upper; - if(config && *config) + if(!config.empty()) { config_upper = cmSystemTools::UpperCase(config); } @@ -2378,7 +2378,8 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const } //---------------------------------------------------------------------------- -cmTarget::CompileInfo const* cmTarget::GetCompileInfo(const char* config) const +cmTarget::CompileInfo const* cmTarget::GetCompileInfo( + const std::string& config) const { // There is no compile information for imported targets. if(this->IsImported()) @@ -2399,7 +2400,7 @@ cmTarget::CompileInfo const* cmTarget::GetCompileInfo(const char* config) const // Lookup/compute/cache the compile information for this configuration. std::string config_upper; - if(config && *config) + if(!config.empty()) { config_upper = cmSystemTools::UpperCase(config); } @@ -2417,7 +2418,8 @@ cmTarget::CompileInfo const* cmTarget::GetCompileInfo(const char* config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetDirectory(const char* config, bool implib) const +std::string cmTarget::GetDirectory(const std::string& config, + bool implib) const { if (this->IsImported()) { @@ -2435,7 +2437,7 @@ std::string cmTarget::GetDirectory(const char* config, bool implib) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetPDBDirectory(const char* config) const +std::string cmTarget::GetPDBDirectory(const std::string& config) const { if(OutputInfo const* info = this->GetOutputInfo(config)) { @@ -2446,7 +2448,7 @@ std::string cmTarget::GetPDBDirectory(const char* config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBDirectory(const char* config) const +std::string cmTarget::GetCompilePDBDirectory(const std::string& config) const { if(CompileInfo const* info = this->GetCompileInfo(config)) { @@ -2456,7 +2458,7 @@ std::string cmTarget::GetCompilePDBDirectory(const char* config) const } //---------------------------------------------------------------------------- -const char* cmTarget::GetLocation(const char* config) const +const char* cmTarget::GetLocation(const std::string& config) const { static std::string location; if (this->IsImported()) @@ -2547,9 +2549,10 @@ void cmTarget::GetTargetVersion(bool soversion, } //---------------------------------------------------------------------------- -const char* cmTarget::GetFeature(const char* feature, const char* config) const +const char* cmTarget::GetFeature(const char* feature, + const std::string& config) const { - if(config && *config) + if(!config.empty()) { std::string featureConfig = feature; featureConfig += "_"; @@ -2798,7 +2801,8 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const class cmTargetCollectLinkLanguages { public: - cmTargetCollectLinkLanguages(cmTarget const* target, const char* config, + cmTargetCollectLinkLanguages(cmTarget const* target, + const std::string& config, std::set& languages, cmTarget const* head): Config(config), Languages(languages), HeadTarget(head), @@ -2870,7 +2874,7 @@ public: } } private: - const char* Config; + std::string Config; std::set& Languages; cmTarget const* HeadTarget; cmMakefile* Makefile; @@ -2879,7 +2883,7 @@ private: }; //---------------------------------------------------------------------------- -std::string cmTarget::GetLinkerLanguage(const char* config, +std::string cmTarget::GetLinkerLanguage(const std::string& config, cmTarget const* head) const { cmTarget const* headTarget = head ? head : this; @@ -2887,10 +2891,11 @@ std::string cmTarget::GetLinkerLanguage(const char* config, } //---------------------------------------------------------------------------- -cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const char* config, +cmTarget::LinkClosure const* cmTarget::GetLinkClosure( + const std::string& config, cmTarget const* head) const { - TargetConfigPair key(head, cmSystemTools::UpperCase(config ? config : "")); + TargetConfigPair key(head, cmSystemTools::UpperCase(config)); cmTargetInternals::LinkClosureMapType::iterator i = this->Internal->LinkClosureMap.find(key); if(i == this->Internal->LinkClosureMap.end()) @@ -2957,7 +2962,7 @@ public: }; //---------------------------------------------------------------------------- -void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc, +void cmTarget::ComputeLinkClosure(const std::string& config, LinkClosure& lc, cmTarget const* head) const { // Get languages built in this target. @@ -3070,7 +3075,7 @@ const char* cmTarget::GetPrefixVariableInternal(bool implib) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetPDBName(const char* config) const +std::string cmTarget::GetPDBName(const std::string& config) const { std::string prefix; std::string base; @@ -3078,8 +3083,7 @@ std::string cmTarget::GetPDBName(const char* config) const this->GetFullNameInternal(config, false, prefix, base, suffix); std::vector props; - std::string configUpper = - cmSystemTools::UpperCase(config? config : ""); + std::string configUpper = cmSystemTools::UpperCase(config); if(!configUpper.empty()) { // PDB_NAME_ @@ -3102,7 +3106,7 @@ std::string cmTarget::GetPDBName(const char* config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBName(const char* config) const +std::string cmTarget::GetCompilePDBName(const std::string& config) const { std::string prefix; std::string base; @@ -3110,7 +3114,7 @@ std::string cmTarget::GetCompilePDBName(const char* config) const this->GetFullNameInternal(config, false, prefix, base, suffix); // Check for a per-configuration output directory target property. - std::string configUpper = cmSystemTools::UpperCase(config? config : ""); + std::string configUpper = cmSystemTools::UpperCase(config); std::string configProp = "COMPILE_PDB_NAME_"; configProp += configUpper; const char* config_name = this->GetProperty(configProp.c_str()); @@ -3129,7 +3133,7 @@ std::string cmTarget::GetCompilePDBName(const char* config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBPath(const char* config) const +std::string cmTarget::GetCompilePDBPath(const std::string& config) const { std::string dir = this->GetCompilePDBDirectory(config); std::string name = this->GetCompilePDBName(config); @@ -3145,7 +3149,7 @@ std::string cmTarget::GetCompilePDBPath(const char* config) const } //---------------------------------------------------------------------------- -bool cmTarget::HasSOName(const char* config) const +bool cmTarget::HasSOName(const std::string& config) const { // soname is supported only for shared libraries and modules, // and then only when the platform supports an soname flag. @@ -3157,7 +3161,7 @@ bool cmTarget::HasSOName(const char* config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetSOName(const char* config) const +std::string cmTarget::GetSOName(const std::string& config) const { if(this->IsImported()) { @@ -3199,7 +3203,7 @@ std::string cmTarget::GetSOName(const char* config) const } //---------------------------------------------------------------------------- -bool cmTarget::HasMacOSXRpathInstallNameDir(const char* config) const +bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; bool macosx_rpath = false; @@ -3311,7 +3315,8 @@ bool cmTarget::MacOSXRpathInstallNameDirDefault() const } //---------------------------------------------------------------------------- -bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config) const +bool cmTarget::IsImportedSharedLibWithoutSOName( + const std::string& config) const { if(this->IsImported() && this->GetType() == cmTarget::SHARED_LIBRARY) { @@ -3324,7 +3329,7 @@ bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config) const } //---------------------------------------------------------------------------- -std::string cmTarget::NormalGetRealName(const char* config) const +std::string cmTarget::NormalGetRealName(const std::string& config) const { // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time @@ -3362,7 +3367,8 @@ std::string cmTarget::NormalGetRealName(const char* config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullName(const char* config, bool implib) const +std::string cmTarget::GetFullName(const std::string& config, + bool implib) const { if(this->IsImported()) { @@ -3376,7 +3382,7 @@ std::string cmTarget::GetFullName(const char* config, bool implib) const //---------------------------------------------------------------------------- std::string -cmTarget::GetFullNameImported(const char* config, bool implib) const +cmTarget::GetFullNameImported(const std::string& config, bool implib) const { return cmSystemTools::GetFilenameName( this->ImportedGetFullPath(config, implib)); @@ -3384,14 +3390,15 @@ cmTarget::GetFullNameImported(const char* config, bool implib) const //---------------------------------------------------------------------------- void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base, - std::string& suffix, const char* config, + std::string& suffix, + const std::string& config, bool implib) const { this->GetFullNameInternal(config, implib, prefix, base, suffix); } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullPath(const char* config, bool implib, +std::string cmTarget::GetFullPath(const std::string& config, bool implib, bool realname) const { if(this->IsImported()) @@ -3405,8 +3412,8 @@ std::string cmTarget::GetFullPath(const char* config, bool implib, } //---------------------------------------------------------------------------- -std::string cmTarget::NormalGetFullPath(const char* config, bool implib, - bool realname) const +std::string cmTarget::NormalGetFullPath(const std::string& config, + bool implib, bool realname) const { std::string fpath = this->GetDirectory(config, implib); fpath += "/"; @@ -3434,7 +3441,7 @@ std::string cmTarget::NormalGetFullPath(const char* config, bool implib, //---------------------------------------------------------------------------- std::string -cmTarget::ImportedGetFullPath(const char* config, bool implib) const +cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const { std::string result; if(cmTarget::ImportInfo const* info = this->GetImportInfo(config, this)) @@ -3451,7 +3458,7 @@ cmTarget::ImportedGetFullPath(const char* config, bool implib) const //---------------------------------------------------------------------------- std::string -cmTarget::GetFullNameInternal(const char* config, bool implib) const +cmTarget::GetFullNameInternal(const std::string& config, bool implib) const { std::string prefix; std::string base; @@ -3461,7 +3468,7 @@ cmTarget::GetFullNameInternal(const char* config, bool implib) const } //---------------------------------------------------------------------------- -void cmTarget::GetFullNameInternal(const char* config, +void cmTarget::GetFullNameInternal(const std::string& config, bool implib, std::string& outPrefix, std::string& outBase, @@ -3507,7 +3514,7 @@ void cmTarget::GetFullNameInternal(const char* config, ? this->GetProperty("IMPORT_SUFFIX") : this->GetProperty("SUFFIX")); const char* configPostfix = 0; - if(config && *config) + if(!config.empty()) { std::string configProp = cmSystemTools::UpperCase(config); configProp += "_POSTFIX"; @@ -3604,7 +3611,7 @@ void cmTarget::GetLibraryNames(std::string& name, std::string& realName, std::string& impName, std::string& pdbName, - const char* config) const + const std::string& config) const { // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time @@ -3708,7 +3715,7 @@ void cmTarget::GetExecutableNames(std::string& name, std::string& realName, std::string& impName, std::string& pdbName, - const char* config) const + const std::string& config) const { // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time @@ -3804,7 +3811,7 @@ void cmTarget::SetPropertyDefault(const std::string& property, } //---------------------------------------------------------------------------- -bool cmTarget::HaveBuildTreeRPATH(const char *config) const +bool cmTarget::HaveBuildTreeRPATH(const std::string& config) const { if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) { @@ -3824,7 +3831,7 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -bool cmTarget::NeedRelinkBeforeInstall(const char* config) const +bool cmTarget::NeedRelinkBeforeInstall(const std::string& config) const { // Only executables and shared libraries can have an rpath and may // need relinking. @@ -3888,7 +3895,8 @@ bool cmTarget::NeedRelinkBeforeInstall(const char* config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForBuildTree(const char* config) const +std::string cmTarget::GetInstallNameDirForBuildTree( + const std::string& config) const { // If building directly for installation then the build tree install_name // is the same as the install tree. @@ -4010,10 +4018,11 @@ const char* cmTarget::GetOutputTargetType(bool implib) const } //---------------------------------------------------------------------------- -bool cmTarget::ComputeOutputDir(const char* config, +bool cmTarget::ComputeOutputDir(const std::string& config, bool implib, std::string& out) const { bool usesDefaultOutputDir = false; + std::string conf = config; // Look for a target property defining the target output directory // based on the target type. @@ -4027,7 +4036,7 @@ bool cmTarget::ComputeOutputDir(const char* config, } // Check for a per-configuration output directory target property. - std::string configUpper = cmSystemTools::UpperCase(config? config : ""); + std::string configUpper = cmSystemTools::UpperCase(conf); const char* configProp = 0; std::string configPropStr = targetTypeName; if(!configPropStr.empty()) @@ -4044,7 +4053,7 @@ bool cmTarget::ComputeOutputDir(const char* config, out = config_outdir; // Skip per-configuration subdirectory. - config = 0; + conf = ""; } else if(const char* outdir = this->GetProperty(propertyName)) { @@ -4077,21 +4086,21 @@ bool cmTarget::ComputeOutputDir(const char* config, (out.c_str(), this->Makefile->GetStartOutputDirectory())); // The generator may add the configuration's subdirectory. - if(config && *config) + if(!conf.empty()) { const char *platforms = this->Makefile->GetDefinition( "CMAKE_XCODE_EFFECTIVE_PLATFORMS"); std::string suffix = usesDefaultOutputDir && platforms ? "$(EFFECTIVE_PLATFORM_NAME)" : ""; this->Makefile->GetLocalGenerator()->GetGlobalGenerator()-> - AppendDirectoryForConfig("/", config, suffix.c_str(), out); + AppendDirectoryForConfig("/", conf, suffix.c_str(), out); } return usesDefaultOutputDir; } //---------------------------------------------------------------------------- -bool cmTarget::ComputePDBOutputDir(const char* kind, const char* config, +bool cmTarget::ComputePDBOutputDir(const char* kind, const std::string& config, std::string& out) const { // Look for a target property defining the target output directory @@ -4103,9 +4112,10 @@ bool cmTarget::ComputePDBOutputDir(const char* kind, const char* config, propertyNameStr += "_OUTPUT_DIRECTORY"; propertyName = propertyNameStr.c_str(); } + std::string conf = config; // Check for a per-configuration output directory target property. - std::string configUpper = cmSystemTools::UpperCase(config? config : ""); + std::string configUpper = cmSystemTools::UpperCase(conf); const char* configProp = 0; std::string configPropStr = kind; if(!configPropStr.empty()) @@ -4122,7 +4132,7 @@ bool cmTarget::ComputePDBOutputDir(const char* kind, const char* config, out = config_outdir; // Skip per-configuration subdirectory. - config = 0; + conf = ""; } else if(const char* outdir = this->GetProperty(propertyName)) { @@ -4141,27 +4151,29 @@ bool cmTarget::ComputePDBOutputDir(const char* kind, const char* config, (out.c_str(), this->Makefile->GetStartOutputDirectory())); // The generator may add the configuration's subdirectory. - if(config && *config) + if(!conf.empty()) { this->Makefile->GetLocalGenerator()->GetGlobalGenerator()-> - AppendDirectoryForConfig("/", config, "", out); + AppendDirectoryForConfig("/", conf, "", out); } return true; } //---------------------------------------------------------------------------- -bool cmTarget::UsesDefaultOutputDir(const char* config, bool implib) const +bool cmTarget::UsesDefaultOutputDir(const std::string& config, + bool implib) const { std::string dir; return this->ComputeOutputDir(config, implib, dir); } //---------------------------------------------------------------------------- -std::string cmTarget::GetOutputName(const char* config, bool implib) const +std::string cmTarget::GetOutputName(const std::string& config, + bool implib) const { std::vector props; std::string type = this->GetOutputTargetType(implib); - std::string configUpper = cmSystemTools::UpperCase(config? config : ""); + std::string configUpper = cmSystemTools::UpperCase(config); if(!type.empty() && !configUpper.empty()) { // _OUTPUT_NAME_ @@ -4495,7 +4507,7 @@ std::string compatibilityAgree(CompatibleType t, bool dominant) template PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, - const char *config, + const std::string& config, const char *defaultValue, CompatibleType t, PropertyType *) @@ -4679,7 +4691,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, //---------------------------------------------------------------------------- bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config) const + const std::string& config) const { return checkInterfacePropertyCompatibility(this, p, config, "FALSE", BoolType, 0); @@ -4687,8 +4699,8 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, //---------------------------------------------------------------------------- const char * cmTarget::GetLinkInterfaceDependentStringProperty( - const std::string &p, - const char *config) const + const std::string &p, + const std::string& config) const { return checkInterfacePropertyCompatibility(this, p, @@ -4699,8 +4711,8 @@ const char * cmTarget::GetLinkInterfaceDependentStringProperty( //---------------------------------------------------------------------------- const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty( - const std::string &p, - const char *config) const + const std::string &p, + const std::string& config) const { return checkInterfacePropertyCompatibility(this, p, @@ -4711,8 +4723,8 @@ const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty( //---------------------------------------------------------------------------- const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( - const std::string &p, - const char *config) const + const std::string &p, + const std::string& config) const { return checkInterfacePropertyCompatibility(this, p, @@ -4724,7 +4736,7 @@ const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( //---------------------------------------------------------------------------- bool isLinkDependentProperty(cmTarget const* tgt, const std::string &p, const std::string& interfaceProperty, - const char *config) + const std::string& config) { std::vector deps; tgt->GetTransitiveTargetClosure(config, tgt, deps); @@ -4762,7 +4774,7 @@ bool isLinkDependentProperty(cmTarget const* tgt, const std::string &p, //---------------------------------------------------------------------------- bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config) const + const std::string& config) const { if (this->TargetTypeValue == OBJECT_LIBRARY || this->TargetTypeValue == INTERFACE_LIBRARY) @@ -4776,7 +4788,7 @@ bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, //---------------------------------------------------------------------------- bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, - const char *config) const + const std::string& config) const { if (this->TargetTypeValue == OBJECT_LIBRARY || this->TargetTypeValue == INTERFACE_LIBRARY) @@ -4790,7 +4802,7 @@ bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, //---------------------------------------------------------------------------- bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const char *config) const + const std::string& config) const { if (this->TargetTypeValue == OBJECT_LIBRARY || this->TargetTypeValue == INTERFACE_LIBRARY) @@ -4803,7 +4815,7 @@ bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p, //---------------------------------------------------------------------------- bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const char *config) const + const std::string& config) const { if (this->TargetTypeValue == OBJECT_LIBRARY || this->TargetTypeValue == INTERFACE_LIBRARY) @@ -4829,7 +4841,7 @@ void cmTarget::GetLanguages(std::set& languages) const } //---------------------------------------------------------------------------- -bool cmTarget::IsChrpathUsed(const char* config) const +bool cmTarget::IsChrpathUsed(const std::string& config) const { // Only certain target types have an rpath. if(!(this->GetType() == cmTarget::SHARED_LIBRARY || @@ -4897,7 +4909,8 @@ bool cmTarget::IsChrpathUsed(const char* config) const //---------------------------------------------------------------------------- cmTarget::ImportInfo const* -cmTarget::GetImportInfo(const char* config, cmTarget const* headTarget) const +cmTarget::GetImportInfo(const std::string& config, + cmTarget const* headTarget) const { // There is no imported information for non-imported targets. if(!this->IsImported()) @@ -4908,7 +4921,7 @@ cmTarget::GetImportInfo(const char* config, cmTarget const* headTarget) const // Lookup/compute/cache the import information for this // configuration. std::string config_upper; - if(config && *config) + if(!config.empty()) { config_upper = cmSystemTools::UpperCase(config); } @@ -5262,7 +5275,8 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } //---------------------------------------------------------------------------- -cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config, +cmTarget::LinkInterface const* cmTarget::GetLinkInterface( + const std::string& config, cmTarget const* head) const { // Imported targets have their own link interface. @@ -5284,7 +5298,7 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config, } // Lookup any existing link interface for this configuration. - TargetConfigPair key(head, cmSystemTools::UpperCase(config? config : "")); + TargetConfigPair key(head, cmSystemTools::UpperCase(config)); cmTargetInternals::LinkInterfaceMapType::iterator i = this->Internal->LinkInterfaceMap.find(key); @@ -5315,7 +5329,7 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config, //---------------------------------------------------------------------------- cmTarget::LinkInterface const* -cmTarget::GetLinkInterfaceLibraries(const char* config, +cmTarget::GetLinkInterfaceLibraries(const std::string& config, cmTarget const* head) const { // Imported targets have their own link interface. @@ -5337,7 +5351,7 @@ cmTarget::GetLinkInterfaceLibraries(const char* config, } // Lookup any existing link interface for this configuration. - TargetConfigPair key(head, cmSystemTools::UpperCase(config? config : "")); + TargetConfigPair key(head, cmSystemTools::UpperCase(config)); cmTargetInternals::LinkInterfaceMapType::iterator i = this->Internal->LinkInterfaceMap.find(key); @@ -5359,7 +5373,7 @@ cmTarget::GetLinkInterfaceLibraries(const char* config, } //---------------------------------------------------------------------------- -void processILibs(const char* config, +void processILibs(const std::string& config, cmTarget const* headTarget, std::string const& name, std::vector& tgts, std::set& emitted) @@ -5387,7 +5401,7 @@ void processILibs(const char* config, } //---------------------------------------------------------------------------- -void cmTarget::GetTransitiveTargetClosure(const char* config, +void cmTarget::GetTransitiveTargetClosure(const std::string& config, cmTarget const* headTarget, std::vector &tgts) const { @@ -5404,7 +5418,7 @@ void cmTarget::GetTransitiveTargetClosure(const char* config, } //---------------------------------------------------------------------------- -void cmTarget::GetTransitivePropertyTargets(const char* config, +void cmTarget::GetTransitivePropertyTargets(const std::string& config, cmTarget const* headTarget, std::vector &tgts) const { @@ -5464,14 +5478,14 @@ void cmTarget::GetTransitivePropertyTargets(const char* config, } //---------------------------------------------------------------------------- -const char* cmTarget::ComputeLinkInterfaceLibraries(const char* config, +const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, LinkInterface& iface, cmTarget const* headTarget, bool &exists) const { // Construct the property name suffix for this configuration. std::string suffix = "_"; - if(config && *config) + if(!config.empty()) { suffix += cmSystemTools::UpperCase(config); } @@ -5642,7 +5656,7 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const char* config, //---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, - const char* config, + const std::string& config, OptionalLinkInterface& iface, cmTarget const* headTarget, const char* explicitLibraries) const @@ -5714,7 +5728,7 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, { // Construct the property name suffix for this configuration. std::string suffix = "_"; - if(config && *config) + if(!config.empty()) { suffix += cmSystemTools::UpperCase(config); } @@ -5742,7 +5756,8 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, //---------------------------------------------------------------------------- cmTarget::LinkImplementation const* -cmTarget::GetLinkImplementation(const char* config, cmTarget const* head) const +cmTarget::GetLinkImplementation(const std::string& config, + cmTarget const* head) const { // There is no link implementation for imported targets. if(this->IsImported()) @@ -5751,7 +5766,7 @@ cmTarget::GetLinkImplementation(const char* config, cmTarget const* head) const } // Lookup any existing link implementation for this configuration. - TargetConfigPair key(head, cmSystemTools::UpperCase(config? config : "")); + TargetConfigPair key(head, cmSystemTools::UpperCase(config)); cmTargetInternals::LinkImplMapType::iterator i = this->Internal->LinkImplMap.find(key); @@ -5776,7 +5791,7 @@ cmTarget::GetLinkImplementation(const char* config, cmTarget const* head) const //---------------------------------------------------------------------------- cmTarget::LinkImplementation const* -cmTarget::GetLinkImplementationLibraries(const char* config, +cmTarget::GetLinkImplementationLibraries(const std::string& config, cmTarget const* head) const { // There is no link implementation for imported targets. @@ -5786,7 +5801,7 @@ cmTarget::GetLinkImplementationLibraries(const char* config, } // Lookup any existing link implementation for this configuration. - TargetConfigPair key(head, cmSystemTools::UpperCase(config? config : "")); + TargetConfigPair key(head, cmSystemTools::UpperCase(config)); cmTargetInternals::LinkImplMapType::iterator i = this->Internal->LinkImplMap.find(key); @@ -5805,7 +5820,7 @@ cmTarget::GetLinkImplementationLibraries(const char* config, } //---------------------------------------------------------------------------- -void cmTarget::ComputeLinkImplementation(const char* config, +void cmTarget::ComputeLinkImplementation(const std::string& config, LinkImplementation& impl, cmTarget const* head) const { @@ -5970,14 +5985,14 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const template PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, const std::string& prop, - const char *config, + const std::string& config, CompatibleType, PropertyType *); template<> bool getLinkInterfaceDependentProperty(cmTarget const* tgt, const std::string& prop, - const char *config, + const std::string& config, CompatibleType, bool *) { return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); @@ -5986,7 +6001,7 @@ bool getLinkInterfaceDependentProperty(cmTarget const* tgt, template<> const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, const std::string& prop, - const char *config, + const std::string& config, CompatibleType t, const char **) { @@ -6012,7 +6027,7 @@ void checkPropertyConsistency(cmTarget const* depender, cmTarget const* dependee, const std::string& propName, std::set &emitted, - const char *config, + const std::string& config, CompatibleType t, PropertyType *) { @@ -6101,7 +6116,7 @@ static std::string intersect(const std::set &s1, //---------------------------------------------------------------------------- void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, - const char* config) const + const std::string& config) const { const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); @@ -6205,12 +6220,12 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, //---------------------------------------------------------------------------- cmComputeLinkInformation* -cmTarget::GetLinkInformation(const char* config, cmTarget const* head) const +cmTarget::GetLinkInformation(const std::string& config, + cmTarget const* head) const { cmTarget const* headTarget = head ? head : this; // Lookup any existing information for this configuration. - TargetConfigPair key(headTarget, - cmSystemTools::UpperCase(config?config:"")); + TargetConfigPair key(headTarget, cmSystemTools::UpperCase(config)); cmTargetLinkInformationMap::iterator i = this->LinkInformation.find(key); if(i == this->LinkInformation.end()) @@ -6237,7 +6252,7 @@ cmTarget::GetLinkInformation(const char* config, cmTarget const* head) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetFrameworkDirectory(const char* config, +std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { std::string fpath; @@ -6252,7 +6267,7 @@ std::string cmTarget::GetFrameworkDirectory(const char* config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetCFBundleDirectory(const char* config, +std::string cmTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { std::string fpath; @@ -6271,7 +6286,7 @@ std::string cmTarget::GetCFBundleDirectory(const char* config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetAppBundleDirectory(const char* config, +std::string cmTarget::GetAppBundleDirectory(const std::string& config, bool contentOnly) const { std::string fpath = this->GetFullName(config, false); @@ -6283,7 +6298,7 @@ std::string cmTarget::GetAppBundleDirectory(const char* config, //---------------------------------------------------------------------------- std::string cmTarget::BuildMacContentDirectory(const std::string& base, - const char* config, + const std::string& config, bool contentOnly) const { std::string fpath = base; @@ -6303,7 +6318,7 @@ std::string cmTarget::BuildMacContentDirectory(const std::string& base, } //---------------------------------------------------------------------------- -std::string cmTarget::GetMacContentDirectory(const char* config, +std::string cmTarget::GetMacContentDirectory(const std::string& config, bool implib) const { // Start with the output directory for the target. diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 41f84a6..65fbb0f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -155,15 +155,15 @@ public: return this->LinkLibraries;} const LinkLibraryVectorType &GetOriginalLinkLibraries() const {return this->OriginalLinkLibraries;} - void GetDirectLinkLibraries(const char *config, + void GetDirectLinkLibraries(const std::string& config, std::vector &, cmTarget const* head) const; - void GetInterfaceLinkLibraries(const char *config, + void GetInterfaceLinkLibraries(const std::string& config, std::vector &, cmTarget const* head) const; /** Compute the link type to use for the given configuration. */ - LinkLibraryType ComputeLinkType(const char* config) const; + LinkLibraryType ComputeLinkType(const std::string& config) const; /** * Clear the dependency information recorded for this target, if any. @@ -232,7 +232,8 @@ public: bool GetPropertyAsBool(const std::string& prop) const; void CheckProperty(const std::string& prop, cmMakefile* context) const; - const char* GetFeature(const char* feature, const char* config) const; + const char* GetFeature(const char* feature, + const std::string& config) const; bool IsImported() const {return this->IsImportedTarget;} @@ -264,14 +265,14 @@ public: /** Get the link interface for the given configuration. Returns 0 if the target cannot be linked. */ - LinkInterface const* GetLinkInterface(const char* config, + LinkInterface const* GetLinkInterface(const std::string& config, cmTarget const* headTarget) const; - LinkInterface const* GetLinkInterfaceLibraries(const char* config, + LinkInterface const* GetLinkInterfaceLibraries(const std::string& config, cmTarget const* headTarget) const; - void GetTransitivePropertyTargets(const char* config, + void GetTransitivePropertyTargets(const std::string& config, cmTarget const* headTarget, std::vector &libs) const; - void GetTransitiveTargetClosure(const char* config, + void GetTransitiveTargetClosure(const std::string& config, cmTarget const* headTarget, std::vector &libs) const; @@ -289,10 +290,11 @@ public: // Needed only for OLD behavior of CMP0003. std::vector WrongConfigLibraries; }; - LinkImplementation const* GetLinkImplementation(const char* config, + LinkImplementation const* GetLinkImplementation(const std::string& config, cmTarget const* head) const; - LinkImplementation const* GetLinkImplementationLibraries(const char* config, + LinkImplementation const* GetLinkImplementationLibraries( + const std::string& config, cmTarget const* head) const; /** Link information from the transitive closure of the link @@ -305,7 +307,7 @@ public: // Languages whose runtime libraries must be linked. std::vector Languages; }; - LinkClosure const* GetLinkClosure(const char* config, + LinkClosure const* GetLinkClosure(const std::string& config, cmTarget const* head) const; /** Strip off leading and trailing whitespace from an item named in @@ -316,23 +318,24 @@ public: configuration name is given then the generator will add its subdirectory for that configuration. Otherwise just the canonical output directory is given. */ - std::string GetDirectory(const char* config = 0, bool implib = false) const; + std::string GetDirectory(const std::string& config = "", + bool implib = false) const; /** Get the directory in which this targets .pdb files will be placed. If the configuration name is given then the generator will add its subdirectory for that configuration. Otherwise just the canonical pdb output directory is given. */ - std::string GetPDBDirectory(const char* config) const; + std::string GetPDBDirectory(const std::string& config) const; /** Get the directory in which to place the target compiler .pdb file. If the configuration name is given then the generator will add its subdirectory for that configuration. Otherwise just the canonical compiler pdb output directory is given. */ - std::string GetCompilePDBDirectory(const char* config = 0) const; + std::string GetCompilePDBDirectory(const std::string& config = "") const; /** Get the location of the target in the build tree for the given configuration. */ - const char* GetLocation(const char* config) const; + const char* GetLocation(const std::string& config) const; /** Get the location of the target in the build tree with a placeholder referencing the configuration in the native build system. This @@ -351,44 +354,46 @@ public: GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; ///! Return the preferred linker language for this target - std::string GetLinkerLanguage(const char* config = 0, + std::string GetLinkerLanguage(const std::string& config = "", cmTarget const* head = 0) const; /** Get the full name of the target according to the settings in its makefile. */ - std::string GetFullName(const char* config=0, bool implib = false) const; + std::string GetFullName(const std::string& config="", + bool implib = false) const; void GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, - const char* config=0, bool implib = false) const; + const std::string& config="", + bool implib = false) const; /** Get the name of the pdb file for the target. */ - std::string GetPDBName(const char* config) const; + std::string GetPDBName(const std::string& config) const; /** Get the name of the compiler pdb file for the target. */ - std::string GetCompilePDBName(const char* config=0) const; + std::string GetCompilePDBName(const std::string& config="") const; /** Get the path for the MSVC /Fd option for this target. */ - std::string GetCompilePDBPath(const char* config=0) const; + std::string GetCompilePDBPath(const std::string& config="") const; /** Whether this library has soname enabled and platform supports it. */ - bool HasSOName(const char* config) const; + bool HasSOName(const std::string& config) const; /** Get the soname of the target. Allowed only for a shared library. */ - std::string GetSOName(const char* config) const; + std::string GetSOName(const std::string& config) const; /** Whether this library has \@rpath and platform supports it. */ - bool HasMacOSXRpathInstallNameDir(const char* config) const; + bool HasMacOSXRpathInstallNameDir(const std::string& config) const; /** Whether this library defaults to \@rpath. */ bool MacOSXRpathInstallNameDirDefault() const; /** Test for special case of a third-party shared library that has no soname at all. */ - bool IsImportedSharedLibWithoutSOName(const char* config) const; + bool IsImportedSharedLibWithoutSOName(const std::string& config) const; /** Get the full path to the target according to the settings in its makefile and the configuration type. */ - std::string GetFullPath(const char* config=0, bool implib = false, + std::string GetFullPath(const std::string& config="", bool implib = false, bool realname = false) const; /** Get the names of the library needed to generate a build rule @@ -396,14 +401,15 @@ public: should be called only on a library target. */ void GetLibraryNames(std::string& name, std::string& soName, std::string& realName, std::string& impName, - std::string& pdbName, const char* config) const; + std::string& pdbName, const std::string& config) const; /** Get the names of the executable needed to generate a build rule that takes into account executable version numbers. This should be called only on an executable target. */ void GetExecutableNames(std::string& name, std::string& realName, std::string& impName, - std::string& pdbName, const char* config) const; + std::string& pdbName, + const std::string& config) const; /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; @@ -416,24 +422,24 @@ public: /** * Compute whether this target must be relinked before installing. */ - bool NeedRelinkBeforeInstall(const char* config) const; + bool NeedRelinkBeforeInstall(const std::string& config) const; - bool HaveBuildTreeRPATH(const char *config) const; + bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; /** Return true if builtin chrpath will work for this target */ - bool IsChrpathUsed(const char* config) const; + bool IsChrpathUsed(const std::string& config) const; /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ - std::string GetInstallNameDirForBuildTree(const char* config) const; + std::string GetInstallNameDirForBuildTree(const std::string& config) const; /** Return the install name directory for the target in the * install tree. For example: "\@rpath/" or "\@loader_path/". */ std::string GetInstallNameDirForInstallTree() const; - cmComputeLinkInformation* GetLinkInformation(const char* config, + cmComputeLinkInformation* GetLinkInformation(const std::string& config, cmTarget const* head = 0) const; // Get the properties @@ -452,7 +458,7 @@ public: const char* GetExportMacro() const; void GetCompileDefinitions(std::vector &result, - const char *config) const; + const std::string& config) const; // Compute the set of languages compiled by the target. This is // computed every time it is called because the languages can change @@ -500,26 +506,29 @@ public: /** Return whether this target uses the default value for its output directory. */ - bool UsesDefaultOutputDir(const char* config, bool implib) const; + bool UsesDefaultOutputDir(const std::string& config, bool implib) const; /** @return the mac content directory for this target. */ - std::string GetMacContentDirectory(const char* config, + std::string GetMacContentDirectory(const std::string& config, bool implib) const; /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; /** @return the Mac framework directory without the base. */ - std::string GetFrameworkDirectory(const char* config, bool rootDir) const; + std::string GetFrameworkDirectory(const std::string& config, + bool rootDir) const; /** @return the Mac CFBundle directory without the base */ - std::string GetCFBundleDirectory(const char* config, bool contentOnly) const; + std::string GetCFBundleDirectory(const std::string& config, + bool contentOnly) const; /** @return the Mac App directory without the base */ - std::string GetAppBundleDirectory(const char* config, + std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; - std::vector GetIncludeDirectories(const char *config) const; + std::vector GetIncludeDirectories( + const std::string& config) const; void InsertInclude(const cmValueWithOrigin &entry, bool before = false); void InsertCompileOption(const cmValueWithOrigin &entry, @@ -529,29 +538,29 @@ public: void AppendBuildInterfaceIncludes(); void GetCompileOptions(std::vector &result, - const char *config) const; + const std::string& config) const; void GetAutoUicOptions(std::vector &result, - const char *config) const; + const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; bool IsLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config) const; + const std::string& config) const; bool IsLinkInterfaceDependentStringProperty(const std::string &p, - const char *config) const; + const std::string& config) const; bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const char *config) const; + const std::string& config) const; bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const char *config) const; + const std::string& config) const; bool GetLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config) const; + const std::string& config) const; const char *GetLinkInterfaceDependentStringProperty(const std::string &p, - const char *config) const; + const std::string& config) const; const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, - const char *config) const; + const std::string& config) const; const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const char *config) const; + const std::string& config) const; std::string GetDebugGeneratorExpressions(const std::string &value, cmTarget::LinkLibraryType llt) const; @@ -631,8 +640,9 @@ private: const char* GetSuffixVariableInternal(bool implib) const; const char* GetPrefixVariableInternal(bool implib) const; - std::string GetFullNameInternal(const char* config, bool implib) const; - void GetFullNameInternal(const char* config, bool implib, + std::string GetFullNameInternal(const std::string& config, + bool implib) const; + void GetFullNameInternal(const std::string& config, bool implib, std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; @@ -645,23 +655,25 @@ private: const char* GetOutputTargetType(bool implib) const; // Get the target base name. - std::string GetOutputName(const char* config, bool implib) const; + std::string GetOutputName(const std::string& config, bool implib) const; - std::string GetFullNameImported(const char* config, bool implib) const; + std::string GetFullNameImported(const std::string& config, + bool implib) const; - std::string ImportedGetFullPath(const char* config, bool implib) const; - std::string NormalGetFullPath(const char* config, bool implib, + std::string ImportedGetFullPath(const std::string& config, + bool implib) const; + std::string NormalGetFullPath(const std::string& config, bool implib, bool realname) const; /** Get the real name of the target. Allowed only for non-imported targets. When a library or executable file is versioned this is the full versioned name. If the target is not versioned this is the same as GetFullName. */ - std::string NormalGetRealName(const char* config) const; + std::string NormalGetRealName(const std::string& config) const; /** Append to @a base the mac content directory and return it. */ std::string BuildMacContentDirectory(const std::string& base, - const char* config, + const std::string& config, bool contentOnly) const; private: @@ -698,37 +710,38 @@ private: // Cache target output paths for each configuration. struct OutputInfo; - OutputInfo const* GetOutputInfo(const char* config) const; + OutputInfo const* GetOutputInfo(const std::string& config) const; bool - ComputeOutputDir(const char* config, bool implib, std::string& out) const; - bool ComputePDBOutputDir(const char* kind, const char* config, + ComputeOutputDir(const std::string& config, + bool implib, std::string& out) const; + bool ComputePDBOutputDir(const char* kind, const std::string& config, std::string& out) const; // Cache import information from properties for each configuration. struct ImportInfo; - ImportInfo const* GetImportInfo(const char* config, + ImportInfo const* GetImportInfo(const std::string& config, cmTarget const* workingTarget) const; void ComputeImportInfo(std::string const& desired_config, ImportInfo& info, cmTarget const* head) const; // Cache target compile paths for each configuration. struct CompileInfo; - CompileInfo const* GetCompileInfo(const char* config) const; + CompileInfo const* GetCompileInfo(const std::string& config) const; mutable cmTargetLinkInformationMap LinkInformation; void CheckPropertyCompatibility(cmComputeLinkInformation *info, - const char* config) const; + const std::string& config) const; - const char* ComputeLinkInterfaceLibraries(const char* config, + const char* ComputeLinkInterfaceLibraries(const std::string& config, LinkInterface& iface, cmTarget const* head, bool &exists) const; - void ComputeLinkImplementation(const char* config, + void ComputeLinkImplementation(const std::string& config, LinkImplementation& impl, cmTarget const* head) const; void ComputeLinkImplementationLanguages(LinkImplementation& impl) const; - void ComputeLinkClosure(const char* config, LinkClosure& lc, + void ComputeLinkClosure(const std::string& config, LinkClosure& lc, cmTarget const* head) const; void ClearLinkMaps(); diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 5dc3e60..a21e1aa 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -64,7 +64,7 @@ void cmTestGenerator::GenerateScriptActions(std::ostream& os, //---------------------------------------------------------------------------- void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, - const char* config, + const std::string& config, Indent const& indent) { this->TestGenerated = true; diff --git a/Source/cmTestGenerator.h b/Source/cmTestGenerator.h index 2c69fc3..5446553 100644 --- a/Source/cmTestGenerator.h +++ b/Source/cmTestGenerator.h @@ -32,7 +32,7 @@ protected: virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent); virtual void GenerateScriptActions(std::ostream& os, Indent const& indent); virtual void GenerateScriptForConfig(std::ostream& os, - const char* config, + const std::string& config, Indent const& indent); virtual void GenerateScriptNoConfig(std::ostream& os, Indent const& indent); virtual bool NeedsScriptNoConfig() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index aa721b7..90155b4 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -140,7 +140,7 @@ cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator() void cmVisualStudio10TargetGenerator::WritePlatformConfigTag( const char* tag, - const char* config, + const std::string& config, int indentLevel, const char* attribute, const char* end, diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 8d69254..02b951c 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -35,7 +35,7 @@ public: // used by cmVisualStudioGeneratorOptions void WritePlatformConfigTag( const char* tag, - const char* config, + const std::string& config, int indentLevel, const char* attribute = 0, const char* end = 0, diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index 8eaf2aa..3a6528a 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -122,26 +122,18 @@ public: void CopyAttributes(cmXCodeObject* ); - void AddDependLibrary(const char* configName, + void AddDependLibrary(const std::string& configName, const std::string& l) { - if(!configName) - { - configName = ""; - } this->DependLibraries[configName].push_back(l); } std::map const& GetDependLibraries() { return this->DependLibraries; } - void AddDependTarget(const char* configName, + void AddDependTarget(const std::string& configName, const std::string& tName) { - if(!configName) - { - configName = ""; - } this->DependTargets[configName].push_back(tName); } std::map const& GetDependTargets() diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 603b6d0..047f09d 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -666,7 +666,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) else if (args[1] == "cmake_autogen" && args.size() >= 4) { cmQtAutoGenerators autogen; - const char *config = args[3].empty() ? 0 : args[3].c_str(); + std::string const& config = args[3]; bool autogenSuccess = autogen.Run(args[2].c_str(), config); return autogenSuccess ? 0 : 1; } -- cgit v0.12 From acb116e3b52362b41988aa27eeb593dd2e7194c0 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 9 Feb 2014 23:07:44 -0500 Subject: stringapi: Return a string reference for the configuration --- Source/cmLocalNinjaGenerator.h | 4 ++-- Source/cmNinjaTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.h | 2 +- Source/cmSourceFileLocation.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 8b26806..2d870fb 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -55,8 +55,8 @@ public: const cmake* GetCMakeInstance() const; cmake* GetCMakeInstance(); - const char* GetConfigName() const - { return this->ConfigName.c_str(); } + std::string const& GetConfigName() const + { return this->ConfigName; } /// @return whether we are processing the top CMakeLists.txt file. bool isRootMakefile() const; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 1c43cb3..78ff4e4 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -91,7 +91,7 @@ cmGlobalNinjaGenerator* cmNinjaTargetGenerator::GetGlobalGenerator() const return this->LocalGenerator->GetGlobalNinjaGenerator(); } -const char* cmNinjaTargetGenerator::GetConfigName() const +std::string const& cmNinjaTargetGenerator::GetConfigName() const { return this->LocalGenerator->GetConfigName(); } diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index b3b37a4..c2e1947 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -65,7 +65,7 @@ protected: cmMakefile* GetMakefile() const { return this->Makefile; } - const char* GetConfigName() const; + std::string const& GetConfigName() const; std::string LanguageCompilerRule(const std::string& lang) const { return lang + "_COMPILER"; } diff --git a/Source/cmSourceFileLocation.h b/Source/cmSourceFileLocation.h index 64b8c1f..c83e8c0 100644 --- a/Source/cmSourceFileLocation.h +++ b/Source/cmSourceFileLocation.h @@ -76,7 +76,7 @@ public: * final name (but could be). Otherwise the returned name is the * final name. */ - const char* GetName() const { return this->Name.c_str(); } + const std::string& GetName() const { return this->Name; } /** * Get the cmMakefile instance for which the source file was created. -- cgit v0.12 From 3def29da3c16ad3a72f05ea8b97ee728e6e3581e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 9 Feb 2014 23:09:05 -0500 Subject: stringapi: Use strings for feature arguments --- Source/cmMakefile.cxx | 2 +- Source/cmMakefile.h | 3 ++- Source/cmMakefileTargetGenerator.cxx | 4 ++-- Source/cmMakefileTargetGenerator.h | 4 ++-- Source/cmNinjaTargetGenerator.cxx | 4 ++-- Source/cmNinjaTargetGenerator.h | 4 ++-- Source/cmTarget.cxx | 2 +- Source/cmTarget.h | 2 +- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 1ef4d46..bb88bc4 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3801,7 +3801,7 @@ bool cmMakefile::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -const char* cmMakefile::GetFeature(const char* feature, +const char* cmMakefile::GetFeature(const std::string& feature, const std::string& config) { // TODO: Define accumulation policy for features (prepend, append, replace). diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1c3ad73..7c82ec2 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -811,7 +811,8 @@ public: cmProperty::ScopeType scope) const; bool GetPropertyAsBool(const std::string& prop) const; - const char* GetFeature(const char* feature, const std::string& config); + const char* GetFeature(const std::string& feature, + const std::string& config); // Get the properties cmPropertyMap &GetProperties() { return this->Properties; }; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 1af5d6c..f0c9a3f 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -2105,13 +2105,13 @@ void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags) } //---------------------------------------------------------------------------- -const char* cmMakefileTargetGenerator::GetFeature(const char* feature) +const char* cmMakefileTargetGenerator::GetFeature(const std::string& feature) { return this->Target->GetFeature(feature, this->ConfigName); } //---------------------------------------------------------------------------- -bool cmMakefileTargetGenerator::GetFeatureAsBool(const char* feature) +bool cmMakefileTargetGenerator::GetFeatureAsBool(const std::string& feature) { return cmSystemTools::IsOn(this->GetFeature(feature)); } diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 21eece4..573ce22 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -263,8 +263,8 @@ protected: void AddFeatureFlags(std::string& flags, const std::string& lang); // Feature query methods. - const char* GetFeature(const char* feature); - bool GetFeatureAsBool(const char* feature); + const char* GetFeature(const std::string& feature); + bool GetFeatureAsBool(const std::string& feature); //================================================================== // Convenience routines that do nothing more than forward to diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 78ff4e4..3ef236a 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -97,13 +97,13 @@ std::string const& cmNinjaTargetGenerator::GetConfigName() const } // TODO: Picked up from cmMakefileTargetGenerator. Refactor it. -const char* cmNinjaTargetGenerator::GetFeature(const char* feature) +const char* cmNinjaTargetGenerator::GetFeature(const std::string& feature) { return this->Target->GetFeature(feature, this->GetConfigName()); } // TODO: Picked up from cmMakefileTargetGenerator. Refactor it. -bool cmNinjaTargetGenerator::GetFeatureAsBool(const char* feature) +bool cmNinjaTargetGenerator::GetFeatureAsBool(const std::string& feature) { return cmSystemTools::IsOn(this->GetFeature(feature)); } diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index c2e1947..e66e55f 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -70,8 +70,8 @@ protected: std::string LanguageCompilerRule(const std::string& lang) const { return lang + "_COMPILER"; } - const char* GetFeature(const char* feature); - bool GetFeatureAsBool(const char* feature); + const char* GetFeature(const std::string& feature); + bool GetFeatureAsBool(const std::string& feature); void AddFeatureFlags(std::string& flags, const std::string& lang); /** diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b8e662a..25ca168 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2549,7 +2549,7 @@ void cmTarget::GetTargetVersion(bool soversion, } //---------------------------------------------------------------------------- -const char* cmTarget::GetFeature(const char* feature, +const char* cmTarget::GetFeature(const std::string& feature, const std::string& config) const { if(!config.empty()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 65fbb0f..15f00be 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -232,7 +232,7 @@ public: bool GetPropertyAsBool(const std::string& prop) const; void CheckProperty(const std::string& prop, cmMakefile* context) const; - const char* GetFeature(const char* feature, + const char* GetFeature(const std::string& feature, const std::string& config) const; bool IsImported() const {return this->IsImportedTarget;} -- cgit v0.12 From 2b17626e9b0ffbd5b3adf81e64aae975a35c8b6b Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 7 Feb 2014 14:43:19 -0500 Subject: stringapi: Pass strings as install directories in CPack --- Source/CPack/cmCPackGenerator.cxx | 18 +++++++++--------- Source/CPack/cmCPackGenerator.h | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 4c52c96..3e1bf3b 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -254,7 +254,7 @@ int cmCPackGenerator::InstallProject() // If the project is a CMAKE project then run pre-install // and then read the cmake_install script to run it if ( !this->InstallProjectViaInstallCMakeProjects( - setDestDir, bareTempInstallDirectory.c_str()) ) + setDestDir, bareTempInstallDirectory) ) { return 0; } @@ -269,7 +269,7 @@ int cmCPackGenerator::InstallProject() //---------------------------------------------------------------------- int cmCPackGenerator::InstallProjectViaInstallCommands( - bool setDestDir, const char* tempInstallDirectory) + bool setDestDir, const std::string& tempInstallDirectory) { (void) setDestDir; const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS"); @@ -312,7 +312,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( //---------------------------------------------------------------------- int cmCPackGenerator::InstallProjectViaInstalledDirectories( - bool setDestDir, const char* tempInstallDirectory) + bool setDestDir, const std::string& tempInstallDirectory) { (void)setDestDir; (void)tempInstallDirectory; @@ -349,7 +349,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( return 0; } std::vector::iterator it; - const char* tempDir = tempInstallDirectory; + const std::string& tempDir = tempInstallDirectory; for ( it = installDirectoriesVector.begin(); it != installDirectoriesVector.end(); ++it ) @@ -457,7 +457,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( //---------------------------------------------------------------------- int cmCPackGenerator::InstallProjectViaInstallScript( - bool setDestDir, const char* tempInstallDirectory) + bool setDestDir, const std::string& tempInstallDirectory) { const char* cmakeScripts = this->GetOption("CPACK_INSTALL_SCRIPT"); @@ -499,7 +499,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript( } else { - this->SetOption("CMAKE_INSTALL_PREFIX", tempInstallDirectory); + this->SetOption("CMAKE_INSTALL_PREFIX", tempInstallDirectory.c_str()); cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Using non-DESTDIR install... (this->SetOption)" << std::endl); @@ -509,9 +509,9 @@ int cmCPackGenerator::InstallProjectViaInstallScript( } this->SetOptionIfNotSet("CMAKE_CURRENT_BINARY_DIR", - tempInstallDirectory); + tempInstallDirectory.c_str()); this->SetOptionIfNotSet("CMAKE_CURRENT_SOURCE_DIR", - tempInstallDirectory); + tempInstallDirectory.c_str()); int res = this->MakefileMap->ReadListFile(0, installScript.c_str()); if ( cmSystemTools::GetErrorOccuredFlag() || !res ) { @@ -524,7 +524,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript( //---------------------------------------------------------------------- int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( - bool setDestDir, const char* baseTempInstallDirectory) + bool setDestDir, const std::string& baseTempInstallDirectory) { const char* cmakeProjects = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS"); diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 7e7c94f..fadd1bf 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -190,13 +190,13 @@ protected: //! Run install commands if specified virtual int InstallProjectViaInstallCommands( - bool setDestDir, const char* tempInstallDirectory); + bool setDestDir, const std::string& tempInstallDirectory); virtual int InstallProjectViaInstallScript( - bool setDestDir, const char* tempInstallDirectory); + bool setDestDir, const std::string& tempInstallDirectory); virtual int InstallProjectViaInstalledDirectories( - bool setDestDir, const char* tempInstallDirectory); + bool setDestDir, const std::string& tempInstallDirectory); virtual int InstallProjectViaInstallCMakeProjects( - bool setDestDir, const char* tempInstallDirectory); + bool setDestDir, const std::string& tempInstallDirectory); /** * The various level of support of -- cgit v0.12 From 5af95c396dc780c04444f549b957c2cba7c75309 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 21 Feb 2014 18:42:53 -0500 Subject: typo: Match argument name with the header --- Source/cmGlobalGenerator.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 70cc16f..b7af21b 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -988,13 +988,13 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const std::string& l, } } -bool cmGlobalGenerator::IgnoreFile(const char* l) const +bool cmGlobalGenerator::IgnoreFile(const char* ext) const { - if(!this->GetLanguageFromExtension(l).empty()) + if(!this->GetLanguageFromExtension(ext).empty()) { return false; } - return (this->IgnoreExtensions.count(l) > 0); + return (this->IgnoreExtensions.count(ext) > 0); } bool cmGlobalGenerator::GetLanguageEnabled(const std::string& l) const -- cgit v0.12 From b3bf31a5488a19ea3c357e346b882a2ca84c63b6 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 21 Feb 2014 19:05:55 -0500 Subject: stringapi: Miscellaneous char* parameters --- Source/CPack/WiX/cmWIXPatchParser.cxx | 12 ++++----- Source/CPack/WiX/cmWIXPatchParser.h | 4 +-- Source/CPack/cmCPackComponentGroup.cxx | 5 ++-- Source/CPack/cmCPackComponentGroup.h | 4 +-- Source/CPack/cmCPackGenerator.cxx | 2 +- Source/CPack/cmCPackGenerator.h | 2 +- Source/CPack/cmCPackOSXX11Generator.cxx | 2 +- Source/CPack/cmCPackOSXX11Generator.h | 2 +- Source/CPack/cmCPackPackageMakerGenerator.cxx | 15 +++++------ Source/CPack/cmCPackPackageMakerGenerator.h | 8 +++--- Source/CTest/cmCTestBZR.cxx | 36 +++++++++++++-------------- Source/CTest/cmCTestBuildCommand.cxx | 4 +-- Source/CTest/cmCTestHG.cxx | 22 ++++++++-------- Source/CTest/cmCTestMemCheckHandler.cxx | 18 +++++--------- Source/CTest/cmCTestSVN.cxx | 18 +++++++------- Source/CTest/cmCTestSubmitHandler.cxx | 14 +++++------ Source/CTest/cmParsePythonCoverage.cxx | 8 +++--- Source/CursesDialog/cmCursesOptionsWidget.cxx | 2 +- Source/CursesDialog/cmCursesOptionsWidget.h | 2 +- Source/CursesDialog/cmCursesStringWidget.cxx | 2 +- Source/CursesDialog/cmCursesStringWidget.h | 2 +- Source/CursesDialog/cmCursesWidget.cxx | 4 +-- Source/CursesDialog/cmCursesWidget.h | 2 +- Source/cmCacheManager.cxx | 4 +-- Source/cmCacheManager.h | 2 +- Source/cmExportFileGenerator.h | 2 +- Source/cmGlobalGenerator.cxx | 9 ++++--- Source/cmGlobalGenerator.h | 8 +++--- Source/cmGlobalVisualStudio6Generator.cxx | 4 +-- Source/cmGlobalVisualStudio6Generator.h | 4 +-- Source/cmGlobalVisualStudio7Generator.cxx | 6 ++--- Source/cmGlobalVisualStudio7Generator.h | 6 ++--- Source/cmGlobalXCodeGenerator.cxx | 14 +++++------ Source/cmGlobalXCodeGenerator.h | 4 +-- Source/cmLocalUnixMakefileGenerator3.cxx | 2 +- Source/cmLocalUnixMakefileGenerator3.h | 10 +++++--- Source/cmLocalVisualStudio10Generator.cxx | 8 +++--- Source/cmLocalVisualStudio10Generator.h | 2 +- Source/cmLocalVisualStudio7Generator.cxx | 8 +++--- Source/cmLocalVisualStudio7Generator.h | 4 +-- Source/cmLocalVisualStudioGenerator.cxx | 4 +-- Source/cmLocalVisualStudioGenerator.h | 2 +- Source/cmTarget.cxx | 3 ++- Source/cmTarget.h | 2 +- Source/cmVisualStudioWCEPlatformParser.cxx | 20 +++++++-------- Source/cmVisualStudioWCEPlatformParser.h | 4 +-- Source/cmXCodeObject.h | 18 +++++++------- Source/cmXMLParser.cxx | 4 +-- Source/cmXMLParser.h | 4 +-- 49 files changed, 173 insertions(+), 175 deletions(-) diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx index 10af1f6..ef67b23 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.cxx +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -34,12 +34,11 @@ cmWIXPatchParser::cmWIXPatchParser( } -void cmWIXPatchParser::StartElement(const char *name, const char **atts) +void cmWIXPatchParser::StartElement(const std::string& name, const char **atts) { - std::string name_str = name; if(State == BEGIN_DOCUMENT) { - if(name_str == "CPackWiXPatch") + if(name == "CPackWiXPatch") { State = BEGIN_FRAGMENTS; } @@ -50,7 +49,7 @@ void cmWIXPatchParser::StartElement(const char *name, const char **atts) } else if(State == BEGIN_FRAGMENTS) { - if(name_str == "CPackWiXFragment") + if(name == "CPackWiXFragment") { State = INSIDE_FRAGMENT; StartFragment(atts); @@ -107,12 +106,11 @@ void cmWIXPatchParser::StartFragment(const char **attributes) } } -void cmWIXPatchParser::EndElement(const char *name) +void cmWIXPatchParser::EndElement(const std::string& name) { - std::string name_str = name; if(State == INSIDE_FRAGMENT) { - if(name_str == "CPackWiXFragment") + if(name == "CPackWiXFragment") { State = BEGIN_FRAGMENTS; ElementStack.clear(); diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h index da3adf5..acfb4c0 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.h +++ b/Source/CPack/WiX/cmWIXPatchParser.h @@ -43,11 +43,11 @@ public: cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger); private: - virtual void StartElement(const char *name, const char **atts); + virtual void StartElement(const std::string& name, const char **atts); void StartFragment(const char **attributes); - virtual void EndElement(const char *name); + virtual void EndElement(const std::string& name); virtual void ReportError(int line, int column, const char* msg); void ReportValidationError(std::string const& message); diff --git a/Source/CPack/cmCPackComponentGroup.cxx b/Source/CPack/cmCPackComponentGroup.cxx index f93eca8..77f11cb 100644 --- a/Source/CPack/cmCPackComponentGroup.cxx +++ b/Source/CPack/cmCPackComponentGroup.cxx @@ -16,7 +16,8 @@ #include //---------------------------------------------------------------------- -unsigned long cmCPackComponent::GetInstalledSize(const char* installDir) const +unsigned long cmCPackComponent::GetInstalledSize( + const std::string& installDir) const { if (this->TotalSize != 0) { @@ -37,7 +38,7 @@ unsigned long cmCPackComponent::GetInstalledSize(const char* installDir) const //---------------------------------------------------------------------- unsigned long -cmCPackComponent::GetInstalledSizeInKbytes(const char* installDir) const +cmCPackComponent::GetInstalledSizeInKbytes(const std::string& installDir) const { unsigned long result = (GetInstalledSize(installDir) + 512) / 1024; return result? result : 1; diff --git a/Source/CPack/cmCPackComponentGroup.h b/Source/CPack/cmCPackComponentGroup.h index abae372..0679638 100644 --- a/Source/CPack/cmCPackComponentGroup.h +++ b/Source/CPack/cmCPackComponentGroup.h @@ -94,11 +94,11 @@ public: /// Get the total installed size of all of the files in this /// component, in bytes. installDir is the directory into which the /// component was installed. - unsigned long GetInstalledSize(const char* installDir) const; + unsigned long GetInstalledSize(const std::string& installDir) const; /// Identical to GetInstalledSize, but returns the result in /// kilobytes. - unsigned long GetInstalledSizeInKbytes(const char* installDir) const; + unsigned long GetInstalledSizeInKbytes(const std::string& installDir) const; private: mutable unsigned long TotalSize; diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 3e1bf3b..a8e104b 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -1139,7 +1139,7 @@ int cmCPackGenerator::DoPackage() } //---------------------------------------------------------------------- -int cmCPackGenerator::Initialize(const char* name, cmMakefile* mf) +int cmCPackGenerator::Initialize(const std::string& name, cmMakefile* mf) { this->MakefileMap = mf; this->Name = name; diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index fadd1bf..efd3bef 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -90,7 +90,7 @@ public: /** * Initialize generator */ - int Initialize(const char* name, cmMakefile* mf); + int Initialize(const std::string& name, cmMakefile* mf); /** * Construct generator diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 95ffab5..28c7f1d 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -272,7 +272,7 @@ bool cmCPackOSXX11Generator::CopyCreateResourceFile(const std::string& name) //---------------------------------------------------------------------- bool cmCPackOSXX11Generator::CopyResourcePlistFile(const std::string& name, - const char* dir, const char* outputFileName /* = 0 */, + const std::string& dir, const char* outputFileName /* = 0 */, bool copyOnly /* = false */) { std::string inFName = "CPack."; diff --git a/Source/CPack/cmCPackOSXX11Generator.h b/Source/CPack/cmCPackOSXX11Generator.h index 7a93f5a..9d0a6d1 100644 --- a/Source/CPack/cmCPackOSXX11Generator.h +++ b/Source/CPack/cmCPackOSXX11Generator.h @@ -39,7 +39,7 @@ protected: //bool CopyCreateResourceFile(const std::string& name, // const std::string& dir); - bool CopyResourcePlistFile(const std::string& name, const char* dir, + bool CopyResourcePlistFile(const std::string& name, const std::string& dir, const char* outputFileName = 0, bool copyOnly = false); std::string InstallPrefix; }; diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index 69886a1..d736948 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -43,14 +43,14 @@ bool cmCPackPackageMakerGenerator::SupportsComponentInstallation() const } //---------------------------------------------------------------------- -int cmCPackPackageMakerGenerator::CopyInstallScript(const char* resdir, - const char* script, - const char* name) +int cmCPackPackageMakerGenerator::CopyInstallScript(const std::string& resdir, + const std::string& script, + const std::string& name) { std::string dst = resdir; dst += "/"; dst += name; - cmSystemTools::CopyFileAlways(script, dst.c_str()); + cmSystemTools::CopyFileAlways(script.c_str(), dst.c_str()); cmSystemTools::SetPermissions(dst.c_str(),0777); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "copy script : " << script << "\ninto " << dst.c_str() << @@ -601,12 +601,13 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile( return true; } -bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(const char* name, - const char* outName) +bool cmCPackPackageMakerGenerator::CopyResourcePlistFile( + const std::string& name, + const char* outName) { if (!outName) { - outName = name; + outName = name.c_str(); } std::string inFName = "CPack."; diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h index bebb633..e350a60 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.h +++ b/Source/CPack/cmCPackPackageMakerGenerator.h @@ -38,9 +38,9 @@ public: virtual bool SupportsComponentInstallation() const; protected: - int CopyInstallScript(const char* resdir, - const char* script, - const char* name); + int CopyInstallScript(const std::string& resdir, + const std::string& script, + const std::string& name); virtual int InitializeInternal(); int PackageFiles(); virtual const char* GetOutputExtension() { return ".dmg"; } @@ -53,7 +53,7 @@ protected: // which will be configured via ConfigureFile. bool CopyCreateResourceFile(const std::string& name, const std::string& dirName); - bool CopyResourcePlistFile(const char* name, const char* outName = 0); + bool CopyResourcePlistFile(const std::string& name, const char* outName = 0); // Run PackageMaker with the given command line, which will (if // successful) produce the given package file. Returns true if diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index 840ebc9..3014a93 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -225,35 +225,35 @@ private: return true; } - virtual void StartElement(const char* name, const char**) + virtual void StartElement(const std::string& name, const char**) { this->CData.clear(); - if(strcmp(name, "log") == 0) + if(name == "log") { this->Rev = Revision(); this->Changes.clear(); } // affected-files can contain blocks of // modified, unknown, renamed, kind-changed, removed, conflicts, added - else if(strcmp(name, "modified") == 0 - || strcmp(name, "renamed") == 0 - || strcmp(name, "kind-changed") == 0) + else if(name == "modified" + || name == "renamed" + || name == "kind-changed") { this->CurChange = Change(); this->CurChange.Action = 'M'; } - else if(strcmp(name, "added") == 0) + else if(name == "added") { this->CurChange = Change(); this->CurChange = 'A'; } - else if(strcmp(name, "removed") == 0) + else if(name == "removed") { this->CurChange = Change(); this->CurChange = 'D'; } - else if(strcmp(name, "unknown") == 0 - || strcmp(name, "conflicts") == 0) + else if(name == "unknown" + || name == "conflicts") { // Should not happen here this->CurChange = Change(); @@ -265,27 +265,27 @@ private: this->CData.insert(this->CData.end(), data, data+length); } - virtual void EndElement(const char* name) + virtual void EndElement(const std::string& name) { - if(strcmp(name, "log") == 0) + if(name == "log") { this->BZR->DoRevision(this->Rev, this->Changes); } - else if((strcmp(name, "file") == 0 || strcmp(name, "directory") == 0) - && !this->CData.empty()) + else if(!this->CData.empty() && + (name == "file" || name == "directory")) { this->CurChange.Path.assign(&this->CData[0], this->CData.size()); cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path); this->Changes.push_back(this->CurChange); } - else if(strcmp(name, "symlink") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "symlink") { // symlinks have an arobase at the end in the log this->CurChange.Path.assign(&this->CData[0], this->CData.size()-1); cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path); this->Changes.push_back(this->CurChange); } - else if(strcmp(name, "committer") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "committer") { this->Rev.Author.assign(&this->CData[0], this->CData.size()); if(this->EmailRegex.find(this->Rev.Author)) @@ -294,15 +294,15 @@ private: this->Rev.EMail = this->EmailRegex.match(2); } } - else if(strcmp(name, "timestamp") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "timestamp") { this->Rev.Date.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "message") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "message") { this->Rev.Log.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "revno") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "revno") { this->Rev.Rev.assign(&this->CData[0], this->CData.size()); } diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index 9738bde..c60ded0 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -131,8 +131,8 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() std::string buildCommand = this->GlobalGenerator-> GenerateCMakeBuildCommand(cmakeBuildTarget ? cmakeBuildTarget : "", - cmakeBuildConfiguration, - cmakeBuildAdditionalFlags, true); + cmakeBuildConfiguration, + cmakeBuildAdditionalFlags ? cmakeBuildAdditionalFlags : "", true); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SetMakeCommand:" << buildCommand.c_str() << "\n"); diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index 5bf9949..0f79d68 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -189,10 +189,10 @@ private: return true; } - virtual void StartElement(const char* name, const char** atts) + virtual void StartElement(const std::string& name, const char** atts) { this->CData.clear(); - if(strcmp(name, "logentry") == 0) + if(name == "logentry") { this->Rev = Revision(); if(const char* rev = this->FindAttribute(atts, "revision")) @@ -208,29 +208,29 @@ private: this->CData.insert(this->CData.end(), data, data+length); } - virtual void EndElement(const char* name) + virtual void EndElement(const std::string& name) { - if(strcmp(name, "logentry") == 0) + if(name == "logentry") { this->HG->DoRevision(this->Rev, this->Changes); } - else if(strcmp(name, "author") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "author") { this->Rev.Author.assign(&this->CData[0], this->CData.size()); } - else if ( strcmp(name, "email") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "email") { this->Rev.EMail.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "date") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "date") { this->Rev.Date.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "msg") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "msg") { this->Rev.Log.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "files") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "files") { std::vector paths = this->SplitCData(); for(unsigned int i = 0; i < paths.size(); ++i) @@ -242,7 +242,7 @@ private: this->Changes.push_back(this->CurChange); } } - else if(strcmp(name, "file_adds") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "file_adds") { std::string added_paths(this->CData.begin(), this->CData.end()); for(unsigned int i = 0; i < this->Changes.size(); ++i) @@ -253,7 +253,7 @@ private: } } } - else if(strcmp(name, "file_dels") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "file_dels") { std::string added_paths(this->CData.begin(), this->CData.end()); for(unsigned int i = 0; i < this->Changes.size(); ++i) diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index f2982a4..f27dbc0 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -49,21 +49,15 @@ class cmBoundsCheckerParser : public cmXMLParser { public: cmBoundsCheckerParser(cmCTest* c) { this->CTest = c;} - void StartElement(const char* name, const char** atts) + void StartElement(const std::string& name, const char** atts) { - if(strcmp(name, "MemoryLeak") == 0) + if(name == "MemoryLeak" || + name == "ResourceLeak") { this->Errors.push_back(cmCTestMemCheckHandler::MLK); } - if(strcmp(name, "ResourceLeak") == 0) - { - this->Errors.push_back(cmCTestMemCheckHandler::MLK); - } - if(strcmp(name, "Error") == 0) - { - this->ParseError(atts); - } - if(strcmp(name, "Dangling Pointer") == 0) + else if(name == "Error" || + name == "Dangling Pointer") { this->ParseError(atts); } @@ -79,7 +73,7 @@ public: ostr << "\n"; this->Log += ostr.str(); } - void EndElement(const char* ) + void EndElement(const std::string& ) { } diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 89592dd..86dc2f2 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -361,10 +361,10 @@ private: return true; } - virtual void StartElement(const char* name, const char** atts) + virtual void StartElement(const std::string& name, const char** atts) { this->CData.clear(); - if(strcmp(name, "logentry") == 0) + if(name == "logentry") { this->Rev = Revision(); this->Rev.SVNInfo = &SVNRepo; @@ -374,7 +374,7 @@ private: } this->Changes.clear(); } - else if(strcmp(name, "path") == 0) + else if(name == "path") { this->CurChange = Change(); if(const char* action = this->FindAttribute(atts, "action")) @@ -389,28 +389,28 @@ private: this->CData.insert(this->CData.end(), data, data+length); } - virtual void EndElement(const char* name) + virtual void EndElement(const std::string& name) { - if(strcmp(name, "logentry") == 0) + if(name == "logentry") { this->SVN->DoRevisionSVN(this->Rev, this->Changes); } - else if(strcmp(name, "path") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "path") { std::string orig_path(&this->CData[0], this->CData.size()); std::string new_path = SVNRepo.BuildLocalPath( orig_path ); this->CurChange.Path.assign(new_path); this->Changes.push_back(this->CurChange); } - else if(strcmp(name, "author") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "author") { this->Rev.Author.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "date") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "date") { this->Rev.Date.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "msg") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "msg") { this->Rev.Log.assign(&this->CData[0], this->CData.size()); } diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 1cd8fc7..3173f15 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -68,10 +68,10 @@ private: return val; } - virtual void StartElement(const char* name, const char** atts) + virtual void StartElement(const std::string& name, const char** atts) { this->CurrentValue.clear(); - if(strcmp(name, "cdash") == 0) + if(name == "cdash") { this->CDashVersion = this->FindAttribute(atts, "version"); } @@ -82,9 +82,9 @@ private: this->CurrentValue.insert(this->CurrentValue.end(), data, data+length); } - virtual void EndElement(const char* name) + virtual void EndElement(const std::string& name) { - if(strcmp(name, "status") == 0) + if(name == "status") { std::string status = cmSystemTools::UpperCase(this->GetCurrentValue()); if(status == "OK" || status == "SUCCESS") @@ -100,15 +100,15 @@ private: this->Status = STATUS_ERROR; } } - else if(strcmp(name, "filename") == 0) + else if(name == "filename") { this->Filename = this->GetCurrentValue(); } - else if(strcmp(name, "md5") == 0) + else if(name == "md5") { this->MD5 = this->GetCurrentValue(); } - else if(strcmp(name, "message") == 0) + else if(name == "message") { this->Message = this->GetCurrentValue(); } diff --git a/Source/CTest/cmParsePythonCoverage.cxx b/Source/CTest/cmParsePythonCoverage.cxx index 38a770a..2578bb8 100644 --- a/Source/CTest/cmParsePythonCoverage.cxx +++ b/Source/CTest/cmParsePythonCoverage.cxx @@ -20,9 +20,9 @@ public: protected: - virtual void StartElement(const char* name, const char** atts) + virtual void StartElement(const std::string& name, const char** atts) { - if(strcmp(name, "class") == 0) + if(name == "class") { int tagCount = 0; while(true) @@ -57,7 +57,7 @@ protected: ++tagCount; } } - else if(strcmp(name, "line") == 0) + else if(name == "line") { int tagCount = 0; int curNumber = -1; @@ -85,7 +85,7 @@ protected: } } - virtual void EndElement(const char*) {} + virtual void EndElement(const std::string&) {} private: diff --git a/Source/CursesDialog/cmCursesOptionsWidget.cxx b/Source/CursesDialog/cmCursesOptionsWidget.cxx index 652b2df..aa680fb 100644 --- a/Source/CursesDialog/cmCursesOptionsWidget.cxx +++ b/Source/CursesDialog/cmCursesOptionsWidget.cxx @@ -89,7 +89,7 @@ void cmCursesOptionsWidget::PreviousOption() this->SetValue(this->Options[this->CurrentOption].c_str()); } -void cmCursesOptionsWidget::SetOption(const char* value) +void cmCursesOptionsWidget::SetOption(const std::string& value) { this->CurrentOption = 0; // default to 0 index this->SetValue(value); diff --git a/Source/CursesDialog/cmCursesOptionsWidget.h b/Source/CursesDialog/cmCursesOptionsWidget.h index b52ac9d..5cee489 100644 --- a/Source/CursesDialog/cmCursesOptionsWidget.h +++ b/Source/CursesDialog/cmCursesOptionsWidget.h @@ -25,7 +25,7 @@ public: // when this widget has focus. Returns true if the input was // handled. virtual bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w); - void SetOption(const char*); + void SetOption(const std::string&); void AddOption(std::string const &); void NextOption(); void PreviousOption(); diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx index bd1ff71..d25022d 100644 --- a/Source/CursesDialog/cmCursesStringWidget.cxx +++ b/Source/CursesDialog/cmCursesStringWidget.cxx @@ -195,7 +195,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm, return true; } -void cmCursesStringWidget::SetString(const char* value) +void cmCursesStringWidget::SetString(const std::string& value) { this->SetValue(value); } diff --git a/Source/CursesDialog/cmCursesStringWidget.h b/Source/CursesDialog/cmCursesStringWidget.h index e939049..dd8c02a 100644 --- a/Source/CursesDialog/cmCursesStringWidget.h +++ b/Source/CursesDialog/cmCursesStringWidget.h @@ -37,7 +37,7 @@ public: /** * Set/Get the string. */ - void SetString(const char* value); + void SetString(const std::string& value); const char* GetString(); virtual const char* GetValue(); diff --git a/Source/CursesDialog/cmCursesWidget.cxx b/Source/CursesDialog/cmCursesWidget.cxx index 5dffcaa..e5363f4 100644 --- a/Source/CursesDialog/cmCursesWidget.cxx +++ b/Source/CursesDialog/cmCursesWidget.cxx @@ -46,10 +46,10 @@ void cmCursesWidget::Move(int x, int y, bool isNewPage) } } -void cmCursesWidget::SetValue(const char* value) +void cmCursesWidget::SetValue(const std::string& value) { this->Value = value; - set_field_buffer(this->Field, 0, value); + set_field_buffer(this->Field, 0, value.c_str()); } const char* cmCursesWidget::GetValue() diff --git a/Source/CursesDialog/cmCursesWidget.h b/Source/CursesDialog/cmCursesWidget.h index 952c67a..d91a0cb 100644 --- a/Source/CursesDialog/cmCursesWidget.h +++ b/Source/CursesDialog/cmCursesWidget.h @@ -40,7 +40,7 @@ public: * Set/Get the value (setting the value also changes the contents * of the field buffer). */ - virtual void SetValue(const char* value); + virtual void SetValue(const std::string& value); virtual const char* GetValue(); /** diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 39b9ae5..159f9c3 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -94,7 +94,7 @@ bool cmCacheManager::LoadCache(const std::string& path, return this->LoadCache(path, internal, emptySet, emptySet); } -static bool ParseEntryWithoutType(const char* entry, +static bool ParseEntryWithoutType(const std::string& entry, std::string& var, std::string& value) { @@ -132,7 +132,7 @@ static bool ParseEntryWithoutType(const char* entry, return flag; } -bool cmCacheManager::ParseEntry(const char* entry, +bool cmCacheManager::ParseEntry(const std::string& entry, std::string& var, std::string& value, CacheEntryType& type) diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 573f828..07a8675 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -136,7 +136,7 @@ public: return static_cast(this->Cache.size()); } ///! Break up a line like VAR:type="value" into var, type and value - static bool ParseEntry(const char* entry, + static bool ParseEntry(const std::string& entry, std::string& var, std::string& value, CacheEntryType& type); diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index cf91c69..abd8ad5 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -50,7 +50,7 @@ public: const char *GetMainExportFileName() const; /** Set the namespace in which to place exported target names. */ - void SetNamespace(const char* ns) { this->Namespace = ns; } + void SetNamespace(const std::string& ns) { this->Namespace = ns; } std::string GetNamespace() const { return this->Namespace; } void SetExportOld(bool exportOld) { this->ExportOld = exportOld; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index b7af21b..a14696d 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1790,7 +1790,7 @@ int cmGlobalGenerator::Build( //---------------------------------------------------------------------------- std::string cmGlobalGenerator::GenerateCMakeBuildCommand( const std::string& target, const std::string& config, - const char* native, + const std::string& native, bool ignoreErrors) { std::string makeCommand = cmSystemTools::GetCMakeCommand(); @@ -1819,7 +1819,7 @@ std::string cmGlobalGenerator::GenerateCMakeBuildCommand( sep = " "; } } - if(native && *native) + if(!native.empty()) { makeCommand += sep; makeCommand += native; @@ -2528,9 +2528,10 @@ std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage( } //---------------------------------------------------------------------------- -void cmGlobalGenerator::AppendDirectoryForConfig(const char*, +void cmGlobalGenerator::AppendDirectoryForConfig(const std::string&, const std::string&, - const char*, std::string&) + const std::string&, + std::string&) { // Subclasses that support multiple configurations should implement // this method to append the subdirectory for the given build diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index e9a1b47..5b97960 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -138,7 +138,7 @@ public: /** Generate a "cmake --build" call for a given target and config. */ std::string GenerateCMakeBuildCommand(const std::string& target, const std::string& config, - const char* native, + const std::string& native, bool ignoreErrors); ///! Set the CMake instance @@ -230,9 +230,9 @@ public: /** Append the subdirectory for the given configuration. If anything is appended the given prefix and suffix will be appended around it, which is useful for leading or trailing slashes. */ - virtual void AppendDirectoryForConfig(const char* prefix, + virtual void AppendDirectoryForConfig(const std::string& prefix, const std::string& config, - const char* suffix, + const std::string& suffix, std::string& dir); /** Get the manifest of all targets that will be built for each @@ -292,7 +292,7 @@ public: return this->BinaryDirectories.insert(dir).second; } /** Supported systems creates a GUID for the given name */ - virtual void CreateGUID(const char*) {} + virtual void CreateGUID(const std::string&) {} /** Return true if the generated build tree may contain multiple builds. i.e. "Can I build Debug and Release in the same tree?" */ diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index f69bcfd..82047d7 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -418,9 +418,9 @@ void cmGlobalVisualStudio6Generator //---------------------------------------------------------------------------- void cmGlobalVisualStudio6Generator -::AppendDirectoryForConfig(const char* prefix, +::AppendDirectoryForConfig(const std::string& prefix, const std::string& config, - const char* suffix, + const std::string& suffix, std::string& dir) { if(!config.empty()) diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 22ec926..f7ef972 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -81,9 +81,9 @@ public: std::vector& generators); /** Append the subdirectory for the given configuration. */ - virtual void AppendDirectoryForConfig(const char* prefix, + virtual void AppendDirectoryForConfig(const std::string& prefix, const std::string& config, - const char* suffix, + const std::string& suffix, std::string& dir); ///! What is the configurations directory variable called? diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 18f7f19..c65bdaa 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -924,7 +924,7 @@ std::string cmGlobalVisualStudio7Generator::GetGUID(const std::string& name) } -void cmGlobalVisualStudio7Generator::CreateGUID(const char* name) +void cmGlobalVisualStudio7Generator::CreateGUID(const std::string& name) { std::string guidStoreName = name; guidStoreName += "_GUID_CMAKE"; @@ -961,9 +961,9 @@ void cmGlobalVisualStudio7Generator //---------------------------------------------------------------------------- void cmGlobalVisualStudio7Generator -::AppendDirectoryForConfig(const char* prefix, +::AppendDirectoryForConfig(const std::string& prefix, const std::string& config, - const char* suffix, + const std::string& suffix, std::string& dir) { if(!config.empty()) diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 009f002..342fa88 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -89,13 +89,13 @@ public: std::vector *GetConfigurations(); ///! Create a GUID or get an existing one. - void CreateGUID(const char* name); + void CreateGUID(const std::string& name); std::string GetGUID(const std::string& name); /** Append the subdirectory for the given configuration. */ - virtual void AppendDirectoryForConfig(const char* prefix, + virtual void AppendDirectoryForConfig(const std::string& prefix, const std::string& config, - const char* suffix, + const std::string& suffix, std::string& dir); ///! What is the configurations directory variable called? diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index c0077b9..ec2e1e9 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -34,17 +34,17 @@ class cmXcodeVersionParser : public cmXMLParser { public: cmXcodeVersionParser(): Version("1.5") {} - void StartElement(const char* , const char** ) + void StartElement(const std::string&, const char**) { this->Data = ""; } - void EndElement(const char* name) + void EndElement(const std::string& name) { - if(strcmp(name, "key") == 0) + if(name == "key") { this->Key = this->Data; } - else if(strcmp(name, "string") == 0) + else if(name == "string") { if(this->Key == "CFBundleShortVersionString") { @@ -1005,7 +1005,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, gtgt->GetTargetSourceFileFlags(*i); if(filetype && - strcmp(filetype->GetString(), "compiled.mach-o.objfile") == 0) + filetype->GetString() == "compiled.mach-o.objfile") { externalObjFiles.push_back(xsf); } @@ -3771,9 +3771,9 @@ std::string cmGlobalXCodeGenerator::XCodeEscapePath(const char* p) //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator -::AppendDirectoryForConfig(const char* prefix, +::AppendDirectoryForConfig(const std::string& prefix, const std::string& config, - const char* suffix, + const std::string& suffix, std::string& dir) { if(this->XcodeVersion > 20) diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 03e75c4..e9149c2 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -72,9 +72,9 @@ public: virtual void Generate(); /** Append the subdirectory for the given configuration. */ - virtual void AppendDirectoryForConfig(const char* prefix, + virtual void AppendDirectoryForConfig(const std::string& prefix, const std::string& config, - const char* suffix, + const std::string& suffix, std::string& dir); ///! What is the configurations directory variable called? diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 2516613..f7088c2 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1299,7 +1299,7 @@ cmLocalUnixMakefileGenerator3::AppendEcho(std::vector& commands, //---------------------------------------------------------------------------- std::string cmLocalUnixMakefileGenerator3 -::CreateMakeVariable(const char* sin, const char* s2in) +::CreateMakeVariable(const std::string& sin, const std::string& s2in) { std::string s = sin; std::string s2 = s2in; diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 37ee874..39f213b 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -75,7 +75,7 @@ public: /** * Set the flag used to keep the make program silent. */ - void SetMakeSilentFlag(const char* s) { this->MakeSilentFlag = s; } + void SetMakeSilentFlag(const std::string& s) { this->MakeSilentFlag = s; } std::string &GetMakeSilentFlag() { return this->MakeSilentFlag; } /** @@ -130,8 +130,9 @@ public: * Set the string used to include one makefile into another default * is include. */ - void SetIncludeDirective(const char* s) { this->IncludeDirective = s; } - const char *GetIncludeDirective() { return this->IncludeDirective.c_str(); } + void SetIncludeDirective(const std::string& s) + { this->IncludeDirective = s; } + const std::string& GetIncludeDirective() { return this->IncludeDirective; } /** * Set max makefile variable size, default is 0 which means unlimited. @@ -192,7 +193,8 @@ public: static std::string ConvertToQuotedOutputPath(const char* p); - std::string CreateMakeVariable(const char* sin, const char* s2in); + std::string CreateMakeVariable(const std::string& sin, + const std::string& s2in); /** Called from command-line hook to bring dependencies up to date for a target. */ diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index aedd6ed..aa70ab9 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -19,7 +19,7 @@ class cmVS10XMLParser : public cmXMLParser { public: - virtual void EndElement(const char* /* name */) + virtual void EndElement(const std::string& /* name */) { } virtual void CharacterDataHandler(const char* data, int length) @@ -30,14 +30,14 @@ class cmVS10XMLParser : public cmXMLParser this->DoGUID = false; } } - virtual void StartElement(const char* name, const char**) + virtual void StartElement(const std::string& name, const char**) { // once the GUID is found do nothing if(this->GUID.size()) { return; } - if(strcmp("ProjectGUID", name) == 0 || strcmp("ProjectGuid", name) == 0) + if("ProjectGUID" == name || "ProjectGuid" == name) { this->DoGUID = true; } @@ -98,7 +98,7 @@ void cmLocalVisualStudio10Generator::Generate() void cmLocalVisualStudio10Generator -::ReadAndStoreExternalGUID(const char* name, +::ReadAndStoreExternalGUID(const std::string& name, const char* path) { cmVS10XMLParser parser; diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index 41db735..b50e345 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -34,7 +34,7 @@ public: * Generate the makefile for this directory. */ virtual void Generate(); - virtual void ReadAndStoreExternalGUID(const char* name, + virtual void ReadAndStoreExternalGUID(const std::string& name, const char* path); protected: diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 5f98a71..0bbafd8 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -2146,10 +2146,10 @@ std::string cmLocalVisualStudio7Generator class cmVS7XMLParser : public cmXMLParser { public: - virtual void EndElement(const char* /* name */) + virtual void EndElement(const std::string& /* name */) { } - virtual void StartElement(const char* name, const char** atts) + virtual void StartElement(const std::string& name, const char** atts) { // once the GUID is found do nothing if(this->GUID.size()) @@ -2157,7 +2157,7 @@ public: return; } int i =0; - if(strcmp("VisualStudioProject", name) == 0) + if("VisualStudioProject" == name) { while(atts[i]) { @@ -2194,7 +2194,7 @@ public: }; void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID( - const char* name, + const std::string& name, const char* path) { cmVS7XMLParser parser; diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index f9bb6e1..d2e66a5 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -51,7 +51,7 @@ public: /** * Specify the type of the build: static, dll, or executable. */ - void SetBuildType(BuildType,const char *name); + void SetBuildType(BuildType,const std::string& name); void SetPlatformName(const char* n) { this->PlatformName = n;} @@ -62,7 +62,7 @@ public: void WriteStampFiles(); virtual std::string ComputeLongestObjectDirectory(cmTarget&) const; - virtual void ReadAndStoreExternalGUID(const char* name, + virtual void ReadAndStoreExternalGUID(const std::string& name, const char* path); virtual void AddCMakeListsRules(); protected: diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 11b0387..6e93d22 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -81,7 +81,7 @@ std::string cmLocalVisualStudioGenerator ::ConstructScript(cmCustomCommand const& cc, const std::string& configName, - const char* newline_text) + const std::string& newline_text) { bool useLocal = this->CustomCommandUseLocal(); const char* workingDirectory = cc.GetWorkingDirectory(); @@ -89,7 +89,7 @@ cmLocalVisualStudioGenerator RelativeRoot relativeRoot = workingDirectory? NONE : START_OUTPUT; // Avoid leading or trailing newlines. - const char* newline = ""; + std::string newline = ""; // Line to check for error between commands. std::string check_error = newline_text; diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index 2297072..94a6293 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -48,7 +48,7 @@ public: /** Construct a script from the given list of command lines. */ std::string ConstructScript(cmCustomCommand const& cc, const std::string& configName, - const char* newline = "\n"); + const std::string& newline = "\n"); /** Label to which to jump in a batch file after a failed step in a sequence of custom commands. */ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 25ca168..5952444 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4100,7 +4100,8 @@ bool cmTarget::ComputeOutputDir(const std::string& config, } //---------------------------------------------------------------------------- -bool cmTarget::ComputePDBOutputDir(const char* kind, const std::string& config, +bool cmTarget::ComputePDBOutputDir(const std::string& kind, + const std::string& config, std::string& out) const { // Look for a target property defining the target output directory diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 15f00be..d5ef18d 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -714,7 +714,7 @@ private: bool ComputeOutputDir(const std::string& config, bool implib, std::string& out) const; - bool ComputePDBOutputDir(const char* kind, const std::string& config, + bool ComputePDBOutputDir(const std::string& kind, const std::string& config, std::string& out) const; // Cache import information from properties for each configuration. diff --git a/Source/cmVisualStudioWCEPlatformParser.cxx b/Source/cmVisualStudioWCEPlatformParser.cxx index 219a5eb..ca226fb 100644 --- a/Source/cmVisualStudioWCEPlatformParser.cxx +++ b/Source/cmVisualStudioWCEPlatformParser.cxx @@ -62,7 +62,7 @@ const char* cmVisualStudioWCEPlatformParser::GetArchitectureFamily() const return 0; } -void cmVisualStudioWCEPlatformParser::StartElement(const char* name, +void cmVisualStudioWCEPlatformParser::StartElement(const std::string& name, const char** attributes) { if(this->FoundRequiredName) @@ -72,7 +72,7 @@ void cmVisualStudioWCEPlatformParser::StartElement(const char* name, this->CharacterData = ""; - if(strcmp(name, "PlatformData") == 0) + if(name == "PlatformData") { this->PlatformName = ""; this->OSMajorVersion = ""; @@ -80,7 +80,7 @@ void cmVisualStudioWCEPlatformParser::StartElement(const char* name, this->Macros.clear(); } - if(strcmp(name, "Macro") == 0) + if(name == "Macro") { std::string macroName; std::string macroValue; @@ -102,7 +102,7 @@ void cmVisualStudioWCEPlatformParser::StartElement(const char* name, this->Macros[macroName] = macroValue; } } - else if(strcmp(name, "Directories") == 0) + else if(name == "Directories") { for(const char** attr = attributes; *attr; attr += 2) { @@ -122,11 +122,11 @@ void cmVisualStudioWCEPlatformParser::StartElement(const char* name, } } -void cmVisualStudioWCEPlatformParser::EndElement(const char* name) +void cmVisualStudioWCEPlatformParser::EndElement(const std::string& name) { if(!this->RequiredName) { - if(strcmp(name, "PlatformName") == 0) + if(name == "PlatformName") { this->AvailablePlatforms.push_back(this->CharacterData); } @@ -138,19 +138,19 @@ void cmVisualStudioWCEPlatformParser::EndElement(const char* name) return; } - if(strcmp(name, "PlatformName") == 0) + if(name == "PlatformName") { this->PlatformName = this->CharacterData; } - else if(strcmp(name, "OSMajorVersion") == 0) + else if(name == "OSMajorVersion") { this->OSMajorVersion = this->CharacterData; } - else if(strcmp(name, "OSMinorVersion") == 0) + else if(name == "OSMinorVersion") { this->OSMinorVersion = this->CharacterData; } - else if(strcmp(name, "Platform") == 0) + else if(name == "Platform") { if(this->PlatformName == this->RequiredName) { diff --git a/Source/cmVisualStudioWCEPlatformParser.h b/Source/cmVisualStudioWCEPlatformParser.h index 466e1dd..042df01 100644 --- a/Source/cmVisualStudioWCEPlatformParser.h +++ b/Source/cmVisualStudioWCEPlatformParser.h @@ -41,8 +41,8 @@ public: return this->AvailablePlatforms; } protected: - virtual void StartElement(const char* name, const char** attributes); - void EndElement(const char* name); + virtual void StartElement(const std::string& name, const char** attributes); + void EndElement(const std::string& name); void CharacterDataHandler(const char* data, int length); private: diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index 3a6528a..ed2940a 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -38,12 +38,12 @@ public: PBXType GetIsA() { return this->IsA;} void SetString(const std::string& s); - const char* GetString() + const std::string& GetString() { - return this->String.c_str(); + return this->String; } - void AddAttribute(const char* name, cmXCodeObject* value) + void AddAttribute(const std::string& name, cmXCodeObject* value) { this->ObjectAttributes[name] = value; } @@ -79,11 +79,11 @@ public: static void PrintList(std::vector const&, std::ostream& out); - const char* GetId() + const std::string& GetId() { - return this->Id.c_str(); + return this->Id; } - void SetId(const char* id) + void SetId(const std::string& id) { this->Id = id; } @@ -95,8 +95,8 @@ public: { this->Target = t; } - const char* GetComment() {return this->Comment.c_str();} - bool HasComment() { return (this->Comment.size() != 0);} + const std::string& GetComment() {return this->Comment;} + bool HasComment() { return (!this->Comment.empty());} cmXCodeObject* GetObject(const char* name) { if(this->ObjectAttributes.count(name)) @@ -141,7 +141,7 @@ public: return this->DependTargets; } std::vector const& GetObjectList() { return this->List;} - void SetComment(const char* c) { this->Comment = c;} + void SetComment(const std::string& c) { this->Comment = c;} static void PrintString(std::ostream& os,std::string String); protected: void PrintString(std::ostream& os) const; diff --git a/Source/cmXMLParser.cxx b/Source/cmXMLParser.cxx index 0c53440..a73fd70 100644 --- a/Source/cmXMLParser.cxx +++ b/Source/cmXMLParser.cxx @@ -152,14 +152,14 @@ int cmXMLParser::ParsingComplete() } //---------------------------------------------------------------------------- -void cmXMLParser::StartElement(const char * name, +void cmXMLParser::StartElement(const std::string& name, const char ** /*atts*/) { std::cout << "Start element: " << name << std::endl; } //---------------------------------------------------------------------------- -void cmXMLParser::EndElement(const char * name) +void cmXMLParser::EndElement(const std::string& name) { std::cout << "End element: " << name << std::endl; } diff --git a/Source/cmXMLParser.h b/Source/cmXMLParser.h index d916075..84a5a7d 100644 --- a/Source/cmXMLParser.h +++ b/Source/cmXMLParser.h @@ -74,11 +74,11 @@ protected: * element. atts = Null-terminated array of attribute name/value pairs. * Even indices are attribute names, and odd indices are values. */ - virtual void StartElement(const char* name, const char** atts); + virtual void StartElement(const std::string& name, const char** atts); //! Called at the end of an element in the XML source opened when //StartElement was called. - virtual void EndElement(const char* name); + virtual void EndElement(const std::string& name); //! Called when there is character data to handle. virtual void CharacterDataHandler(const char* data, int length); -- cgit v0.12 From 11ed3e2cfe70e7d9d5a8e1f8e24fa61bbf6420b0 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 21 Feb 2014 19:06:54 -0500 Subject: stringapi: Add string overload for the Def struct --- Source/cmDefinitions.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 4c1ad0a..d615fb0 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -59,6 +59,7 @@ private: public: Def(): std_string(), Exists(false) {} Def(const char* v): std_string(v?v:""), Exists(v?true:false) {} + Def(const std_string& v): std_string(v), Exists(true) {} Def(Def const& d): std_string(d), Exists(d.Exists) {} bool Exists; }; -- cgit v0.12 From 24b5e93de2c753e94cae3b41c1ca7cddaa03e5e7 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 24 Feb 2014 17:38:30 -0500 Subject: stringapi: Use strings for directories --- Source/cmGlobalGenerator.cxx | 9 +++++---- Source/cmGlobalGenerator.h | 6 +++--- Source/cmGlobalNinjaGenerator.cxx | 2 +- Source/cmGlobalNinjaGenerator.h | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 2 +- Source/cmGlobalUnixMakefileGenerator3.h | 2 +- Source/cmGlobalVisualStudio10Generator.cxx | 4 ++-- Source/cmGlobalVisualStudio10Generator.h | 2 +- Source/cmGlobalVisualStudio6Generator.cxx | 2 +- Source/cmGlobalVisualStudio6Generator.h | 2 +- Source/cmGlobalVisualStudio7Generator.cxx | 2 +- Source/cmGlobalVisualStudio7Generator.h | 2 +- Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmGlobalXCodeGenerator.h | 2 +- Source/cmMakefile.cxx | 9 +++++---- Source/cmMakefile.h | 2 +- Source/cmQtAutoGenerators.cxx | 20 ++++++++++++-------- Source/cmQtAutoGenerators.h | 8 ++++---- Source/cmake.cxx | 2 +- 19 files changed, 44 insertions(+), 38 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a14696d..c1cce2e 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1614,7 +1614,8 @@ void cmGlobalGenerator::CheckLocalGenerators() } } -int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, +int cmGlobalGenerator::TryCompile(const std::string& srcdir, + const std::string& bindir, const std::string& projectName, const std::string& target, bool fast, std::string *output, cmMakefile *mf) @@ -1665,7 +1666,7 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, void cmGlobalGenerator::GenerateBuildCommand( std::vector& makeCommand, const char*, const std::string&, - const char*, const std::string&, const std::string&, bool, + const std::string&, const std::string&, const std::string&, bool, std::vector const&) { makeCommand.push_back( @@ -1673,7 +1674,7 @@ void cmGlobalGenerator::GenerateBuildCommand( } int cmGlobalGenerator::Build( - const char *, const char *bindir, + const std::string&, const std::string& bindir, const std::string& projectName, const std::string& target, std::string *output, const char *makeCommandCSTR, @@ -1687,7 +1688,7 @@ int cmGlobalGenerator::Build( * Run an executable command and put the stdout in output. */ std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(bindir); + cmSystemTools::ChangeDirectory(bindir.c_str()); if(output) { *output += "Change Dir: "; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 5b97960..761fb07 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -105,7 +105,7 @@ public: * Try running cmake and building a file. This is used for dynamically * loaded commands, not as part of the usual build process. */ - virtual int TryCompile(const char *srcdir, const char *bindir, + virtual int TryCompile(const std::string& srcdir, const std::string& bindir, const std::string& projectName, const std::string& targetName, bool fast, std::string *output, cmMakefile* mf); @@ -117,7 +117,7 @@ public: * empty then all is assumed. clean indicates if a "make clean" should be * done first. */ - int Build(const char *srcdir, const char *bindir, + int Build(const std::string& srcdir, const std::string& bindir, const std::string& projectName, const std::string& targetName, std::string *output, const char *makeProgram, const std::string& config, @@ -130,7 +130,7 @@ public: virtual void GenerateBuildCommand( std::vector& makeCommand, const char* makeProgram, - const std::string& projectName, const char *projectDir, + const std::string& projectName, const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, std::vector const& makeOptions = std::vector() ); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 16e9788..73a6245 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -553,7 +553,7 @@ void cmGlobalNinjaGenerator ::GenerateBuildCommand(std::vector& makeCommand, const char* makeProgram, const std::string& /*projectName*/, - const char* /*projectDir*/, + const std::string& /*projectDir*/, const std::string& targetName, const std::string& /*config*/, bool /*fast*/, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 86c2912..4a28486 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -195,7 +195,7 @@ public: std::vector& makeCommand, const char* makeProgram, const std::string& projectName, - const char* projectDir, + const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index d947150..9ddbe5b 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -567,7 +567,7 @@ void cmGlobalUnixMakefileGenerator3 ::GenerateBuildCommand(std::vector& makeCommand, const char* makeProgram, const std::string& /*projectName*/, - const char* /*projectDir*/, + const std::string& /*projectDir*/, const std::string& targetName, const std::string& /*config*/, bool fast, diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 8924fa8..d64afaf 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -111,7 +111,7 @@ public: std::vector& makeCommand, const char* makeProgram, const std::string& projectName, - const char* projectDir, + const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 0bc572b..3819a5b 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -312,7 +312,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( std::vector& makeCommand, const char* makeProgram, const std::string& projectName, - const char* projectDir, + const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, @@ -334,7 +334,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( cmSlnData slnData; { std::string slnFile; - if(projectDir && *projectDir) + if(!projectDir.empty()) { slnFile = projectDir; slnFile += "/"; diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 085f2d2..5d902ee 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -36,7 +36,7 @@ public: std::vector& makeCommand, const char* makeProgram, const std::string& projectName, - const char* projectDir, + const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 82047d7..3a51fce 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -118,7 +118,7 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand( std::vector& makeCommand, const char* makeProgram, const std::string& projectName, - const char* /*projectDir*/, + const std::string& /*projectDir*/, const std::string& targetName, const std::string& config, bool /*fast*/, diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index f7ef972..eb3dddf 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -56,7 +56,7 @@ public: std::vector& makeCommand, const char* makeProgram, const std::string& projectName, - const char* projectDir, + const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index c65bdaa..3927100 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -185,7 +185,7 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand( std::vector& makeCommand, const char* makeProgram, const std::string& projectName, - const char* /*projectDir*/, + const std::string& /*projectDir*/, const std::string& targetName, const std::string& config, bool /*fast*/, diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 342fa88..b659480 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -64,7 +64,7 @@ public: std::vector& makeCommand, const char* makeProgram, const std::string& projectName, - const char* projectDir, + const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index ec2e1e9..e1f2a91 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -262,7 +262,7 @@ cmGlobalXCodeGenerator::GenerateBuildCommand( std::vector& makeCommand, const char* makeProgram, const std::string& projectName, - const char* /*projectDir*/, + const std::string& /*projectDir*/, const std::string& targetName, const std::string& config, bool /*fast*/, diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index e9149c2..aec7958 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -57,7 +57,7 @@ public: std::vector& makeCommand, const char* makeProgram, const std::string& projectName, - const char* projectDir, + const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index bb88bc4..e61b12b 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3060,7 +3060,8 @@ void cmMakefile::ExpandSourceListArguments( } } -int cmMakefile::TryCompile(const char *srcdir, const char *bindir, +int cmMakefile::TryCompile(const std::string& srcdir, + const std::string& bindir, const std::string& projectName, const std::string& targetName, bool fast, @@ -3069,15 +3070,15 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir, { this->Internal->IsSourceFileTryCompile = fast; // does the binary directory exist ? If not create it... - if (!cmSystemTools::FileIsDirectory(bindir)) + if (!cmSystemTools::FileIsDirectory(bindir.c_str())) { - cmSystemTools::MakeDirectory(bindir); + cmSystemTools::MakeDirectory(bindir.c_str()); } // change to the tests directory and run cmake // use the cmake object instead of calling cmake std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(bindir); + cmSystemTools::ChangeDirectory(bindir.c_str()); // make sure the same generator is used // use this program as the cmake to be run, it should not diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 7c82ec2..fb40c1b 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -126,7 +126,7 @@ public: * Try running cmake and building a file. This is used for dynalically * loaded commands, not as part of the usual build process. */ - int TryCompile(const char *srcdir, const char *bindir, + int TryCompile(const std::string& srcdir, const std::string& bindir, const std::string& projectName, const std::string& targetName, bool fast, const std::vector *cmakeArgs, diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 8eee991..48a6b38 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -952,7 +952,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) } static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, - const char* targetDirectory) + const std::string& targetDirectory) { cmGlobalGenerator* gg = new cmGlobalGenerator(); gg->SetCMakeInstance(cm); @@ -967,7 +967,7 @@ static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, return gg; } -bool cmQtAutoGenerators::Run(const char* targetDirectory, +bool cmQtAutoGenerators::Run(const std::string& targetDirectory, const std::string& config) { bool success = true; @@ -994,10 +994,11 @@ bool cmQtAutoGenerators::Run(const char* targetDirectory, } bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, - const char* targetDirectory, + const std::string& targetDirectory, const std::string& config) { - std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); + std::string filename( + cmSystemTools::CollapseFullPath(targetDirectory.c_str())); cmSystemTools::ConvertToUnixSlashes(filename); filename += "/AutogenInfo.cmake"; @@ -1137,9 +1138,10 @@ std::string cmQtAutoGenerators::MakeCompileSettingsString(cmMakefile* makefile) bool cmQtAutoGenerators::ReadOldMocDefinitionsFile(cmMakefile* makefile, - const char* targetDirectory) + const std::string& targetDirectory) { - std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); + std::string filename( + cmSystemTools::CollapseFullPath(targetDirectory.c_str())); cmSystemTools::ConvertToUnixSlashes(filename); filename += "/AutomocOldMocDefinitions.cmake"; @@ -1153,9 +1155,11 @@ bool cmQtAutoGenerators::ReadOldMocDefinitionsFile(cmMakefile* makefile, void -cmQtAutoGenerators::WriteOldMocDefinitionsFile(const char* targetDirectory) +cmQtAutoGenerators::WriteOldMocDefinitionsFile( + const std::string& targetDirectory) { - std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); + std::string filename( + cmSystemTools::CollapseFullPath(targetDirectory.c_str())); cmSystemTools::ConvertToUnixSlashes(filename); filename += "/AutomocOldMocDefinitions.cmake"; diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index af4ceb9..a593dd5 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -21,7 +21,7 @@ class cmQtAutoGenerators { public: cmQtAutoGenerators(); - bool Run(const char* targetDirectory, const std::string& config); + bool Run(const std::string& targetDirectory, const std::string& config); bool InitializeAutogenTarget(cmTarget* target); void SetupAutoGenerateTarget(cmTarget const* target); @@ -37,11 +37,11 @@ private: void SetupAutoRccTarget(cmTarget const* target); bool ReadAutogenInfoFile(cmMakefile* makefile, - const char* targetDirectory, + const std::string& targetDirectory, const std::string& config); bool ReadOldMocDefinitionsFile(cmMakefile* makefile, - const char* targetDirectory); - void WriteOldMocDefinitionsFile(const char* targetDirectory); + const std::string& targetDirectory); + void WriteOldMocDefinitionsFile(const std::string& targetDirectory); std::string MakeCompileSettingsString(cmMakefile* makefile); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 5ada30e..13572f4 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2667,7 +2667,7 @@ int cmake::Build(const std::string& dir, return 1; } projName = it.GetValue(); - return gen->Build(0, dir.c_str(), + return gen->Build("", dir.c_str(), projName.c_str(), target.c_str(), &output, 0, -- cgit v0.12 From 1a1b737c99ac0bd0d555fde2fadf77f08516a4ea Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 24 Feb 2014 17:36:27 -0500 Subject: stringapi: Use strings for generator names --- Source/CTest/cmCTestBuildCommand.cxx | 3 +-- Source/cmComputeLinkInformation.cxx | 5 +++-- Source/cmExternalMakefileProjectGenerator.cxx | 22 ++++++++++---------- Source/cmExternalMakefileProjectGenerator.h | 11 +++++----- Source/cmExtraCodeBlocksGenerator.cxx | 9 +++++---- Source/cmExtraCodeBlocksGenerator.h | 6 +++--- Source/cmExtraCodeLiteGenerator.cxx | 2 +- Source/cmExtraCodeLiteGenerator.h | 6 +++--- Source/cmExtraEclipseCDT4Generator.cxx | 2 +- Source/cmExtraEclipseCDT4Generator.h | 6 +++--- Source/cmExtraKateGenerator.cxx | 4 ++-- Source/cmExtraKateGenerator.h | 6 +++--- Source/cmExtraSublimeTextGenerator.cxx | 11 +++++----- Source/cmExtraSublimeTextGenerator.h | 6 +++--- Source/cmGlobalBorlandMakefileGenerator.h | 4 ++-- Source/cmGlobalGenerator.cxx | 4 ++-- Source/cmGlobalGenerator.h | 8 ++++---- Source/cmGlobalGeneratorFactory.h | 8 +++++--- Source/cmGlobalJOMMakefileGenerator.h | 4 ++-- Source/cmGlobalKdevelopGenerator.cxx | 2 +- Source/cmGlobalKdevelopGenerator.h | 6 +++--- Source/cmGlobalMSYSMakefileGenerator.h | 4 ++-- Source/cmGlobalMinGWMakefileGenerator.h | 4 ++-- Source/cmGlobalNMakeMakefileGenerator.h | 4 ++-- Source/cmGlobalNinjaGenerator.h | 4 ++-- Source/cmGlobalUnixMakefileGenerator3.cxx | 4 ++-- Source/cmGlobalUnixMakefileGenerator3.h | 4 ++-- Source/cmGlobalVisualStudio10Generator.cxx | 24 ++++++++++++---------- Source/cmGlobalVisualStudio10Generator.h | 7 ++++--- Source/cmGlobalVisualStudio11Generator.cxx | 24 ++++++++++++---------- Source/cmGlobalVisualStudio11Generator.h | 7 ++++--- Source/cmGlobalVisualStudio12Generator.cxx | 24 ++++++++++++---------- Source/cmGlobalVisualStudio12Generator.h | 7 ++++--- Source/cmGlobalVisualStudio6Generator.h | 4 ++-- Source/cmGlobalVisualStudio71Generator.cxx | 9 +++++---- Source/cmGlobalVisualStudio71Generator.h | 8 ++++---- Source/cmGlobalVisualStudio7Generator.cxx | 22 +++++++++++--------- Source/cmGlobalVisualStudio7Generator.h | 10 ++++----- Source/cmGlobalVisualStudio8Generator.cxx | 29 ++++++++++++++++----------- Source/cmGlobalVisualStudio8Generator.h | 9 +++++---- Source/cmGlobalVisualStudio9Generator.cxx | 14 +++++++------ Source/cmGlobalVisualStudio9Generator.h | 5 +++-- Source/cmGlobalVisualStudioGenerator.cxx | 4 ++-- Source/cmGlobalVisualStudioGenerator.h | 2 +- Source/cmGlobalWatcomWMakeGenerator.h | 4 ++-- Source/cmGlobalXCodeGenerator.cxx | 7 ++++--- Source/cmGlobalXCodeGenerator.h | 4 ++-- Source/cmLocalVisualStudio7Generator.h | 2 +- Source/cmMakefile.cxx | 4 ++-- Source/cmQtAutoGenerators.cxx | 2 +- Source/cmake.cxx | 16 ++++++++------- Source/cmake.h | 4 ++-- 52 files changed, 221 insertions(+), 190 deletions(-) diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index c60ded0..04eabd2 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -101,8 +101,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() } if ( this->GlobalGenerator ) { - if ( strcmp(this->GlobalGenerator->GetName(), - cmakeGeneratorName) != 0 ) + if ( this->GlobalGenerator->GetName() != cmakeGeneratorName ) { delete this->GlobalGenerator; this->GlobalGenerator = 0; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index e4e2047..62eaec2 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1127,9 +1127,10 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) // Full path libraries should specify a valid library file name. // See documentation of CMP0008. + std::string generator = this->GlobalGenerator->GetName(); if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && - (strstr(this->GlobalGenerator->GetName(), "Visual Studio") || - strstr(this->GlobalGenerator->GetName(), "Xcode"))) + (generator.find("Visual Studio") != generator.npos || + generator.find("Xcode") != generator.npos)) { std::string file = cmSystemTools::GetFilenameName(item); if(!this->ExtractAnyLibraryName.find(file.c_str())) diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx index 0d42c35..d89a1c8 100644 --- a/Source/cmExternalMakefileProjectGenerator.cxx +++ b/Source/cmExternalMakefileProjectGenerator.cxx @@ -20,13 +20,13 @@ void cmExternalMakefileProjectGenerator } std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName( - const char* globalGenerator, - const char* extraGenerator) + const std::string& globalGenerator, + const std::string& extraGenerator) { std::string fullName; - if (globalGenerator) + if (!globalGenerator.empty()) { - if (extraGenerator && *extraGenerator) + if (!extraGenerator.empty()) { fullName = extraGenerator; fullName += " - "; @@ -36,22 +36,22 @@ std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName( return fullName; } -const char* cmExternalMakefileProjectGenerator::GetGlobalGeneratorName( - const char* fullName) +std::string cmExternalMakefileProjectGenerator::GetGlobalGeneratorName( + const std::string& fullName) { // at least one global generator must be supported assert(!this->SupportedGlobalGenerators.empty()); - if (fullName==0) + if (fullName.empty()) { - return 0; + return ""; } std::string currentName = fullName; // if we get only the short name, take the first global generator as default if (currentName == this->GetName()) { - return this->SupportedGlobalGenerators[0].c_str(); + return this->SupportedGlobalGenerators[0]; } // otherwise search for the matching global generator @@ -63,8 +63,8 @@ const char* cmExternalMakefileProjectGenerator::GetGlobalGeneratorName( if (this->CreateFullGeneratorName(it->c_str(), this->GetName()) == currentName) { - return it->c_str(); + return *it; } } - return 0; + return ""; } diff --git a/Source/cmExternalMakefileProjectGenerator.h b/Source/cmExternalMakefileProjectGenerator.h index bce441d..cba1c76 100644 --- a/Source/cmExternalMakefileProjectGenerator.h +++ b/Source/cmExternalMakefileProjectGenerator.h @@ -37,10 +37,10 @@ public: virtual ~cmExternalMakefileProjectGenerator() {} ///! Get the name for this generator. - virtual const char* GetName() const = 0; + virtual std::string GetName() const = 0; /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry, - const char* fullName) const = 0; + const std::string& fullName) const = 0; virtual void EnableLanguage(std::vector const& languages, cmMakefile *, bool optional); @@ -53,12 +53,13 @@ public: {return this->SupportedGlobalGenerators;} ///! Get the name of the global generator for the given full name - const char* GetGlobalGeneratorName(const char* fullName); + std::string GetGlobalGeneratorName(const std::string& fullName); /** Create a full name from the given global generator name and the * extra generator name */ - static std::string CreateFullGeneratorName(const char* globalGenerator, - const char* extraGenerator); + static std::string CreateFullGeneratorName( + const std::string& globalGenerator, + const std::string& extraGenerator); ///! Generate the project files, the Makefiles have already been generated virtual void Generate() = 0; diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 01d1155..4a59704 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -38,7 +38,7 @@ http://forums.codeblocks.org/index.php/topic,6789.0.html //---------------------------------------------------------------------------- void cmExtraCodeBlocksGenerator -::GetDocumentation(cmDocumentationEntry& entry, const char*) const +::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const { entry.Name = this->GetName(); entry.Brief = "Generates CodeBlocks project files."; @@ -761,7 +761,8 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( const std::string& target) { std::string command = make; - if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0) + std::string generator = this->GlobalGenerator->GetName(); + if (generator == "NMake Makefiles") { // For Windows ConvertToOutputPath already adds quotes when required. // These need to be escaped, see @@ -772,7 +773,7 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( command += " VERBOSE=1 "; command += target; } - else if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0) + else if (generator == "MinGW Makefiles") { // no escaping of spaces in this case, see // http://public.kitware.com/Bug/view.php?id=10014 @@ -783,7 +784,7 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( command += " VERBOSE=1 "; command += target; } - else if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0) + else if (generator == "Ninja") { command += " -v "; command += target; diff --git a/Source/cmExtraCodeBlocksGenerator.h b/Source/cmExtraCodeBlocksGenerator.h index 1cbc3f3..0435ad8 100644 --- a/Source/cmExtraCodeBlocksGenerator.h +++ b/Source/cmExtraCodeBlocksGenerator.h @@ -28,14 +28,14 @@ class cmExtraCodeBlocksGenerator : public cmExternalMakefileProjectGenerator public: cmExtraCodeBlocksGenerator(); - virtual const char* GetName() const + virtual std::string GetName() const { return cmExtraCodeBlocksGenerator::GetActualName();} - static const char* GetActualName() { return "CodeBlocks";} + static std::string GetActualName() { return "CodeBlocks";} static cmExternalMakefileProjectGenerator* New() { return new cmExtraCodeBlocksGenerator; } /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry, - const char* fullName) const; + const std::string& fullName) const; virtual void Generate(); private: diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 1e34fe0..15fe8bb 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -28,7 +28,7 @@ //---------------------------------------------------------------------------- void cmExtraCodeLiteGenerator::GetDocumentation(cmDocumentationEntry& entry, - const char*) const + const std::string&) const { entry.Name = this->GetName(); entry.Brief = "Generates CodeLite project files."; diff --git a/Source/cmExtraCodeLiteGenerator.h b/Source/cmExtraCodeLiteGenerator.h index 984313e..6b4965d 100644 --- a/Source/cmExtraCodeLiteGenerator.h +++ b/Source/cmExtraCodeLiteGenerator.h @@ -35,14 +35,14 @@ protected: public: cmExtraCodeLiteGenerator(); - virtual const char* GetName() const + virtual std::string GetName() const { return cmExtraCodeLiteGenerator::GetActualName();} - static const char* GetActualName() { return "CodeLite";} + static std::string GetActualName() { return "CodeLite";} static cmExternalMakefileProjectGenerator* New() { return new cmExtraCodeLiteGenerator; } /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry, - const char* fullName) const; + const std::string& fullName) const; virtual void Generate(); void CreateProjectFile(const std::vector& lgs); diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 38a2470..4aabc7e 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -45,7 +45,7 @@ cmExtraEclipseCDT4Generator //---------------------------------------------------------------------------- void cmExtraEclipseCDT4Generator -::GetDocumentation(cmDocumentationEntry& entry, const char*) const +::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const { entry.Name = this->GetName(); entry.Brief = "Generates Eclipse CDT 4.0 project files."; diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index d88b247..ef99760 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -33,14 +33,14 @@ public: return new cmExtraEclipseCDT4Generator; } - virtual const char* GetName() const { + virtual std::string GetName() const { return cmExtraEclipseCDT4Generator::GetActualName(); } - static const char* GetActualName() { return "Eclipse CDT4"; } + static std::string GetActualName() { return "Eclipse CDT4"; } virtual void GetDocumentation(cmDocumentationEntry& entry, - const char* fullName) const; + const std::string& fullName) const; virtual void EnableLanguage(std::vector const& languages, cmMakefile *, bool optional); diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index a0d37d4..567542e 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -25,7 +25,7 @@ //---------------------------------------------------------------------------- void cmExtraKateGenerator -::GetDocumentation(cmDocumentationEntry& entry, const char*) const +::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const { entry.Name = this->GetName(); entry.Brief = "Generates Kate project files."; @@ -52,7 +52,7 @@ void cmExtraKateGenerator::Generate() this->ProjectName = this->GenerateProjectName(mf->GetProjectName(), mf->GetSafeDefinition("CMAKE_BUILD_TYPE"), this->GetPathBasename(mf->GetHomeOutputDirectory())); - this->UseNinja = (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0); + this->UseNinja = (this->GlobalGenerator->GetName() == "Ninja"); this->CreateKateProjectFile(mf); this->CreateDummyKateProjectFile(mf); diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h index 6ced5fe..f800feb 100644 --- a/Source/cmExtraKateGenerator.h +++ b/Source/cmExtraKateGenerator.h @@ -28,14 +28,14 @@ class cmExtraKateGenerator : public cmExternalMakefileProjectGenerator public: cmExtraKateGenerator(); - virtual const char* GetName() const + virtual std::string GetName() const { return cmExtraKateGenerator::GetActualName();} - static const char* GetActualName() { return "Kate";} + static std::string GetActualName() { return "Kate";} static cmExternalMakefileProjectGenerator* New() { return new cmExtraKateGenerator; } /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry, - const char* fullName) const; + const std::string& fullName) const; virtual void Generate(); private: diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 03c7c92..f973a84 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -41,7 +41,7 @@ http://sublimetext.info/docs/en/reference/build_systems.html //---------------------------------------------------------------------------- void cmExtraSublimeTextGenerator -::GetDocumentation(cmDocumentationEntry& entry, const char*) const +::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const { entry.Name = this->GetName(); entry.Brief = "Generates Sublime Text 2 project files."; @@ -290,7 +290,7 @@ void cmExtraSublimeTextGenerator:: // Ninja uses ninja.build files (look for a way to get the output file name // from cmMakefile or something) std::string makefileName; - if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0) + if (this->GlobalGenerator->GetName() == "Ninja") { makefileName = "build.ninja"; } @@ -320,7 +320,8 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand( { std::string command = "\""; command += make + "\""; - if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0) + std::string generator = this->GlobalGenerator->GetName(); + if (generator == "NMake Makefiles") { std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile); command += ", \"/NOLOGO\", \"/f\", \""; @@ -329,7 +330,7 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand( command += target; command += "\""; } - else if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0) + else if (generator == "Ninja") { std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile); command += ", \"-f\", \""; @@ -341,7 +342,7 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand( else { std::string makefileName; - if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0) + if (generator == "MinGW Makefiles") { // no escaping of spaces in this case, see // http://public.kitware.com/Bug/view.php?id=10014 diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h index 44dfb31..4173b7d 100644 --- a/Source/cmExtraSublimeTextGenerator.h +++ b/Source/cmExtraSublimeTextGenerator.h @@ -31,15 +31,15 @@ public: typedef std::map > MapSourceFileFlags; cmExtraSublimeTextGenerator(); - virtual const char* GetName() const + virtual std::string GetName() const { return cmExtraSublimeTextGenerator::GetActualName();} - static const char* GetActualName() + static std::string GetActualName() { return "Sublime Text 2";} static cmExternalMakefileProjectGenerator* New() { return new cmExtraSublimeTextGenerator; } /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry, - const char* fullName) const; + const std::string& fullName) const; virtual void Generate(); private: diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index 70004ea..470dea4 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -28,9 +28,9 @@ public: (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalBorlandMakefileGenerator::GetActualName();} - static const char* GetActualName() {return "Borland Makefiles";} + static std::string GetActualName() {return "Borland Makefiles";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index c1cce2e..5dee5d7 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2599,9 +2599,9 @@ void cmGlobalGenerator::SetExternalMakefileProjectGenerator( } } -const char* cmGlobalGenerator::GetExtraGeneratorName() const +std::string cmGlobalGenerator::GetExtraGeneratorName() const { - return this->ExtraGenerator==0 ? 0 : this->ExtraGenerator->GetName(); + return this->ExtraGenerator? this->ExtraGenerator->GetName() : std::string(); } void cmGlobalGenerator::FileReplacedDuringGenerate(const std::string& filename) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 761fb07..38dc63a 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -51,11 +51,11 @@ public: virtual cmLocalGenerator *CreateLocalGenerator(); ///! Get the name for this generator - virtual const char *GetName() const { return "Generic"; }; + virtual std::string GetName() const { return "Generic"; }; /** Check whether the given name matches the current generator. */ - virtual bool MatchesGeneratorName(const char* name) const - { return strcmp(this->GetName(), name) == 0; } + virtual bool MatchesGeneratorName(const std::string& name) const + { return this->GetName() == name; } /** Set the generator-specific toolset name. Returns true if toolset is supported and false otherwise. */ @@ -163,7 +163,7 @@ public: void SetExternalMakefileProjectGenerator( cmExternalMakefileProjectGenerator *extraGenerator); - const char* GetExtraGeneratorName() const; + std::string GetExtraGeneratorName() const; void AddInstallComponent(const char* component); diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h index fd1d65f..3c2cd60 100644 --- a/Source/cmGlobalGeneratorFactory.h +++ b/Source/cmGlobalGeneratorFactory.h @@ -29,7 +29,8 @@ public: virtual ~cmGlobalGeneratorFactory() {} /** Create a GlobalGenerator */ - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* n) const = 0; + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& n) const = 0; /** Get the documentation entry for this factory */ virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0; @@ -43,8 +44,9 @@ class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory { public: /** Create a GlobalGenerator */ - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if (strcmp(name, T::GetActualName())) return 0; + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { + if (name != T::GetActualName()) return 0; return new T; } /** Get the documentation entry for this factory */ diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h index 28893bf..344e013 100644 --- a/Source/cmGlobalJOMMakefileGenerator.h +++ b/Source/cmGlobalJOMMakefileGenerator.h @@ -27,11 +27,11 @@ public: return new cmGlobalGeneratorSimpleFactory (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalJOMMakefileGenerator::GetActualName();} // use NMake Makefiles in the name so that scripts/tests that depend on the // name NMake Makefiles will work - static const char* GetActualName() {return "NMake Makefiles JOM";} + static std::string GetActualName() {return "NMake Makefiles JOM";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 2d485f6..71e08cc 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -25,7 +25,7 @@ //---------------------------------------------------------------------------- void cmGlobalKdevelopGenerator -::GetDocumentation(cmDocumentationEntry& entry, const char*) const +::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const { entry.Name = this->GetName(); entry.Brief = "Generates KDevelop 3 project files."; diff --git a/Source/cmGlobalKdevelopGenerator.h b/Source/cmGlobalKdevelopGenerator.h index a1ad39d..0d59fc5 100644 --- a/Source/cmGlobalKdevelopGenerator.h +++ b/Source/cmGlobalKdevelopGenerator.h @@ -33,14 +33,14 @@ class cmGlobalKdevelopGenerator : public cmExternalMakefileProjectGenerator public: cmGlobalKdevelopGenerator(); - virtual const char* GetName() const + virtual std::string GetName() const { return cmGlobalKdevelopGenerator::GetActualName();} - static const char* GetActualName() { return "KDevelop3";} + static std::string GetActualName() { return "KDevelop3";} static cmExternalMakefileProjectGenerator* New() { return new cmGlobalKdevelopGenerator; } /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry, - const char* fullName) const; + const std::string& fullName) const; virtual void Generate(); private: diff --git a/Source/cmGlobalMSYSMakefileGenerator.h b/Source/cmGlobalMSYSMakefileGenerator.h index 659de11..c4825bd 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.h +++ b/Source/cmGlobalMSYSMakefileGenerator.h @@ -28,9 +28,9 @@ public: (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalMSYSMakefileGenerator::GetActualName();} - static const char* GetActualName() {return "MSYS Makefiles";} + static std::string GetActualName() {return "MSYS Makefiles";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalMinGWMakefileGenerator.h b/Source/cmGlobalMinGWMakefileGenerator.h index 7951e98..4289422 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.h +++ b/Source/cmGlobalMinGWMakefileGenerator.h @@ -27,9 +27,9 @@ public: return new cmGlobalGeneratorSimpleFactory (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalMinGWMakefileGenerator::GetActualName();} - static const char* GetActualName() {return "MinGW Makefiles";} + static std::string GetActualName() {return "MinGW Makefiles";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index 5756fbd..2ff44e3 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -27,9 +27,9 @@ public: return new cmGlobalGeneratorSimpleFactory (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalNMakeMakefileGenerator::GetActualName();} - static const char* GetActualName() {return "NMake Makefiles";} + static std::string GetActualName() {return "NMake Makefiles";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 4a28486..2467af9 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -173,11 +173,11 @@ public: virtual cmLocalGenerator* CreateLocalGenerator(); /// Overloaded methods. @see cmGlobalGenerator::GetName(). - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalNinjaGenerator::GetActualName(); } /// @return the name of this generator. - static const char* GetActualName() { return "Ninja"; } + static std::string GetActualName() { return "Ninja"; } /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation() static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 9ddbe5b..08a1c62 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -72,7 +72,7 @@ std::string cmGlobalUnixMakefileGenerator3::GetEditCacheCommand() const { // If generating for an extra IDE, the edit_cache target cannot // launch a terminal-interactive tool, so always use cmake-gui. - if(this->GetExtraGeneratorName()) + if(!this->GetExtraGeneratorName().empty()) { return cmSystemTools::GetCMakeGUICommand(); } @@ -579,7 +579,7 @@ void cmGlobalUnixMakefileGenerator3 // Since we have full control over the invocation of nmake, let us // make it quiet. - if ( strcmp(this->GetName(), "NMake Makefiles") == 0 ) + if ( this->GetName() == "NMake Makefiles" ) { makeCommand.push_back("/NOLOGO"); } diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index d64afaf..ea2b6c0 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -60,9 +60,9 @@ public: (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalUnixMakefileGenerator3::GetActualName();} - static const char* GetActualName() {return "Unix Makefiles";} + static std::string GetActualName() {return "Unix Makefiles";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 3819a5b..2dc658e 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -21,13 +21,14 @@ static const char vs10generatorName[] = "Visual Studio 10 2010"; // Map generator name without year to name with year. -static const char* cmVS10GenName(const char* name, std::string& genName) +static const char* cmVS10GenName(const std::string& name, std::string& genName) { - if(strncmp(name, vs10generatorName, sizeof(vs10generatorName)-6) != 0) + if(strncmp(name.c_str(), vs10generatorName, + sizeof(vs10generatorName)-6) != 0) { return 0; } - const char* p = name + sizeof(vs10generatorName) - 6; + const char* p = name.c_str() + sizeof(vs10generatorName) - 6; if(cmHasLiteralPrefix(p, " 2010")) { p += 5; @@ -40,27 +41,27 @@ class cmGlobalVisualStudio10Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { std::string genName; const char* p = cmVS10GenName(name, genName); if(!p) { return 0; } - name = genName.c_str(); if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio10Generator( - name, NULL, NULL); + genName, "", ""); } if(strcmp(p, " Win64") == 0) { return new cmGlobalVisualStudio10Generator( - name, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64", "CMAKE_FORCE_WIN64"); } if(strcmp(p, " IA64") == 0) { return new cmGlobalVisualStudio10Generator( - name, "Itanium", "CMAKE_FORCE_IA64"); + genName, "Itanium", "CMAKE_FORCE_IA64"); } return 0; } @@ -87,8 +88,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( - const char* name, const char* platformName, - const char* additionalPlatformDefinition) + const std::string& name, const std::string& platformName, + const std::string& additionalPlatformDefinition) : cmGlobalVisualStudio8Generator(name, platformName, additionalPlatformDefinition) { @@ -102,7 +103,8 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( //---------------------------------------------------------------------------- bool -cmGlobalVisualStudio10Generator::MatchesGeneratorName(const char* name) const +cmGlobalVisualStudio10Generator::MatchesGeneratorName( + const std::string& name) const { std::string genName; if(cmVS10GenName(name, genName)) diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 5d902ee..d3ad69e 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -24,11 +24,12 @@ class cmGlobalVisualStudio10Generator : public cmGlobalVisualStudio8Generator { public: - cmGlobalVisualStudio10Generator(const char* name, - const char* platformName, const char* additionalPlatformDefinition); + cmGlobalVisualStudio10Generator(const std::string& name, + const std::string& platformName, + const std::string& additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); - virtual bool MatchesGeneratorName(const char* name) const; + virtual bool MatchesGeneratorName(const std::string& name) const; virtual bool SetGeneratorToolset(std::string const& ts); diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 1f0c47a..4caa7f2 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -16,13 +16,14 @@ static const char vs11generatorName[] = "Visual Studio 11 2012"; // Map generator name without year to name with year. -static const char* cmVS11GenName(const char* name, std::string& genName) +static const char* cmVS11GenName(const std::string& name, std::string& genName) { - if(strncmp(name, vs11generatorName, sizeof(vs11generatorName)-6) != 0) + if(strncmp(name.c_str(), vs11generatorName, + sizeof(vs11generatorName)-6) != 0) { return 0; } - const char* p = name + sizeof(vs11generatorName) - 6; + const char* p = name.c_str() + sizeof(vs11generatorName) - 6; if(cmHasLiteralPrefix(p, " 2012")) { p += 5; @@ -35,27 +36,27 @@ class cmGlobalVisualStudio11Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { std::string genName; const char* p = cmVS11GenName(name, genName); if(!p) { return 0; } - name = genName.c_str(); if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio11Generator( - name, NULL, NULL); + genName, "", ""); } if(strcmp(p, " Win64") == 0) { return new cmGlobalVisualStudio11Generator( - name, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64", "CMAKE_FORCE_WIN64"); } if(strcmp(p, " ARM") == 0) { return new cmGlobalVisualStudio11Generator( - name, "ARM", NULL); + genName, "ARM", ""); } if(*p++ != ' ') @@ -107,8 +108,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( - const char* name, const char* platformName, - const char* additionalPlatformDefinition) + const std::string& name, const std::string& platformName, + const std::string& additionalPlatformDefinition) : cmGlobalVisualStudio10Generator(name, platformName, additionalPlatformDefinition) { @@ -121,7 +122,8 @@ cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( //---------------------------------------------------------------------------- bool -cmGlobalVisualStudio11Generator::MatchesGeneratorName(const char* name) const +cmGlobalVisualStudio11Generator::MatchesGeneratorName( + const std::string& name) const { std::string genName; if(cmVS11GenName(name, genName)) diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 7ef77e7..48ea489 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -20,11 +20,12 @@ class cmGlobalVisualStudio11Generator: public cmGlobalVisualStudio10Generator { public: - cmGlobalVisualStudio11Generator(const char* name, - const char* platformName, const char* additionalPlatformDefinition); + cmGlobalVisualStudio11Generator(const std::string& name, + const std::string& platformName, + const std::string& additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); - virtual bool MatchesGeneratorName(const char* name) const; + virtual bool MatchesGeneratorName(const std::string& name) const; virtual void WriteSLNHeader(std::ostream& fout); diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 3074794..6cd9f12 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -16,13 +16,14 @@ static const char vs12generatorName[] = "Visual Studio 12 2013"; // Map generator name without year to name with year. -static const char* cmVS12GenName(const char* name, std::string& genName) +static const char* cmVS12GenName(const std::string& name, std::string& genName) { - if(strncmp(name, vs12generatorName, sizeof(vs12generatorName)-6) != 0) + if(strncmp(name.c_str(), vs12generatorName, + sizeof(vs12generatorName)-6) != 0) { return 0; } - const char* p = name + sizeof(vs12generatorName) - 6; + const char* p = name.c_str() + sizeof(vs12generatorName) - 6; if(cmHasLiteralPrefix(p, " 2013")) { p += 5; @@ -35,27 +36,27 @@ class cmGlobalVisualStudio12Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { std::string genName; const char* p = cmVS12GenName(name, genName); if(!p) { return 0; } - name = genName.c_str(); if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio12Generator( - name, NULL, NULL); + genName, "", ""); } if(strcmp(p, " Win64") == 0) { return new cmGlobalVisualStudio12Generator( - name, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64", "CMAKE_FORCE_WIN64"); } if(strcmp(p, " ARM") == 0) { return new cmGlobalVisualStudio12Generator( - name, "ARM", NULL); + genName, "ARM", ""); } return 0; } @@ -82,8 +83,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator( - const char* name, const char* platformName, - const char* additionalPlatformDefinition) + const std::string& name, const std::string& platformName, + const std::string& additionalPlatformDefinition) : cmGlobalVisualStudio11Generator(name, platformName, additionalPlatformDefinition) { @@ -96,7 +97,8 @@ cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator( //---------------------------------------------------------------------------- bool -cmGlobalVisualStudio12Generator::MatchesGeneratorName(const char* name) const +cmGlobalVisualStudio12Generator::MatchesGeneratorName( + const std::string& name) const { std::string genName; if(cmVS12GenName(name, genName)) diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index 5a4a78d..4557f28 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -20,11 +20,12 @@ class cmGlobalVisualStudio12Generator: public cmGlobalVisualStudio11Generator { public: - cmGlobalVisualStudio12Generator(const char* name, - const char* platformName, const char* additionalPlatformDefinition); + cmGlobalVisualStudio12Generator(const std::string& name, + const std::string& platformName, + const std::string& additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); - virtual bool MatchesGeneratorName(const char* name) const; + virtual bool MatchesGeneratorName(const std::string& name) const; virtual void WriteSLNHeader(std::ostream& fout); diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index eb3dddf..14046f0 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -31,9 +31,9 @@ public: (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalVisualStudio6Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 6";} + static std::string GetActualName() {return "Visual Studio 6";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 08bcc5b..4bea5ac 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -17,7 +17,8 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator( - const char* platformName) : cmGlobalVisualStudio7Generator(platformName) + const std::string& platformName) + : cmGlobalVisualStudio7Generator(platformName) { this->ProjectConfigurationSectionName = "ProjectConfiguration"; } @@ -279,10 +280,10 @@ void cmGlobalVisualStudio71Generator ::WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmTarget::TargetType, const std::set& configsPartOfDefaultBuild, - const char* platformMapping) + std::string const& platformMapping) { - const char* platformName = - platformMapping ? platformMapping : this->GetPlatformName(); + const std::string& platformName = + !platformMapping.empty() ? platformMapping : this->GetPlatformName(); std::string guid = this->GetGUID(name); for(std::vector::iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index 75cc6ae..2b5259a 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -23,15 +23,15 @@ class cmGlobalVisualStudio71Generator : public cmGlobalVisualStudio7Generator { public: - cmGlobalVisualStudio71Generator(const char* platformName = NULL); + cmGlobalVisualStudio71Generator(const std::string& platformName = ""); static cmGlobalGeneratorFactory* NewFactory() { return new cmGlobalGeneratorSimpleFactory (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalVisualStudio71Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 7 .NET 2003";} + static std::string GetActualName() {return "Visual Studio 7 .NET 2003";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); @@ -67,7 +67,7 @@ protected: virtual void WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmTarget::TargetType type, const std::set& configsPartOfDefaultBuild, - const char* platformMapping = NULL); + const std::string& platformMapping = ""); virtual void WriteExternalProject(std::ostream& fout, const std::string& name, const char* path, diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 3927100..03772dd 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -19,16 +19,19 @@ #include cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( - const char* platformName) + const std::string& platformName) { this->IntelProjectVersion = 0; this->DevEnvCommandInitialized = false; - if (!platformName) + if (platformName.empty()) { - platformName = "Win32"; + this->PlatformName = "Win32"; + } + else + { + this->PlatformName = platformName; } - this->PlatformName = platformName; } cmGlobalVisualStudio7Generator::~cmGlobalVisualStudio7Generator() @@ -260,7 +263,7 @@ cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator() void cmGlobalVisualStudio7Generator::AddPlatformDefinitions(cmMakefile* mf) { cmGlobalVisualStudioGenerator::AddPlatformDefinitions(mf); - mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName()); + mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName().c_str()); mf->AddDefinition("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION", this->GetIntelProjectVersion()); } @@ -381,9 +384,10 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( { std::set allConfigurations(this->Configurations.begin(), this->Configurations.end()); + const char* mapping = target->GetProperty("VS_PLATFORM_MAPPING"); this->WriteProjectConfigurations( fout, target->GetName().c_str(), target->GetType(), - allConfigurations, target->GetProperty("VS_PLATFORM_MAPPING")); + allConfigurations, mapping ? mapping : ""); } else { @@ -732,10 +736,10 @@ void cmGlobalVisualStudio7Generator ::WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmTarget::TargetType, const std::set& configsPartOfDefaultBuild, - const char* platformMapping) + const std::string& platformMapping) { - const char* platformName = - platformMapping ? platformMapping : this->GetPlatformName(); + const std::string& platformName = + !platformMapping.empty() ? platformMapping : this->GetPlatformName(); std::string guid = this->GetGUID(name); for(std::vector::iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index b659480..9ab0462 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -26,7 +26,7 @@ struct cmIDEFlagTable; class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator { public: - cmGlobalVisualStudio7Generator(const char* platformName = NULL); + cmGlobalVisualStudio7Generator(const std::string& platformName = ""); ~cmGlobalVisualStudio7Generator(); static cmGlobalGeneratorFactory* NewFactory() { @@ -34,12 +34,12 @@ public: (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalVisualStudio7Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 7";} + static std::string GetActualName() {return "Visual Studio 7";} ///! Get the name for the platform. - const char* GetPlatformName() const { return this->PlatformName.c_str(); } + const std::string& GetPlatformName() const { return this->PlatformName; } ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); @@ -131,7 +131,7 @@ protected: virtual void WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmTarget::TargetType type, const std::set& configsPartOfDefaultBuild, - const char* platformMapping = NULL); + const std::string& platformMapping = ""); virtual void WriteSLNGlobalSections(std::ostream& fout, cmLocalGenerator* root); virtual void WriteSLNFooter(std::ostream& fout); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 2ae1bbc..08c1397 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -23,17 +23,19 @@ class cmGlobalVisualStudio8Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if(strstr(name, vs8generatorName) != name) + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { + if(strncmp(name.c_str(), vs8generatorName, + sizeof(vs8generatorName) - 1) != 0) { return 0; } - const char* p = name + sizeof(vs8generatorName) - 1; + const char* p = name.c_str() + sizeof(vs8generatorName) - 1; if(p[0] == '\0') { return new cmGlobalVisualStudio8Generator( - name, NULL, NULL); + name, "", ""); } if(p[0] != ' ') @@ -57,7 +59,7 @@ public: } cmGlobalVisualStudio8Generator* ret = new cmGlobalVisualStudio8Generator( - name, p, NULL); + name, p, ""); ret->WindowsCEVersion = parser.GetOSVersion(); return ret; } @@ -90,14 +92,14 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio8Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator( - const char* name, const char* platformName, - const char* additionalPlatformDefinition) + const std::string& name, const std::string& platformName, + const std::string& additionalPlatformDefinition) : cmGlobalVisualStudio71Generator(platformName) { this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms"; this->Name = name; - if (additionalPlatformDefinition) + if (!additionalPlatformDefinition.empty()) { this->AdditionalPlatformDefinition = additionalPlatformDefinition; } @@ -374,7 +376,7 @@ cmGlobalVisualStudio8Generator ::WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmTarget::TargetType type, const std::set& configsPartOfDefaultBuild, - const char* platformMapping) + std::string const& platformMapping) { std::string guid = this->GetGUID(name); for(std::vector::iterator i = this->Configurations.begin(); @@ -382,7 +384,8 @@ cmGlobalVisualStudio8Generator { fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|" - << (platformMapping ? platformMapping : this->GetPlatformName()) + << (!platformMapping.empty()? + platformMapping : this->GetPlatformName()) << "\n"; std::set::const_iterator ci = configsPartOfDefaultBuild.find(*i); @@ -390,7 +393,8 @@ cmGlobalVisualStudio8Generator { fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() << ".Build.0 = " << *i << "|" - << (platformMapping ? platformMapping : this->GetPlatformName()) + << (!platformMapping.empty()? + platformMapping : this->GetPlatformName()) << "\n"; } bool needsDeploy = (type == cmTarget::EXECUTABLE || @@ -399,7 +403,8 @@ cmGlobalVisualStudio8Generator { fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() << ".Deploy.0 = " << *i << "|" - << (platformMapping ? platformMapping : this->GetPlatformName()) + << (!platformMapping.empty()? + platformMapping : this->GetPlatformName()) << "\n"; } } diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index bafb9eb..2459c05 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -23,12 +23,13 @@ class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator { public: - cmGlobalVisualStudio8Generator(const char* name, - const char* platformName, const char* additionalPlatformDefinition); + cmGlobalVisualStudio8Generator(const std::string& name, + const std::string& platformName, + const std::string& additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); ///! Get the name for the generator. - virtual const char* GetName() const {return this->Name.c_str();} + virtual std::string GetName() const {return this->Name;} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); @@ -81,7 +82,7 @@ protected: virtual void WriteProjectConfigurations( std::ostream& fout, const std::string& name, cmTarget::TargetType type, const std::set& configsPartOfDefaultBuild, - const char* platformMapping = NULL); + const std::string& platformMapping = ""); virtual bool ComputeTargetDepends(); virtual void WriteProjectDepends(std::ostream& fout, const std::string& name, diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index ccc27ad..c0051c7 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -22,17 +22,19 @@ class cmGlobalVisualStudio9Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if(strstr(name, vs9generatorName) != name) + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { + if(strncmp(name.c_str(), vs9generatorName, + sizeof(vs9generatorName) - 1) != 0) { return 0; } - const char* p = name + sizeof(vs9generatorName) - 1; + const char* p = name.c_str() + sizeof(vs9generatorName) - 1; if(p[0] == '\0') { return new cmGlobalVisualStudio9Generator( - name, NULL, NULL); + name, "", ""); } if(p[0] != ' ') @@ -96,8 +98,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator( - const char* name, const char* platformName, - const char* additionalPlatformDefinition) + const std::string& name, const std::string& platformName, + const std::string& additionalPlatformDefinition) : cmGlobalVisualStudio8Generator(name, platformName, additionalPlatformDefinition) { diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h index 202aa8d..fb87bbe 100644 --- a/Source/cmGlobalVisualStudio9Generator.h +++ b/Source/cmGlobalVisualStudio9Generator.h @@ -24,8 +24,9 @@ class cmGlobalVisualStudio9Generator : public cmGlobalVisualStudio8Generator { public: - cmGlobalVisualStudio9Generator(const char* name, - const char* platformName, const char* additionalPlatformDefinition); + cmGlobalVisualStudio9Generator(const std::string& name, + const std::string& platformName, + const std::string& additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); ///! create the correct local generator diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index b2a705e..69c893c 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -22,7 +22,7 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator() { - this->AdditionalPlatformDefinition = NULL; + this->AdditionalPlatformDefinition = ""; } //---------------------------------------------------------------------------- @@ -518,7 +518,7 @@ void cmGlobalVisualStudioGenerator::FindMakeProgram(cmMakefile* mf) //---------------------------------------------------------------------------- void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf) { - if(this->AdditionalPlatformDefinition) + if(!this->AdditionalPlatformDefinition.empty()) { mf->AddDefinition(this->AdditionalPlatformDefinition, "TRUE"); } diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index dc0f9c7..7e8dcf8 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -110,7 +110,7 @@ protected: std::string GetUtilityDepend(cmTarget const* target); typedef std::map UtilityDependsMap; UtilityDependsMap UtilityDepends; - const char* AdditionalPlatformDefinition; + std::string AdditionalPlatformDefinition; private: virtual std::string GetVSMakeProgram() = 0; diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h index d5350ef..2057a42 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -27,9 +27,9 @@ public: return new cmGlobalGeneratorSimpleFactory (); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalWatcomWMakeGenerator::GetActualName();} - static const char* GetActualName() {return "Watcom WMake";} + static std::string GetActualName() {return "Watcom WMake";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index e1f2a91..30bded5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -116,7 +116,8 @@ public: class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const; + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const; virtual void GetDocumentation(cmDocumentationEntry& entry) const { cmGlobalXCodeGenerator::GetDocumentation(entry); } @@ -152,9 +153,9 @@ cmGlobalGeneratorFactory* cmGlobalXCodeGenerator::NewFactory() //---------------------------------------------------------------------------- cmGlobalGenerator* cmGlobalXCodeGenerator::Factory -::CreateGlobalGenerator(const char* name) const +::CreateGlobalGenerator(const std::string& name) const { - if (strcmp(name, GetActualName())) + if (name != GetActualName()) return 0; #if defined(CMAKE_BUILD_WITH_CMAKE) cmXcodeVersionParser parser; diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index aec7958..54c6f96 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -33,9 +33,9 @@ public: static cmGlobalGeneratorFactory* NewFactory(); ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalXCodeGenerator::GetActualName();} - static const char* GetActualName() {return "Xcode";} + static std::string GetActualName() {return "Xcode";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index d2e66a5..6c04559 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -53,7 +53,7 @@ public: */ void SetBuildType(BuildType,const std::string& name); - void SetPlatformName(const char* n) { this->PlatformName = n;} + void SetPlatformName(const std::string& n) { this->PlatformName = n;} void SetExtraFlagTable(cmVS7FlagTable const* table) { this->ExtraFlagTable = table; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e61b12b..e8be29f 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1378,8 +1378,8 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove) // VS6 IDE does not support definition values with spaces in // combination with '"', '$', or ';'. - if((strcmp(this->LocalGenerator->GetGlobalGenerator()->GetName(), - "Visual Studio 6") == 0) && + if((this->LocalGenerator->GetGlobalGenerator()->GetName() == + "Visual Studio 6") && (def.find(" ") != def.npos && def.find_first_of("\"$;") != def.npos)) { return false; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 48a6b38..c32f624 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -251,7 +251,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) bool usePRE_BUILD = false; cmLocalGenerator* localGen = makefile->GetLocalGenerator(); cmGlobalGenerator* gg = localGen->GetGlobalGenerator(); - if(strstr(gg->GetName(), "Visual Studio")) + if(gg->GetName().find("Visual Studio") != std::string::npos) { cmLocalVisualStudioGenerator* vslg = static_cast(localGen); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 13572f4..abe27a5 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -965,7 +965,7 @@ int cmake::AddCMakePaths() return 1; } -void cmake::AddExtraGenerator(const char* name, +void cmake::AddExtraGenerator(const std::string& name, CreateExtraGeneratorFunctionType newFunction) { cmExternalMakefileProjectGenerator* extraGenerator = newFunction(); @@ -1034,9 +1034,10 @@ void cmake::GetRegisteredGenerators(std::vector& names) } } -cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name) +cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname) { cmExternalMakefileProjectGenerator* extraGenerator = 0; + std::string name = gname; RegisteredExtraGeneratorsMap::const_iterator extraGenIt = this->ExtraGenerators.find(name); if (extraGenIt != this->ExtraGenerators.end()) @@ -1324,7 +1325,8 @@ int cmake::ActualConfigure() if(genName) { std::string fullName = cmExternalMakefileProjectGenerator:: - CreateFullGeneratorName(genName, extraGenName); + CreateFullGeneratorName(genName, + extraGenName ? extraGenName : ""); this->GlobalGenerator = this->CreateGlobalGenerator(fullName.c_str()); } if(this->GlobalGenerator) @@ -1417,13 +1419,13 @@ int cmake::ActualConfigure() if(!this->CacheManager->GetCacheValue("CMAKE_GENERATOR")) { this->CacheManager->AddCacheEntry("CMAKE_GENERATOR", - this->GlobalGenerator->GetName(), + this->GlobalGenerator->GetName().c_str(), "Name of generator.", cmCacheManager::INTERNAL); this->CacheManager->AddCacheEntry("CMAKE_EXTRA_GENERATOR", - this->GlobalGenerator->GetExtraGeneratorName(), - "Name of external makefile project generator.", - cmCacheManager::INTERNAL); + this->GlobalGenerator->GetExtraGeneratorName().c_str(), + "Name of external makefile project generator.", + cmCacheManager::INTERNAL); } if(const char* tsName = diff --git a/Source/cmake.h b/Source/cmake.h index 933502a..3134493 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -175,7 +175,7 @@ class cmake void PreLoadCMakeFiles(); ///! Create a GlobalGenerator - cmGlobalGenerator* CreateGlobalGenerator(const char* name); + cmGlobalGenerator* CreateGlobalGenerator(const std::string& name); ///! Return the global generator assigned to this instance of cmake cmGlobalGenerator* GetGlobalGenerator() { return this->GlobalGenerator; } @@ -380,7 +380,7 @@ protected: void AddDefaultCommands(); void AddDefaultGenerators(); void AddDefaultExtraGenerators(); - void AddExtraGenerator(const char* name, + void AddExtraGenerator(const std::string& name, CreateExtraGeneratorFunctionType newFunction); cmPolicies *Policies; -- cgit v0.12 From 6557382dcffef8ed6b11394cb65775d82f1c0aa7 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 24 Feb 2014 17:38:55 -0500 Subject: stringapi: Use strings for program paths --- Source/cmBuildCommand.cxx | 4 ++-- Source/cmGlobalGenerator.cxx | 31 ++++++++++++++++++------------ Source/cmGlobalGenerator.h | 8 ++++---- Source/cmGlobalNinjaGenerator.cxx | 2 +- Source/cmGlobalNinjaGenerator.h | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 2 +- Source/cmGlobalUnixMakefileGenerator3.h | 2 +- Source/cmGlobalVisualStudio10Generator.cxx | 2 +- Source/cmGlobalVisualStudio10Generator.h | 2 +- Source/cmGlobalVisualStudio6Generator.cxx | 2 +- Source/cmGlobalVisualStudio6Generator.h | 2 +- Source/cmGlobalVisualStudio7Generator.cxx | 2 +- Source/cmGlobalVisualStudio7Generator.h | 2 +- Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmGlobalXCodeGenerator.h | 2 +- Source/cmake.cxx | 2 +- 16 files changed, 38 insertions(+), 31 deletions(-) diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx index d8e1a2c..780ffa8 100644 --- a/Source/cmBuildCommand.cxx +++ b/Source/cmBuildCommand.cxx @@ -107,7 +107,7 @@ bool cmBuildCommand std::string makecommand = this->Makefile->GetLocalGenerator() ->GetGlobalGenerator()->GenerateCMakeBuildCommand(target, configuration, - 0, true); + "", true); this->Makefile->AddDefinition(variable, makecommand.c_str()); @@ -137,7 +137,7 @@ bool cmBuildCommand std::string makecommand = this->Makefile->GetLocalGenerator() ->GetGlobalGenerator()->GenerateCMakeBuildCommand("", configType.c_str(), - 0, true); + "", true); if(cacheValue) { diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 5dee5d7..faed66a 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -89,19 +89,25 @@ bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts) return false; } -std::string cmGlobalGenerator::SelectMakeProgram(const char* makeProgram, - std::string makeDefault) const +std::string cmGlobalGenerator::SelectMakeProgram( + const std::string& inMakeProgram, + const std::string& makeDefault) const { - if(cmSystemTools::IsOff(makeProgram)) + std::string makeProgram = inMakeProgram; + if(cmSystemTools::IsOff(makeProgram.c_str())) { - makeProgram = + const char* makeProgramCSTR = this->CMakeInstance->GetCacheDefinition("CMAKE_MAKE_PROGRAM"); - if(cmSystemTools::IsOff(makeProgram)) + if(cmSystemTools::IsOff(makeProgramCSTR)) { - makeProgram = makeDefault.c_str(); + makeProgram = makeDefault; } - if(cmSystemTools::IsOff(makeProgram) && - !(makeProgram && *makeProgram)) + else + { + makeProgram = makeProgramCSTR; + } + if(cmSystemTools::IsOff(makeProgram.c_str()) && + !makeProgram.empty()) { makeProgram = "CMAKE_MAKE_PROGRAM-NOTFOUND"; } @@ -1660,13 +1666,14 @@ int cmGlobalGenerator::TryCompile(const std::string& srcdir, mf->GetSafeDefinition("CMAKE_TRY_COMPILE_CONFIGURATION"); return this->Build(srcdir,bindir,projectName, newTarget.c_str(), - output,0,config,false,fast, + output,"",config,false,fast, this->TryCompileTimeout); } void cmGlobalGenerator::GenerateBuildCommand( - std::vector& makeCommand, const char*, const std::string&, - const std::string&, const std::string&, const std::string&, bool, + std::vector& makeCommand, const std::string&, + const std::string&, const std::string&, const std::string&, + const std::string&, bool, std::vector const&) { makeCommand.push_back( @@ -1677,7 +1684,7 @@ int cmGlobalGenerator::Build( const std::string&, const std::string& bindir, const std::string& projectName, const std::string& target, std::string *output, - const char *makeCommandCSTR, + const std::string& makeCommandCSTR, const std::string& config, bool clean, bool fast, double timeout, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 38dc63a..91e71a8 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -120,7 +120,7 @@ public: int Build(const std::string& srcdir, const std::string& bindir, const std::string& projectName, const std::string& targetName, std::string *output, - const char *makeProgram, const std::string& config, + const std::string& makeProgram, const std::string& config, bool clean, bool fast, double timeout, cmSystemTools::OutputOption outputflag=cmSystemTools::OUTPUT_NONE, @@ -129,7 +129,7 @@ public: virtual void GenerateBuildCommand( std::vector& makeCommand, - const char* makeProgram, + const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, const std::string& targetName, const std::string& config, bool fast, std::vector const& makeOptions = std::vector() @@ -345,8 +345,8 @@ protected: cmTarget const*> > AutogensType; void CreateQtAutoGeneratorsTargets(AutogensType& autogens); - std::string SelectMakeProgram(const char* makeProgram, - std::string makeDefault = "") const; + std::string SelectMakeProgram(const std::string& makeProgram, + const std::string& makeDefault = "") const; // Fill the ProjectMap, this must be called after LocalGenerators // has been populated. diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 73a6245..785b902 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -551,7 +551,7 @@ bool cmGlobalNinjaGenerator::UsingMinGW = false; // cmGlobalGenerator::Build() void cmGlobalNinjaGenerator ::GenerateBuildCommand(std::vector& makeCommand, - const char* makeProgram, + const std::string& makeProgram, const std::string& /*projectName*/, const std::string& /*projectDir*/, const std::string& targetName, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 2467af9..7725cf3 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -193,7 +193,7 @@ public: /// Overloaded methods. @see cmGlobalGenerator::GenerateBuildCommand() virtual void GenerateBuildCommand( std::vector& makeCommand, - const char* makeProgram, + const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, const std::string& targetName, diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 08a1c62..d41cee6 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -565,7 +565,7 @@ cmGlobalUnixMakefileGenerator3 //---------------------------------------------------------------------------- void cmGlobalUnixMakefileGenerator3 ::GenerateBuildCommand(std::vector& makeCommand, - const char* makeProgram, + const std::string& makeProgram, const std::string& /*projectName*/, const std::string& /*projectDir*/, const std::string& targetName, diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index ea2b6c0..8115176 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -109,7 +109,7 @@ public: // change the build command for speed virtual void GenerateBuildCommand( std::vector& makeCommand, - const char* makeProgram, + const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, const std::string& targetName, diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 2dc658e..840e888 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -312,7 +312,7 @@ std::string cmGlobalVisualStudio10Generator::FindDevEnvCommand() //---------------------------------------------------------------------------- void cmGlobalVisualStudio10Generator::GenerateBuildCommand( std::vector& makeCommand, - const char* makeProgram, + const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, const std::string& targetName, diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index d3ad69e..999a9d5 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -35,7 +35,7 @@ public: virtual void GenerateBuildCommand( std::vector& makeCommand, - const char* makeProgram, + const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, const std::string& targetName, diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 3a51fce..7397bbb 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -116,7 +116,7 @@ std::string cmGlobalVisualStudio6Generator::FindMSDevCommand() void cmGlobalVisualStudio6Generator::GenerateBuildCommand( std::vector& makeCommand, - const char* makeProgram, + const std::string& makeProgram, const std::string& projectName, const std::string& /*projectDir*/, const std::string& targetName, diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 14046f0..2797e11 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -54,7 +54,7 @@ public: */ virtual void GenerateBuildCommand( std::vector& makeCommand, - const char* makeProgram, + const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, const std::string& targetName, diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 03772dd..320b440 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -186,7 +186,7 @@ const char* cmGlobalVisualStudio7Generator::ExternalProjectType( //---------------------------------------------------------------------------- void cmGlobalVisualStudio7Generator::GenerateBuildCommand( std::vector& makeCommand, - const char* makeProgram, + const std::string& makeProgram, const std::string& projectName, const std::string& /*projectDir*/, const std::string& targetName, diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 9ab0462..0d2e410 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -62,7 +62,7 @@ public: */ virtual void GenerateBuildCommand( std::vector& makeCommand, - const char* makeProgram, + const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, const std::string& targetName, diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 30bded5..30a2a1e 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -261,7 +261,7 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vectorconst& void cmGlobalXCodeGenerator::GenerateBuildCommand( std::vector& makeCommand, - const char* makeProgram, + const std::string& makeProgram, const std::string& projectName, const std::string& /*projectDir*/, const std::string& targetName, diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 54c6f96..93315ba 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -55,7 +55,7 @@ public: */ virtual void GenerateBuildCommand( std::vector& makeCommand, - const char* makeProgram, + const std::string& makeProgram, const std::string& projectName, const std::string& projectDir, const std::string& targetName, diff --git a/Source/cmake.cxx b/Source/cmake.cxx index abe27a5..ab12411 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2672,7 +2672,7 @@ int cmake::Build(const std::string& dir, return gen->Build("", dir.c_str(), projName.c_str(), target.c_str(), &output, - 0, + "", config.c_str(), clean, false, 0, cmSystemTools::OUTPUT_PASSTHROUGH, nativeOptions); -- cgit v0.12 From 85fc9f26a703f28b356c93d405446c39bba43846 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 24 Feb 2014 20:19:17 -0500 Subject: stringapi: Command names --- Source/CTest/cmCTestBuildCommand.h | 2 +- Source/CTest/cmCTestConfigureCommand.h | 2 +- Source/CTest/cmCTestCoverageCommand.h | 2 +- Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h | 2 +- Source/CTest/cmCTestMemCheckCommand.h | 2 +- Source/CTest/cmCTestReadCustomFilesCommand.h | 2 +- Source/CTest/cmCTestRunScriptCommand.h | 2 +- Source/CTest/cmCTestSleepCommand.h | 2 +- Source/CTest/cmCTestStartCommand.h | 2 +- Source/CTest/cmCTestSubmitCommand.h | 2 +- Source/CTest/cmCTestTestCommand.h | 2 +- Source/CTest/cmCTestTestHandler.cxx | 8 ++++---- Source/CTest/cmCTestUpdateCommand.h | 2 +- Source/CTest/cmCTestUploadCommand.h | 2 +- Source/cmAddCompileOptionsCommand.h | 2 +- Source/cmAddCustomCommandCommand.h | 2 +- Source/cmAddCustomTargetCommand.h | 2 +- Source/cmAddDefinitionsCommand.h | 2 +- Source/cmAddDependenciesCommand.h | 2 +- Source/cmAddExecutableCommand.h | 2 +- Source/cmAddLibraryCommand.h | 2 +- Source/cmAddSubDirectoryCommand.h | 2 +- Source/cmAddTestCommand.h | 2 +- Source/cmAuxSourceDirectoryCommand.h | 2 +- Source/cmBreakCommand.h | 2 +- Source/cmBuildCommand.h | 2 +- Source/cmBuildNameCommand.h | 2 +- Source/cmCMakeHostSystemInformationCommand.h | 2 +- Source/cmCMakeMinimumRequired.h | 2 +- Source/cmCMakePolicyCommand.h | 2 +- Source/cmCommand.h | 2 +- Source/cmConfigureFileCommand.h | 2 +- Source/cmCreateTestSourceList.h | 2 +- Source/cmDefinePropertyCommand.h | 2 +- Source/cmDocumentationSection.h | 4 ++-- Source/cmElseCommand.h | 2 +- Source/cmElseIfCommand.h | 2 +- Source/cmEnableLanguageCommand.h | 2 +- Source/cmEnableTestingCommand.h | 2 +- Source/cmEndForEachCommand.h | 2 +- Source/cmEndFunctionCommand.h | 2 +- Source/cmEndIfCommand.h | 2 +- Source/cmEndMacroCommand.h | 2 +- Source/cmEndWhileCommand.h | 2 +- Source/cmExecProgramCommand.h | 2 +- Source/cmExecuteProcessCommand.h | 2 +- Source/cmExportCommand.h | 2 +- Source/cmExportLibraryDependenciesCommand.h | 2 +- Source/cmFLTKWrapUICommand.h | 2 +- Source/cmFileCommand.h | 2 +- Source/cmFindFileCommand.h | 2 +- Source/cmFindLibraryCommand.h | 2 +- Source/cmFindPackageCommand.h | 2 +- Source/cmFindPathCommand.h | 2 +- Source/cmFindProgramCommand.h | 2 +- Source/cmForEachCommand.h | 2 +- Source/cmFunctionCommand.cxx | 2 +- Source/cmFunctionCommand.h | 2 +- Source/cmGetCMakePropertyCommand.h | 2 +- Source/cmGetDirectoryPropertyCommand.h | 2 +- Source/cmGetFilenameComponentCommand.h | 2 +- Source/cmGetPropertyCommand.h | 2 +- Source/cmGetSourceFilePropertyCommand.h | 2 +- Source/cmGetTargetPropertyCommand.h | 2 +- Source/cmGetTestPropertyCommand.h | 2 +- Source/cmIfCommand.h | 2 +- Source/cmIncludeCommand.h | 2 +- Source/cmIncludeDirectoryCommand.h | 2 +- Source/cmIncludeExternalMSProjectCommand.h | 2 +- Source/cmIncludeRegularExpressionCommand.h | 2 +- Source/cmInstallCommand.h | 2 +- Source/cmInstallFilesCommand.h | 2 +- Source/cmInstallProgramsCommand.h | 2 +- Source/cmInstallTargetsCommand.h | 2 +- Source/cmLinkDirectoriesCommand.h | 2 +- Source/cmLinkLibrariesCommand.h | 2 +- Source/cmListCommand.h | 2 +- Source/cmLoadCacheCommand.h | 2 +- Source/cmLoadCommandCommand.cxx | 2 +- Source/cmLoadCommandCommand.h | 2 +- Source/cmMacroCommand.cxx | 2 +- Source/cmMacroCommand.h | 2 +- Source/cmMakeDirectoryCommand.h | 2 +- Source/cmMarkAsAdvancedCommand.h | 2 +- Source/cmMathCommand.h | 2 +- Source/cmMessageCommand.h | 2 +- Source/cmOptionCommand.h | 2 +- Source/cmOutputRequiredFilesCommand.h | 2 +- Source/cmProjectCommand.h | 2 +- Source/cmQTWrapCPPCommand.h | 2 +- Source/cmQTWrapUICommand.h | 2 +- Source/cmRemoveCommand.h | 2 +- Source/cmRemoveDefinitionsCommand.h | 2 +- Source/cmReturnCommand.h | 2 +- Source/cmSeparateArgumentsCommand.h | 2 +- Source/cmSetCommand.h | 2 +- Source/cmSetDirectoryPropertiesCommand.h | 2 +- Source/cmSetPropertyCommand.h | 2 +- Source/cmSetSourceFilesPropertiesCommand.h | 2 +- Source/cmSetTargetPropertiesCommand.h | 2 +- Source/cmSetTestsPropertiesCommand.h | 2 +- Source/cmSiteNameCommand.h | 2 +- Source/cmSourceGroupCommand.h | 2 +- Source/cmStringCommand.h | 2 +- Source/cmSubdirCommand.h | 2 +- Source/cmSubdirDependsCommand.h | 2 +- Source/cmTargetCompileDefinitionsCommand.h | 2 +- Source/cmTargetCompileOptionsCommand.h | 2 +- Source/cmTargetIncludeDirectoriesCommand.h | 2 +- Source/cmTargetLinkLibrariesCommand.h | 2 +- Source/cmTryCompileCommand.h | 2 +- Source/cmTryRunCommand.h | 2 +- Source/cmUnsetCommand.h | 2 +- Source/cmUseMangledMesaCommand.h | 2 +- Source/cmUtilitySourceCommand.h | 2 +- Source/cmVariableRequiresCommand.h | 2 +- Source/cmVariableWatchCommand.h | 2 +- Source/cmWhileCommand.h | 2 +- Source/cmWriteFileCommand.h | 2 +- Source/cmake.cxx | 9 +++++---- Source/cmake.h | 8 ++++---- 121 files changed, 132 insertions(+), 131 deletions(-) diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h index 08887fe..2632ebc 100644 --- a/Source/CTest/cmCTestBuildCommand.h +++ b/Source/CTest/cmCTestBuildCommand.h @@ -43,7 +43,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_build";} + virtual std::string GetName() const { return "ctest_build";} virtual bool InitialPass(std::vector const& args, cmExecutionStatus &status); diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h index b592c5a..7941d4e 100644 --- a/Source/CTest/cmCTestConfigureCommand.h +++ b/Source/CTest/cmCTestConfigureCommand.h @@ -38,7 +38,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_configure";} + virtual std::string GetName() const { return "ctest_configure";} cmTypeMacro(cmCTestConfigureCommand, cmCTestHandlerCommand); diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h index 3731592..5762e07 100644 --- a/Source/CTest/cmCTestCoverageCommand.h +++ b/Source/CTest/cmCTestCoverageCommand.h @@ -39,7 +39,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_coverage";} + virtual std::string GetName() const { return "ctest_coverage";} cmTypeMacro(cmCTestCoverageCommand, cmCTestHandlerCommand); diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h index 07e59a4..d182d17 100644 --- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h +++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h @@ -48,7 +48,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_empty_binary_directory";} + virtual std::string GetName() const { return "ctest_empty_binary_directory";} cmTypeMacro(cmCTestEmptyBinaryDirectoryCommand, cmCTestCommand); diff --git a/Source/CTest/cmCTestMemCheckCommand.h b/Source/CTest/cmCTestMemCheckCommand.h index b50170d..e239d46 100644 --- a/Source/CTest/cmCTestMemCheckCommand.h +++ b/Source/CTest/cmCTestMemCheckCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_memcheck";} + virtual std::string GetName() const { return "ctest_memcheck";} cmTypeMacro(cmCTestMemCheckCommand, cmCTestTestCommand); diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.h b/Source/CTest/cmCTestReadCustomFilesCommand.h index 9c0af81..c95694a 100644 --- a/Source/CTest/cmCTestReadCustomFilesCommand.h +++ b/Source/CTest/cmCTestReadCustomFilesCommand.h @@ -46,7 +46,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_read_custom_files";} + virtual std::string GetName() const { return "ctest_read_custom_files";} cmTypeMacro(cmCTestReadCustomFilesCommand, cmCTestCommand); diff --git a/Source/CTest/cmCTestRunScriptCommand.h b/Source/CTest/cmCTestRunScriptCommand.h index f34bd13..0998e5c 100644 --- a/Source/CTest/cmCTestRunScriptCommand.h +++ b/Source/CTest/cmCTestRunScriptCommand.h @@ -47,7 +47,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_run_script";} + virtual std::string GetName() const { return "ctest_run_script";} cmTypeMacro(cmCTestRunScriptCommand, cmCTestCommand); }; diff --git a/Source/CTest/cmCTestSleepCommand.h b/Source/CTest/cmCTestSleepCommand.h index c6baf1c..740a7e1 100644 --- a/Source/CTest/cmCTestSleepCommand.h +++ b/Source/CTest/cmCTestSleepCommand.h @@ -47,7 +47,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_sleep";} + virtual std::string GetName() const { return "ctest_sleep";} cmTypeMacro(cmCTestSleepCommand, cmCTestCommand); diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h index e5535c1..3b8843f 100644 --- a/Source/CTest/cmCTestStartCommand.h +++ b/Source/CTest/cmCTestStartCommand.h @@ -55,7 +55,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_start";} + virtual std::string GetName() const { return "ctest_start";} cmTypeMacro(cmCTestStartCommand, cmCTestCommand); diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h index 64c6cae..3673fbd 100644 --- a/Source/CTest/cmCTestSubmitCommand.h +++ b/Source/CTest/cmCTestSubmitCommand.h @@ -48,7 +48,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_submit";} + virtual std::string GetName() const { return "ctest_submit";} cmTypeMacro(cmCTestSubmitCommand, cmCTestHandlerCommand); diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h index 451ac99..a1e5f36 100644 --- a/Source/CTest/cmCTestTestCommand.h +++ b/Source/CTest/cmCTestTestCommand.h @@ -39,7 +39,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_test";} + virtual std::string GetName() const { return "ctest_test";} cmTypeMacro(cmCTestTestCommand, cmCTestHandlerCommand); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index b1dddcb..5970656 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -60,7 +60,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "subdirs";} + virtual std::string GetName() const { return "subdirs";} cmTypeMacro(cmCTestSubdirCommand, cmCommand); @@ -157,7 +157,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "add_subdirectory";} + virtual std::string GetName() const { return "add_subdirectory";} cmTypeMacro(cmCTestAddSubdirectoryCommand, cmCommand); @@ -243,7 +243,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "add_test";} + virtual std::string GetName() const { return "add_test";} cmTypeMacro(cmCTestAddTestCommand, cmCommand); @@ -287,7 +287,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "set_tests_properties";} + virtual std::string GetName() const { return "set_tests_properties";} cmTypeMacro(cmCTestSetTestsPropertiesCommand, cmCommand); diff --git a/Source/CTest/cmCTestUpdateCommand.h b/Source/CTest/cmCTestUpdateCommand.h index a785bd8..fb80333 100644 --- a/Source/CTest/cmCTestUpdateCommand.h +++ b/Source/CTest/cmCTestUpdateCommand.h @@ -39,7 +39,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_update";} + virtual std::string GetName() const { return "ctest_update";} cmTypeMacro(cmCTestUpdateCommand, cmCTestHandlerCommand); diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h index e867fb6..4a07608 100644 --- a/Source/CTest/cmCTestUploadCommand.h +++ b/Source/CTest/cmCTestUploadCommand.h @@ -43,7 +43,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_upload";} + virtual std::string GetName() const { return "ctest_upload";} cmTypeMacro(cmCTestUploadCommand, cmCTestHandlerCommand); diff --git a/Source/cmAddCompileOptionsCommand.h b/Source/cmAddCompileOptionsCommand.h index 38ed208..f147ec0 100644 --- a/Source/cmAddCompileOptionsCommand.h +++ b/Source/cmAddCompileOptionsCommand.h @@ -35,7 +35,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "add_compile_options";} + virtual std::string GetName() const {return "add_compile_options";} cmTypeMacro(cmAddCompileOptionsCommand, cmCommand); }; diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h index 114957f..1d6ddb2 100644 --- a/Source/cmAddCustomCommandCommand.h +++ b/Source/cmAddCustomCommandCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "add_custom_command";} + virtual std::string GetName() const {return "add_custom_command";} cmTypeMacro(cmAddCustomCommandCommand, cmCommand); protected: diff --git a/Source/cmAddCustomTargetCommand.h b/Source/cmAddCustomTargetCommand.h index d0fcdad..d2b00ad 100644 --- a/Source/cmAddCustomTargetCommand.h +++ b/Source/cmAddCustomTargetCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const + virtual std::string GetName() const {return "add_custom_target";} cmTypeMacro(cmAddCustomTargetCommand, cmCommand); diff --git a/Source/cmAddDefinitionsCommand.h b/Source/cmAddDefinitionsCommand.h index d05f187..9800fd2 100644 --- a/Source/cmAddDefinitionsCommand.h +++ b/Source/cmAddDefinitionsCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "add_definitions";} + virtual std::string GetName() const {return "add_definitions";} cmTypeMacro(cmAddDefinitionsCommand, cmCommand); }; diff --git a/Source/cmAddDependenciesCommand.h b/Source/cmAddDependenciesCommand.h index 247cc54..db3712a 100644 --- a/Source/cmAddDependenciesCommand.h +++ b/Source/cmAddDependenciesCommand.h @@ -40,7 +40,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "add_dependencies";} + virtual std::string GetName() const { return "add_dependencies";} cmTypeMacro(cmAddDependenciesCommand, cmCommand); }; diff --git a/Source/cmAddExecutableCommand.h b/Source/cmAddExecutableCommand.h index 30ecce3..e134077 100644 --- a/Source/cmAddExecutableCommand.h +++ b/Source/cmAddExecutableCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "add_executable";} + virtual std::string GetName() const { return "add_executable";} cmTypeMacro(cmAddExecutableCommand, cmCommand); }; diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h index 1001043..350708b 100644 --- a/Source/cmAddLibraryCommand.h +++ b/Source/cmAddLibraryCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "add_library";} + virtual std::string GetName() const { return "add_library";} cmTypeMacro(cmAddLibraryCommand, cmCommand); }; diff --git a/Source/cmAddSubDirectoryCommand.h b/Source/cmAddSubDirectoryCommand.h index 1e5b1ab..abf3efc 100644 --- a/Source/cmAddSubDirectoryCommand.h +++ b/Source/cmAddSubDirectoryCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "add_subdirectory";} + virtual std::string GetName() const { return "add_subdirectory";} cmTypeMacro(cmAddSubDirectoryCommand, cmCommand); }; diff --git a/Source/cmAddTestCommand.h b/Source/cmAddTestCommand.h index 9173454..624288f 100644 --- a/Source/cmAddTestCommand.h +++ b/Source/cmAddTestCommand.h @@ -40,7 +40,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "add_test";} + virtual std::string GetName() const { return "add_test";} cmTypeMacro(cmAddTestCommand, cmCommand); private: diff --git a/Source/cmAuxSourceDirectoryCommand.h b/Source/cmAuxSourceDirectoryCommand.h index 8b5fa8a..6615273 100644 --- a/Source/cmAuxSourceDirectoryCommand.h +++ b/Source/cmAuxSourceDirectoryCommand.h @@ -44,7 +44,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "aux_source_directory";} + virtual std::string GetName() const { return "aux_source_directory";} cmTypeMacro(cmAuxSourceDirectoryCommand, cmCommand); }; diff --git a/Source/cmBreakCommand.h b/Source/cmBreakCommand.h index 52f0e9c..1fcae50 100644 --- a/Source/cmBreakCommand.h +++ b/Source/cmBreakCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "break";} + virtual std::string GetName() const {return "break";} cmTypeMacro(cmBreakCommand, cmCommand); }; diff --git a/Source/cmBuildCommand.h b/Source/cmBuildCommand.h index 2160655..3fb618f 100644 --- a/Source/cmBuildCommand.h +++ b/Source/cmBuildCommand.h @@ -50,7 +50,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "build_command";} + virtual std::string GetName() const {return "build_command";} cmTypeMacro(cmBuildCommand, cmCommand); }; diff --git a/Source/cmBuildNameCommand.h b/Source/cmBuildNameCommand.h index 2f7acde..8f8038f 100644 --- a/Source/cmBuildNameCommand.h +++ b/Source/cmBuildNameCommand.h @@ -21,7 +21,7 @@ public: virtual cmCommand* Clone() { return new cmBuildNameCommand; } virtual bool InitialPass(std::vector const& args, cmExecutionStatus &status); - virtual const char* GetName() const {return "build_name";} + virtual std::string GetName() const {return "build_name";} virtual bool IsScriptable() const { return true; } virtual bool IsDiscouraged() const { return true; } }; diff --git a/Source/cmCMakeHostSystemInformationCommand.h b/Source/cmCMakeHostSystemInformationCommand.h index 27ba638..463b180 100644 --- a/Source/cmCMakeHostSystemInformationCommand.h +++ b/Source/cmCMakeHostSystemInformationCommand.h @@ -48,7 +48,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const + virtual std::string GetName() const { return "cmake_host_system_information"; } diff --git a/Source/cmCMakeMinimumRequired.h b/Source/cmCMakeMinimumRequired.h index 0cdd4c5..31b7271 100644 --- a/Source/cmCMakeMinimumRequired.h +++ b/Source/cmCMakeMinimumRequired.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "cmake_minimum_required";} + virtual std::string GetName() const {return "cmake_minimum_required";} cmTypeMacro(cmCMakeMinimumRequired, cmCommand); diff --git a/Source/cmCMakePolicyCommand.h b/Source/cmCMakePolicyCommand.h index 7e3f4e6..8dc8fbe 100644 --- a/Source/cmCMakePolicyCommand.h +++ b/Source/cmCMakePolicyCommand.h @@ -46,7 +46,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "cmake_policy";} + virtual std::string GetName() const {return "cmake_policy";} cmTypeMacro(cmCMakePolicyCommand, cmCommand); private: diff --git a/Source/cmCommand.h b/Source/cmCommand.h index 2378ef0..b15869a 100644 --- a/Source/cmCommand.h +++ b/Source/cmCommand.h @@ -124,7 +124,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const = 0; + virtual std::string GetName() const = 0; /** * Enable the command. diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h index 86de92c..8155ef7 100644 --- a/Source/cmConfigureFileCommand.h +++ b/Source/cmConfigureFileCommand.h @@ -34,7 +34,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "configure_file";} + virtual std::string GetName() const { return "configure_file";} /** * This determines if the command is invoked when in script mode. diff --git a/Source/cmCreateTestSourceList.h b/Source/cmCreateTestSourceList.h index 8b1e4de..2f6b541 100644 --- a/Source/cmCreateTestSourceList.h +++ b/Source/cmCreateTestSourceList.h @@ -40,7 +40,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "create_test_sourcelist";} + virtual std::string GetName() const {return "create_test_sourcelist";} cmTypeMacro(cmCreateTestSourceList, cmCommand); }; diff --git a/Source/cmDefinePropertyCommand.h b/Source/cmDefinePropertyCommand.h index 8dc4d96..bc5c8a4 100644 --- a/Source/cmDefinePropertyCommand.h +++ b/Source/cmDefinePropertyCommand.h @@ -32,7 +32,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "define_property";} + virtual std::string GetName() const { return "define_property";} cmTypeMacro(cmDefinePropertyCommand, cmCommand); private: diff --git a/Source/cmDocumentationSection.h b/Source/cmDocumentationSection.h index 636860d..d796da8 100644 --- a/Source/cmDocumentationSection.h +++ b/Source/cmDocumentationSection.h @@ -34,8 +34,8 @@ public: void Clear() { this->Entries.clear(); } /** Return the name of this section. */ - const char* GetName() const - { return this->Name.c_str(); } + std::string GetName() const + { return this->Name; } /** Return a pointer to the first entry of this section. */ const std::vector &GetEntries() const diff --git a/Source/cmElseCommand.h b/Source/cmElseCommand.h index d472e99..dde5fcc 100644 --- a/Source/cmElseCommand.h +++ b/Source/cmElseCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "else";} + virtual std::string GetName() const { return "else";} cmTypeMacro(cmElseCommand, cmCommand); }; diff --git a/Source/cmElseIfCommand.h b/Source/cmElseIfCommand.h index d811b35..c627cbe 100644 --- a/Source/cmElseIfCommand.h +++ b/Source/cmElseIfCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "elseif";} + virtual std::string GetName() const { return "elseif";} cmTypeMacro(cmElseIfCommand, cmCommand); }; diff --git a/Source/cmEnableLanguageCommand.h b/Source/cmEnableLanguageCommand.h index a248042..2b09e11 100644 --- a/Source/cmEnableLanguageCommand.h +++ b/Source/cmEnableLanguageCommand.h @@ -43,7 +43,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "enable_language";} + virtual std::string GetName() const {return "enable_language";} cmTypeMacro(cmEnableLanguageCommand, cmCommand); }; diff --git a/Source/cmEnableTestingCommand.h b/Source/cmEnableTestingCommand.h index e102f5e..d028c59 100644 --- a/Source/cmEnableTestingCommand.h +++ b/Source/cmEnableTestingCommand.h @@ -48,7 +48,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "enable_testing";} + virtual std::string GetName() const { return "enable_testing";} cmTypeMacro(cmEnableTestingCommand, cmCommand); diff --git a/Source/cmEndForEachCommand.h b/Source/cmEndForEachCommand.h index 44d29b5..c3be387 100644 --- a/Source/cmEndForEachCommand.h +++ b/Source/cmEndForEachCommand.h @@ -52,7 +52,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "endforeach";} + virtual std::string GetName() const { return "endforeach";} cmTypeMacro(cmEndForEachCommand, cmCommand); }; diff --git a/Source/cmEndFunctionCommand.h b/Source/cmEndFunctionCommand.h index 4fdca6b..3a42c17 100644 --- a/Source/cmEndFunctionCommand.h +++ b/Source/cmEndFunctionCommand.h @@ -52,7 +52,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "endfunction";} + virtual std::string GetName() const { return "endfunction";} cmTypeMacro(cmEndFunctionCommand, cmCommand); }; diff --git a/Source/cmEndIfCommand.h b/Source/cmEndIfCommand.h index 634da60..a8248c8 100644 --- a/Source/cmEndIfCommand.h +++ b/Source/cmEndIfCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "endif";} + virtual std::string GetName() const { return "endif";} cmTypeMacro(cmEndIfCommand, cmCommand); }; diff --git a/Source/cmEndMacroCommand.h b/Source/cmEndMacroCommand.h index db15f27..fdc04ee 100644 --- a/Source/cmEndMacroCommand.h +++ b/Source/cmEndMacroCommand.h @@ -52,7 +52,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "endmacro";} + virtual std::string GetName() const { return "endmacro";} cmTypeMacro(cmEndMacroCommand, cmCommand); }; diff --git a/Source/cmEndWhileCommand.h b/Source/cmEndWhileCommand.h index 41138d1..ec1cb65 100644 --- a/Source/cmEndWhileCommand.h +++ b/Source/cmEndWhileCommand.h @@ -52,7 +52,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "endwhile";} + virtual std::string GetName() const { return "endwhile";} cmTypeMacro(cmEndWhileCommand, cmCommand); }; diff --git a/Source/cmExecProgramCommand.h b/Source/cmExecProgramCommand.h index 6d28cdc..23d10f9 100644 --- a/Source/cmExecProgramCommand.h +++ b/Source/cmExecProgramCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const + virtual std::string GetName() const {return "exec_program";} /** diff --git a/Source/cmExecuteProcessCommand.h b/Source/cmExecuteProcessCommand.h index bd0f783..6906a08 100644 --- a/Source/cmExecuteProcessCommand.h +++ b/Source/cmExecuteProcessCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const + virtual std::string GetName() const {return "execute_process";} /** diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h index c0e445f..f9506bb 100644 --- a/Source/cmExportCommand.h +++ b/Source/cmExportCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "export";} + virtual std::string GetName() const { return "export";} cmTypeMacro(cmExportCommand, cmCommand); diff --git a/Source/cmExportLibraryDependenciesCommand.h b/Source/cmExportLibraryDependenciesCommand.h index 29b568f..2ea4e79 100644 --- a/Source/cmExportLibraryDependenciesCommand.h +++ b/Source/cmExportLibraryDependenciesCommand.h @@ -21,7 +21,7 @@ public: virtual cmCommand* Clone() { return new cmExportLibraryDependenciesCommand; } virtual bool InitialPass(std::vector const& args, cmExecutionStatus &status); - virtual const char* GetName() const { return "export_library_dependencies";} + virtual std::string GetName() const { return "export_library_dependencies";} virtual bool IsDiscouraged() const { return true; } virtual void FinalPass(); diff --git a/Source/cmFLTKWrapUICommand.h b/Source/cmFLTKWrapUICommand.h index b94390c..617fcd9 100644 --- a/Source/cmFLTKWrapUICommand.h +++ b/Source/cmFLTKWrapUICommand.h @@ -52,7 +52,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "fltk_wrap_ui";} + virtual std::string GetName() const { return "fltk_wrap_ui";} private: /** diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index ba45815..8d66fdf 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -46,7 +46,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "file";} + virtual std::string GetName() const { return "file";} cmTypeMacro(cmFileCommand, cmCommand); diff --git a/Source/cmFindFileCommand.h b/Source/cmFindFileCommand.h index 3f0baa2..daf1d65 100644 --- a/Source/cmFindFileCommand.h +++ b/Source/cmFindFileCommand.h @@ -33,7 +33,7 @@ public: { return new cmFindFileCommand; } - virtual const char* GetName() const { return "find_file";} + virtual std::string GetName() const { return "find_file";} cmTypeMacro(cmFindFileCommand, cmFindPathCommand); }; diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h index a9ec40e..e257174 100644 --- a/Source/cmFindLibraryCommand.h +++ b/Source/cmFindLibraryCommand.h @@ -49,7 +49,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "find_library";} + virtual std::string GetName() const {return "find_library";} cmTypeMacro(cmFindLibraryCommand, cmFindBase); diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 72c1e3c..2249459 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -49,7 +49,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "find_package";} + virtual std::string GetName() const { return "find_package";} cmTypeMacro(cmFindPackageCommand, cmFindCommon); private: diff --git a/Source/cmFindPathCommand.h b/Source/cmFindPathCommand.h index 8df4540..a51da79 100644 --- a/Source/cmFindPathCommand.h +++ b/Source/cmFindPathCommand.h @@ -49,7 +49,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "find_path";} + virtual std::string GetName() const {return "find_path";} cmTypeMacro(cmFindPathCommand, cmFindBase); bool IncludeFileInPath; diff --git a/Source/cmFindProgramCommand.h b/Source/cmFindProgramCommand.h index 7f4811c..70f758f 100644 --- a/Source/cmFindProgramCommand.h +++ b/Source/cmFindProgramCommand.h @@ -48,7 +48,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "find_program";} + virtual std::string GetName() const { return "find_program";} cmTypeMacro(cmFindProgramCommand, cmFindBase); diff --git a/Source/cmForEachCommand.h b/Source/cmForEachCommand.h index e548ba8..9b7c85a 100644 --- a/Source/cmForEachCommand.h +++ b/Source/cmForEachCommand.h @@ -59,7 +59,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "foreach";} + virtual std::string GetName() const { return "foreach";} cmTypeMacro(cmForEachCommand, cmCommand); private: diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 85b89d9..9b981a3 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -64,7 +64,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return this->Args[0].c_str(); } + virtual std::string GetName() const { return this->Args[0]; } cmTypeMacro(cmFunctionHelperCommand, cmCommand); diff --git a/Source/cmFunctionCommand.h b/Source/cmFunctionCommand.h index a8bd3e7..2df435e 100644 --- a/Source/cmFunctionCommand.h +++ b/Source/cmFunctionCommand.h @@ -57,7 +57,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "function";} + virtual std::string GetName() const { return "function";} cmTypeMacro(cmFunctionCommand, cmCommand); }; diff --git a/Source/cmGetCMakePropertyCommand.h b/Source/cmGetCMakePropertyCommand.h index 6c58bb4..1511406 100644 --- a/Source/cmGetCMakePropertyCommand.h +++ b/Source/cmGetCMakePropertyCommand.h @@ -37,7 +37,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "get_cmake_property";} + virtual std::string GetName() const { return "get_cmake_property";} cmTypeMacro(cmGetCMakePropertyCommand, cmCommand); }; diff --git a/Source/cmGetDirectoryPropertyCommand.h b/Source/cmGetDirectoryPropertyCommand.h index aea04ad..6c5750a 100644 --- a/Source/cmGetDirectoryPropertyCommand.h +++ b/Source/cmGetDirectoryPropertyCommand.h @@ -37,7 +37,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "get_directory_property";} + virtual std::string GetName() const { return "get_directory_property";} cmTypeMacro(cmGetDirectoryPropertyCommand, cmCommand); }; diff --git a/Source/cmGetFilenameComponentCommand.h b/Source/cmGetFilenameComponentCommand.h index e2cd219..534de53 100644 --- a/Source/cmGetFilenameComponentCommand.h +++ b/Source/cmGetFilenameComponentCommand.h @@ -46,7 +46,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "get_filename_component";} + virtual std::string GetName() const { return "get_filename_component";} cmTypeMacro(cmGetFilenameComponentCommand, cmCommand); }; diff --git a/Source/cmGetPropertyCommand.h b/Source/cmGetPropertyCommand.h index e1630ff..8c3738f 100644 --- a/Source/cmGetPropertyCommand.h +++ b/Source/cmGetPropertyCommand.h @@ -39,7 +39,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "get_property";} + virtual std::string GetName() const { return "get_property";} cmTypeMacro(cmGetPropertyCommand, cmCommand); private: diff --git a/Source/cmGetSourceFilePropertyCommand.h b/Source/cmGetSourceFilePropertyCommand.h index 338318e..ab8ce36 100644 --- a/Source/cmGetSourceFilePropertyCommand.h +++ b/Source/cmGetSourceFilePropertyCommand.h @@ -32,7 +32,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "get_source_file_property";} + virtual std::string GetName() const { return "get_source_file_property";} cmTypeMacro(cmGetSourceFilePropertyCommand, cmCommand); }; diff --git a/Source/cmGetTargetPropertyCommand.h b/Source/cmGetTargetPropertyCommand.h index 4985b3c..a35c6fe 100644 --- a/Source/cmGetTargetPropertyCommand.h +++ b/Source/cmGetTargetPropertyCommand.h @@ -32,7 +32,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "get_target_property";} + virtual std::string GetName() const { return "get_target_property";} cmTypeMacro(cmGetTargetPropertyCommand, cmCommand); }; diff --git a/Source/cmGetTestPropertyCommand.h b/Source/cmGetTestPropertyCommand.h index 2dccabe..2819492 100644 --- a/Source/cmGetTestPropertyCommand.h +++ b/Source/cmGetTestPropertyCommand.h @@ -32,7 +32,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "get_test_property";} + virtual std::string GetName() const { return "get_test_property";} cmTypeMacro(cmGetTestPropertyCommand, cmCommand); }; diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h index 02d87ed..b9de845 100644 --- a/Source/cmIfCommand.h +++ b/Source/cmIfCommand.h @@ -63,7 +63,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "if";} + virtual std::string GetName() const { return "if";} /** * This determines if the command is invoked when in script mode. diff --git a/Source/cmIncludeCommand.h b/Source/cmIncludeCommand.h index 267723d..0dcd7de 100644 --- a/Source/cmIncludeCommand.h +++ b/Source/cmIncludeCommand.h @@ -46,7 +46,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "include";} + virtual std::string GetName() const {return "include";} cmTypeMacro(cmIncludeCommand, cmCommand); }; diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h index c621dcb..6cc2c83 100644 --- a/Source/cmIncludeDirectoryCommand.h +++ b/Source/cmIncludeDirectoryCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "include_directories";} + virtual std::string GetName() const { return "include_directories";} cmTypeMacro(cmIncludeDirectoryCommand, cmCommand); diff --git a/Source/cmIncludeExternalMSProjectCommand.h b/Source/cmIncludeExternalMSProjectCommand.h index 8ca674f..081f77a 100644 --- a/Source/cmIncludeExternalMSProjectCommand.h +++ b/Source/cmIncludeExternalMSProjectCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "include_external_msproject";} + virtual std::string GetName() const {return "include_external_msproject";} cmTypeMacro(cmIncludeExternalMSProjectCommand, cmCommand); }; diff --git a/Source/cmIncludeRegularExpressionCommand.h b/Source/cmIncludeRegularExpressionCommand.h index 0c5fa6f..c58f018 100644 --- a/Source/cmIncludeRegularExpressionCommand.h +++ b/Source/cmIncludeRegularExpressionCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "include_regular_expression";} + virtual std::string GetName() const {return "include_regular_expression";} cmTypeMacro(cmIncludeRegularExpressionCommand, cmCommand); }; diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index 9db2490..8e14a08 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "install";} + virtual std::string GetName() const { return "install";} cmTypeMacro(cmInstallCommand, cmCommand); diff --git a/Source/cmInstallFilesCommand.h b/Source/cmInstallFilesCommand.h index 5583fe4..4551ab1 100644 --- a/Source/cmInstallFilesCommand.h +++ b/Source/cmInstallFilesCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "install_files";} + virtual std::string GetName() const { return "install_files";} /** * This is called at the end after all the information diff --git a/Source/cmInstallProgramsCommand.h b/Source/cmInstallProgramsCommand.h index 95acfa2..90c7ba3 100644 --- a/Source/cmInstallProgramsCommand.h +++ b/Source/cmInstallProgramsCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "install_programs";} + virtual std::string GetName() const { return "install_programs";} /** * This is called at the end after all the information diff --git a/Source/cmInstallTargetsCommand.h b/Source/cmInstallTargetsCommand.h index 2aa34db..e6cbe6e 100644 --- a/Source/cmInstallTargetsCommand.h +++ b/Source/cmInstallTargetsCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "install_targets";} + virtual std::string GetName() const { return "install_targets";} /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const diff --git a/Source/cmLinkDirectoriesCommand.h b/Source/cmLinkDirectoriesCommand.h index c6eb40c..8e04baf 100644 --- a/Source/cmLinkDirectoriesCommand.h +++ b/Source/cmLinkDirectoriesCommand.h @@ -43,7 +43,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "link_directories";} + virtual std::string GetName() const { return "link_directories";} cmTypeMacro(cmLinkDirectoriesCommand, cmCommand); private: diff --git a/Source/cmLinkLibrariesCommand.h b/Source/cmLinkLibrariesCommand.h index 74de23c..c572439 100644 --- a/Source/cmLinkLibrariesCommand.h +++ b/Source/cmLinkLibrariesCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "link_libraries";} + virtual std::string GetName() const { return "link_libraries";} /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const diff --git a/Source/cmListCommand.h b/Source/cmListCommand.h index b79ff0d..5ea1d9f 100644 --- a/Source/cmListCommand.h +++ b/Source/cmListCommand.h @@ -44,7 +44,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "list";} + virtual std::string GetName() const { return "list";} cmTypeMacro(cmListCommand, cmCommand); protected: diff --git a/Source/cmLoadCacheCommand.h b/Source/cmLoadCacheCommand.h index ff8625f..04207d0 100644 --- a/Source/cmLoadCacheCommand.h +++ b/Source/cmLoadCacheCommand.h @@ -40,7 +40,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "load_cache";} + virtual std::string GetName() const { return "load_cache";} cmTypeMacro(cmLoadCacheCommand, cmCommand); protected: diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index 21ee0fe..36e9980 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -69,7 +69,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return info.Name; } + virtual std::string GetName() const { return info.Name; } static const char* LastName; static void TrapsForSignals(int sig) diff --git a/Source/cmLoadCommandCommand.h b/Source/cmLoadCommandCommand.h index 11bcf09..4581269 100644 --- a/Source/cmLoadCommandCommand.h +++ b/Source/cmLoadCommandCommand.h @@ -20,7 +20,7 @@ public: virtual cmCommand* Clone() { return new cmLoadCommandCommand; } virtual bool InitialPass(std::vector const& args, cmExecutionStatus &status); - virtual const char* GetName() const {return "load_command";} + virtual std::string GetName() const {return "load_command";} virtual bool IsDiscouraged() const { return true; } cmTypeMacro(cmLoadCommandCommand, cmCommand); }; diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 499d3c6..9d253b8 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -65,7 +65,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return this->Args[0].c_str(); } + virtual std::string GetName() const { return this->Args[0]; } cmTypeMacro(cmMacroHelperCommand, cmCommand); diff --git a/Source/cmMacroCommand.h b/Source/cmMacroCommand.h index 4c585d8..5c1cc00 100644 --- a/Source/cmMacroCommand.h +++ b/Source/cmMacroCommand.h @@ -57,7 +57,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "macro";} + virtual std::string GetName() const { return "macro";} cmTypeMacro(cmMacroCommand, cmCommand); }; diff --git a/Source/cmMakeDirectoryCommand.h b/Source/cmMakeDirectoryCommand.h index 49a4009..71b97eb 100644 --- a/Source/cmMakeDirectoryCommand.h +++ b/Source/cmMakeDirectoryCommand.h @@ -44,7 +44,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "make_directory";} + virtual std::string GetName() const { return "make_directory";} /** * This determines if the command is invoked when in script mode. diff --git a/Source/cmMarkAsAdvancedCommand.h b/Source/cmMarkAsAdvancedCommand.h index b65e4a8..38064a3 100644 --- a/Source/cmMarkAsAdvancedCommand.h +++ b/Source/cmMarkAsAdvancedCommand.h @@ -40,7 +40,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "mark_as_advanced";} + virtual std::string GetName() const {return "mark_as_advanced";} /** * This determines if the command is invoked when in script mode. diff --git a/Source/cmMathCommand.h b/Source/cmMathCommand.h index c826ef1..76dc102 100644 --- a/Source/cmMathCommand.h +++ b/Source/cmMathCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "math";} + virtual std::string GetName() const { return "math";} cmTypeMacro(cmMathCommand, cmCommand); protected: diff --git a/Source/cmMessageCommand.h b/Source/cmMessageCommand.h index fec9a32..c0ae2a3 100644 --- a/Source/cmMessageCommand.h +++ b/Source/cmMessageCommand.h @@ -39,7 +39,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "message";} + virtual std::string GetName() const { return "message";} /** * This determines if the command is invoked when in script mode. diff --git a/Source/cmOptionCommand.h b/Source/cmOptionCommand.h index 89e3ac1..12a6472 100644 --- a/Source/cmOptionCommand.h +++ b/Source/cmOptionCommand.h @@ -40,7 +40,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "option";} + virtual std::string GetName() const {return "option";} /** * This determines if the command is invoked when in script mode. diff --git a/Source/cmOutputRequiredFilesCommand.h b/Source/cmOutputRequiredFilesCommand.h index dd5ed6c..95eba38 100644 --- a/Source/cmOutputRequiredFilesCommand.h +++ b/Source/cmOutputRequiredFilesCommand.h @@ -22,7 +22,7 @@ public: virtual cmCommand* Clone() { return new cmOutputRequiredFilesCommand; } virtual bool InitialPass(std::vector const& args, cmExecutionStatus &status); - virtual const char* GetName() const { return "output_required_files";} + virtual std::string GetName() const { return "output_required_files";} virtual bool IsDiscouraged() const { return true; } void ListDependencies(cmDependInformation const *info, diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h index f7d086d..7aacb55 100644 --- a/Source/cmProjectCommand.h +++ b/Source/cmProjectCommand.h @@ -43,7 +43,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "project";} + virtual std::string GetName() const {return "project";} cmTypeMacro(cmProjectCommand, cmCommand); }; diff --git a/Source/cmQTWrapCPPCommand.h b/Source/cmQTWrapCPPCommand.h index 868eb91..85729dd 100644 --- a/Source/cmQTWrapCPPCommand.h +++ b/Source/cmQTWrapCPPCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "qt_wrap_cpp";} + virtual std::string GetName() const { return "qt_wrap_cpp";} }; diff --git a/Source/cmQTWrapUICommand.h b/Source/cmQTWrapUICommand.h index 3406dac..4aa9a61 100644 --- a/Source/cmQTWrapUICommand.h +++ b/Source/cmQTWrapUICommand.h @@ -43,7 +43,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "qt_wrap_ui";} + virtual std::string GetName() const { return "qt_wrap_ui";} }; diff --git a/Source/cmRemoveCommand.h b/Source/cmRemoveCommand.h index ad73908..94161f8 100644 --- a/Source/cmRemoveCommand.h +++ b/Source/cmRemoveCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "remove";} + virtual std::string GetName() const {return "remove";} /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const diff --git a/Source/cmRemoveDefinitionsCommand.h b/Source/cmRemoveDefinitionsCommand.h index 4e291fc..cac94be 100644 --- a/Source/cmRemoveDefinitionsCommand.h +++ b/Source/cmRemoveDefinitionsCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "remove_definitions";} + virtual std::string GetName() const {return "remove_definitions";} cmTypeMacro(cmRemoveDefinitionsCommand, cmCommand); }; diff --git a/Source/cmReturnCommand.h b/Source/cmReturnCommand.h index 2822b62..4ff81ef 100644 --- a/Source/cmReturnCommand.h +++ b/Source/cmReturnCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "return";} + virtual std::string GetName() const {return "return";} cmTypeMacro(cmReturnCommand, cmCommand); }; diff --git a/Source/cmSeparateArgumentsCommand.h b/Source/cmSeparateArgumentsCommand.h index ce02360..a527ae7 100644 --- a/Source/cmSeparateArgumentsCommand.h +++ b/Source/cmSeparateArgumentsCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "separate_arguments";} + virtual std::string GetName() const {return "separate_arguments";} cmTypeMacro(cmSeparateArgumentsCommand, cmCommand); }; diff --git a/Source/cmSetCommand.h b/Source/cmSetCommand.h index 6cef0a0..4adc2d9 100644 --- a/Source/cmSetCommand.h +++ b/Source/cmSetCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "set";} + virtual std::string GetName() const {return "set";} cmTypeMacro(cmSetCommand, cmCommand); }; diff --git a/Source/cmSetDirectoryPropertiesCommand.h b/Source/cmSetDirectoryPropertiesCommand.h index 6240598..f444a1b 100644 --- a/Source/cmSetDirectoryPropertiesCommand.h +++ b/Source/cmSetDirectoryPropertiesCommand.h @@ -37,7 +37,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "set_directory_properties";} + virtual std::string GetName() const { return "set_directory_properties";} /** * Static entry point for use by other commands diff --git a/Source/cmSetPropertyCommand.h b/Source/cmSetPropertyCommand.h index 5757d21..eaa0233 100644 --- a/Source/cmSetPropertyCommand.h +++ b/Source/cmSetPropertyCommand.h @@ -34,7 +34,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "set_property";} + virtual std::string GetName() const { return "set_property";} /** * This determines if the command is invoked when in script mode. diff --git a/Source/cmSetSourceFilesPropertiesCommand.h b/Source/cmSetSourceFilesPropertiesCommand.h index 8541a96..5fa5a3a 100644 --- a/Source/cmSetSourceFilesPropertiesCommand.h +++ b/Source/cmSetSourceFilesPropertiesCommand.h @@ -32,7 +32,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "set_source_files_properties";} + virtual std::string GetName() const { return "set_source_files_properties";} cmTypeMacro(cmSetSourceFilesPropertiesCommand, cmCommand); diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h index cfe35df..3981ef3 100644 --- a/Source/cmSetTargetPropertiesCommand.h +++ b/Source/cmSetTargetPropertiesCommand.h @@ -32,7 +32,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "set_target_properties";} + virtual std::string GetName() const { return "set_target_properties";} /** * Used by this command and cmSetPropertiesCommand diff --git a/Source/cmSetTestsPropertiesCommand.h b/Source/cmSetTestsPropertiesCommand.h index 7f8d57d..dabe944 100644 --- a/Source/cmSetTestsPropertiesCommand.h +++ b/Source/cmSetTestsPropertiesCommand.h @@ -32,7 +32,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "set_tests_properties";} + virtual std::string GetName() const { return "set_tests_properties";} cmTypeMacro(cmSetTestsPropertiesCommand, cmCommand); diff --git a/Source/cmSiteNameCommand.h b/Source/cmSiteNameCommand.h index eb9d4d8..ec63ef8 100644 --- a/Source/cmSiteNameCommand.h +++ b/Source/cmSiteNameCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "site_name";} + virtual std::string GetName() const {return "site_name";} cmTypeMacro(cmSiteNameCommand, cmCommand); }; diff --git a/Source/cmSourceGroupCommand.h b/Source/cmSourceGroupCommand.h index 5d8b48c..410411b 100644 --- a/Source/cmSourceGroupCommand.h +++ b/Source/cmSourceGroupCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "source_group";} + virtual std::string GetName() const {return "source_group";} cmTypeMacro(cmSourceGroupCommand, cmCommand); }; diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h index 66b48e6..b8053c5 100644 --- a/Source/cmStringCommand.h +++ b/Source/cmStringCommand.h @@ -50,7 +50,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "string";} + virtual std::string GetName() const { return "string";} cmTypeMacro(cmStringCommand, cmCommand); static void ClearMatches(cmMakefile* mf); diff --git a/Source/cmSubdirCommand.h b/Source/cmSubdirCommand.h index 8be8335..6addd8f 100644 --- a/Source/cmSubdirCommand.h +++ b/Source/cmSubdirCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "subdirs";} + virtual std::string GetName() const { return "subdirs";} /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const diff --git a/Source/cmSubdirDependsCommand.h b/Source/cmSubdirDependsCommand.h index f78cfb7..75a5685 100644 --- a/Source/cmSubdirDependsCommand.h +++ b/Source/cmSubdirDependsCommand.h @@ -20,7 +20,7 @@ public: virtual cmCommand* Clone() { return new cmSubdirDependsCommand; } virtual bool InitialPass(std::vector const& args, cmExecutionStatus &status); - virtual const char* GetName() const { return "subdir_depends";} + virtual std::string GetName() const { return "subdir_depends";} virtual bool IsDiscouraged() const { return true; } cmTypeMacro(cmSubdirDependsCommand, cmCommand); }; diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index 7405e90..5ba9e03 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -36,7 +36,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "target_compile_definitions";} + virtual std::string GetName() const { return "target_compile_definitions";} cmTypeMacro(cmTargetCompileDefinitionsCommand, cmTargetPropCommandBase); diff --git a/Source/cmTargetCompileOptionsCommand.h b/Source/cmTargetCompileOptionsCommand.h index 3713e5a..d58dc07 100644 --- a/Source/cmTargetCompileOptionsCommand.h +++ b/Source/cmTargetCompileOptionsCommand.h @@ -36,7 +36,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "target_compile_options";} + virtual std::string GetName() const { return "target_compile_options";} cmTypeMacro(cmTargetCompileOptionsCommand, cmTargetPropCommandBase); diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index 6863ee5..c8b22fb 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -37,7 +37,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "target_include_directories";} + virtual std::string GetName() const { return "target_include_directories";} cmTypeMacro(cmTargetIncludeDirectoriesCommand, cmTargetPropCommandBase); diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index e2f3743..47dd8bd 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "target_link_libraries";} + virtual std::string GetName() const { return "target_link_libraries";} cmTypeMacro(cmTargetLinkLibrariesCommand, cmCommand); private: diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index 8e6bbc1..a09c47f 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -40,7 +40,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "try_compile";} + virtual std::string GetName() const { return "try_compile";} cmTypeMacro(cmTryCompileCommand, cmCoreTryCompile); diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h index d0bf9ce..9b97b16 100644 --- a/Source/cmTryRunCommand.h +++ b/Source/cmTryRunCommand.h @@ -40,7 +40,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "try_run";} + virtual std::string GetName() const { return "try_run";} cmTypeMacro(cmTryRunCommand, cmCoreTryCompile); private: diff --git a/Source/cmUnsetCommand.h b/Source/cmUnsetCommand.h index 2308139..62c2bd3 100644 --- a/Source/cmUnsetCommand.h +++ b/Source/cmUnsetCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "unset";} + virtual std::string GetName() const {return "unset";} cmTypeMacro(cmUnsetCommand, cmCommand); }; diff --git a/Source/cmUseMangledMesaCommand.h b/Source/cmUseMangledMesaCommand.h index dca75a5..da927c7 100644 --- a/Source/cmUseMangledMesaCommand.h +++ b/Source/cmUseMangledMesaCommand.h @@ -21,7 +21,7 @@ public: virtual cmCommand* Clone() { return new cmUseMangledMesaCommand; } virtual bool InitialPass(std::vector const& args, cmExecutionStatus &status); - virtual const char* GetName() const { return "use_mangled_mesa";} + virtual std::string GetName() const { return "use_mangled_mesa";} virtual bool IsScriptable() const { return true; } virtual bool IsDiscouraged() const { return true; } protected: diff --git a/Source/cmUtilitySourceCommand.h b/Source/cmUtilitySourceCommand.h index 83d115c..23afdbe 100644 --- a/Source/cmUtilitySourceCommand.h +++ b/Source/cmUtilitySourceCommand.h @@ -21,7 +21,7 @@ public: virtual cmCommand* Clone() { return new cmUtilitySourceCommand; } virtual bool InitialPass(std::vector const& args, cmExecutionStatus &status); - virtual const char* GetName() const { return "utility_source";} + virtual std::string GetName() const { return "utility_source";} virtual bool IsDiscouraged() const { return true; } }; diff --git a/Source/cmVariableRequiresCommand.h b/Source/cmVariableRequiresCommand.h index 881b149..7e68de1 100644 --- a/Source/cmVariableRequiresCommand.h +++ b/Source/cmVariableRequiresCommand.h @@ -21,7 +21,7 @@ public: virtual cmCommand* Clone() { return new cmVariableRequiresCommand; } virtual bool InitialPass(std::vector const& args, cmExecutionStatus &status); - virtual const char* GetName() const { return "variable_requires";} + virtual std::string GetName() const { return "variable_requires";} virtual bool IsDiscouraged() const { return true; } }; diff --git a/Source/cmVariableWatchCommand.h b/Source/cmVariableWatchCommand.h index fb6062c..c1ee9b1 100644 --- a/Source/cmVariableWatchCommand.h +++ b/Source/cmVariableWatchCommand.h @@ -54,7 +54,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "variable_watch";} + virtual std::string GetName() const { return "variable_watch";} cmTypeMacro(cmVariableWatchCommand, cmCommand); diff --git a/Source/cmWhileCommand.h b/Source/cmWhileCommand.h index 45badd0..9fafffc 100644 --- a/Source/cmWhileCommand.h +++ b/Source/cmWhileCommand.h @@ -66,7 +66,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "while";} + virtual std::string GetName() const { return "while";} cmTypeMacro(cmWhileCommand, cmCommand); }; diff --git a/Source/cmWriteFileCommand.h b/Source/cmWriteFileCommand.h index 84a38fc..0d06878 100644 --- a/Source/cmWriteFileCommand.h +++ b/Source/cmWriteFileCommand.h @@ -44,7 +44,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "write_file";} + virtual std::string GetName() const { return "write_file";} /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const diff --git a/Source/cmake.cxx b/Source/cmake.cxx index ab12411..d37bd94 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -221,13 +221,13 @@ void cmake::CleanupCommandsAndMacros() } } -bool cmake::CommandExists(const char* name) const +bool cmake::CommandExists(const std::string& name) const { std::string sName = cmSystemTools::LowerCase(name); return (this->Commands.find(sName) != this->Commands.end()); } -cmCommand *cmake::GetCommand(const char *name) +cmCommand *cmake::GetCommand(const std::string& name) { cmCommand* rm = 0; std::string sName = cmSystemTools::LowerCase(name); @@ -239,7 +239,8 @@ cmCommand *cmake::GetCommand(const char *name) return rm; } -void cmake::RenameCommand(const char*oldName, const char* newName) +void cmake::RenameCommand(const std::string& oldName, + const std::string& newName) { // if the command already exists, free the old one std::string sOldName = cmSystemTools::LowerCase(oldName); @@ -262,7 +263,7 @@ void cmake::RenameCommand(const char*oldName, const char* newName) this->Commands.erase(pos); } -void cmake::RemoveCommand(const char* name) +void cmake::RemoveCommand(const std::string& name) { std::string sName = cmSystemTools::LowerCase(name); RegisteredCommandsMap::iterator pos = this->Commands.find(sName); diff --git a/Source/cmake.h b/Source/cmake.h index 3134493..6772740 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -218,20 +218,20 @@ class cmake * Add a command to this cmake instance */ void AddCommand(cmCommand* ); - void RenameCommand(const char* oldName, const char* newName); - void RemoveCommand(const char* name); + void RenameCommand(const std::string& oldName, const std::string& newName); + void RemoveCommand(const std::string& name); void RemoveUnscriptableCommands(); /** * Get a command by its name */ - cmCommand *GetCommand(const char *name); + cmCommand *GetCommand(const std::string& name); /** Get list of all commands */ RegisteredCommandsMap* GetCommands() { return &this->Commands; } /** Check if a command exists. */ - bool CommandExists(const char* name) const; + bool CommandExists(const std::string& name) const; ///! Parse command line arguments void SetArgs(const std::vector&, -- cgit v0.12 From 94fc63e2d5402bc4fa570a92e1f5fe6aba088392 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 24 Feb 2014 20:24:01 -0500 Subject: stringapi: Use strings for cache iterator values --- Source/CursesDialog/cmCursesCacheEntryComposite.cxx | 5 +++-- Source/QtDialog/QCMake.cxx | 12 ++++++------ Source/cmCacheManager.h | 6 +++--- Source/cmMakefile.cxx | 8 ++++++-- Source/cmOptionCommand.cxx | 5 +---- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx index 7929ce7..682f95f 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx @@ -51,7 +51,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( { case cmCacheManager::BOOL: this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1); - if (cmSystemTools::IsOn(it.GetValue())) + if (cmSystemTools::IsOn(it.GetValue().c_str())) { static_cast(this->Entry)->SetValueAsBool(true); } @@ -94,7 +94,8 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( } break; case cmCacheManager::UNINITIALIZED: - cmSystemTools::Error("Found an undefined variable: ", it.GetName()); + cmSystemTools::Error("Found an undefined variable: ", + it.GetName().c_str()); break; default: // TODO : put warning message here diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 0fe5f8c..12da320 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -111,7 +111,7 @@ void QCMake::setBinaryDirectory(const QString& _dir) cmCacheManager::CacheIterator itm = cachem->NewIterator(); if ( itm.Find("CMAKE_HOME_DIRECTORY")) { - setSourceDirectory(QString::fromLocal8Bit(itm.GetValue())); + setSourceDirectory(QString::fromLocal8Bit(itm.GetValue().c_str())); } if ( itm.Find("CMAKE_GENERATOR")) { @@ -201,11 +201,11 @@ void QCMake::setProperties(const QCMakePropertyList& newProps) } QCMakeProperty prop; - prop.Key = QString::fromLocal8Bit(i.GetName()); + prop.Key = QString::fromLocal8Bit(i.GetName().c_str()); int idx = props.indexOf(prop); if(idx == -1) { - toremove.append(QString::fromLocal8Bit(i.GetName())); + toremove.append(QString::fromLocal8Bit(i.GetName().c_str())); } else { @@ -286,15 +286,15 @@ QCMakePropertyList QCMake::properties() const } QCMakeProperty prop; - prop.Key = QString::fromLocal8Bit(i.GetName()); + prop.Key = QString::fromLocal8Bit(i.GetName().c_str()); prop.Help = QString::fromLocal8Bit(i.GetProperty("HELPSTRING")); - prop.Value = QString::fromLocal8Bit(i.GetValue()); + prop.Value = QString::fromLocal8Bit(i.GetValue().c_str()); prop.Advanced = i.GetPropertyAsBool("ADVANCED"); if(i.GetType() == cmCacheManager::BOOL) { prop.Type = QCMakeProperty::BOOL; - prop.Value = cmSystemTools::IsOn(i.GetValue()); + prop.Value = cmSystemTools::IsOn(i.GetValue().c_str()); } else if(i.GetType() == cmCacheManager::PATH) { diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 07a8675..d9a9112 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -56,8 +56,8 @@ public: bool Find(const std::string&); bool IsAtEnd() const; void Next(); - const char *GetName() const { - return this->Position->first.c_str(); } + std::string GetName() const { + return this->Position->first; } const char* GetProperty(const std::string&) const ; bool GetPropertyAsBool(const std::string&) const ; bool PropertyExists(const std::string&) const; @@ -65,7 +65,7 @@ public: void AppendProperty(const std::string& property, const char* value, bool asString=false); void SetProperty(const std::string& property, bool value); - const char* GetValue() const { return this->GetEntry().Value.c_str(); } + std::string GetValue() const { return this->GetEntry().Value; } bool GetValueAsBool() const; void SetValue(const char*); CacheEntryType GetType() const { return this->GetEntry().Type; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e8be29f..a083c78 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1796,7 +1796,8 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, cmCacheManager::CacheEntryType type, bool force) { - const char* val = value; + bool haveVal = value ? true : false; + std::string val = haveVal ? value : ""; cmCacheManager::CacheIterator it = this->GetCacheManager()->GetCacheIterator(name.c_str()); if(!it.IsAtEnd() && (it.GetType() == cmCacheManager::UNINITIALIZED) && @@ -1807,6 +1808,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, if(!force) { val = it.GetValue(); + haveVal = true; } if ( type == cmCacheManager::PATH || type == cmCacheManager::FILEPATH ) { @@ -1829,10 +1831,12 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, this->GetCacheManager()->AddCacheEntry(name, nvalue.c_str(), doc, type); val = it.GetValue(); + haveVal = true; } } - this->GetCacheManager()->AddCacheEntry(name, val, doc, type); + this->GetCacheManager()->AddCacheEntry(name, haveVal ? val.c_str() : 0, doc, + type); // if there was a definition then remove it this->Internal->VarStack.top().Set(name, 0); } diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx index 776a3a4..dbe2478 100644 --- a/Source/cmOptionCommand.cxx +++ b/Source/cmOptionCommand.cxx @@ -55,10 +55,7 @@ bool cmOptionCommand it.SetProperty("HELPSTRING", args[1].c_str()); return true; } - if ( it.GetValue() ) - { - initialValue = it.GetValue(); - } + initialValue = it.GetValue(); } if(args.size() == 3) { -- cgit v0.12 From 7abf4e313d8e8d59c38f402efaf9cca4e4a2d3ba Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 24 Feb 2014 20:32:55 -0500 Subject: stringapi: Use strings for dependency information --- Source/cmFLTKWrapUICommand.cxx | 2 +- Source/cmGlobalVisualStudio8Generator.cxx | 2 +- Source/cmLocalGenerator.cxx | 2 +- Source/cmLocalVisualStudio6Generator.cxx | 2 +- Source/cmLocalVisualStudio7Generator.cxx | 2 +- Source/cmMakefile.cxx | 14 +++++++------- Source/cmMakefile.h | 6 +++--- Source/cmMakefileTargetGenerator.cxx | 10 ++++------ Source/cmMakefileTargetGenerator.h | 2 +- Source/cmQTWrapCPPCommand.cxx | 2 +- Source/cmQTWrapUICommand.cxx | 2 +- 11 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index 4dd81be..dd99c43 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -78,7 +78,7 @@ bool cmFLTKWrapUICommand commandLines.push_back(commandLine); // Add command for generating the .h and .cxx files - const char* no_main_dependency = 0; + std::string no_main_dependency = ""; const char* no_comment = 0; const char* no_working_dir = 0; this->Makefile->AddCustomCommandToOutput(cxxres.c_str(), diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 08c1397..ab4380c 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -316,7 +316,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() // file as the main dependency because it would get // overwritten by the CreateVCProjBuildRule. // (this could be avoided with per-target source files) - const char* no_main_dependency = 0; + std::string no_main_dependency = ""; if(cmSourceFile* file = mf->AddCustomCommandToOutput( stamps, listFiles, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index cd9f9bd..761db48 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -747,7 +747,7 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, this->Makefile->AddCustomCommandToOutput( targetFullPath.c_str(), objVector, - 0, + "", commandLines, comment.c_str(), this->Makefile->GetStartOutputDirectory() diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 0e246a5..f1fd994 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -578,7 +578,7 @@ cmLocalVisualStudio6Generator std::string comment = this->ConstructComment(origCommand, ""); // Add the rule with the given dependencies and commands. - const char* no_main_dependency = 0; + std::string no_main_dependency = ""; if(cmSourceFile* outsf = this->Makefile->AddCustomCommandToOutput( output, depends, no_main_dependency, diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 0bbafd8..4491140 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -141,7 +141,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() force_command.push_back("."); cmCustomCommandLines force_commands; force_commands.push_back(force_command); - const char* no_main_dependency = 0; + std::string no_main_dependency = ""; std::string force = this->Makefile->GetStartOutputDirectory(); force += cmake::GetCMakeFilesDirectory(); force += "/"; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index a083c78..92177c8 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -950,7 +950,7 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target, cmSourceFile* cmMakefile::AddCustomCommandToOutput(const std::vector& outputs, const std::vector& depends, - const char* main_dependency, + const std::string& main_dependency, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, @@ -980,7 +980,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector& outputs, // Choose a source file on which to store the custom command. cmSourceFile* file = 0; - if(main_dependency && main_dependency[0]) + if(!main_dependency.empty()) { // The main dependency was specified. Use it unless a different // custom command already used it. @@ -1048,7 +1048,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector& outputs, // Construct a complete list of dependencies. std::vector depends2(depends); - if(main_dependency && main_dependency[0]) + if(!main_dependency.empty()) { depends2.push_back(main_dependency); } @@ -1104,7 +1104,7 @@ cmMakefile::UpdateOutputToSourceMap(std::string const& output, cmSourceFile* cmMakefile::AddCustomCommandToOutput(const std::string& output, const std::vector& depends, - const char* main_dependency, + const std::string& main_dependency, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, @@ -1123,7 +1123,7 @@ void cmMakefile::AddCustomCommandOldStyle(const std::string& target, const std::vector& outputs, const std::vector& depends, - const char* source, + const std::string& source, const cmCustomCommandLines& commandLines, const char* comment) { @@ -1160,7 +1160,7 @@ cmMakefile::AddCustomCommandOldStyle(const std::string& target, else { // The source may not be a real file. Do not use a main dependency. - const char* no_main_dependency = 0; + std::string no_main_dependency = ""; std::vector depends2 = depends; depends2.push_back(source); sf = this->AddCustomCommandToOutput(output, depends2, no_main_dependency, @@ -1251,7 +1251,7 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName, force += cmake::GetCMakeFilesDirectory(); force += "/"; force += utilityName; - const char* no_main_dependency = 0; + std::string no_main_dependency = ""; bool no_replace = false; this->AddCustomCommandToOutput(force.c_str(), depends, no_main_dependency, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index fb40c1b..460a85c 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -177,7 +177,7 @@ public: cmSourceFile* AddCustomCommandToOutput( const std::vector& outputs, const std::vector& depends, - const char* main_dependency, + const std::string& main_dependency, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace = false, @@ -185,7 +185,7 @@ public: cmSourceFile* AddCustomCommandToOutput( const std::string& output, const std::vector& depends, - const char* main_dependency, + const std::string& main_dependency, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace = false, @@ -193,7 +193,7 @@ public: void AddCustomCommandOldStyle(const std::string& target, const std::vector& outputs, const std::vector& depends, - const char* source, + const std::string& source, const cmCustomCommandLines& commandLines, const char* comment); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f0c9a3f..28a8f04 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1496,8 +1496,9 @@ cmMakefileTargetGenerator } //---------------------------------------------------------------------------- -void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output, - bool relink) +void cmMakefileTargetGenerator::WriteTargetDriverRule( + const std::string& main_output, + bool relink) { // Compute the name of the driver target. std::string dir = @@ -1510,10 +1511,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output, // Build the list of target outputs to drive. std::vector depends; - if(main_output) - { - depends.push_back(main_output); - } + depends.push_back(main_output); const char* comment = 0; if(relink) diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 573ce22..bed945b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -119,7 +119,7 @@ protected: std::string::size_type limit = std::string::npos); // write the driver rule to build target outputs - void WriteTargetDriverRule(const char* main_output, bool relink); + void WriteTargetDriverRule(const std::string& main_output, bool relink); void DriveCustomCommands(std::vector& depends); diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx index 0d3c994..ca007cb 100644 --- a/Source/cmQTWrapCPPCommand.cxx +++ b/Source/cmQTWrapCPPCommand.cxx @@ -97,7 +97,7 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector const& argsIn, depends.push_back(moc_exe); depends.push_back(hname); - const char* no_main_dependency = 0; + std::string no_main_dependency = ""; const char* no_working_dir = 0; this->Makefile->AddCustomCommandToOutput(newName.c_str(), depends, diff --git a/Source/cmQTWrapUICommand.cxx b/Source/cmQTWrapUICommand.cxx index a6a4b51..2a1129d 100644 --- a/Source/cmQTWrapUICommand.cxx +++ b/Source/cmQTWrapUICommand.cxx @@ -128,7 +128,7 @@ bool cmQTWrapUICommand::InitialPass(std::vector const& argsIn, std::vector depends; depends.push_back(uiName); - const char* no_main_dependency = 0; + std::string no_main_dependency = ""; const char* no_comment = 0; const char* no_working_dir = 0; this->Makefile->AddCustomCommandToOutput(hName.c_str(), -- cgit v0.12 From caaad357598ec8c92f15ab0d682add9e70e2223c Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 24 Feb 2014 20:47:20 -0500 Subject: speedup: Cache strings for comparisons --- Source/cmExtraCodeBlocksGenerator.cxx | 3 ++- Source/cmExtraCodeLiteGenerator.cxx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 4a59704..03f59c4 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -414,12 +414,13 @@ void cmExtraCodeBlocksGenerator std::string lang = (*si)->GetLanguage(); if (lang == "C" || lang == "CXX") { + std::string srcext = (*si)->GetExtension(); for(std::vector::const_iterator ext = mf->GetSourceExtensions().begin(); ext != mf->GetSourceExtensions().end(); ++ext) { - if ((*si)->GetExtension() == *ext) + if (srcext == *ext) { isCFile = true; break; diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 15fe8bb..5a9e125 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -223,12 +223,13 @@ void cmExtraCodeLiteGenerator std::string lang = (*si)->GetLanguage(); if (lang == "C" || lang == "CXX") { + std::string srcext = (*si)->GetExtension(); for(std::vector::const_iterator ext = mf->GetSourceExtensions().begin(); ext != mf->GetSourceExtensions().end(); ++ext) { - if ((*si)->GetExtension() == *ext) + if (srcext == *ext) { isCFile = true; break; -- cgit v0.12 From 219d6ad6101cb90f951b193d721a19896f7a6b20 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 24 Feb 2014 20:31:04 -0500 Subject: speedup: Avoid excess iterator dereferences --- Source/cmGlobalUnixMakefileGenerator3.cxx | 125 ++++++++++++++++-------------- 1 file changed, 68 insertions(+), 57 deletions(-) diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index d41cee6..2cdc976 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -477,24 +477,26 @@ cmGlobalUnixMakefileGenerator3 for(cmGeneratorTargetsType::iterator l = targets.begin(); l != targets.end(); ++l) { - if((l->second->GetType() == cmTarget::EXECUTABLE) || - (l->second->GetType() == cmTarget::STATIC_LIBRARY) || - (l->second->GetType() == cmTarget::SHARED_LIBRARY) || - (l->second->GetType() == cmTarget::MODULE_LIBRARY) || - (l->second->GetType() == cmTarget::OBJECT_LIBRARY) || - (l->second->GetType() == cmTarget::UTILITY)) + cmGeneratorTarget* gtarget = l->second; + int type = gtarget->GetType(); + if((type == cmTarget::EXECUTABLE) || + (type == cmTarget::STATIC_LIBRARY) || + (type == cmTarget::SHARED_LIBRARY) || + (type == cmTarget::MODULE_LIBRARY) || + (type == cmTarget::OBJECT_LIBRARY) || + (type == cmTarget::UTILITY)) { - if(l->second->Target->IsImported()) + if(gtarget->Target->IsImported()) { continue; } // Add this to the list of depends rules in this directory. - if((!check_all || !l->second->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && + if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && (!check_relink || - l->second->Target + gtarget->Target ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str()))) { - std::string tname = lg->GetRelativeTargetDirectory(*l->second->Target); + std::string tname = lg->GetRelativeTargetDirectory(*gtarget->Target); tname += "/"; tname += pass; depends.push_back(tname); @@ -643,45 +645,48 @@ cmGlobalUnixMakefileGenerator3 for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if(t->second->Target->IsImported()) + cmGeneratorTarget* gtarget = t->second; + if(gtarget->Target->IsImported()) { continue; } // Don't emit the same rule twice (e.g. two targets with the same // simple name) - if(!t->second->GetName().empty() && - emitted.insert(t->second->GetName()).second && + int type = gtarget->GetType(); + std::string name = gtarget->GetName(); + if(!name.empty() && + emitted.insert(name).second && // Handle user targets here. Global targets are handled in // the local generator on a per-directory basis. - ((t->second->GetType() == cmTarget::EXECUTABLE) || - (t->second->GetType() == cmTarget::STATIC_LIBRARY) || - (t->second->GetType() == cmTarget::SHARED_LIBRARY) || - (t->second->GetType() == cmTarget::MODULE_LIBRARY) || - (t->second->GetType() == cmTarget::OBJECT_LIBRARY) || - (t->second->GetType() == cmTarget::UTILITY))) + ((type == cmTarget::EXECUTABLE) || + (type == cmTarget::STATIC_LIBRARY) || + (type == cmTarget::SHARED_LIBRARY) || + (type == cmTarget::MODULE_LIBRARY) || + (type == cmTarget::OBJECT_LIBRARY) || + (type == cmTarget::UTILITY))) { // Add a rule to build the target by name. lg->WriteDivider(ruleFileStream); ruleFileStream << "# Target rules for targets named " - << t->second->GetName() << "\n\n"; + << name << "\n\n"; // Write the rule. commands.clear(); std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash(); tmp += "Makefile2"; commands.push_back(lg->GetRecursiveMakeCall - (tmp.c_str(),t->second->GetName())); + (tmp.c_str(),name)); depends.clear(); depends.push_back("cmake_check_build_system"); lg->WriteMakeRule(ruleFileStream, "Build rule for target.", - t->second->GetName(), depends, commands, + name, depends, commands, true); // Add a fast rule to build the target std::string localName = - lg->GetRelativeTargetDirectory(*t->second->Target); + lg->GetRelativeTargetDirectory(*gtarget->Target); std::string makefileName; makefileName = localName; makefileName += "/build.make"; @@ -689,7 +694,7 @@ cmGlobalUnixMakefileGenerator3 commands.clear(); std::string makeTargetName = localName; makeTargetName += "/build"; - localName = t->second->GetName(); + localName = name; localName += "/fast"; commands.push_back(lg->GetRecursiveMakeCall (makefileName.c_str(), makeTargetName.c_str())); @@ -698,12 +703,12 @@ cmGlobalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(t->second->Target + if(gtarget->Target ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str())) { - makeTargetName = lg->GetRelativeTargetDirectory(*t->second->Target); + makeTargetName = lg->GetRelativeTargetDirectory(*gtarget->Target); makeTargetName += "/preinstall"; - localName = t->second->GetName(); + localName = name; localName += "/preinstall"; depends.clear(); commands.clear(); @@ -741,25 +746,28 @@ cmGlobalUnixMakefileGenerator3 for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if(t->second->Target->IsImported()) + cmGeneratorTarget* gtarget = t->second; + if(gtarget->Target->IsImported()) { continue; } - if (!t->second->GetName().empty() - && ((t->second->GetType() == cmTarget::EXECUTABLE) - || (t->second->GetType() == cmTarget::STATIC_LIBRARY) - || (t->second->GetType() == cmTarget::SHARED_LIBRARY) - || (t->second->GetType() == cmTarget::MODULE_LIBRARY) - || (t->second->GetType() == cmTarget::OBJECT_LIBRARY) - || (t->second->GetType() == cmTarget::UTILITY))) + int type = gtarget->GetType(); + std::string name = gtarget->GetName(); + if (!name.empty() + && ( (type == cmTarget::EXECUTABLE) + || (type == cmTarget::STATIC_LIBRARY) + || (type == cmTarget::SHARED_LIBRARY) + || (type == cmTarget::MODULE_LIBRARY) + || (type == cmTarget::OBJECT_LIBRARY) + || (type == cmTarget::UTILITY))) { std::string makefileName; // Add a rule to build the target by name. - localName = lg->GetRelativeTargetDirectory(*t->second->Target); + localName = lg->GetRelativeTargetDirectory(*gtarget->Target); makefileName = localName; makefileName += "/build.make"; - bool needRequiresStep = this->NeedRequiresStep(*t->second->Target); + bool needRequiresStep = this->NeedRequiresStep(*gtarget->Target); lg->WriteDivider(ruleFileStream); ruleFileStream @@ -801,7 +809,7 @@ cmGlobalUnixMakefileGenerator3 cmLocalGenerator::SHELL); progCmd << " "; std::vector& progFiles = - this->ProgressMap[t->second->Target].Marks; + this->ProgressMap[gtarget->Target].Marks; for (std::vector::iterator i = progFiles.begin(); i != progFiles.end(); ++i) { @@ -810,15 +818,15 @@ cmGlobalUnixMakefileGenerator3 commands.push_back(progCmd.str()); } progressDir = "Built target "; - progressDir += t->second->GetName(); + progressDir += name; lg->AppendEcho(commands,progressDir.c_str()); - this->AppendGlobalTargetDepends(depends,*t->second->Target); + this->AppendGlobalTargetDepends(depends,*gtarget->Target); lg->WriteMakeRule(ruleFileStream, "All Build rule for target.", localName.c_str(), depends, commands, true); // add the all/all dependency - if(!this->IsExcluded(this->LocalGenerators[0], *t->second->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) { depends.clear(); depends.push_back(localName); @@ -843,7 +851,7 @@ cmGlobalUnixMakefileGenerator3 // std::set emitted; progCmd << " " - << this->CountProgressMarksInTarget(t->second->Target, emitted); + << this->CountProgressMarksInTarget(gtarget->Target, emitted); commands.push_back(progCmd.str()); } std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash(); @@ -861,7 +869,7 @@ cmGlobalUnixMakefileGenerator3 } depends.clear(); depends.push_back("cmake_check_build_system"); - localName = lg->GetRelativeTargetDirectory(*t->second->Target); + localName = lg->GetRelativeTargetDirectory(*gtarget->Target); localName += "/rule"; lg->WriteMakeRule(ruleFileStream, "Build rule for subdir invocation for target.", @@ -872,13 +880,13 @@ cmGlobalUnixMakefileGenerator3 depends.clear(); depends.push_back(localName); lg->WriteMakeRule(ruleFileStream, "Convenience name for target.", - t->second->GetName(), depends, commands, true); + name, depends, commands, true); // Add rules to prepare the target for installation. - if(t->second->Target + if(gtarget->Target ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str())) { - localName = lg->GetRelativeTargetDirectory(*t->second->Target); + localName = lg->GetRelativeTargetDirectory(*gtarget->Target); localName += "/preinstall"; depends.clear(); commands.clear(); @@ -888,7 +896,7 @@ cmGlobalUnixMakefileGenerator3 "Pre-install relink rule for target.", localName.c_str(), depends, commands, true); - if(!this->IsExcluded(this->LocalGenerators[0], *t->second->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) { depends.clear(); depends.push_back(localName); @@ -899,7 +907,7 @@ cmGlobalUnixMakefileGenerator3 } // add the clean rule - localName = lg->GetRelativeTargetDirectory(*t->second->Target); + localName = lg->GetRelativeTargetDirectory(*gtarget->Target); makeTargetName = localName; makeTargetName += "/clean"; depends.clear(); @@ -1066,18 +1074,21 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule cmTargets& targets = lg2->GetMakefile()->GetTargets(); for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) { - if((t->second.GetType() == cmTarget::EXECUTABLE) || - (t->second.GetType() == cmTarget::STATIC_LIBRARY) || - (t->second.GetType() == cmTarget::SHARED_LIBRARY) || - (t->second.GetType() == cmTarget::MODULE_LIBRARY) || - (t->second.GetType() == cmTarget::OBJECT_LIBRARY) || - (t->second.GetType() == cmTarget::GLOBAL_TARGET) || - (t->second.GetType() == cmTarget::UTILITY)) + cmTarget const& target = t->second; + cmTarget::TargetType type = target.GetType(); + if((type == cmTarget::EXECUTABLE) || + (type == cmTarget::STATIC_LIBRARY) || + (type == cmTarget::SHARED_LIBRARY) || + (type == cmTarget::MODULE_LIBRARY) || + (type == cmTarget::OBJECT_LIBRARY) || + (type == cmTarget::GLOBAL_TARGET) || + (type == cmTarget::UTILITY)) { - if(emittedTargets.insert(t->second.GetName()).second) + std::string name = target.GetName(); + if(emittedTargets.insert(name).second) { path = "... "; - path += t->second.GetName(); + path += name; lg->AppendEcho(commands,path.c_str()); } } -- cgit v0.12 From 191f25e2bd0a8b63d5abfecfd403b9f1414dfc8d Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 6 Mar 2014 17:22:09 -0500 Subject: stringapi: Prevent a NULL dereference in WiX --- Source/CPack/cmCPackGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index a8e104b..3915b31 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -1089,7 +1089,7 @@ int cmCPackGenerator::DoPackage() * may update this during PackageFiles. * (either putting several names or updating the provided one) */ - packageFileNames.push_back(tempPackageFileName); + packageFileNames.push_back(tempPackageFileName ? tempPackageFileName : ""); toplevel = tempDirectory; if ( !this->PackageFiles() || cmSystemTools::GetErrorOccuredFlag()) { -- cgit v0.12 From b633b263082ae2c74a030aefb9048b0a20098b61 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 7 Mar 2014 10:53:45 -0500 Subject: CPackWiX: Fix test to build with expected config --- Tests/CMakeLists.txt | 2 ++ Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 854b239..7b4d149 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -829,6 +829,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ if(WIX_LIGHT_EXECUTABLE) add_test(CPackWiXGenerator ${CMAKE_CTEST_COMMAND} + -C \${CTEST_CONFIGURATION_TYPE} --build-and-test "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator" "${CMake_BINARY_DIR}/Tests/CPackWiXGenerator" @@ -837,6 +838,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-options ${build_options} --test-command ${CMAKE_CMAKE_COMMAND} "-DCPackWiXGenerator_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackWiXGenerator" + "-Dconfig=\${CTEST_CONFIGURATION_TYPE}" -P "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake") endif() endif() diff --git a/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake b/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake index 30e33cf2..ca9fd90 100644 --- a/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake +++ b/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake @@ -10,7 +10,12 @@ message(STATUS "CMAKE_COMMAND: ${CMAKE_COMMAND}") message(STATUS "CMAKE_CPACK_COMMAND: ${CMAKE_CPACK_COMMAND}") message(STATUS "CPackWiXGenerator_BINARY_DIR: ${CPackWiXGenerator_BINARY_DIR}") +if(config) + set(_C_config -C ${config}) +endif() + execute_process(COMMAND "${CMAKE_CPACK_COMMAND}" + ${_C_config} RESULT_VARIABLE CPack_result OUTPUT_VARIABLE CPack_output ERROR_VARIABLE CPack_error -- cgit v0.12 From 6aad93f407f341fae1afb80ebeab532451c39458 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 9 Mar 2014 00:01:06 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f1302da..5355d87 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 0) -set(CMake_VERSION_PATCH 20140308) +set(CMake_VERSION_PATCH 20140309) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 52285a993b714c81d8d79fddde2631612dab335c Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 4 Mar 2014 16:35:44 +0100 Subject: libarchive: Fix compliation with Open Watcom --- Utilities/cmlibarchive/libarchive/archive.h | 2 +- Utilities/cmlibarchive/libarchive/archive_entry.h | 4 ++-- Utilities/cmlibarchive/libarchive/archive_windows.h | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Utilities/cmlibarchive/libarchive/archive.h b/Utilities/cmlibarchive/libarchive/archive.h index 1a1d32a..83d2c16 100644 --- a/Utilities/cmlibarchive/libarchive/archive.h +++ b/Utilities/cmlibarchive/libarchive/archive.h @@ -54,7 +54,7 @@ /* Get appropriate definitions of standard POSIX-style types. */ /* These should match the types used in 'struct stat' */ -#if defined(_WIN32) && !defined(__CYGWIN__) +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) # define __LA_INT64_T __int64 # if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_) # define __LA_SSIZE_T ssize_t diff --git a/Utilities/cmlibarchive/libarchive/archive_entry.h b/Utilities/cmlibarchive/libarchive/archive_entry.h index 85ea885..ae6a76e 100644 --- a/Utilities/cmlibarchive/libarchive/archive_entry.h +++ b/Utilities/cmlibarchive/libarchive/archive_entry.h @@ -48,7 +48,7 @@ #endif /* Get a suitable 64-bit integer type. */ -#if defined(_WIN32) && !defined(__CYGWIN__) +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) # define __LA_INT64_T __int64 #else #include @@ -63,7 +63,7 @@ #if ARCHIVE_VERSION_NUMBER >= 3999000 /* Switch to plain 'int' for libarchive 4.0. It's less broken than 'mode_t' */ # define __LA_MODE_T int -#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) +#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) && !defined(__WATCOMC__) # define __LA_MODE_T unsigned short #else # define __LA_MODE_T mode_t diff --git a/Utilities/cmlibarchive/libarchive/archive_windows.h b/Utilities/cmlibarchive/libarchive/archive_windows.h index 620810c..1dd61b6 100644 --- a/Utilities/cmlibarchive/libarchive/archive_windows.h +++ b/Utilities/cmlibarchive/libarchive/archive_windows.h @@ -188,6 +188,9 @@ #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) /* directory */ #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) /* regular file */ #endif + +#if !defined(__WATCOMC__) + #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) /* Symbolic link */ #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) /* Socket */ @@ -227,6 +230,8 @@ #define S_IWOTH _S_IWOTH #define S_IROTH _S_IROTH +#endif + #define F_DUPFD 0 /* Duplicate file descriptor. */ #define F_GETFD 1 /* Get file descriptor flags. */ #define F_SETFD 2 /* Set file descriptor flags. */ -- cgit v0.12 From 4d8260921ffcdfac058c42a6ba7fd14cc81de4b6 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 10 Mar 2014 00:01:06 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 5355d87..46264b1 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 0) -set(CMake_VERSION_PATCH 20140309) +set(CMake_VERSION_PATCH 20140310) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 45abfb0c4d622c86880b2b32619f79417410a6c8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 6 Mar 2014 15:06:22 +0100 Subject: find_dependency: Extend the tests for use of EXACT macro parameter. --- Tests/Module/FindDependency/CMakeLists.txt | 3 ++- Tests/Module/FindDependency/main.cpp | 12 ++++++++++++ Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake | 9 +++++++++ .../FindDependency/packages/Pack4/Pack4ConfigVersion.cmake | 11 +++++++++++ Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake | 3 +++ .../FindDependency/packages/Pack5/Pack5ConfigVersion.cmake | 11 +++++++++++ Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake | 3 +++ .../FindDependency/packages/Pack6/Pack6ConfigVersion.cmake | 11 +++++++++++ 8 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake create mode 100644 Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake create mode 100644 Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake create mode 100644 Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake create mode 100644 Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake create mode 100644 Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake diff --git a/Tests/Module/FindDependency/CMakeLists.txt b/Tests/Module/FindDependency/CMakeLists.txt index b13f48a..dcb998a 100644 --- a/Tests/Module/FindDependency/CMakeLists.txt +++ b/Tests/Module/FindDependency/CMakeLists.txt @@ -5,6 +5,7 @@ project(FindDependency) set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/packages") find_package(Pack1 REQUIRED) +find_package(Pack4 4.3 EXACT REQUIRED) add_executable(FindDependency main.cpp) -target_link_libraries(FindDependency Pack1::Lib) +target_link_libraries(FindDependency Pack1::Lib Pack4::Lib) diff --git a/Tests/Module/FindDependency/main.cpp b/Tests/Module/FindDependency/main.cpp index d635b31..50c5958 100644 --- a/Tests/Module/FindDependency/main.cpp +++ b/Tests/Module/FindDependency/main.cpp @@ -11,6 +11,18 @@ #error Expected HAVE_PACK3 #endif +#ifndef HAVE_PACK4 +#error Expected HAVE_PACK4 +#endif + +#ifndef HAVE_PACK5 +#error Expected HAVE_PACK5 +#endif + +#ifndef HAVE_PACK6 +#error Expected HAVE_PACK6 +#endif + int main(int argc, char** argv) { return 0; diff --git a/Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake b/Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake new file mode 100644 index 0000000..62fddb1 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake @@ -0,0 +1,9 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack5 3.1) # Actual version is 3.3. EXACT not propagated. +find_dependency(Pack6 5.5 EXACT) + +add_library(Pack4::Lib INTERFACE IMPORTED) +set_property(TARGET Pack4::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK4) +set_property(TARGET Pack4::Lib PROPERTY INTERFACE_LINK_LIBRARIES Pack5::Lib Pack6::Lib) diff --git a/Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake new file mode 100644 index 0000000..ae982b0 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "4.3") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake b/Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake new file mode 100644 index 0000000..1edda9a --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake @@ -0,0 +1,3 @@ + +add_library(Pack5::Lib INTERFACE IMPORTED) +set_property(TARGET Pack5::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK5) diff --git a/Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake new file mode 100644 index 0000000..e944f96 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "3.3") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake b/Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake new file mode 100644 index 0000000..d6c85fb --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake @@ -0,0 +1,3 @@ + +add_library(Pack6::Lib INTERFACE IMPORTED) +set_property(TARGET Pack6::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK6) diff --git a/Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake new file mode 100644 index 0000000..0dd00d2 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "5.5") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() -- cgit v0.12 From d71db3a0d88fd41c7e8f3ef23368e919d5c5cded Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 6 Mar 2014 16:18:56 -0500 Subject: FindSDL: Make FindSDL_*.cmake path suffixes consistent with main module Add the 'SDL' path suffix to the FindSDL_*.cmake modules. Add a comment explaining the purpose of suffixes as in commit v3.0.0-rc1~540^2 (FindSDL: Add path suffixes for /include/..., 2013-10-08). Inspired-by: Adrien Destugues --- Modules/FindSDL_image.cmake | 4 +++- Modules/FindSDL_mixer.cmake | 4 +++- Modules/FindSDL_net.cmake | 4 +++- Modules/FindSDL_sound.cmake | 4 +++- Modules/FindSDL_ttf.cmake | 4 +++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Modules/FindSDL_image.cmake b/Modules/FindSDL_image.cmake index e5173e3..fc2c043 100644 --- a/Modules/FindSDL_image.cmake +++ b/Modules/FindSDL_image.cmake @@ -54,7 +54,9 @@ find_path(SDL_IMAGE_INCLUDE_DIR SDL_image.h HINTS ENV SDLIMAGEDIR ENV SDLDIR - PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include + PATH_SUFFIXES SDL + # path suffixes to search inside ENV{SDLDIR} + include/SDL include/SDL12 include/SDL11 include ) if(CMAKE_SIZEOF_VOID_P EQUAL 8) diff --git a/Modules/FindSDL_mixer.cmake b/Modules/FindSDL_mixer.cmake index 8f2f066..176fee6 100644 --- a/Modules/FindSDL_mixer.cmake +++ b/Modules/FindSDL_mixer.cmake @@ -54,7 +54,9 @@ find_path(SDL_MIXER_INCLUDE_DIR SDL_mixer.h HINTS ENV SDLMIXERDIR ENV SDLDIR - PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include + PATH_SUFFIXES SDL + # path suffixes to search inside ENV{SDLDIR} + include/SDL include/SDL12 include/SDL11 include ) if(CMAKE_SIZEOF_VOID_P EQUAL 8) diff --git a/Modules/FindSDL_net.cmake b/Modules/FindSDL_net.cmake index e5c2cdb..ef23573 100644 --- a/Modules/FindSDL_net.cmake +++ b/Modules/FindSDL_net.cmake @@ -54,7 +54,9 @@ find_path(SDL_NET_INCLUDE_DIR SDL_net.h HINTS ENV SDLNETDIR ENV SDLDIR - PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include + PATH_SUFFIXES SDL + # path suffixes to search inside ENV{SDLDIR} + include/SDL include/SDL12 include/SDL11 include ) if(CMAKE_SIZEOF_VOID_P EQUAL 8) diff --git a/Modules/FindSDL_sound.cmake b/Modules/FindSDL_sound.cmake index 3a6ab7b..8b22ff7 100644 --- a/Modules/FindSDL_sound.cmake +++ b/Modules/FindSDL_sound.cmake @@ -98,7 +98,9 @@ find_path(SDL_SOUND_INCLUDE_DIR SDL_sound.h HINTS ENV SDLSOUNDDIR ENV SDLDIR - PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include + PATH_SUFFIXES SDL + # path suffixes to search inside ENV{SDLDIR} + include/SDL include/SDL12 include/SDL11 include ) find_library(SDL_SOUND_LIBRARY diff --git a/Modules/FindSDL_ttf.cmake b/Modules/FindSDL_ttf.cmake index 3f58ac1..4b527fa 100644 --- a/Modules/FindSDL_ttf.cmake +++ b/Modules/FindSDL_ttf.cmake @@ -54,7 +54,9 @@ find_path(SDL_TTF_INCLUDE_DIR SDL_ttf.h HINTS ENV SDLTTFDIR ENV SDLDIR - PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include + PATH_SUFFIXES SDL + # path suffixes to search inside ENV{SDLDIR} + include/SDL include/SDL12 include/SDL11 include ) if(CMAKE_SIZEOF_VOID_P EQUAL 8) -- cgit v0.12 From b79a1f67195f6bb7fddd52215f442f319139b531 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 3 Mar 2014 16:01:23 +0100 Subject: FindFreetype: Add plain 'freetype2' path suffix On Haiku, the headers are not in an 'include' directory. --- Modules/FindFreetype.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake index 6f03c86..f0f9fe1 100644 --- a/Modules/FindFreetype.cmake +++ b/Modules/FindFreetype.cmake @@ -62,7 +62,7 @@ find_path(FREETYPE_INCLUDE_DIR_ft2build ft2build.h ENV GTKMM_BASEPATH [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path] [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path] - PATH_SUFFIXES include/freetype2 include + PATH_SUFFIXES include/freetype2 include freetype2 ) find_path(FREETYPE_INCLUDE_DIR_freetype2 @@ -79,7 +79,7 @@ find_path(FREETYPE_INCLUDE_DIR_freetype2 ENV GTKMM_BASEPATH [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path] [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path] - PATH_SUFFIXES include/freetype2 include + PATH_SUFFIXES include/freetype2 include freetype2 ) find_library(FREETYPE_LIBRARY -- cgit v0.12 From 6c90f0a6938cf2ed2190db34ebc918a9e29fe4bf Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 3 Mar 2014 15:47:08 +0100 Subject: Ninja: Detect command-line length limit on Haiku --- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index a49fc2d..c24c5e0 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -591,7 +591,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmSystemTools::GetEnv(forceRspFile) == 0) { #ifdef _WIN32 commandLineLengthLimit = 8000 - linkRuleLength; -#elif defined(__linux) || defined(__APPLE__) +#elif defined(__linux) || defined(__APPLE__) || defined(__HAIKU__) // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac commandLineLengthLimit = ((int)sysconf(_SC_ARG_MAX))-linkRuleLength-1000; #else -- cgit v0.12 From ef1c1153d34548863bcc5cb6d767881eb5b93b04 Mon Sep 17 00:00:00 2001 From: Volkan Gezer Date: Thu, 6 Mar 2014 09:15:23 +0100 Subject: CTest: Teach ctest_coverage() to read CTEST_COVERAGE_EXTRA_FLAGS Use it to set the CoverageExtraFlags value just as COVERAGE_EXTRA_FLAGS does in the CTest module for creating DartConfiguration.tcl. --- Source/CTest/cmCTestCoverageCommand.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/CTest/cmCTestCoverageCommand.cxx b/Source/CTest/cmCTestCoverageCommand.cxx index 72ff720..41f016b 100644 --- a/Source/CTest/cmCTestCoverageCommand.cxx +++ b/Source/CTest/cmCTestCoverageCommand.cxx @@ -25,7 +25,8 @@ cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler() { this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "CoverageCommand", "CTEST_COVERAGE_COMMAND"); - + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS"); cmCTestCoverageHandler* handler = static_cast( this->CTest->GetInitializedHandler("coverage")); if ( !handler ) -- cgit v0.12 From 93d5c4dc22e0c430320117a08e0faf081f31ffa0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 10 Mar 2014 10:21:11 -0400 Subject: Help: Add release notes for topic 'ctest-coverage-extra' --- Help/release/dev/ctest-coverage-extra.rst | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Help/release/dev/ctest-coverage-extra.rst diff --git a/Help/release/dev/ctest-coverage-extra.rst b/Help/release/dev/ctest-coverage-extra.rst new file mode 100644 index 0000000..85d023b --- /dev/null +++ b/Help/release/dev/ctest-coverage-extra.rst @@ -0,0 +1,5 @@ +ctest-coverage-extra +-------------------- + +* The :command:`ctest_coverage` command learned to read variable + ``CTEST_COVERAGE_EXTRA_FLAGS`` to set ``CoverageExtraFlags``. -- cgit v0.12 From 172d8d94f4aa71a7c134513d48d8647d0d230215 Mon Sep 17 00:00:00 2001 From: Ryo ONODERA Date: Sat, 8 Mar 2014 20:35:00 -0500 Subject: cmELF: Fix typo in comment, 32-bit => 64-bit (#14799) --- Source/cmELF.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 353f2e9..bc1c25b 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -181,7 +181,7 @@ struct cmELFTypes32 static const char* GetName() { return "32-bit"; } }; -// Configure the implementation template for 32-bit ELF files. +// Configure the implementation template for 64-bit ELF files. struct cmELFTypes64 { typedef Elf64_Ehdr ELF_Ehdr; -- cgit v0.12 From f1b689b64a96fbf1e6f3b154d1bd4ee28ea3d625 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 9 Mar 2014 10:41:06 +0100 Subject: Makefile: Improve handling of WMake verbose output and errors * The '-e' option has nothing to do with verbose output. It is now properly handled by .ERASE directive in make file * The '-s' option sets silent output globally, it cannot be switched off. It is now handled only by .SILENT directive in make file directive is simply controlled by a conditonal block. Remove SilentNoColon member variable as it is no longer needed. --- Source/cmGlobalWatcomWMakeGenerator.cxx | 3 +-- Source/cmLocalUnixMakefileGenerator3.cxx | 37 +++++++++++++++++++++----------- Source/cmLocalUnixMakefileGenerator3.h | 7 ------ 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx index 98ce685..671166e 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.cxx +++ b/Source/cmGlobalWatcomWMakeGenerator.cxx @@ -43,11 +43,10 @@ void cmGlobalWatcomWMakeGenerator cmLocalGenerator *cmGlobalWatcomWMakeGenerator::CreateLocalGenerator() { cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3; - lg->SetSilentNoColon(true); lg->SetDefineWindowsNULL(true); lg->SetWindowsShell(true); lg->SetWatcomWMake(true); - lg->SetMakeSilentFlag("-s -h -e"); + lg->SetMakeSilentFlag("-h"); lg->SetGlobalGenerator(this); lg->SetIgnoreLibPrefix(true); lg->SetPassMakeflags(false); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index f7088c2..935da57 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -80,7 +80,6 @@ static std::string cmSplitExtension(std::string const& in, std::string& base) //---------------------------------------------------------------------------- cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3() { - this->SilentNoColon = false; this->WindowsShell = false; this->IncludeDirective = "include"; this->MakefileVariableSize = 0; @@ -758,15 +757,17 @@ cmLocalUnixMakefileGenerator3 depends.push_back(".hpux_make_needs_suffix_list"); this->WriteMakeRule(makefileStream, 0, ".SUFFIXES", depends, no_commands, false); - - cmGlobalUnixMakefileGenerator3* gg = - static_cast(this->GlobalGenerator); - // Write special target to silence make output. This must be after - // the default target in case VERBOSE is set (which changes the - // name). The setting of CMAKE_VERBOSE_MAKEFILE to ON will cause a - // "VERBOSE=1" to be added as a make variable which will change the - // name of this special target. This gives a make-time choice to - // the user. + if(this->WatcomWMake) + { + // Switch on WMake feature, if an error or interrupt occurs during + // makefile processing, the current target being made may be deleted + // without prompting (the same as command line -e option). + makefileStream << + "\n" + ".ERASE\n" + "\n" + ; + } if(this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")) { makefileStream @@ -774,12 +775,22 @@ cmLocalUnixMakefileGenerator3 << "VERBOSE = 1\n" << "\n"; } - if(this->SilentNoColon) + if(this->WatcomWMake) { - makefileStream << "$(VERBOSE).SILENT\n"; + makefileStream << + "!ifndef VERBOSE\n" + ".SILENT\n" + "!endif\n" + ; } else { + // Write special target to silence make output. This must be after + // the default target in case VERBOSE is set (which changes the + // name). The setting of CMAKE_VERBOSE_MAKEFILE to ON will cause a + // "VERBOSE=1" to be added as a make variable which will change the + // name of this special target. This gives a make-time choice to + // the user. this->WriteMakeRule(makefileStream, "Suppress display of executed commands.", "$(VERBOSE).SILENT", @@ -789,6 +800,8 @@ cmLocalUnixMakefileGenerator3 // Work-around for makes that drop rules that have no dependencies // or commands. + cmGlobalUnixMakefileGenerator3* gg = + static_cast(this->GlobalGenerator); std::string hack = gg->GetEmptyRuleHackDepends(); if(!hack.empty()) { diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 39f213b..7987c96 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -121,12 +121,6 @@ public: void SetUnixCD(bool v) {this->UnixCD = v;} /** - * Set Support Verbose Variable. If true, then .SILENT will - * be not end with : i.e. .SILENT: or .SILENT - */ - void SetSilentNoColon(bool v) {this->SilentNoColon = v;} - - /** * Set the string used to include one makefile into another default * is include. */ @@ -339,7 +333,6 @@ private: bool DefineWindowsNULL; bool UnixCD; bool PassMakeflags; - bool SilentNoColon; bool MakeCommandEscapeTargetTwice; bool BorlandMakeCurlyHack; //========================================================================== -- cgit v0.12 From e8c027bcc014eb2b84b663af9b79a5eefc437973 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Sun, 9 Mar 2014 16:16:39 +0200 Subject: cmcurl: Include the local curl directories before all others. In some cases, it was possible for the include directory of the system-wide libcurl to be added to the include path before cmcurl's, which would result in them being picked up and causing the build to fail if the curl versions differ too much. One way to trigger this is to have OpenSSL installed into a non-default location together with libcurl (/usr/local, for example). If cmcurl is built with CMAKE_USE_OPENSSL on, -I/usr/local/include would end up being added before -I${PATH_TO_CMCURL}. --- Utilities/cmcurl/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index abf04d8..1b918c9 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -172,6 +172,11 @@ IF(NOT CURL_SPECIAL_LIBZ) CHECK_LIBRARY_EXISTS_CONCAT("z" inflateEnd HAVE_LIBZ) ENDIF(NOT CURL_SPECIAL_LIBZ) +# Include the local directories before any others so that we do not end up +# including system curl's include directory first by mistake. +INCLUDE_DIRECTORIES(${LIBCURL_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${LIBCURL_BINARY_DIR}) + OPTION(CMAKE_USE_OPENSSL "Use OpenSSL code with curl." OFF) MARK_AS_ADVANCED(CMAKE_USE_OPENSSL) IF(CMAKE_USE_OPENSSL) @@ -679,8 +684,6 @@ INCLUDE(CMake/OtherTests.cmake) # The rest of the build -INCLUDE_DIRECTORIES(${LIBCURL_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${LIBCURL_BINARY_DIR}) OPTION(CMAKE_BUILD_CURL_SHARED "Should curl be built shared" TRUE) IF(CMAKE_BUILD_CURL_SHARED) SET(LIBRARY_TYPE SHARED) -- cgit v0.12 From 49ef91d7a6dc75b5bbc7a6b06ed909b23d13fd72 Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Thu, 6 Mar 2014 18:54:52 +0100 Subject: FindPkgConfig: restructure documentation and document commands and variables --- Modules/FindPkgConfig.cmake | 253 +++++++++++++++++++++----------------------- 1 file changed, 118 insertions(+), 135 deletions(-) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 7179d17..b0ceb2b 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -2,141 +2,15 @@ # FindPkgConfig # ------------- # -# a pkg-config module for CMake +# A `pkg-config` module for CMake. # +# Finds the ``pkg-config`` executable and add the +# :command:`pkg_check_modules` and :command:`pkg_search_module` +# commands. # -# -# To find the pkg-config executable, it uses the variable -# PKG_CONFIG_EXECUTABLE or the environment variable PKG_CONFIG first. -# -# -# -# Usage: -# -# :: -# -# pkg_check_modules( [REQUIRED] [QUIET] []*) -# checks for all the given modules -# -# -# -# :: -# -# pkg_search_module( [REQUIRED] [QUIET] []*) -# checks for given modules and uses the first working one -# -# -# -# When the 'REQUIRED' argument was set, macros will fail with an error -# when module(s) could not be found -# -# When the 'QUIET' argument is set, no status messages will be printed. -# -# It sets the following variables: -# -# :: -# -# PKG_CONFIG_FOUND ... if pkg-config executable was found -# PKG_CONFIG_EXECUTABLE ... pathname of the pkg-config program -# PKG_CONFIG_VERSION_STRING ... the version of the pkg-config program found -# (since CMake 2.8.8) -# -# -# -# For the following variables two sets of values exist; first one is the -# common one and has the given PREFIX. The second set contains flags -# which are given out when pkgconfig was called with the '--static' -# option. -# -# :: -# -# _FOUND ... set to 1 if module(s) exist -# _LIBRARIES ... only the libraries (w/o the '-l') -# _LIBRARY_DIRS ... the paths of the libraries (w/o the '-L') -# _LDFLAGS ... all required linker flags -# _LDFLAGS_OTHER ... all other linker flags -# _INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I') -# _CFLAGS ... all required cflags -# _CFLAGS_OTHER ... the other compiler flags -# -# -# -# :: -# -# = for common case -# = _STATIC for static linking -# -# -# -# There are some special variables whose prefix depends on the count of -# given modules. When there is only one module, stays -# unchanged. When there are multiple modules, the prefix will be -# changed to _: -# -# :: -# -# _VERSION ... version of the module -# _PREFIX ... prefix-directory of the module -# _INCLUDEDIR ... include-dir of the module -# _LIBDIR ... lib-dir of the module -# -# -# -# :: -# -# = when |MODULES| == 1, else -# = _ -# -# -# -# A parameter can have the following formats: -# -# :: -# -# {MODNAME} ... matches any version -# {MODNAME}>={VERSION} ... at least version is required -# {MODNAME}={VERSION} ... exactly version is required -# {MODNAME}<={VERSION} ... modules must not be newer than -# -# -# -# Examples -# -# :: -# -# pkg_check_modules (GLIB2 glib-2.0) -# -# -# -# :: -# -# pkg_check_modules (GLIB2 glib-2.0>=2.10) -# requires at least version 2.10 of glib2 and defines e.g. -# GLIB2_VERSION=2.10.3 -# -# -# -# :: -# -# pkg_check_modules (FOO glib-2.0>=2.10 gtk+-2.0) -# requires both glib2 and gtk2, and defines e.g. -# FOO_glib-2.0_VERSION=2.10.3 -# FOO_gtk+-2.0_VERSION=2.8.20 -# -# -# -# :: -# -# pkg_check_modules (XRENDER REQUIRED xrender) -# defines e.g.: -# XRENDER_LIBRARIES=Xrender;X11 -# XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp -# -# -# -# :: -# -# pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2) +# In order to find the ``pkg-config`` executable, it uses the +# :variable:`PKG_CONFIG_EXECUTABLE` variable or the ``PKG_CONFIG`` +# environment variable first. #============================================================================= # Copyright 2006-2014 Kitware, Inc. @@ -397,7 +271,94 @@ endmacro() ### User visible macros start here ### -### +#[========================================[.rst: +.. command:: pkg_check_modules + + Checks for all the given modules. :: + + pkg_check_modules( [REQUIRED] [QUIET] []*) + + When the ``REQUIRED`` argument was set, macros will fail with an error + when module(s) could not be found. + + When the ``QUIET`` argument is set, no status messages will be printed. + + It sets the following variables: :: + + PKG_CONFIG_FOUND ... if pkg-config executable was found + PKG_CONFIG_EXECUTABLE ... pathname of the pkg-config program + PKG_CONFIG_VERSION_STRING ... the version of the pkg-config program found + (since CMake 2.8.8) + + For the following variables two sets of values exist; first one is the + common one and has the given PREFIX. The second set contains flags + which are given out when ``pkg-config`` was called with the ``--static`` + option. :: + + _FOUND ... set to 1 if module(s) exist + _LIBRARIES ... only the libraries (w/o the '-l') + _LIBRARY_DIRS ... the paths of the libraries (w/o the '-L') + _LDFLAGS ... all required linker flags + _LDFLAGS_OTHER ... all other linker flags + _INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I') + _CFLAGS ... all required cflags + _CFLAGS_OTHER ... the other compiler flags + + :: + + = for common case + = _STATIC for static linking + + There are some special variables whose prefix depends on the count of + given modules. When there is only one module, stays + unchanged. When there are multiple modules, the prefix will be + changed to _: :: + + _VERSION ... version of the module + _PREFIX ... prefix-directory of the module + _INCLUDEDIR ... include-dir of the module + _LIBDIR ... lib-dir of the module + + :: + + = when |MODULES| == 1, else + = _ + + A parameter can have the following formats: :: + + {MODNAME} ... matches any version + {MODNAME}>={VERSION} ... at least version is required + {MODNAME}={VERSION} ... exactly version is required + {MODNAME}<={VERSION} ... modules must not be newer than + + Examples + + .. code-block:: cmake + + pkg_check_modules (GLIB2 glib-2.0) + + .. code-block:: cmake + + pkg_check_modules (GLIB2 glib-2.0>=2.10) + + Requires at least version 2.10 of glib2 and defines e.g. + ``GLIB2_VERSION=2.10.3`` + + .. code-block:: cmake + + pkg_check_modules (FOO glib-2.0>=2.10 gtk+-2.0) + + Requires both glib2 and gtk2, and defines e.g. + ``FOO_glib-2.0_VERSION=2.10.3`` and ``FOO_gtk+-2.0_VERSION=2.8.20`` + + .. code-block:: cmake + + pkg_check_modules (XRENDER REQUIRED xrender) + + Defines e.g.: + ``XRENDER_LIBRARIES=Xrender;X11`` and + ``XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp`` +#]========================================] macro(pkg_check_modules _prefix _module0) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) @@ -408,7 +369,21 @@ macro(pkg_check_modules _prefix _module0) endif() endmacro() -### + +#[========================================[.rst: +.. command:: pkg_search_module + + Same as :command:`pkg_check_modules`, but instead it checks for given + modules and uses the first working one. :: + + pkg_search_module( [REQUIRED] [QUIET] []*) + + Examples + + .. code-block:: cmake + + pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2) +#]========================================] macro(pkg_search_module _prefix _module0) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) @@ -440,6 +415,14 @@ macro(pkg_search_module _prefix _module0) endif() endmacro() + +#[========================================[.rst: +.. variable:: PKG_CONFIG_EXECUTABLE + + Path to the pkg-config executable. +#]========================================] + + ### Local Variables: ### mode: cmake ### End: -- cgit v0.12 From 649789a736bb217f818696eae36ee6e6a2e1aa61 Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Thu, 6 Mar 2014 23:23:52 -0700 Subject: Unicode: cmake-gui encoding now matches KWSys encoding. A UTF-8 QTextCodec is used with QString when KWSys is configured to treat strings as UTF-8. This means QString::toLocal8Bit() will convert to UTF-8. --- Source/QtDialog/CMakeLists.txt | 5 +++++ Source/QtDialog/CMakeSetup.cxx | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 4308a4d..0dd01d8 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -55,6 +55,11 @@ else() endif() endif() + +if(WIN32 AND KWSYS_ENCODING_DEFAULT_CODEPAGE MATCHES CP_UTF8) + add_definitions(-DKWSYS_CP_UTF8) +endif() + set(SRCS AddCacheEntry.cxx AddCacheEntry.h diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 821121e..995929e 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -14,6 +14,7 @@ #include #include #include +#include #include "QMacInstallDialog.h" #include "CMakeSetupDialog.h" #include "cmDocumentation.h" @@ -78,6 +79,13 @@ int main(int argc, char** argv) QApplication app(argc, argv); +#if defined(KWSYS_CP_UTF8) + QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8"); + QTextCodec::setCodecForCStrings(utf8_codec); + QTextCodec::setCodecForLocale(utf8_codec); + QTextCodec::setCodecForTr(utf8_codec); +#endif + // clean out standard Qt paths for plugins, which we don't use anyway // when creating Mac bundles, it potentially causes problems foreach(QString p, QApplication::libraryPaths()) -- cgit v0.12 From 64b93354dc6207ad270f2c5e72e43c54d7d3af67 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 11 Mar 2014 00:01:07 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 46264b1..18e328a 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 0) -set(CMake_VERSION_PATCH 20140310) +set(CMake_VERSION_PATCH 20140311) #set(CMake_VERSION_RC 1) -- cgit v0.12 From f74a8405b6caa8ac253ce0357642a244ab192410 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 11 Mar 2014 14:36:58 +0100 Subject: Test error cases in find_dependency. --- Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/find_dependency/CMakeLists.txt | 4 ++++ Tests/RunCMake/find_dependency/EXACT-no-version-result.txt | 1 + Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt | 6 ++++++ Tests/RunCMake/find_dependency/EXACT-no-version.cmake | 4 ++++ Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake | 2 ++ Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake | 11 +++++++++++ Tests/RunCMake/find_dependency/RunCMakeTest.cmake | 5 +++++ Tests/RunCMake/find_dependency/extra-args-result.txt | 1 + Tests/RunCMake/find_dependency/extra-args-stderr.txt | 5 +++++ Tests/RunCMake/find_dependency/extra-args.cmake | 4 ++++ Tests/RunCMake/find_dependency/invalid-arg-3-result.txt | 1 + Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt | 5 +++++ Tests/RunCMake/find_dependency/invalid-arg-3.cmake | 4 ++++ 14 files changed, 54 insertions(+) create mode 100644 Tests/RunCMake/find_dependency/CMakeLists.txt create mode 100644 Tests/RunCMake/find_dependency/EXACT-no-version-result.txt create mode 100644 Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt create mode 100644 Tests/RunCMake/find_dependency/EXACT-no-version.cmake create mode 100644 Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake create mode 100644 Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake create mode 100644 Tests/RunCMake/find_dependency/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/find_dependency/extra-args-result.txt create mode 100644 Tests/RunCMake/find_dependency/extra-args-stderr.txt create mode 100644 Tests/RunCMake/find_dependency/extra-args.cmake create mode 100644 Tests/RunCMake/find_dependency/invalid-arg-3-result.txt create mode 100644 Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt create mode 100644 Tests/RunCMake/find_dependency/invalid-arg-3.cmake diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index d401a93..499d12b 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -49,6 +49,7 @@ add_RunCMake_test(GeneratorToolset) add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) add_RunCMake_test(ObjectLibrary) +add_RunCMake_test(find_dependency) if(NOT WIN32) add_RunCMake_test(PositionIndependentCode) set(SKIP_VISIBILITY 0) diff --git a/Tests/RunCMake/find_dependency/CMakeLists.txt b/Tests/RunCMake/find_dependency/CMakeLists.txt new file mode 100644 index 0000000..04d09f2 --- /dev/null +++ b/Tests/RunCMake/find_dependency/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 2.8.4) +project(${RunCMake_TEST} NONE) +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}") +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version-result.txt b/Tests/RunCMake/find_dependency/EXACT-no-version-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_dependency/EXACT-no-version-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt b/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt new file mode 100644 index 0000000..6f4fc04 --- /dev/null +++ b/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:35 \(message\): + Invalid arguments to find_dependency. EXACT may only be specified if a + VERSION is specified +Call Stack \(most recent call first\): + EXACT-no-version.cmake:4 \(find_dependency\) + CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version.cmake b/Tests/RunCMake/find_dependency/EXACT-no-version.cmake new file mode 100644 index 0000000..b05665b7 --- /dev/null +++ b/Tests/RunCMake/find_dependency/EXACT-no-version.cmake @@ -0,0 +1,4 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 EXACT) diff --git a/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake b/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake new file mode 100644 index 0000000..7d55ef6 --- /dev/null +++ b/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake @@ -0,0 +1,2 @@ + +add_library(Pack1::Lib INTERFACE IMPORTED) diff --git a/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake b/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake new file mode 100644 index 0000000..dfb7b6c --- /dev/null +++ b/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "1.3") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/RunCMake/find_dependency/RunCMakeTest.cmake b/Tests/RunCMake/find_dependency/RunCMakeTest.cmake new file mode 100644 index 0000000..b85104a --- /dev/null +++ b/Tests/RunCMake/find_dependency/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(EXACT-no-version) +run_cmake(invalid-arg-3) +run_cmake(extra-args) diff --git a/Tests/RunCMake/find_dependency/extra-args-result.txt b/Tests/RunCMake/find_dependency/extra-args-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_dependency/extra-args-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/extra-args-stderr.txt b/Tests/RunCMake/find_dependency/extra-args-stderr.txt new file mode 100644 index 0000000..1b52380 --- /dev/null +++ b/Tests/RunCMake/find_dependency/extra-args-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:47 \(message\): + Invalid arguments to find_dependency +Call Stack \(most recent call first\): + extra-args.cmake:4 \(find_dependency\) + CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/extra-args.cmake b/Tests/RunCMake/find_dependency/extra-args.cmake new file mode 100644 index 0000000..209645a --- /dev/null +++ b/Tests/RunCMake/find_dependency/extra-args.cmake @@ -0,0 +1,4 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 1.2 EXACT PATHS "${CMAKE_BINARY_DIR}") diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3-result.txt b/Tests/RunCMake/find_dependency/invalid-arg-3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_dependency/invalid-arg-3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt b/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt new file mode 100644 index 0000000..c36148f --- /dev/null +++ b/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:42 \(message\): + Invalid arguments to find_dependency +Call Stack \(most recent call first\): + invalid-arg-3.cmake:4 \(find_dependency\) + CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3.cmake b/Tests/RunCMake/find_dependency/invalid-arg-3.cmake new file mode 100644 index 0000000..40ede07 --- /dev/null +++ b/Tests/RunCMake/find_dependency/invalid-arg-3.cmake @@ -0,0 +1,4 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 1.2 EXACTYPO) -- cgit v0.12 From 21c573f682f9eafbc8d4402f7febbb1bec1cb86a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 11 Mar 2014 00:04:11 +0100 Subject: Remove some c_str() calls. Use the clang RemoveCStrCalls tool to automatically migrate the code. This was only run on linux, so does not have any positive or negative effect on other platforms. --- Source/CPack/cmCPackDebGenerator.cxx | 6 +- Source/CPack/cmCPackGenerator.cxx | 76 +++++----- Source/CPack/cmCPackNSISGenerator.cxx | 2 +- Source/CPack/cmCPackRPMGenerator.cxx | 4 +- Source/CPack/cpack.cxx | 2 +- Source/CTest/cmCTestBuildAndTestHandler.cxx | 10 +- Source/CTest/cmCTestBuildCommand.cxx | 2 +- Source/CTest/cmCTestConfigureCommand.cxx | 2 +- Source/CTest/cmCTestCoverageHandler.cxx | 12 +- .../CTest/cmCTestEmptyBinaryDirectoryCommand.cxx | 2 +- Source/CTest/cmCTestGenericHandler.cxx | 6 +- Source/CTest/cmCTestHandlerCommand.cxx | 2 +- Source/CTest/cmCTestLaunch.cxx | 4 +- Source/CTest/cmCTestP4.cxx | 2 +- Source/CTest/cmCTestRunScriptCommand.cxx | 2 +- Source/CTest/cmCTestScriptHandler.cxx | 10 +- Source/CTest/cmCTestStartCommand.cxx | 4 +- Source/CTest/cmCTestSubmitHandler.cxx | 4 +- Source/CTest/cmCTestTestHandler.cxx | 30 ++-- Source/CTest/cmParseMumpsCoverage.cxx | 2 +- Source/CursesDialog/cmCursesLabelWidget.cxx | 2 +- Source/CursesDialog/cmCursesOptionsWidget.cxx | 4 +- Source/CursesDialog/cmCursesPathWidget.cxx | 4 +- Source/cmAddCustomCommandCommand.cxx | 22 +-- Source/cmAddCustomTargetCommand.cxx | 10 +- Source/cmAddDependenciesCommand.cxx | 4 +- Source/cmAddExecutableCommand.cxx | 24 +-- Source/cmAddLibraryCommand.cxx | 58 ++++---- Source/cmAddSubDirectoryCommand.cxx | 6 +- Source/cmAddTestCommand.cxx | 14 +- Source/cmAuxSourceDirectoryCommand.cxx | 6 +- Source/cmBuildCommand.cxx | 4 +- Source/cmBuildNameCommand.cxx | 6 +- Source/cmCMakeHostSystemInformationCommand.cxx | 4 +- Source/cmCMakeMinimumRequired.cxx | 4 +- Source/cmCMakePolicyCommand.cxx | 12 +- Source/cmCPluginAPI.cxx | 6 +- Source/cmCTest.cxx | 12 +- Source/cmCommandArgumentParserHelper.cxx | 12 +- Source/cmComputeLinkDepends.cxx | 10 +- Source/cmComputeLinkInformation.cxx | 38 ++--- Source/cmComputeTargetDepends.cxx | 18 +-- Source/cmConfigureFileCommand.cxx | 6 +- Source/cmCoreTryCompile.cxx | 14 +- Source/cmCreateTestSourceList.cxx | 4 +- Source/cmCustomCommandGenerator.cxx | 4 +- Source/cmDefinePropertyCommand.cxx | 6 +- Source/cmDepends.cxx | 8 +- Source/cmDependsC.cxx | 6 +- Source/cmDependsFortran.cxx | 22 +-- Source/cmDocumentation.cxx | 2 +- Source/cmExecProgramCommand.cxx | 4 +- Source/cmExecuteProcessCommand.cxx | 16 +- Source/cmExportBuildFileGenerator.cxx | 8 +- Source/cmExportCommand.cxx | 24 +-- Source/cmExportFileGenerator.cxx | 12 +- Source/cmExportInstallFileGenerator.cxx | 2 +- Source/cmExportLibraryDependenciesCommand.cxx | 2 +- Source/cmExportTryCompileFileGenerator.cxx | 4 +- Source/cmExternalMakefileProjectGenerator.cxx | 2 +- Source/cmExtraCodeBlocksGenerator.cxx | 14 +- Source/cmExtraCodeLiteGenerator.cxx | 2 +- Source/cmExtraEclipseCDT4Generator.cxx | 10 +- Source/cmExtraSublimeTextGenerator.cxx | 10 +- Source/cmFLTKWrapUICommand.cxx | 10 +- Source/cmFileCommand.cxx | 142 +++++++++--------- Source/cmFindBase.cxx | 8 +- Source/cmFindCommon.cxx | 8 +- Source/cmFindLibraryCommand.cxx | 6 +- Source/cmFindPackageCommand.cxx | 110 +++++++------- Source/cmFindPathCommand.cxx | 6 +- Source/cmFindProgramCommand.cxx | 6 +- Source/cmForEachCommand.cxx | 16 +- Source/cmFunctionCommand.cxx | 12 +- Source/cmGeneratorExpression.cxx | 2 +- Source/cmGeneratorExpressionDAGChecker.cxx | 6 +- Source/cmGeneratorExpressionEvaluationFile.cxx | 10 +- Source/cmGeneratorExpressionEvaluator.cxx | 16 +- Source/cmGeneratorTarget.cxx | 16 +- Source/cmGetCMakePropertyCommand.cxx | 4 +- Source/cmGetDirectoryPropertyCommand.cxx | 12 +- Source/cmGetFilenameComponentCommand.cxx | 12 +- Source/cmGetPropertyCommand.cxx | 50 +++---- Source/cmGetSourceFilePropertyCommand.cxx | 2 +- Source/cmGetTargetPropertyCommand.cxx | 10 +- Source/cmGetTestPropertyCommand.cxx | 8 +- Source/cmGlobalGenerator.cxx | 56 +++---- Source/cmGlobalKdevelopGenerator.cxx | 2 +- Source/cmGlobalNinjaGenerator.cxx | 4 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 60 ++++---- Source/cmGraphVizWriter.cxx | 12 +- Source/cmIfCommand.cxx | 12 +- Source/cmIncludeCommand.cxx | 8 +- Source/cmIncludeRegularExpressionCommand.cxx | 2 +- Source/cmInstallCommand.cxx | 76 +++++----- Source/cmInstallExportGenerator.cxx | 8 +- Source/cmInstallFilesCommand.cxx | 4 +- Source/cmInstallProgramsCommand.cxx | 2 +- Source/cmInstallTargetsCommand.cxx | 2 +- Source/cmLinkDirectoriesCommand.cxx | 2 +- Source/cmLinkLibrariesCommand.cxx | 6 +- Source/cmListCommand.cxx | 56 +++---- Source/cmListFileCache.cxx | 4 +- Source/cmLoadCacheCommand.cxx | 8 +- Source/cmLoadCommandCommand.cxx | 10 +- Source/cmLocalGenerator.cxx | 164 ++++++++++----------- Source/cmLocalNinjaGenerator.cxx | 10 +- Source/cmLocalUnixMakefileGenerator3.cxx | 92 ++++++------ Source/cmMacroCommand.cxx | 6 +- Source/cmMakeDepend.cxx | 8 +- Source/cmMakeDirectoryCommand.cxx | 2 +- Source/cmMakefile.cxx | 84 +++++------ Source/cmMakefileExecutableTargetGenerator.cxx | 40 ++--- Source/cmMakefileLibraryTargetGenerator.cxx | 60 ++++---- Source/cmMakefileTargetGenerator.cxx | 148 +++++++++---------- Source/cmMakefileUtilityTargetGenerator.cxx | 4 +- Source/cmMarkAsAdvancedCommand.cxx | 4 +- Source/cmMathCommand.cxx | 6 +- Source/cmMessageCommand.cxx | 2 +- Source/cmNinjaNormalTargetGenerator.cxx | 16 +- Source/cmNinjaTargetGenerator.cxx | 32 ++-- Source/cmOSXBundleGenerator.cxx | 6 +- Source/cmOptionCommand.cxx | 4 +- Source/cmOrderDirectories.cxx | 2 +- Source/cmOutputRequiredFilesCommand.cxx | 2 +- Source/cmPolicies.cxx | 6 +- Source/cmProjectCommand.cxx | 26 ++-- Source/cmQTWrapCPPCommand.cxx | 10 +- Source/cmQTWrapUICommand.cxx | 16 +- Source/cmQtAutoGenerators.cxx | 62 ++++---- Source/cmScriptGenerator.cxx | 2 +- Source/cmSeparateArgumentsCommand.cxx | 8 +- Source/cmSetCommand.cxx | 2 +- Source/cmSetDirectoryPropertiesCommand.cxx | 4 +- Source/cmSetPropertyCommand.cxx | 22 +-- Source/cmSetSourceFilesPropertiesCommand.cxx | 6 +- Source/cmSetTargetPropertiesCommand.cxx | 8 +- Source/cmSetTestsPropertiesCommand.cxx | 6 +- Source/cmSiteNameCommand.cxx | 4 +- Source/cmSourceFile.cxx | 6 +- Source/cmSourceGroupCommand.cxx | 6 +- Source/cmStringCommand.cxx | 76 +++++----- Source/cmSubdirCommand.cxx | 8 +- Source/cmSystemTools.cxx | 6 +- Source/cmTarget.cxx | 136 ++++++++--------- Source/cmTargetLinkLibrariesCommand.cxx | 14 +- Source/cmTargetPropCommandBase.cxx | 8 +- Source/cmTestGenerator.cxx | 2 +- Source/cmTryRunCommand.cxx | 26 ++-- Source/cmUseMangledMesaCommand.cxx | 2 +- Source/cmUtilitySourceCommand.cxx | 6 +- Source/cmVariableRequiresCommand.cxx | 8 +- Source/cmVariableWatchCommand.cxx | 2 +- Source/cmWriteFileCommand.cxx | 4 +- Source/cmake.cxx | 112 +++++++------- Source/cmcmd.cxx | 16 +- Source/kwsys/SystemTools.cxx | 4 +- 157 files changed, 1384 insertions(+), 1384 deletions(-) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 0162d55..9ae5839 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -506,7 +506,7 @@ int cmCPackDebGenerator::createDeb() controlExtraList.begin(); i != controlExtraList.end(); ++i) { std::string filenamename = - cmsys::SystemTools::GetFilenameName(i->c_str()); + cmsys::SystemTools::GetFilenameName(*i); std::string localcopy = this->GetOption("WDIR"); localcopy += "/"; localcopy += filenamename; @@ -588,9 +588,9 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix( // the current COMPONENT belongs to. std::string groupVar = "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; - if (NULL != GetOption(groupVar.c_str())) + if (NULL != GetOption(groupVar)) { - return std::string(GetOption(groupVar.c_str())); + return std::string(GetOption(groupVar)); } else { diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 3915b31..cf514aa 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -357,9 +357,9 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( std::list > symlinkedFiles; cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl); cmsys::Glob gl; - std::string top = it->c_str(); + std::string top = *it; it ++; - std::string subdir = it->c_str(); + std::string subdir = *it; std::string findExpr = top; findExpr += "/*"; cmCPackLogger(cmCPackLog::LOG_OUTPUT, @@ -473,7 +473,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript( it != cmakeScriptsVector.end(); ++it ) { - std::string installScript = it->c_str(); + std::string installScript = *it; cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install script: " << installScript << std::endl); @@ -562,13 +562,13 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( << std::endl); return 0; } - std::string installDirectory = it->c_str(); + std::string installDirectory = *it; ++it; - std::string installProjectName = it->c_str(); + std::string installProjectName = *it; ++it; - std::string installComponent = it->c_str(); + std::string installComponent = *it; ++it; - std::string installSubDirectory = it->c_str(); + std::string installSubDirectory = *it; std::string installFile = installDirectory + "/cmake_install.cmake"; std::vector componentsVector; @@ -586,7 +586,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( // Determine the installation types for this project (if provided). std::string installTypesVar = "CPACK_" + cmSystemTools::UpperCase(installComponent) + "_INSTALL_TYPES"; - const char *installTypes = this->GetOption(installTypesVar.c_str()); + const char *installTypes = this->GetOption(installTypesVar); if (installTypes && *installTypes) { std::vector installTypesVector; @@ -596,15 +596,15 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( installTypeIt != installTypesVector.end(); ++installTypeIt) { - this->GetInstallationType(installProjectName.c_str(), - installTypeIt->c_str()); + this->GetInstallationType(installProjectName, + *installTypeIt); } } // Determine the set of components that will be used in this project std::string componentsVar = "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(installComponent); - const char *components = this->GetOption(componentsVar.c_str()); + const char *components = this->GetOption(componentsVar); if (components && *components) { cmSystemTools::ExpandListArgument(components, componentsVector); @@ -613,7 +613,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( compIt != componentsVector.end(); ++compIt) { - GetComponent(installProjectName.c_str(), compIt->c_str()); + GetComponent(installProjectName, *compIt); } componentInstall = true; } @@ -641,7 +641,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( = this->MakefileMap->GetDefinition("CMAKE_MAKE_PROGRAM"); std::vector buildCommand; globalGenerator->GenerateBuildCommand(buildCommand, cmakeMakeProgram, - installProjectName.c_str(), installDirectory.c_str(), + installProjectName, installDirectory, globalGenerator->GetPreinstallTargetName(), buildConfig, false); std::string buildCommandStr = @@ -932,19 +932,19 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string absoluteDestFileComponent = std::string("CPACK_ABSOLUTE_DESTINATION_FILES") + "_" + GetComponentInstallDirNameSuffix(installComponent); - if (NULL != this->GetOption(absoluteDestFileComponent.c_str())) + if (NULL != this->GetOption(absoluteDestFileComponent)) { std::string absoluteDestFilesListComponent = - this->GetOption(absoluteDestFileComponent.c_str()); + this->GetOption(absoluteDestFileComponent); absoluteDestFilesListComponent +=";"; absoluteDestFilesListComponent += mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"); - this->SetOption(absoluteDestFileComponent.c_str(), + this->SetOption(absoluteDestFileComponent, absoluteDestFilesListComponent.c_str()); } else { - this->SetOption(absoluteDestFileComponent.c_str(), + this->SetOption(absoluteDestFileComponent, mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")); } } @@ -1428,14 +1428,14 @@ std::string cmCPackGenerator::GetComponentPackageFileName( std::string suffix="-"+groupOrComponentName; /* check if we should use DISPLAY name */ std::string dispNameVar = "CPACK_"+Name+"_USE_DISPLAY_NAME_IN_FILENAME"; - if (IsOn(dispNameVar.c_str())) + if (IsOn(dispNameVar)) { /* the component Group case */ if (isGroupName) { std::string groupDispVar = "CPACK_COMPONENT_GROUP_" + cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME"; - const char* groupDispName = GetOption(groupDispVar.c_str()); + const char* groupDispName = GetOption(groupDispVar); if (groupDispName) { suffix = "-"+std::string(groupDispName); @@ -1446,7 +1446,7 @@ std::string cmCPackGenerator::GetComponentPackageFileName( { std::string dispVar = "CPACK_COMPONENT_" + cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME"; - const char* dispName = GetOption(dispVar.c_str()); + const char* dispName = GetOption(dispVar); if(dispName) { suffix = "-"+std::string(dispName); @@ -1497,7 +1497,7 @@ cmCPackGenerator::GetInstallationType(const std::string& projectName, installType->Name = name; const char* displayName - = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str()); + = this->GetOption(macroPrefix + "_DISPLAY_NAME"); if (displayName && *displayName) { installType->DisplayName = displayName; @@ -1527,7 +1527,7 @@ cmCPackGenerator::GetComponent(const std::string& projectName, + cmsys::SystemTools::UpperCase(name); component->Name = name; const char* displayName - = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str()); + = this->GetOption(macroPrefix + "_DISPLAY_NAME"); if (displayName && *displayName) { component->DisplayName = displayName; @@ -1537,23 +1537,23 @@ cmCPackGenerator::GetComponent(const std::string& projectName, component->DisplayName = component->Name; } component->IsHidden - = this->IsOn((macroPrefix + "_HIDDEN").c_str()); + = this->IsOn(macroPrefix + "_HIDDEN"); component->IsRequired - = this->IsOn((macroPrefix + "_REQUIRED").c_str()); + = this->IsOn(macroPrefix + "_REQUIRED"); component->IsDisabledByDefault - = this->IsOn((macroPrefix + "_DISABLED").c_str()); + = this->IsOn(macroPrefix + "_DISABLED"); component->IsDownloaded - = this->IsOn((macroPrefix + "_DOWNLOADED").c_str()) + = this->IsOn(macroPrefix + "_DOWNLOADED") || cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL")); - const char* archiveFile = this->GetOption((macroPrefix + - "_ARCHIVE_FILE").c_str()); + const char* archiveFile = this->GetOption(macroPrefix + + "_ARCHIVE_FILE"); if (archiveFile && *archiveFile) { component->ArchiveFile = archiveFile; } - const char* groupName = this->GetOption((macroPrefix + "_GROUP").c_str()); + const char* groupName = this->GetOption(macroPrefix + "_GROUP"); if (groupName && *groupName) { component->Group = GetComponentGroup(projectName, groupName); @@ -1565,7 +1565,7 @@ cmCPackGenerator::GetComponent(const std::string& projectName, } const char* description - = this->GetOption((macroPrefix + "_DESCRIPTION").c_str()); + = this->GetOption(macroPrefix + "_DESCRIPTION"); if (description && *description) { component->Description = description; @@ -1573,7 +1573,7 @@ cmCPackGenerator::GetComponent(const std::string& projectName, // Determine the installation types. const char *installTypes - = this->GetOption((macroPrefix + "_INSTALL_TYPES").c_str()); + = this->GetOption(macroPrefix + "_INSTALL_TYPES"); if (installTypes && *installTypes) { std::vector installTypesVector; @@ -1589,7 +1589,7 @@ cmCPackGenerator::GetComponent(const std::string& projectName, } // Determine the component dependencies. - const char *depends = this->GetOption((macroPrefix + "_DEPENDS").c_str()); + const char *depends = this->GetOption(macroPrefix + "_DEPENDS"); if (depends && *depends) { std::vector dependsVector; @@ -1600,7 +1600,7 @@ cmCPackGenerator::GetComponent(const std::string& projectName, ++dependIt) { cmCPackComponent *child = GetComponent(projectName, - dependIt->c_str()); + *dependIt); component->Dependencies.push_back(child); child->ReverseDependencies.push_back(component); } @@ -1624,7 +1624,7 @@ cmCPackGenerator::GetComponentGroup(const std::string& projectName, // Define the group group->Name = name; const char* displayName - = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str()); + = this->GetOption(macroPrefix + "_DISPLAY_NAME"); if (displayName && *displayName) { group->DisplayName = displayName; @@ -1635,17 +1635,17 @@ cmCPackGenerator::GetComponentGroup(const std::string& projectName, } const char* description - = this->GetOption((macroPrefix + "_DESCRIPTION").c_str()); + = this->GetOption(macroPrefix + "_DESCRIPTION"); if (description && *description) { group->Description = description; } group->IsBold - = this->IsOn((macroPrefix + "_BOLD_TITLE").c_str()); + = this->IsOn(macroPrefix + "_BOLD_TITLE"); group->IsExpandedByDefault - = this->IsOn((macroPrefix + "_EXPANDED").c_str()); + = this->IsOn(macroPrefix + "_EXPANDED"); const char* parentGroupName - = this->GetOption((macroPrefix + "_PARENT_GROUP").c_str()); + = this->GetOption(macroPrefix + "_PARENT_GROUP"); if (parentGroupName && *parentGroupName) { group->ParentGroup = GetComponentGroup(projectName, parentGroupName); diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 62bfa91..f433834 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -629,7 +629,7 @@ void cmCPackNSISGenerator::CreateMenuLinks( cmOStringStream& str, // if so add a desktop link std::string desktop = "CPACK_CREATE_DESKTOP_LINK_"; desktop += linkName; - if(this->IsSet(desktop.c_str())) + if(this->IsSet(desktop)) { str << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n"; str << " CreateShortCut \"$DESKTOP\\" diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index 66a4194..c6171dc 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -272,9 +272,9 @@ std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix( // the current COMPONENT belongs to. std::string groupVar = "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; - if (NULL != GetOption(groupVar.c_str())) + if (NULL != GetOption(groupVar)) { - return std::string(GetOption(groupVar.c_str())); + return std::string(GetOption(groupVar)); } else { diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index d74c38d..d1a16f0 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -326,7 +326,7 @@ int main (int argc, char const* const* argv) cdit != definitions.Map.end(); ++cdit ) { - globalMF->AddDefinition(cdit->first.c_str(), cdit->second.c_str()); + globalMF->AddDefinition(cdit->first, cdit->second.c_str()); } const char* cpackModulesPath = diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 0fac136..4a3eec5 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -241,11 +241,11 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) { // Make the generator available for the Build call below. cm.SetGlobalGenerator(cm.CreateGlobalGenerator( - this->BuildGenerator.c_str())); + this->BuildGenerator)); cm.SetGeneratorToolset(this->BuildGeneratorToolset); // Load the cache to make CMAKE_MAKE_PROGRAM available. - cm.GetCacheManager()->LoadCache(this->BinaryDir.c_str()); + cm.GetCacheManager()->LoadCache(this->BinaryDir); } else { @@ -295,9 +295,9 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) config = "Debug"; } int retVal = cm.GetGlobalGenerator()->Build( - this->SourceDir.c_str(), this->BinaryDir.c_str(), - this->BuildProject.c_str(), tarIt->c_str(), - &output, this->BuildMakeProgram.c_str(), + this->SourceDir, this->BinaryDir, + this->BuildProject, *tarIt, + &output, this->BuildMakeProgram, config, !this->BuildNoClean, false, remainingTime); diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index 04eabd2..de42e2b 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -151,7 +151,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() "\n" "Alternatively, set CTEST_BUILD_COMMAND to build the project " "with a custom command line."; - this->SetError(ostr.str().c_str()); + this->SetError(ostr.str()); return 0; } } diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 5eed409..1aa8768 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -69,7 +69,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() cmOStringStream e; e << "CMakeLists.txt file does not exist [" << cmakelists_file << "]"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return 0; } diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 2e35b75..2c21a13 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -157,7 +157,7 @@ void cmCTestCoverageHandler::CleanCoverageLogFiles(std::ostream& log) logGlob += this->CTest->GetCurrentTag(); logGlob += "/CoverageLog*"; cmsys::Glob gl; - gl.FindFiles(logGlob.c_str()); + gl.FindFiles(logGlob); std::vector const& files = gl.GetFiles(); for(std::vector::const_iterator fi = files.begin(); fi != files.end(); ++fi) @@ -241,7 +241,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, bool buildSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(), fBinDir.c_str()); // Always check parent directory of the file. - std::string fileDir = cmSystemTools::GetFilenamePath(fFile.c_str()); + std::string fileDir = cmSystemTools::GetFilenamePath(fFile); std::string checkDir; // We also need to check the binary/source directory pair. @@ -296,7 +296,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, checkDir = fSrcDir; } fFile = checkDir + "/" + relPath; - fFile = cmSystemTools::GetFilenamePath(fFile.c_str()); + fFile = cmSystemTools::GetFilenamePath(fFile); if ( fileDir == fFile ) { @@ -503,7 +503,7 @@ int cmCTestCoverageHandler::ProcessHandler() } const std::string fileName - = cmSystemTools::GetFilenameName(fullFileName.c_str()); + = cmSystemTools::GetFilenameName(fullFileName); std::string shortFileName = this->CTest->GetShortPathToFile(fullFileName.c_str()); const cmCTestCoverageHandlerContainer::SingleFileCoverageVector& fcov @@ -947,7 +947,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( // Call gcov to get coverage data for this *.gcda file: // - std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str()); + std::string fileDir = cmSystemTools::GetFilenamePath(*it); std::string command = "\"" + gcovCommand + "\" " + gcovExtraFlags + " " + "-o \"" + fileDir + "\" " + @@ -1814,7 +1814,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( total_tested += functionsCalled; total_untested += (totalFunctions - functionsCalled); - std::string fileName = cmSystemTools::GetFilenameName(file.c_str()); + std::string fileName = cmSystemTools::GetFilenameName(file); std::string shortFileName = this->CTest->GetShortPathToFile(file.c_str()); diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx index abc33de..a470b3b 100644 --- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx +++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx @@ -26,7 +26,7 @@ bool cmCTestEmptyBinaryDirectoryCommand { cmOStringStream ostr; ostr << "problem removing the binary directory: " << args[0].c_str(); - this->SetError(ostr.str().c_str()); + this->SetError(ostr.str()); return false; } diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index ae498ea..08cfaec 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -75,7 +75,7 @@ void cmCTestGenericHandler::Initialize() it != this->PersistentOptions.end(); ++ it ) { - this->Options[it->first.c_str()] = it->second.c_str(); + this->Options[it->first] = it->second.c_str(); } } @@ -121,7 +121,7 @@ bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part, return false; } if( !this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), - ostr.str().c_str(), xofs, true) ) + ostr.str(), xofs, true) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create resulting XML file: " << ostr.str().c_str() @@ -153,7 +153,7 @@ bool cmCTestGenericHandler::StartLogFile(const char* name, ostr << "_" << this->CTest->GetCurrentTag(); } ostr << ".log"; - if( !this->CTest->OpenOutputFile("Temporary", ostr.str().c_str(), xofs) ) + if( !this->CTest->OpenOutputFile("Temporary", ostr.str(), xofs) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create log file: " << ostr.str().c_str() << std::endl); diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index 2e2feb0..0e29160 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -48,7 +48,7 @@ bool cmCTestHandlerCommand { cmOStringStream e; e << "called with unknown argument \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index c9f9e9e..10a5199 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -680,8 +680,8 @@ bool cmCTestLaunch::ScrapeLog(std::string const& fname) continue; } - if(this->Match(line.c_str(), this->RegexWarning) && - !this->Match(line.c_str(), this->RegexWarningSuppress)) + if(this->Match(line, this->RegexWarning) && + !this->Match(line, this->RegexWarningSuppress)) { return true; } diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index 1ad94bc..0bb1a99 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -352,7 +352,7 @@ void cmCTestP4::SetP4Options(std::vector &CommandOptions) for(std::vector::const_iterator ai = args.begin(); ai != args.end(); ++ai) { - P4Options.push_back(ai->c_str()); + P4Options.push_back(*ai); } } diff --git a/Source/CTest/cmCTestRunScriptCommand.cxx b/Source/CTest/cmCTestRunScriptCommand.cxx index fe429bd..bdf9b9c 100644 --- a/Source/CTest/cmCTestRunScriptCommand.cxx +++ b/Source/CTest/cmCTestRunScriptCommand.cxx @@ -56,7 +56,7 @@ bool cmCTestRunScriptCommand &ret); cmOStringStream str; str << ret; - this->Makefile->AddDefinition(returnVariable.c_str(), str.str().c_str()); + this->Makefile->AddDefinition(returnVariable, str.str().c_str()); } } return true; diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 7f13855..4d419c2 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -337,8 +337,8 @@ void cmCTestScriptHandler::CreateCMake() // Set CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR. // Also, some commands need Makefile->GetCurrentDirectory(). std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - this->Makefile->SetStartDirectory(cwd.c_str()); - this->Makefile->SetStartOutputDirectory(cwd.c_str()); + this->Makefile->SetStartDirectory(cwd); + this->Makefile->SetStartOutputDirectory(cwd); // remove all cmake commands which are not scriptable, since they can't be // used in ctest scripts @@ -436,7 +436,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) for (std::map::const_iterator it = defs.begin(); it != defs.end(); ++it) { - this->Makefile->AddDefinition(it->first.c_str(), it->second.c_str()); + this->Makefile->AddDefinition(it->first, it->second.c_str()); } // finally read in the script @@ -646,7 +646,7 @@ int cmCTestScriptHandler::RunCurrentScript() if (!this->CTestEnv.empty()) { std::vector envArgs; - cmSystemTools::ExpandListArgument(this->CTestEnv.c_str(),envArgs); + cmSystemTools::ExpandListArgument(this->CTestEnv,envArgs); cmSystemTools::AppendEnv(envArgs); } @@ -772,7 +772,7 @@ int cmCTestScriptHandler::PerformExtraUpdates() ++ it ) { std::vector cvsArgs; - cmSystemTools::ExpandListArgument(it->c_str(),cvsArgs); + cmSystemTools::ExpandListArgument(*it,cvsArgs); if (cvsArgs.size() == 2) { std::string fullCommand = command; diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index 228a173..da46f4a 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -131,7 +131,7 @@ bool cmCTestStartCommand << " " << sourceDir << "\n" << "which is not an existing directory. " << "Set CTEST_CHECKOUT_COMMAND to a command line to create it."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -160,7 +160,7 @@ bool cmCTestStartCommand::InitialCheckout( { // Use a generic VC object to run and log the command. cmCTestVC vc(this->CTest, ofs); - vc.SetSourceDirectory(sourceDir.c_str()); + vc.SetSourceDirectory(sourceDir); if(!vc.InitialCheckout(initialCheckoutCommand)) { return false; diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 3173f15..bc3c333 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -339,7 +339,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod")); std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions")); std::vector args; - cmSystemTools::ExpandListArgument(curlopt.c_str(), args); + cmSystemTools::ExpandListArgument(curlopt, args); bool verifyPeerOff = false; bool verifyHostOff = false; for( std::vector::iterator i = args.begin(); @@ -461,7 +461,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, else { char md5[33]; - cmSystemTools::ComputeFileMD5(local_file.c_str(), md5); + cmSystemTools::ComputeFileMD5(local_file, md5); md5[32] = 0; upload_as += md5; } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 5970656..efeb658 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -125,7 +125,7 @@ bool cmCTestSubdirCommand { std::string m = "Could not find include file: "; m += fname; - this->SetError(m.c_str()); + this->SetError(m); return false; } } @@ -213,7 +213,7 @@ bool cmCTestAddSubdirectoryCommand { std::string m = "Could not find include file: "; m += fname; - this->SetError(m.c_str()); + this->SetError(m); return false; } return true; @@ -1506,7 +1506,7 @@ std::string cmCTestTestHandler // then try with the exe extension else { - failed.push_back(attempted[ai].c_str()); + failed.push_back(attempted[ai]); tempPath = attempted[ai]; tempPath += cmSystemTools::GetExecutableExtension(); if(cmSystemTools::FileExists(tempPath.c_str()) @@ -1517,7 +1517,7 @@ std::string cmCTestTestHandler } else { - failed.push_back(tempPath.c_str()); + failed.push_back(tempPath); } } } @@ -2154,7 +2154,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "ATTACHED_FILES" ) { std::vector lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); for(std::vector::iterator f = lval.begin(); f != lval.end(); ++f) @@ -2165,7 +2165,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "ATTACHED_FILES_ON_FAIL" ) { std::vector lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); for(std::vector::iterator f = lval.begin(); f != lval.end(); ++f) @@ -2176,7 +2176,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "RESOURCE_LOCK" ) { std::vector lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); for(std::vector::iterator f = lval.begin(); f != lval.end(); ++f) @@ -2196,7 +2196,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "REQUIRED_FILES" ) { std::vector lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); for(std::vector::iterator f = lval.begin(); f != lval.end(); ++f) @@ -2211,14 +2211,14 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "FAIL_REGULAR_EXPRESSION" ) { std::vector lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); std::vector::iterator crit; for ( crit = lval.begin(); crit != lval.end(); ++ crit ) { rtit->ErrorRegularExpressions.push_back( std::pair( cmsys::RegularExpression(crit->c_str()), - std::string(crit->c_str()))); + std::string(*crit))); } } if ( key == "PROCESSORS" ) @@ -2240,7 +2240,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "DEPENDS" ) { std::vector lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); std::vector::iterator crit; for ( crit = lval.begin(); crit != lval.end(); ++ crit ) { @@ -2250,7 +2250,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "ENVIRONMENT" ) { std::vector lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); std::vector::iterator crit; for ( crit = lval.begin(); crit != lval.end(); ++ crit ) { @@ -2260,7 +2260,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "LABELS" ) { std::vector lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); std::vector::iterator crit; for ( crit = lval.begin(); crit != lval.end(); ++ crit ) { @@ -2284,14 +2284,14 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "PASS_REGULAR_EXPRESSION" ) { std::vector lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); std::vector::iterator crit; for ( crit = lval.begin(); crit != lval.end(); ++ crit ) { rtit->RequiredRegularExpressions.push_back( std::pair( cmsys::RegularExpression(crit->c_str()), - std::string(crit->c_str()))); + std::string(*crit))); } } if ( key == "WORKING_DIRECTORY" ) diff --git a/Source/CTest/cmParseMumpsCoverage.cxx b/Source/CTest/cmParseMumpsCoverage.cxx index fe98964..6236211 100644 --- a/Source/CTest/cmParseMumpsCoverage.cxx +++ b/Source/CTest/cmParseMumpsCoverage.cxx @@ -122,7 +122,7 @@ bool cmParseMumpsCoverage::LoadPackages(const char* d) glob.RecurseOn(); std::string pat = d; pat += "/*.m"; - glob.FindFiles(pat.c_str()); + glob.FindFiles(pat); std::vector& files = glob.GetFiles(); std::vector::iterator fileIt; for ( fileIt = files.begin(); fileIt != files.end(); diff --git a/Source/CursesDialog/cmCursesLabelWidget.cxx b/Source/CursesDialog/cmCursesLabelWidget.cxx index b5ed312..b50eb64 100644 --- a/Source/CursesDialog/cmCursesLabelWidget.cxx +++ b/Source/CursesDialog/cmCursesLabelWidget.cxx @@ -19,7 +19,7 @@ cmCursesLabelWidget::cmCursesLabelWidget(int width, int height, field_opts_off(this->Field, O_EDIT); field_opts_off(this->Field, O_ACTIVE); field_opts_off(this->Field, O_STATIC); - this->SetValue(name.c_str()); + this->SetValue(name); } cmCursesLabelWidget::~cmCursesLabelWidget() diff --git a/Source/CursesDialog/cmCursesOptionsWidget.cxx b/Source/CursesDialog/cmCursesOptionsWidget.cxx index aa680fb..d76ba2a 100644 --- a/Source/CursesDialog/cmCursesOptionsWidget.cxx +++ b/Source/CursesDialog/cmCursesOptionsWidget.cxx @@ -74,7 +74,7 @@ void cmCursesOptionsWidget::NextOption() { this->CurrentOption = 0; } - this->SetValue(this->Options[this->CurrentOption].c_str()); + this->SetValue(this->Options[this->CurrentOption]); } void cmCursesOptionsWidget::PreviousOption() { @@ -86,7 +86,7 @@ void cmCursesOptionsWidget::PreviousOption() { this->CurrentOption--; } - this->SetValue(this->Options[this->CurrentOption].c_str()); + this->SetValue(this->Options[this->CurrentOption]); } void cmCursesOptionsWidget::SetOption(const std::string& value) diff --git a/Source/CursesDialog/cmCursesPathWidget.cxx b/Source/CursesDialog/cmCursesPathWidget.cxx index 893ca99..cd93bc3 100644 --- a/Source/CursesDialog/cmCursesPathWidget.cxx +++ b/Source/CursesDialog/cmCursesPathWidget.cxx @@ -59,7 +59,7 @@ void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w) } std::vector dirs; - cmSystemTools::SimpleGlob(glob.c_str(), dirs, (this->Type == cmCacheManager::PATH?-1:0)); + cmSystemTools::SimpleGlob(glob, dirs, (this->Type == cmCacheManager::PATH?-1:0)); if ( this->CurrentIndex < dirs.size() ) { cstr = dirs[this->CurrentIndex]; @@ -74,7 +74,7 @@ void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w) cstr += "/"; } - this->SetString(cstr.c_str()); + this->SetString(cstr); touchwin(w); wrefresh(w); form_driver(form, REQ_END_FIELD); diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 3de04f5..c3a9a16 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -273,7 +273,7 @@ bool cmAddCustomCommandCommand { // Lookup an existing command. if(cmSourceFile* sf = - this->Makefile->GetSourceFileWithOutput(output[0].c_str())) + this->Makefile->GetSourceFileWithOutput(output[0])) { if(cmCustomCommand* cc = sf->GetCustomCommand()) { @@ -288,7 +288,7 @@ bool cmAddCustomCommandCommand cmOStringStream e; e << "given APPEND option with output \"" << output[0].c_str() << "\" which is not already a custom command output."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -305,7 +305,7 @@ bool cmAddCustomCommandCommand { // Source is empty, use the target. std::vector no_depends; - this->Makefile->AddCustomCommandToTarget(target.c_str(), no_depends, + this->Makefile->AddCustomCommandToTarget(target, no_depends, commandLines, cctype, comment, working.c_str(), escapeOldStyle); @@ -314,7 +314,7 @@ bool cmAddCustomCommandCommand { // Target is empty, use the output. this->Makefile->AddCustomCommandToOutput(output, depends, - main_dependency.c_str(), + main_dependency, commandLines, comment, working.c_str(), false, escapeOldStyle); @@ -324,7 +324,7 @@ bool cmAddCustomCommandCommand { bool okay = false; if(cmSourceFile* sf = - this->Makefile->GetSourceFileWithOutput(output[0].c_str())) + this->Makefile->GetSourceFileWithOutput(output[0])) { if(cmCustomCommand* cc = sf->GetCustomCommand()) { @@ -337,7 +337,7 @@ bool cmAddCustomCommandCommand cmOStringStream e; e << "could not locate source file with a custom command producing \"" << output[0] << "\" even though this command tried to create it!"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -367,7 +367,7 @@ bool cmAddCustomCommandCommand { e << "The SOURCE signatures of add_custom_command are no longer " "supported."; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { return false; @@ -375,8 +375,8 @@ bool cmAddCustomCommandCommand } // Use the old-style mode for backward compatibility. - this->Makefile->AddCustomCommandOldStyle(target.c_str(), outputs, depends, - source.c_str(), commandLines, + this->Makefile->AddCustomCommandOldStyle(target, outputs, depends, + source, commandLines, comment); } @@ -397,7 +397,7 @@ cmAddCustomCommandCommand { std::string e = "attempted to have a file \"" + *o + "\" in a source directory as an output of custom command."; - this->SetError(e.c_str()); + this->SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -409,7 +409,7 @@ cmAddCustomCommandCommand cmOStringStream msg; msg << "called with OUTPUT containing a \"" << (*o)[pos] << "\". This character is not allowed."; - this->SetError(msg.str().c_str()); + this->SetError(msg.str()); return false; } } diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index ef62523..da02f00 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -34,7 +34,7 @@ bool cmAddCustomTargetCommand e << "called with invalid target name \"" << targetName << "\". Target names may not contain a slash. " << "Use ADD_CUSTOM_COMMAND to generate files."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -149,7 +149,7 @@ bool cmAddCustomTargetCommand cmOStringStream msg; msg << "called with target name containing a \"" << targetName[pos] << "\". This character is not allowed."; - this->SetError(msg.str().c_str()); + this->SetError(msg.str()); return false; } @@ -187,7 +187,7 @@ bool cmAddCustomTargetCommand "\" is reserved or not valid for certain " "CMake features, such as generator expressions, and may result " "in undefined behavior."; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { @@ -208,7 +208,7 @@ bool cmAddCustomTargetCommand std::string msg; if(!this->Makefile->EnforceUniqueName(targetName, msg, true)) { - this->SetError(msg.c_str()); + this->SetError(msg); return false; } } @@ -224,7 +224,7 @@ bool cmAddCustomTargetCommand // Add the utility target to the makefile. bool escapeOldStyle = !verbatim; cmTarget* target = - this->Makefile->AddUtilityCommand(targetName.c_str(), excludeFromAll, + this->Makefile->AddUtilityCommand(targetName, excludeFromAll, working_directory.c_str(), depends, commandLines, escapeOldStyle, comment); diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx index b55334f..e897d81 100644 --- a/Source/cmAddDependenciesCommand.cxx +++ b/Source/cmAddDependenciesCommand.cxx @@ -38,7 +38,7 @@ bool cmAddDependenciesCommand cmOStringStream e; e << "Cannot add target-level dependencies to INTERFACE library " "target \"" << target_name << "\".\n"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -46,7 +46,7 @@ bool cmAddDependenciesCommand ++s; // skip over target_name for (; s != args.end(); ++s) { - target->AddUtility(s->c_str(), this->Makefile); + target->AddUtility(*s, this->Makefile); } } else diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index 62b6667..6e48e90 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -101,7 +101,7 @@ bool cmAddExecutableCommand "\" is reserved or not valid for certain " "CMake features, such as generator expressions, and may result " "in undefined behavior."; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { @@ -132,9 +132,9 @@ bool cmAddExecutableCommand } if (isAlias) { - if(!cmGeneratorExpression::IsValidTargetName(exename.c_str())) + if(!cmGeneratorExpression::IsValidTargetName(exename)) { - this->SetError(("Invalid name for ALIAS: " + exename).c_str()); + this->SetError("Invalid name for ALIAS: " + exename); return false; } if(excludeFromAll) @@ -151,7 +151,7 @@ bool cmAddExecutableCommand { cmOStringStream e; e << "ALIAS requires exactly one target argument."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -161,7 +161,7 @@ bool cmAddExecutableCommand cmOStringStream e; e << "cannot create ALIAS target \"" << exename << "\" because target \"" << aliasedName << "\" is itself an ALIAS."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } cmTarget *aliasedTarget = @@ -172,7 +172,7 @@ bool cmAddExecutableCommand e << "cannot create ALIAS target \"" << exename << "\" because target \"" << aliasedName << "\" does not already " "exist."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } cmTarget::TargetType type = aliasedTarget->GetType(); @@ -182,7 +182,7 @@ bool cmAddExecutableCommand e << "cannot create ALIAS target \"" << exename << "\" because target \"" << aliasedName << "\" is not an " "executable."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } if(aliasedTarget->IsImported()) @@ -190,10 +190,10 @@ bool cmAddExecutableCommand cmOStringStream e; e << "cannot create ALIAS target \"" << exename << "\" because target \"" << aliasedName << "\" is IMPORTED."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } - this->Makefile->AddAlias(exename.c_str(), aliasedTarget); + this->Makefile->AddAlias(exename, aliasedTarget); return true; } @@ -206,12 +206,12 @@ bool cmAddExecutableCommand cmOStringStream e; e << "cannot create imported target \"" << exename << "\" because another target with the same name already exists."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } // Create the imported target. - this->Makefile->AddImportedTarget(exename.c_str(), cmTarget::EXECUTABLE, + this->Makefile->AddImportedTarget(exename, cmTarget::EXECUTABLE, importGlobal); return true; } @@ -221,7 +221,7 @@ bool cmAddExecutableCommand std::string msg; if(!this->Makefile->EnforceUniqueName(exename, msg)) { - this->SetError(msg.c_str()); + this->SetError(msg); return false; } } diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index 009b1ca..6159f86 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -53,7 +53,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library specified with conflicting STATIC type."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } ++s; @@ -66,7 +66,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library specified with conflicting SHARED type."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } ++s; @@ -79,7 +79,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library specified with conflicting MODULE type."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } ++s; @@ -92,7 +92,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library specified with conflicting OBJECT type."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } ++s; @@ -105,7 +105,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library specified with conflicting UNKNOWN type."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } ++s; @@ -118,7 +118,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library specified with conflicting ALIAS type."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } ++s; @@ -130,21 +130,21 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library specified with conflicting/multiple types."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } if (isAlias) { cmOStringStream e; e << "INTERFACE library specified with conflicting ALIAS type."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } if (excludeFromAll) { cmOStringStream e; e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } ++s; @@ -157,7 +157,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } ++s; @@ -177,7 +177,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "GLOBAL option may only be used with IMPORTED libraries."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } else @@ -192,14 +192,14 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library requires no source arguments."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } if (importGlobal && !importTarget) { cmOStringStream e; e << "INTERFACE library specified as GLOBAL, but not as IMPORTED."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -236,7 +236,7 @@ bool cmAddLibraryCommand "\" is reserved or not valid for certain " "CMake features, such as generator expressions, and may result " "in undefined behavior."; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { @@ -247,9 +247,9 @@ bool cmAddLibraryCommand if (isAlias) { - if(!cmGeneratorExpression::IsValidTargetName(libName.c_str())) + if(!cmGeneratorExpression::IsValidTargetName(libName)) { - this->SetError(("Invalid name for ALIAS: " + libName).c_str()); + this->SetError("Invalid name for ALIAS: " + libName); return false; } if(excludeFromAll) @@ -266,7 +266,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "ALIAS requires exactly one target argument."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -276,7 +276,7 @@ bool cmAddLibraryCommand cmOStringStream e; e << "cannot create ALIAS target \"" << libName << "\" because target \"" << aliasedName << "\" is itself an ALIAS."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } cmTarget *aliasedTarget = @@ -287,7 +287,7 @@ bool cmAddLibraryCommand e << "cannot create ALIAS target \"" << libName << "\" because target \"" << aliasedName << "\" does not already " "exist."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } cmTarget::TargetType aliasedType = aliasedTarget->GetType(); @@ -300,7 +300,7 @@ bool cmAddLibraryCommand cmOStringStream e; e << "cannot create ALIAS target \"" << libName << "\" because target \"" << aliasedName << "\" is not a library."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } if(aliasedTarget->IsImported()) @@ -308,10 +308,10 @@ bool cmAddLibraryCommand cmOStringStream e; e << "cannot create ALIAS target \"" << libName << "\" because target \"" << aliasedName << "\" is IMPORTED."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } - this->Makefile->AddAlias(libName.c_str(), aliasedTarget); + this->Makefile->AddAlias(libName, aliasedTarget); return true; } @@ -364,7 +364,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "Invalid name for IMPORTED INTERFACE library target: " << libName; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -375,12 +375,12 @@ bool cmAddLibraryCommand cmOStringStream e; e << "cannot create imported target \"" << libName << "\" because another target with the same name already exists."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } // Create the imported target. - this->Makefile->AddImportedTarget(libName.c_str(), type, importGlobal); + this->Makefile->AddImportedTarget(libName, type, importGlobal); return true; } @@ -399,7 +399,7 @@ bool cmAddLibraryCommand std::string msg; if(!this->Makefile->EnforceUniqueName(libName, msg)) { - this->SetError(msg.c_str()); + this->SetError(msg); return false; } } @@ -413,11 +413,11 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "Invalid name for INTERFACE library target: " << libName; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } - this->Makefile->AddLibrary(libName.c_str(), + this->Makefile->AddLibrary(libName, type, srclists, excludeFromAll); @@ -439,7 +439,7 @@ bool cmAddLibraryCommand ++s; } - this->Makefile->AddLibrary(libName.c_str(), type, srclists, excludeFromAll); + this->Makefile->AddLibrary(libName, type, srclists, excludeFromAll); return true; } diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index 5b1c9c6..4ea2524 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -66,7 +66,7 @@ bool cmAddSubDirectoryCommand::InitialPass std::string error = "given source \""; error += srcArg; error += "\" which is not an existing directory."; - this->SetError(error.c_str()); + this->SetError(error); return false; } srcPath = cmSystemTools::CollapseFullPath(srcPath.c_str()); @@ -87,7 +87,7 @@ bool cmAddSubDirectoryCommand::InitialPass << this->Makefile->GetCurrentDirectory() << "\". " << "When specifying an out-of-tree source a binary directory " << "must be explicitly specified."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -121,7 +121,7 @@ bool cmAddSubDirectoryCommand::InitialPass binPath = cmSystemTools::CollapseFullPath(binPath.c_str()); // Add the subdirectory using the computed full paths. - this->Makefile->AddSubDirectory(srcPath.c_str(), binPath.c_str(), + this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, false, true); return true; diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx index a9165f5..2531a1a 100644 --- a/Source/cmAddTestCommand.cxx +++ b/Source/cmAddTestCommand.cxx @@ -44,7 +44,7 @@ bool cmAddTestCommand // Create the test but add a generator only the first time it is // seen. This preserves behavior from before test generators. - cmTest* test = this->Makefile->GetTest(args[0].c_str()); + cmTest* test = this->Makefile->GetTest(args[0]); if(test) { // If the test was already added by a new-style signature do not @@ -54,13 +54,13 @@ bool cmAddTestCommand cmOStringStream e; e << " given test name \"" << args[0] << "\" which already exists in this directory."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } else { - test = this->Makefile->CreateTest(args[0].c_str()); + test = this->Makefile->CreateTest(args[0]); test->SetOldStyle(true); this->Makefile->AddTestGenerator(new cmTestGenerator(test)); } @@ -137,7 +137,7 @@ bool cmAddTestCommand::HandleNameMode(std::vector const& args) { cmOStringStream e; e << " given unknown argument:\n " << args[i] << "\n"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -157,17 +157,17 @@ bool cmAddTestCommand::HandleNameMode(std::vector const& args) } // Require a unique test name within the directory. - if(this->Makefile->GetTest(name.c_str())) + if(this->Makefile->GetTest(name)) { cmOStringStream e; e << " given test NAME \"" << name << "\" which already exists in this directory."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } // Add the test. - cmTest* test = this->Makefile->CreateTest(name.c_str()); + cmTest* test = this->Makefile->CreateTest(name); test->SetOldStyle(false); test->SetCommand(command); if(!working_directory.empty()) diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx index 01f64b7..d8c3c43 100644 --- a/Source/cmAuxSourceDirectoryCommand.cxx +++ b/Source/cmAuxSourceDirectoryCommand.cxx @@ -40,7 +40,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass } // was the list already populated - const char *def = this->Makefile->GetDefinition(args[1].c_str()); + const char *def = this->Makefile->GetDefinition(args[1]); if (def) { sourceListValue = def; @@ -72,7 +72,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass // add the file as a class file so // depends can be done cmSourceFile* sf = - this->Makefile->GetOrCreateSource(fullname.c_str()); + this->Makefile->GetOrCreateSource(fullname); sf->SetProperty("ABSTRACT","0"); if(!sourceListValue.empty()) { @@ -83,7 +83,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass } } } - this->Makefile->AddDefinition(args[1].c_str(), sourceListValue.c_str()); + this->Makefile->AddDefinition(args[1], sourceListValue.c_str()); return true; } diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx index 780ffa8..93f7801 100644 --- a/Source/cmBuildCommand.cxx +++ b/Source/cmBuildCommand.cxx @@ -80,7 +80,7 @@ bool cmBuildCommand { cmOStringStream e; e << "unknown argument \"" << args[i] << "\""; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -136,7 +136,7 @@ bool cmBuildCommand } std::string makecommand = this->Makefile->GetLocalGenerator() - ->GetGlobalGenerator()->GenerateCMakeBuildCommand("", configType.c_str(), + ->GetGlobalGenerator()->GenerateCMakeBuildCommand("", configType, "", true); if(cacheValue) diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx index e3528e1..c64209f 100644 --- a/Source/cmBuildNameCommand.cxx +++ b/Source/cmBuildNameCommand.cxx @@ -25,7 +25,7 @@ bool cmBuildNameCommand this->SetError("called with incorrect number of arguments"); return false; } - const char* cacheValue = this->Makefile->GetDefinition(args[0].c_str()); + const char* cacheValue = this->Makefile->GetDefinition(args[0]); if(cacheValue) { // do we need to correct the value? @@ -36,7 +36,7 @@ bool cmBuildNameCommand cmSystemTools::ReplaceString(cv,"/", "_"); cmSystemTools::ReplaceString(cv,"(", "_"); cmSystemTools::ReplaceString(cv,")", "_"); - this->Makefile->AddCacheDefinition(args[0].c_str(), + this->Makefile->AddCacheDefinition(args[0], cv.c_str(), "Name of build.", cmCacheManager::STRING); @@ -71,7 +71,7 @@ bool cmBuildNameCommand cmSystemTools::ReplaceString(buildname, ")", "_"); - this->Makefile->AddCacheDefinition(args[0].c_str(), + this->Makefile->AddCacheDefinition(args[0], buildname.c_str(), "Name of build.", cmCacheManager::STRING); diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx index 62f2383..5234538 100644 --- a/Source/cmCMakeHostSystemInformationCommand.cxx +++ b/Source/cmCMakeHostSystemInformationCommand.cxx @@ -53,7 +53,7 @@ bool cmCMakeHostSystemInformationCommand result_list += value; } - this->Makefile->AddDefinition(variable.c_str(), result_list.c_str()); + this->Makefile->AddDefinition(variable, result_list.c_str()); return true; } @@ -97,7 +97,7 @@ bool cmCMakeHostSystemInformationCommand else { std::string e = "does not recognize " + key; - this->SetError(e.c_str()); + this->SetError(e); return false; } diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx index 6e2ca64..ba3a832 100644 --- a/Source/cmCMakeMinimumRequired.cxx +++ b/Source/cmCMakeMinimumRequired.cxx @@ -80,7 +80,7 @@ bool cmCMakeMinimumRequired { cmOStringStream e; e << "could not parse VERSION \"" << version_string.c_str() << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -135,7 +135,7 @@ bool cmCMakeMinimumRequired::EnforceUnknownArguments() cmOStringStream e; e << "called with unknown argument \"" << this->UnknownArguments[0] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } return true; diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx index f4be559..ddd5d6a 100644 --- a/Source/cmCMakePolicyCommand.cxx +++ b/Source/cmCMakePolicyCommand.cxx @@ -58,7 +58,7 @@ bool cmCMakePolicyCommand cmOStringStream e; e << "given unknown first argument \"" << args[0] << "\""; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -84,7 +84,7 @@ bool cmCMakePolicyCommand::HandleSetMode(std::vector const& args) { cmOStringStream e; e << "SET given unrecognized policy status \"" << args[2] << "\""; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -116,7 +116,7 @@ bool cmCMakePolicyCommand::HandleGetMode(std::vector const& args) cmOStringStream e; e << "GET given policy \"" << id << "\" which is not known to this " << "version of CMake."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -126,15 +126,15 @@ bool cmCMakePolicyCommand::HandleGetMode(std::vector const& args) { case cmPolicies::OLD: // Report that the policy is set to OLD. - this->Makefile->AddDefinition(var.c_str(), "OLD"); + this->Makefile->AddDefinition(var, "OLD"); break; case cmPolicies::WARN: // Report that the policy is not set. - this->Makefile->AddDefinition(var.c_str(), ""); + this->Makefile->AddDefinition(var, ""); break; case cmPolicies::NEW: // Report that the policy is set to NEW. - this->Makefile->AddDefinition(var.c_str(), "NEW"); + this->Makefile->AddDefinition(var, "NEW"); break; case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index cb62f21..dd2a1b8 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -557,9 +557,9 @@ void CCONV *cmGetSource(void *arg, const char *name) sf->RealSourceFile = rsf; sf->FullPath = rsf->GetFullPath(); sf->SourceName = - cmSystemTools::GetFilenameWithoutLastExtension(sf->FullPath.c_str()); + cmSystemTools::GetFilenameWithoutLastExtension(sf->FullPath); sf->SourceExtension = - cmSystemTools::GetFilenameLastExtension(sf->FullPath.c_str()); + cmSystemTools::GetFilenameLastExtension(sf->FullPath); // Store the proxy in the map so it can be re-used and deleted later. cmCPluginAPISourceFileMap::value_type entry(rsf, sf); @@ -583,7 +583,7 @@ void * CCONV cmAddSource(void *arg, void *arg2) } // Create the real cmSourceFile instance and copy over saved information. - cmSourceFile* rsf = mf->GetOrCreateSource(osf->FullPath.c_str()); + cmSourceFile* rsf = mf->GetOrCreateSource(osf->FullPath); rsf->GetProperties() = osf->Properties; for(std::vector::iterator i = osf->Depends.begin(); i != osf->Depends.end(); ++i) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index ee9b664..678b497 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -649,8 +649,8 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) { std::string src_dir - = this->GetCTestConfiguration("SourceDirectory").c_str(); - std::string bld_dir = this->GetCTestConfiguration("BuildDirectory").c_str(); + = this->GetCTestConfiguration("SourceDirectory"); + std::string bld_dir = this->GetCTestConfiguration("BuildDirectory"); this->DartVersion = 1; this->DropSiteCDash = false; for(Part p = PartStart; p != PartCount; p = Part(p+1)) @@ -688,7 +688,7 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) { std::string m = "Could not find include file: "; m += fname; - command->SetError(m.c_str()); + command->SetError(m); return false; } } @@ -930,7 +930,7 @@ bool cmCTest::AddIfExists(Part part, const char* file) { std::string name = file; name += ".gz"; - if ( this->CTestFileExists(name.c_str()) ) + if ( this->CTestFileExists(name) ) { this->AddSubmitFile(part, file); } @@ -2246,7 +2246,7 @@ bool cmCTest::AddVariableDefinition(const std::string &arg) std::string value; cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED; - if (cmCacheManager::ParseEntry(arg.c_str(), name, value, type)) + if (cmCacheManager::ParseEntry(arg, name, value, type)) { this->Definitions[name] = value; return true; @@ -2611,7 +2611,7 @@ void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def, for ( it = slist.begin(); it != slist.end(); ++it ) { cmCTestLog(this, DEBUG, " -- " << it->c_str() << std::endl); - vec.push_back(it->c_str()); + vec.push_back(*it); } } diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index 6284cb7..c9490ca 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -79,7 +79,7 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key, { if (this->EscapeQuotes) { - return this->AddString(cmSystemTools::EscapeQuotes(ptr).c_str()); + return this->AddString(cmSystemTools::EscapeQuotes(ptr)); } else { @@ -94,7 +94,7 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key, { if(this->EscapeQuotes) { - return this->AddString(cmSystemTools::EscapeQuotes(c).c_str()); + return this->AddString(cmSystemTools::EscapeQuotes(c)); } else { @@ -120,7 +120,7 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) { cmOStringStream ostr; ostr << this->FileLine; - return this->AddString(ostr.str().c_str()); + return this->AddString(ostr.str()); } const char* value = this->Makefile->GetDefinition(var); if(!value && !this->RemoveEmpty) @@ -144,14 +144,14 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) bt.push_back(lfc); msg << "uninitialized variable \'" << var << "\'"; this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, - msg.str().c_str(), bt); + msg.str(), bt); } } return 0; } if (this->EscapeQuotes && value) { - return this->AddString(cmSystemTools::EscapeQuotes(value).c_str()); + return this->AddString(cmSystemTools::EscapeQuotes(value)); } return this->AddString(value ? value : ""); } @@ -181,7 +181,7 @@ char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var) std::string ref = "@"; ref += var; ref += "@"; - return this->AddString(ref.c_str()); + return this->AddString(ref); } char* cmCommandArgumentParserHelper::CombineUnions(char* in1, char* in2) diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 2d1da55..995f191 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -312,7 +312,7 @@ int cmComputeLinkDepends::AddLinkEntry(int depender_index, int index = lei->second; LinkEntry& entry = this->EntryList[index]; entry.Item = item; - entry.Target = this->FindTargetToLink(depender_index, entry.Item.c_str()); + entry.Target = this->FindTargetToLink(depender_index, entry.Item); entry.IsFlag = (!entry.Target && item[0] == '-' && item[1] != 'l' && item.substr(0, 10) != "-framework"); @@ -328,7 +328,7 @@ int cmComputeLinkDepends::AddLinkEntry(int depender_index, // Look for an old-style _LIB_DEPENDS variable. std::string var = entry.Item; var += "_LIB_DEPENDS"; - if(const char* val = this->Makefile->GetDefinition(var.c_str())) + if(const char* val = this->Makefile->GetDefinition(var)) { // The item dependencies are known. Follow them. BFSEntry qe = {index, val}; @@ -435,7 +435,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) LinkEntry& entry = this->EntryList[lei->second]; entry.Item = dep.Item; entry.Target = this->FindTargetToLink(dep.DependerIndex, - dep.Item.c_str()); + dep.Item); // This item was added specifically because it is a dependent // shared library. It may get special treatment @@ -506,7 +506,7 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index, { std::string var = *di; var += "_LINK_TYPE"; - if(const char* val = this->Makefile->GetDefinition(var.c_str())) + if(const char* val = this->Makefile->GetDefinition(var)) { if(strcmp(val, "debug") == 0) { @@ -1000,7 +1000,7 @@ void cmComputeLinkDepends::CheckWrongConfigItem(int depender_index, // directories of targets linked in another configuration as link // directories. if(cmTarget const* tgt - = this->FindTargetToLink(depender_index, item.c_str())) + = this->FindTargetToLink(depender_index, item)) { if(!tgt->IsImported()) { diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 62eaec2..ea8536f 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -293,7 +293,7 @@ cmComputeLinkInformation std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_"; loader_flag_var += this->LinkLanguage; loader_flag_var += "_FLAG"; - this->LoaderFlag = this->Makefile->GetDefinition(loader_flag_var.c_str()); + this->LoaderFlag = this->Makefile->GetDefinition(loader_flag_var); } // Get options needed to link libraries. @@ -317,8 +317,8 @@ cmComputeLinkInformation rtVar += this->LinkLanguage; rtVar += "_FLAG"; std::string rtSepVar = rtVar + "_SEP"; - this->RuntimeFlag = this->Makefile->GetSafeDefinition(rtVar.c_str()); - this->RuntimeSep = this->Makefile->GetSafeDefinition(rtSepVar.c_str()); + this->RuntimeFlag = this->Makefile->GetSafeDefinition(rtVar); + this->RuntimeSep = this->Makefile->GetSafeDefinition(rtSepVar); this->RuntimeAlways = (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); @@ -330,7 +330,7 @@ cmComputeLinkInformation rlVar += "_RPATH_LINK_"; rlVar += this->LinkLanguage; rlVar += "_FLAG"; - this->RPathLinkFlag = this->Makefile->GetSafeDefinition(rlVar.c_str()); + this->RPathLinkFlag = this->Makefile->GetSafeDefinition(rlVar); } // Check if we need to include the runtime search path at link time. @@ -338,7 +338,7 @@ cmComputeLinkInformation std::string var = "CMAKE_SHARED_LIBRARY_LINK_"; var += this->LinkLanguage; var += "_WITH_RUNTIME_PATH"; - this->LinkWithRuntimePath = this->Makefile->IsOn(var.c_str()); + this->LinkWithRuntimePath = this->Makefile->IsOn(var); } // Check the platform policy for missing soname case. @@ -505,7 +505,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target, this->Config.c_str(), + cmComputeLinkDepends cld(this->Target, this->Config, this->HeadTarget); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); @@ -593,7 +593,7 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang) std::string libVar = "CMAKE_"; libVar += lang; libVar += "_IMPLICIT_LINK_LIBRARIES"; - if(const char* libs = this->Makefile->GetDefinition(libVar.c_str())) + if(const char* libs = this->Makefile->GetDefinition(libVar)) { std::vector libsVec; cmSystemTools::ExpandListArgument(libs, libsVec); @@ -602,7 +602,7 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang) { if(this->ImplicitLinkLibs.find(*i) == this->ImplicitLinkLibs.end()) { - this->AddItem(i->c_str(), 0); + this->AddItem(*i, 0); } } } @@ -612,7 +612,7 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang) std::string dirVar = "CMAKE_"; dirVar += lang; dirVar += "_IMPLICIT_LINK_DIRECTORIES"; - if(const char* dirs = this->Makefile->GetDefinition(dirVar.c_str())) + if(const char* dirs = this->Makefile->GetDefinition(dirVar)) { std::vector dirsVec; cmSystemTools::ExpandListArgument(dirs, dirsVec); @@ -820,7 +820,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() static_link_type_flag_var += this->LinkLanguage; static_link_type_flag_var += "_FLAGS"; static_link_type_flag = - this->Makefile->GetDefinition(static_link_type_flag_var.c_str()); + this->Makefile->GetDefinition(static_link_type_flag_var); std::string shared_link_type_flag_var = "CMAKE_"; shared_link_type_flag_var += target_type_str; @@ -828,7 +828,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() shared_link_type_flag_var += this->LinkLanguage; shared_link_type_flag_var += "_FLAGS"; shared_link_type_flag = - this->Makefile->GetDefinition(shared_link_type_flag_var.c_str()); + this->Makefile->GetDefinition(shared_link_type_flag_var); } // We can support link type switching only if all needed flags are @@ -1370,7 +1370,7 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item) // Add the item using the -framework option. this->Items.push_back(Item("-framework", false)); - fw = this->LocalGenerator->EscapeForShell(fw.c_str()); + fw = this->LocalGenerator->EscapeForShell(fw); this->Items.push_back(Item(fw, false)); } @@ -1419,7 +1419,7 @@ void cmComputeLinkInformation::ComputeFrameworkInfo() implicitDirVar += this->LinkLanguage; implicitDirVar += "_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES"; if(const char* implicitDirs = - this->Makefile->GetDefinition(implicitDirVar.c_str())) + this->Makefile->GetDefinition(implicitDirVar)) { cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec); } @@ -1506,9 +1506,9 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, // Print the warning at most once for this item. std::string wid = "CMP0008-WARNING-GIVEN-"; wid += item; - if(!this->CMakeInstance->GetPropertyAsBool(wid.c_str())) + if(!this->CMakeInstance->GetPropertyAsBool(wid)) { - this->CMakeInstance->SetProperty(wid.c_str(), "1"); + this->CMakeInstance->SetProperty(wid, "1"); cmOStringStream w; w << (this->Makefile->GetPolicies() ->GetPolicyWarning(cmPolicies::CMP0008)) << "\n" @@ -1692,7 +1692,7 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo() implicitDirVar += this->LinkLanguage; implicitDirVar += "_IMPLICIT_LINK_DIRECTORIES"; if(const char* implicitDirs = - this->Makefile->GetDefinition(implicitDirVar.c_str())) + this->Makefile->GetDefinition(implicitDirVar)) { cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec); } @@ -1710,7 +1710,7 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo() implicitLibVar += this->LinkLanguage; implicitLibVar += "_IMPLICIT_LINK_LIBRARIES"; if(const char* implicitLibs = - this->Makefile->GetDefinition(implicitLibVar.c_str())) + this->Makefile->GetDefinition(implicitLibVar)) { cmSystemTools::ExpandListArgument(implicitLibs, implicitLibVec); } @@ -1978,11 +1978,11 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, { std::string useVar = "CMAKE_" + *li + "_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH"; - if(this->Makefile->IsOn(useVar.c_str())) + if(this->Makefile->IsOn(useVar)) { std::string dirVar = "CMAKE_" + *li + "_IMPLICIT_LINK_DIRECTORIES"; - if(const char* dirs = this->Makefile->GetDefinition(dirVar.c_str())) + if(const char* dirs = this->Makefile->GetDefinition(dirVar)) { cmCLI_ExpandListUnique(dirs, runtimeDirs, emitted); } diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 5c739b8..b4dbce7 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -223,8 +223,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // Don't emit the same library twice for this target. if(emitted.insert(*lib).second) { - this->AddTargetDepend(depender_index, lib->c_str(), true); - this->AddInterfaceDepends(depender_index, lib->c_str(), + this->AddTargetDepend(depender_index, *lib, true); + this->AddInterfaceDepends(depender_index, *lib, true, emitted); } } @@ -235,7 +235,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) it != configs.end(); ++it) { std::vector tlibs; - depender->GetDirectLinkLibraries(it->c_str(), tlibs, depender); + depender->GetDirectLinkLibraries(*it, tlibs, depender); // A target should not depend on itself. emitted.insert(depender->GetName()); @@ -245,8 +245,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // Don't emit the same library twice for this target. if(emitted.insert(*lib).second) { - this->AddTargetDepend(depender_index, lib->c_str(), true); - this->AddInterfaceDepends(depender_index, lib->c_str(), + this->AddTargetDepend(depender_index, *lib, true); + this->AddInterfaceDepends(depender_index, *lib, true, emitted); } } @@ -265,7 +265,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // Don't emit the same utility twice for this target. if(emitted.insert(*util).second) { - this->AddTargetDepend(depender_index, util->c_str(), false); + this->AddTargetDepend(depender_index, *util, false); } } } @@ -288,8 +288,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, // Don't emit the same library twice for this target. if(emitted.insert(*lib).second) { - this->AddTargetDepend(depender_index, lib->c_str(), true); - this->AddInterfaceDepends(depender_index, lib->c_str(), + this->AddTargetDepend(depender_index, *lib, true); + this->AddInterfaceDepends(depender_index, *lib, true, emitted); } } @@ -326,7 +326,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, // A target should not depend on itself. emitted.insert(depender->GetName()); this->AddInterfaceDepends(depender_index, dependee, - it->c_str(), emitted); + *it, emitted); } } } diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx index f8ec642..395e6c8 100644 --- a/Source/cmConfigureFileCommand.cxx +++ b/Source/cmConfigureFileCommand.cxx @@ -38,7 +38,7 @@ bool cmConfigureFileCommand e << "input location\n" << " " << this->InputFile << "\n" << "is a directory but a file was expected."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -61,14 +61,14 @@ bool cmConfigureFileCommand { std::string e = "attempted to configure a file: " + this->OutputFile + " into a source directory."; - this->SetError(e.c_str()); + this->SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } std::string errorMessage; if (!this->NewLineStyle.ReadFromArguments(args, errorMessage)) { - this->SetError(errorMessage.c_str()); + this->SetError(errorMessage); return false; } this->CopyOnly = false; diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index ab7b024..3987283 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -307,13 +307,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) std::string rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE"; std::string rulesOverrideLang = rulesOverrideBase + "_" + *li; if(const char* rulesOverridePath = - this->Makefile->GetDefinition(rulesOverrideLang.c_str())) + this->Makefile->GetDefinition(rulesOverrideLang)) { fprintf(fout, "set(%s \"%s\")\n", rulesOverrideLang.c_str(), rulesOverridePath); } else if(const char* rulesOverridePath2 = - this->Makefile->GetDefinition(rulesOverrideBase.c_str())) + this->Makefile->GetDefinition(rulesOverrideBase)) { fprintf(fout, "set(%s \"%s\")\n", rulesOverrideBase.c_str(), rulesOverridePath2); @@ -325,7 +325,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) li != testLangs.end(); ++li) { std::string langFlags = "CMAKE_" + *li + "_FLAGS"; - const char* flags = this->Makefile->GetDefinition(langFlags.c_str()); + const char* flags = this->Makefile->GetDefinition(langFlags); fprintf(fout, "set(CMAKE_%s_FLAGS %s)\n", li->c_str(), lg->EscapeForCMake(flags?flags:"").c_str()); fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}" @@ -484,7 +484,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) std::string output; // actually do the try compile now that everything is setup int res = this->Makefile->TryCompile(sourceDirectory, - this->BinaryDirectory.c_str(), + this->BinaryDirectory, projectName, targetName, this->SrcFileSignature, @@ -496,14 +496,14 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) } // set the result var to the return value to indicate success or failure - this->Makefile->AddCacheDefinition(argv[0].c_str(), + this->Makefile->AddCacheDefinition(argv[0], (res == 0 ? "TRUE" : "FALSE"), "Result of TRY_COMPILE", cmCacheManager::INTERNAL); if ( outputVariable.size() > 0 ) { - this->Makefile->AddDefinition(outputVariable.c_str(), output.c_str()); + this->Makefile->AddDefinition(outputVariable, output.c_str()); } if (this->SrcFileSignature) @@ -540,7 +540,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) if(!copyFileError.empty()) { - this->Makefile->AddDefinition(copyFileError.c_str(), + this->Makefile->AddDefinition(copyFileError, copyFileErrorMessage.c_str()); } } diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx index de20cb7..02fb8cb 100644 --- a/Source/cmCreateTestSourceList.cxx +++ b/Source/cmCreateTestSourceList.cxx @@ -169,13 +169,13 @@ bool cmCreateTestSourceList // Construct the source list. std::string sourceListValue; { - cmSourceFile* sf = this->Makefile->GetOrCreateSource(driver.c_str()); + cmSourceFile* sf = this->Makefile->GetOrCreateSource(driver); sf->SetProperty("ABSTRACT","0"); sourceListValue = args[1]; } for(i = testsBegin; i != tests.end(); ++i) { - cmSourceFile* sf = this->Makefile->GetOrCreateSource(i->c_str()); + cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i); sf->SetProperty("ABSTRACT","0"); sourceListValue += ";"; sourceListValue += *i; diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index d8a756d..b9cf777 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -63,11 +63,11 @@ cmCustomCommandGenerator cmd += " "; if(this->OldStyle) { - cmd += this->LG->EscapeForShellOldStyle(arg.c_str()); + cmd += this->LG->EscapeForShellOldStyle(arg); } else { - cmd += this->LG->EscapeForShell(arg.c_str(), this->MakeVars); + cmd += this->LG->EscapeForShell(arg, this->MakeVars); } } } diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx index 1ad98af..6b729de 100644 --- a/Source/cmDefinePropertyCommand.cxx +++ b/Source/cmDefinePropertyCommand.cxx @@ -58,7 +58,7 @@ bool cmDefinePropertyCommand << "Valid scopes are " << "GLOBAL, DIRECTORY, TARGET, SOURCE, " << "TEST, VARIABLE, CACHED_VARIABLE."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -102,7 +102,7 @@ bool cmDefinePropertyCommand { cmOStringStream e; e << "given invalid argument \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -128,7 +128,7 @@ bool cmDefinePropertyCommand // Actually define the property. this->Makefile->GetCMakeInstance()->DefineProperty - (this->PropertyName.c_str(), scope, + (this->PropertyName, scope, this->BriefDocs.c_str(), this->FullDocs.c_str(), inherited); return true; diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index 51150f2..50a395e 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -47,7 +47,7 @@ bool cmDepends::Write(std::ostream &makeDepends, std::string srcLang = "CMAKE_DEPENDS_CHECK_"; srcLang += this->Language; cmMakefile* mf = this->LocalGenerator->GetMakefile(); - const char* srcStr = mf->GetSafeDefinition(srcLang.c_str()); + const char* srcStr = mf->GetSafeDefinition(srcLang); std::vector pairs; cmSystemTools::ExpandListArgument(srcStr, pairs); @@ -61,7 +61,7 @@ bool cmDepends::Write(std::ostream &makeDepends, std::string obj = *si++; // Make sure the object file is relative to the top of the build tree. - obj = this->LocalGenerator->Convert(obj.c_str(), + obj = this->LocalGenerator->Convert(obj, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE); dependencies[obj].insert(src); @@ -305,7 +305,7 @@ void cmDepends::SetIncludePathFromLanguage(const std::string& lang) includePathVar += lang; includePathVar += "_TARGET_INCLUDE_PATH"; cmMakefile* mf = this->LocalGenerator->GetMakefile(); - includePath = mf->GetDefinition(includePathVar.c_str()); + includePath = mf->GetDefinition(includePathVar); if(includePath) { cmSystemTools::ExpandListArgument(includePath, this->IncludePath); @@ -316,7 +316,7 @@ void cmDepends::SetIncludePathFromLanguage(const std::string& lang) includePathVar = "CMAKE_"; includePathVar += lang; includePathVar += "_INCLUDE_PATH"; - includePath = mf->GetDefinition(includePathVar.c_str()); + includePath = mf->GetDefinition(includePathVar); if(includePath) { cmSystemTools::ExpandListArgument(includePath, this->IncludePath); diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 57a66da..56ef6e2 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -54,14 +54,14 @@ cmDependsC::cmDependsC(cmLocalGenerator* lg, std::string scanRegexVar = "CMAKE_"; scanRegexVar += lang; scanRegexVar += "_INCLUDE_REGEX_SCAN"; - if(const char* sr = mf->GetDefinition(scanRegexVar.c_str())) + if(const char* sr = mf->GetDefinition(scanRegexVar)) { scanRegex = sr; } std::string complainRegexVar = "CMAKE_"; complainRegexVar += lang; complainRegexVar += "_INCLUDE_REGEX_COMPLAIN"; - if(const char* cr = mf->GetDefinition(complainRegexVar.c_str())) + if(const char* cr = mf->GetDefinition(complainRegexVar)) { complainRegex = cr; } @@ -274,7 +274,7 @@ bool cmDependsC::WriteDependencies(const std::set& sources, i != dependencies.end(); ++i) { makeDepends << obj << ": " << - this->LocalGenerator->Convert(i->c_str(), + this->LocalGenerator->Convert(*i, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE) << std::endl; diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index b3fbaa2..1d91b4a 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -292,15 +292,15 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, stamp += ".mod.stamp"; fcStream << "\n"; fcStream << " \"" << - this->LocalGenerator->Convert(mod_lower.c_str(), + this->LocalGenerator->Convert(mod_lower, cmLocalGenerator::START_OUTPUT) << "\"\n"; fcStream << " \"" << - this->LocalGenerator->Convert(mod_upper.c_str(), + this->LocalGenerator->Convert(mod_upper, cmLocalGenerator::START_OUTPUT) << "\"\n"; fcStream << " \"" << - this->LocalGenerator->Convert(stamp.c_str(), + this->LocalGenerator->Convert(stamp, cmLocalGenerator::START_OUTPUT) << "\"\n"; } @@ -449,7 +449,7 @@ cmDependsFortran i != info.Includes.end(); ++i) { makeDepends << obj << ": " << - this->LocalGenerator->Convert(i->c_str(), + this->LocalGenerator->Convert(*i, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE) << std::endl; @@ -480,7 +480,7 @@ cmDependsFortran proxy += "/"; proxy += *i; proxy += ".mod.proxy"; - proxy = this->LocalGenerator->Convert(proxy.c_str(), + proxy = this->LocalGenerator->Convert(proxy, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE); @@ -497,7 +497,7 @@ cmDependsFortran { // This module is known. Depend on its timestamp file. std::string stampFile = - this->LocalGenerator->Convert(required->second.c_str(), + this->LocalGenerator->Convert(required->second, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE); makeDepends << obj << ": " << stampFile << "\n"; @@ -510,7 +510,7 @@ cmDependsFortran if(this->FindModule(*i, module)) { module = - this->LocalGenerator->Convert(module.c_str(), + this->LocalGenerator->Convert(module, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE); makeDepends << obj << ": " << module << "\n"; @@ -526,7 +526,7 @@ cmDependsFortran proxy += "/"; proxy += *i; proxy += ".mod.proxy"; - proxy = this->LocalGenerator->Convert(proxy.c_str(), + proxy = this->LocalGenerator->Convert(proxy, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE); makeDepends << proxy << ": " << obj << ".provides" << std::endl; @@ -552,7 +552,7 @@ cmDependsFortran modFile += "/"; modFile += *i; modFile = - this->LocalGenerator->Convert(modFile.c_str(), + this->LocalGenerator->Convert(modFile, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::SHELL); std::string stampFile = stamp_dir; @@ -560,7 +560,7 @@ cmDependsFortran stampFile += m; stampFile += ".mod.stamp"; stampFile = - this->LocalGenerator->Convert(stampFile.c_str(), + this->LocalGenerator->Convert(stampFile, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::SHELL); makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod " @@ -582,7 +582,7 @@ cmDependsFortran // the target finishes building. std::string driver = this->TargetDirectory; driver += "/build"; - driver = this->LocalGenerator->Convert(driver.c_str(), + driver = this->LocalGenerator->Convert(driver, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE); makeDepends << driver << ": " << obj << ".provides.build\n"; diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 96b5f04..a4bc83d 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -672,7 +672,7 @@ bool cmDocumentation::PrintFiles(std::ostream& os, for (std::vector::const_iterator i = files.begin(); i != files.end(); ++i) { - found = r.ProcessFile(i->c_str()) || found; + found = r.ProcessFile(*i) || found; } return found; } diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx index 6c11345..9b59088 100644 --- a/Source/cmExecProgramCommand.cxx +++ b/Source/cmExecProgramCommand.cxx @@ -132,14 +132,14 @@ bool cmExecProgramCommand } std::string coutput = std::string(output, first, last-first+1); - this->Makefile->AddDefinition(output_variable.c_str(), coutput.c_str()); + this->Makefile->AddDefinition(output_variable, coutput.c_str()); } if ( return_variable.size() > 0 ) { char buffer[100]; sprintf(buffer, "%d", retVal); - this->Makefile->AddDefinition(return_variable.c_str(), buffer); + this->Makefile->AddDefinition(return_variable, buffer); } return true; diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index 994c170..40f70b8 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -191,7 +191,7 @@ bool cmExecuteProcessCommand { cmOStringStream e; e << " given unknown argument \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -200,7 +200,7 @@ bool cmExecuteProcessCommand { std::string e = "attempted to output into a file: " + output_file + " into a source directory."; - this->SetError(e.c_str()); + this->SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -326,12 +326,12 @@ bool cmExecuteProcessCommand // Store the output obtained. if(!output_variable.empty() && tempOutput.size()) { - this->Makefile->AddDefinition(output_variable.c_str(), + this->Makefile->AddDefinition(output_variable, &*tempOutput.begin()); } if(!merge_output && !error_variable.empty() && tempError.size()) { - this->Makefile->AddDefinition(error_variable.c_str(), + this->Makefile->AddDefinition(error_variable, &*tempError.begin()); } @@ -345,19 +345,19 @@ bool cmExecuteProcessCommand int v = cmsysProcess_GetExitValue(cp); char buf[100]; sprintf(buf, "%d", v); - this->Makefile->AddDefinition(result_variable.c_str(), buf); + this->Makefile->AddDefinition(result_variable, buf); } break; case cmsysProcess_State_Exception: - this->Makefile->AddDefinition(result_variable.c_str(), + this->Makefile->AddDefinition(result_variable, cmsysProcess_GetExceptionString(cp)); break; case cmsysProcess_State_Error: - this->Makefile->AddDefinition(result_variable.c_str(), + this->Makefile->AddDefinition(result_variable, cmsysProcess_GetErrorString(cp)); break; case cmsysProcess_State_Expired: - this->Makefile->AddDefinition(result_variable.c_str(), + this->Makefile->AddDefinition(result_variable, "Process terminated due to timeout"); break; } diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index f991f45..e79206d 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -47,7 +47,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) cmOStringStream e; e << "given target \"" << te->GetName() << "\" more than once."; this->Makefile->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), this->Backtrace); + ->IssueMessage(cmake::FATAL_ERROR, e.str(), this->Backtrace); return false; } if (te->GetType() == cmTarget::INTERFACE_LIBRARY) @@ -106,7 +106,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) ci = this->Configurations.begin(); ci != this->Configurations.end(); ++ci) { - this->GenerateImportConfig(os, ci->c_str(), missingTargets); + this->GenerateImportConfig(os, *ci, missingTargets); } this->GenerateMissingTargetsCheckCode(os, missingTargets); @@ -315,7 +315,7 @@ cmExportBuildFileGenerator << "consider using the APPEND option with multiple separate calls."; this->Makefile->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), this->Backtrace); + ->IssueMessage(cmake::FATAL_ERROR, e.str(), this->Backtrace); } std::string @@ -328,7 +328,7 @@ cmExportBuildFileGenerator::InstallNameDir(cmTarget* target, if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = - target->GetInstallNameDirForBuildTree(config.c_str()); + target->GetInstallNameDirForBuildTree(config); } return install_name_dir; diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index bda8dda..dcb77ba 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -92,7 +92,7 @@ bool cmExportCommand cmOStringStream e; e << "FILE option given filename \"" << this->Filename.GetString() << "\" which does not have an extension of \".cmake\".\n"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } fname = this->Filename.GetString(); @@ -106,7 +106,7 @@ bool cmExportCommand cmOStringStream e; e << "FILE option given filename \"" << fname << "\" which is in the source tree.\n"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -128,7 +128,7 @@ bool cmExportCommand { cmOStringStream e; e << "EXPORT signature does not recognise the APPEND option."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -137,7 +137,7 @@ bool cmExportCommand cmOStringStream e; e << "EXPORT signature does not recognise the " "EXPORT_LINK_INTERFACE_LIBRARIES option."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -147,7 +147,7 @@ bool cmExportCommand { cmOStringStream e; e << "Export set \"" << setName << "\" not found."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } this->ExportSet = setMap[setName]; @@ -164,18 +164,18 @@ bool cmExportCommand cmOStringStream e; e << "given ALIAS target \"" << *currentTarget << "\" which may not be exported."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } - if(cmTarget* target = gg->FindTarget(currentTarget->c_str())) + if(cmTarget* target = gg->FindTarget(*currentTarget)) { if(target->GetType() == cmTarget::OBJECT_LIBRARY) { cmOStringStream e; e << "given OBJECT library \"" << *currentTarget << "\" which may not be exported."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -184,7 +184,7 @@ bool cmExportCommand cmOStringStream e; e << "given target \"" << *currentTarget << "\" which is not built by this project."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } targets.push_back(*currentTarget); @@ -229,7 +229,7 @@ bool cmExportCommand ci = configurationTypes.begin(); ci != configurationTypes.end(); ++ci) { - ebfg->AddConfiguration(ci->c_str()); + ebfg->AddConfiguration(*ci); } } else @@ -266,7 +266,7 @@ bool cmExportCommand::HandlePackage(std::vector const& args) { cmOStringStream e; e << "PACKAGE given unknown argument: " << args[i]; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -284,7 +284,7 @@ bool cmExportCommand::HandlePackage(std::vector const& args) cmOStringStream e; e << "PACKAGE given invalid package name \"" << package << "\". " << "Package names must match \"" << packageExpr << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 3c3c6df..b38c48b 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -275,7 +275,7 @@ static bool checkInterfaceDirs(const std::string &prepro, e << "Target \"" << target->GetName() << "\" " "INTERFACE_INCLUDE_DIRECTORIES property contains relative path:\n" " \"" << *li << "\""; - target->GetMakefile()->IssueMessage(messageType, e.str().c_str()); + target->GetMakefile()->IssueMessage(messageType, e.str()); } if (isSubDirectory(li->c_str(), installDir)) { @@ -286,7 +286,7 @@ static bool checkInterfaceDirs(const std::string &prepro, e << "Target \"" << target->GetName() << "\" " "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n" " \"" << *li << "\"\nwhich is prefixed in the build directory."; - target->GetMakefile()->IssueMessage(messageType, e.str().c_str()); + target->GetMakefile()->IssueMessage(messageType, e.str()); } if (!inSourceBuild) { @@ -295,7 +295,7 @@ static bool checkInterfaceDirs(const std::string &prepro, e << "Target \"" << target->GetName() << "\" " "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n" " \"" << *li << "\"\nwhich is prefixed in the source directory."; - target->GetMakefile()->IssueMessage(messageType, e.str().c_str()); + target->GetMakefile()->IssueMessage(messageType, e.str()); } } } @@ -498,14 +498,14 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( for (std::vector::const_iterator ci = configNames.begin(); ci != configNames.end(); ++ci) { - getCompatibleInterfaceProperties(target, ifaceProperties, ci->c_str()); + getCompatibleInterfaceProperties(target, ifaceProperties, *ci); } } for (std::set::const_iterator it = ifaceProperties.begin(); it != ifaceProperties.end(); ++it) { - this->PopulateInterfaceProperty(("INTERFACE_" + *it).c_str(), + this->PopulateInterfaceProperty("INTERFACE_" + *it, target, properties); } } @@ -712,7 +712,7 @@ cmExportFileGenerator const char *propContent; if (const char *prop_suffixed = target->GetProperty( - ("LINK_INTERFACE_LIBRARIES" + suffix).c_str())) + "LINK_INTERFACE_LIBRARIES" + suffix)) { propContent = prop_suffixed; } diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 5e7d5e4..3dc1f6c 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -211,7 +211,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) ci = this->Configurations.begin(); ci != this->Configurations.end(); ++ci) { - if(!this->GenerateImportFileConfig(ci->c_str(), missingTargets)) + if(!this->GenerateImportFileConfig(*ci, missingTargets)) { result = false; } diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index b04b937..688d2eb 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -138,7 +138,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const break; } std::string lib = li->first; - if(cmTarget* libtgt = global->FindTarget(lib.c_str())) + if(cmTarget* libtgt = global->FindTarget(lib)) { // Handle simple output name changes. This command is // deprecated so we do not support full target name diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index fe8c8ec..3350d7c 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -102,7 +102,7 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, { const std::string libs = i->second.GetValue(); - std::string evalResult = this->FindTargets(i->first.c_str(), + std::string evalResult = this->FindTargets(i->first, target, emitted); std::vector depends; @@ -129,7 +129,7 @@ cmExportTryCompileFileGenerator::InstallNameDir(cmTarget* target, if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = - target->GetInstallNameDirForBuildTree(config.c_str()); + target->GetInstallNameDirForBuildTree(config); } return install_name_dir; diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx index d89a1c8..9264671 100644 --- a/Source/cmExternalMakefileProjectGenerator.cxx +++ b/Source/cmExternalMakefileProjectGenerator.cxx @@ -60,7 +60,7 @@ std::string cmExternalMakefileProjectGenerator::GetGlobalGeneratorName( it != this->SupportedGlobalGenerators.end(); ++it) { - if (this->CreateFullGeneratorName(it->c_str(), this->GetName()) + if (this->CreateFullGeneratorName(*it, this->GetName()) == currentName) { return *it; diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 03f59c4..edb9c38 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -334,7 +334,7 @@ void cmExtraCodeBlocksGenerator if (strcmp(makefile->GetStartOutputDirectory(), makefile->GetHomeOutputDirectory())==0) { - this->AppendTarget(fout, ti->first.c_str(), 0, + this->AppendTarget(fout, ti->first, 0, make.c_str(), makefile, compiler.c_str()); } } @@ -350,7 +350,7 @@ void cmExtraCodeBlocksGenerator break; } - this->AppendTarget(fout, ti->first.c_str(), 0, + this->AppendTarget(fout, ti->first, 0, make.c_str(), makefile, compiler.c_str()); break; case cmTarget::EXECUTABLE: @@ -359,11 +359,11 @@ void cmExtraCodeBlocksGenerator case cmTarget::MODULE_LIBRARY: case cmTarget::OBJECT_LIBRARY: { - this->AppendTarget(fout, ti->first.c_str(), &ti->second, + this->AppendTarget(fout, ti->first, &ti->second, make.c_str(), makefile, compiler.c_str()); std::string fastTarget = ti->first; fastTarget += "/fast"; - this->AppendTarget(fout, fastTarget.c_str(), &ti->second, + this->AppendTarget(fout, fastTarget, &ti->second, make.c_str(), makefile, compiler.c_str()); } break; @@ -626,7 +626,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, if (!systemIncludeDirs.empty()) { std::vector dirs; - cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs); + cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs); for(std::vector::const_iterator dirIt=dirs.begin(); dirIt != dirs.end(); ++dirIt) @@ -640,7 +640,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, if (!systemIncludeDirs.empty()) { std::vector dirs; - cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs); + cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs); for(std::vector::const_iterator dirIt=dirs.begin(); dirIt != dirs.end(); ++dirIt) @@ -697,7 +697,7 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf) std::string hostSystemName = mf->GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME"); std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME"); - std::string compilerId = mf->GetSafeDefinition(compilerIdVar.c_str()); + std::string compilerId = mf->GetSafeDefinition(compilerIdVar); std::string compiler = "gcc"; // default to gcc if (compilerId == "MSVC") { diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 5a9e125..da397b1 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -404,7 +404,7 @@ cmExtraCodeLiteGenerator::GetCodeLiteCompilerName(const cmMakefile* mf) const compilerIdVar = "CMAKE_C_COMPILER_ID"; } - std::string compilerId = mf->GetSafeDefinition(compilerIdVar.c_str()); + std::string compilerId = mf->GetSafeDefinition(compilerIdVar); std::string compiler = "gnu g++"; // default to g++ // Since we need the compiler for parsing purposes only diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 4aabc7e..d02e54d 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -205,7 +205,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, std::string cacheEntryName = "CMAKE_ECLIPSE_ENVVAR_"; cacheEntryName += envVar; const char* cacheValue = mf->GetCacheManager()->GetCacheValue( - cacheEntryName.c_str()); + cacheEntryName); // now we have both, decide which one to use std::string valueToUse; @@ -219,7 +219,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, // The variable is in the env, but not in the cache. Use it and put it // in the cache valueToUse = envVarValue; - mf->AddCacheDefinition(cacheEntryName.c_str(), valueToUse.c_str(), + mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), cacheEntryName.c_str(), cmCacheManager::STRING, true); mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory()); @@ -240,7 +240,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, if (valueToUse.find(envVarValue) == std::string::npos) { valueToUse = envVarValue; - mf->AddCacheDefinition(cacheEntryName.c_str(), valueToUse.c_str(), + mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), cacheEntryName.c_str(), cmCacheManager::STRING, true); mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory()); @@ -981,7 +981,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const std::string systemIncludeDirs = mf->GetSafeDefinition( "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS"); std::vector dirs; - cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs); + cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs); this->AppendIncludeDirectories(fout, dirs, emmited); } compiler = mf->GetSafeDefinition("CMAKE_CXX_COMPILER"); @@ -990,7 +990,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const std::string systemIncludeDirs = mf->GetSafeDefinition( "CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS"); std::vector dirs; - cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs); + cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs); this->AppendIncludeDirectories(fout, dirs, emmited); } diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index f973a84..ec5ffc2 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -177,7 +177,7 @@ void cmExtraSublimeTextGenerator:: if (strcmp(makefile->GetStartOutputDirectory(), makefile->GetHomeOutputDirectory())==0) { - this->AppendTarget(fout, ti->first.c_str(), *lg, 0, + this->AppendTarget(fout, ti->first, *lg, 0, make.c_str(), makefile, compiler.c_str(), sourceFileFlags, false); } @@ -194,7 +194,7 @@ void cmExtraSublimeTextGenerator:: break; } - this->AppendTarget(fout, ti->first.c_str(), *lg, 0, + this->AppendTarget(fout, ti->first, *lg, 0, make.c_str(), makefile, compiler.c_str(), sourceFileFlags, false); break; @@ -204,12 +204,12 @@ void cmExtraSublimeTextGenerator:: case cmTarget::MODULE_LIBRARY: case cmTarget::OBJECT_LIBRARY: { - this->AppendTarget(fout, ti->first.c_str(), *lg, &ti->second, + this->AppendTarget(fout, ti->first, *lg, &ti->second, make.c_str(), makefile, compiler.c_str(), sourceFileFlags, false); std::string fastTarget = ti->first; fastTarget += "/fast"; - this->AppendTarget(fout, fastTarget.c_str(), *lg, &ti->second, + this->AppendTarget(fout, fastTarget, *lg, &ti->second, make.c_str(), makefile, compiler.c_str(), sourceFileFlags, false); } @@ -440,7 +440,7 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target, { std::string defPropName = "COMPILE_DEFINITIONS_"; defPropName += cmSystemTools::UpperCase(config); - lg->AppendDefines(defines, source->GetProperty(defPropName.c_str())); + lg->AppendDefines(defines, source->GetProperty(defPropName)); } std::string definesString; diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index dd99c43..0a36b82 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -48,7 +48,7 @@ bool cmFLTKWrapUICommand for(std::vector::iterator i = (newArgs.begin() + 1); i != newArgs.end(); i++) { - cmSourceFile *curr = this->Makefile->GetSource(i->c_str()); + cmSourceFile *curr = this->Makefile->GetSource(*i); // if we should use the source GUI // to generate .cxx and .h files if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE")) @@ -81,16 +81,16 @@ bool cmFLTKWrapUICommand std::string no_main_dependency = ""; const char* no_comment = 0; const char* no_working_dir = 0; - this->Makefile->AddCustomCommandToOutput(cxxres.c_str(), + this->Makefile->AddCustomCommandToOutput(cxxres, depends, no_main_dependency, commandLines, no_comment, no_working_dir); - this->Makefile->AddCustomCommandToOutput(hname.c_str(), + this->Makefile->AddCustomCommandToOutput(hname, depends, no_main_dependency, commandLines, no_comment, no_working_dir); - cmSourceFile *sf = this->Makefile->GetSource(cxxres.c_str()); + cmSourceFile *sf = this->Makefile->GetSource(cxxres); sf->AddDepend(hname.c_str()); sf->AddDepend(origname.c_str()); this->GeneratedSourcesClasses.push_back(sf); @@ -110,7 +110,7 @@ bool cmFLTKWrapUICommand } std::string varName = this->Target; varName += "_FLTK_UI_SRCS"; - this->Makefile->AddDefinition(varName.c_str(), sourceListValue.c_str()); + this->Makefile->AddDefinition(varName, sourceListValue.c_str()); return true; } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index e79bc6c..9fabdc7 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -174,7 +174,7 @@ bool cmFileCommand } std::string e = "does not recognize sub-command "+subCommand; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -205,7 +205,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector const& args, std::string e = "attempted to write a file: " + fileName + " into a source directory."; - this->SetError(e.c_str()); + this->SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -235,7 +235,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector const& args, std::string error = "Internal CMake error when trying to open file: "; error += fileName.c_str(); error += " for writing."; - this->SetError(error.c_str()); + this->SetError(error); return false; } file << message; @@ -295,7 +295,7 @@ bool cmFileCommand::HandleReadCommand(std::vector const& args) std::string error = "Internal CMake error when trying to open file: "; error += fileName.c_str(); error += " for reading."; - this->SetError(error.c_str()); + this->SetError(error); return false; } @@ -359,7 +359,7 @@ bool cmFileCommand::HandleReadCommand(std::vector const& args) } } } - this->Makefile->AddDefinition(variable.c_str(), output.c_str()); + this->Makefile->AddDefinition(variable, output.c_str()); return true; } @@ -371,23 +371,23 @@ bool cmFileCommand::HandleHashCommand(std::vector const& args) { cmOStringStream e; e << args[0] << " requires a file name and output variable"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } cmsys::auto_ptr hash(cmCryptoHash::New(args[0].c_str())); if(hash.get()) { - std::string out = hash->HashFile(args[1].c_str()); + std::string out = hash->HashFile(args[1]); if(!out.empty()) { - this->Makefile->AddDefinition(args[2].c_str(), out.c_str()); + this->Makefile->AddDefinition(args[2], out.c_str()); return true; } cmOStringStream e; e << args[0] << " failed to read file \"" << args[1] << "\": " << cmSystemTools::GetLastSystemError(); - this->SetError(e.str().c_str()); + this->SetError(e.str()); } return false; #else @@ -481,7 +481,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) cmOStringStream e; e << "STRINGS option LIMIT_INPUT value \"" << args[i] << "\" is not an unsigned integer."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } arg_mode = arg_none; @@ -494,7 +494,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) cmOStringStream e; e << "STRINGS option LIMIT_OUTPUT value \"" << args[i] << "\" is not an unsigned integer."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } arg_mode = arg_none; @@ -507,7 +507,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) cmOStringStream e; e << "STRINGS option LIMIT_COUNT value \"" << args[i] << "\" is not an unsigned integer."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } limit_count = count; @@ -521,7 +521,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) cmOStringStream e; e << "STRINGS option LENGTH_MINIMUM value \"" << args[i] << "\" is not an unsigned integer."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } minlen = len; @@ -535,7 +535,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) cmOStringStream e; e << "STRINGS option LENGTH_MAXIMUM value \"" << args[i] << "\" is not an unsigned integer."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } maxlen = len; @@ -548,7 +548,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) cmOStringStream e; e << "STRINGS option REGEX value \"" << args[i] << "\" could not be compiled."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } have_regex = true; @@ -559,7 +559,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) cmOStringStream e; e << "STRINGS given unknown argument \"" << args[i] << "\""; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -586,7 +586,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) { cmOStringStream e; e << "STRINGS file \"" << fileName << "\" cannot be read."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -709,7 +709,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) } // Save the output in a makefile variable. - this->Makefile->AddDefinition(outVar.c_str(), output.c_str()); + this->Makefile->AddDefinition(outVar, output.c_str()); return true; } @@ -844,7 +844,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, } } - this->Makefile->AddDefinition(variable.c_str(), output.c_str()); + this->Makefile->AddDefinition(variable, output.c_str()); return true; } @@ -873,14 +873,14 @@ bool cmFileCommand::HandleMakeDirectoryCommand( { std::string e = "attempted to create a directory: " + *cdir + " into a source directory."; - this->SetError(e.c_str()); + this->SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } if ( !cmSystemTools::MakeDirectory(cdir->c_str()) ) { std::string error = "problem creating directory: " + *cdir; - this->SetError(error.c_str()); + this->SetError(error); return false; } } @@ -926,7 +926,7 @@ cmFileCommand::HandleDifferentCommand(std::vector const& args) { cmOStringStream e; e << "DIFFERENT given unknown argument " << args[i]; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -1041,7 +1041,7 @@ protected: { cmOStringStream e; e << this->Name << " cannot set permissions on \"" << toFile << "\""; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } return true; @@ -1065,7 +1065,7 @@ protected: { cmOStringStream e; e << this->Name << " given invalid permission \"" << arg << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } return true; @@ -1092,7 +1092,7 @@ protected: // The input file does not exist and installation is not optional. cmOStringStream e; e << this->Name << " cannot find \"" << fromFile << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } @@ -1125,14 +1125,14 @@ protected: { cmOStringStream e; e << "option " << arg << " may not appear before PATTERN or REGEX."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); this->Doing = DoingError; } void NotAfterMatch(std::string const& arg) { cmOStringStream e; e << "option " << arg << " may not appear after PATTERN or REGEX."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); this->Doing = DoingError; } virtual void DefaultFilePermissions() @@ -1170,7 +1170,7 @@ bool cmFileCopier::Parse(std::vector const& args) { cmOStringStream e; e << "called with unknown argument \"" << args[i] << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } @@ -1186,7 +1186,7 @@ bool cmFileCopier::Parse(std::vector const& args) { cmOStringStream e; e << this->Name << " given no DESTINATION"; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } @@ -1366,7 +1366,7 @@ bool cmFileCopier::CheckValue(std::string const& arg) { cmOStringStream e; e << "could not compile PATTERN \"" << arg << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); this->Doing = DoingError; } } @@ -1382,7 +1382,7 @@ bool cmFileCopier::CheckValue(std::string const& arg) { cmOStringStream e; e << "could not compile REGEX \"" << arg << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); this->Doing = DoingError; } break; @@ -1462,7 +1462,7 @@ bool cmFileCopier::Install(const char* fromFile, const char* toFile) { cmOStringStream e; e << "INSTALL encountered an empty string input file name."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } @@ -1504,7 +1504,7 @@ bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile) cmOStringStream e; e << this->Name << " cannot read symlink \"" << fromFile << "\" to duplicate at \"" << toFile << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } @@ -1537,7 +1537,7 @@ bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile) cmOStringStream e; e << this->Name << " cannot duplicate symlink \"" << fromFile << "\" at \"" << toFile << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } } @@ -1569,7 +1569,7 @@ bool cmFileCopier::InstallFile(const char* fromFile, const char* toFile, cmOStringStream e; e << this->Name << " cannot copy file \"" << fromFile << "\" to \"" << toFile << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } @@ -1588,7 +1588,7 @@ bool cmFileCopier::InstallFile(const char* fromFile, const char* toFile, cmOStringStream e; e << this->Name << " cannot set modification time on \"" << toFile << "\""; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } } @@ -1619,7 +1619,7 @@ bool cmFileCopier::InstallDirectory(const char* source, cmOStringStream e; e << this->Name << " cannot make directory \"" << destination << "\": " << cmSystemTools::GetLastSystemError(); - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } @@ -1910,7 +1910,7 @@ bool cmFileInstaller::CheckKeyword(std::string const& arg) e << "INSTALL called with old-style " << arg << " argument. " << "This script was generated with an older version of CMake. " << "Re-run this cmake version on your build tree."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); this->Doing = DoingError; } else @@ -1976,7 +1976,7 @@ bool cmFileInstaller { cmOStringStream e; e << "Option TYPE given unknown value \"" << stype << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } return true; @@ -2047,7 +2047,7 @@ bool cmFileInstaller::HandleInstallDestination() "absolute path or remove DESTDIR environment variable." "\nDESTINATION=\n"; message += destination; - this->FileCommand->SetError(message.c_str()); + this->FileCommand->SetError(message); return false; } } @@ -2061,7 +2061,7 @@ bool cmFileInstaller::HandleInstallDestination() { std::string errstring = "cannot create directory: " + destination + ". Maybe need administrative privileges."; - this->FileCommand->SetError(errstring.c_str()); + this->FileCommand->SetError(errstring); return false; } } @@ -2069,7 +2069,7 @@ bool cmFileInstaller::HandleInstallDestination() { std::string errstring = "INSTALL destination: " + destination + " is not a directory."; - this->FileCommand->SetError(errstring.c_str()); + this->FileCommand->SetError(errstring); return false; } return true; @@ -2118,7 +2118,7 @@ cmFileCommand::HandleRPathChangeCommand(std::vector const& args) { cmOStringStream e; e << "RPATH_CHANGE given unknown argument " << args[i]; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -2141,7 +2141,7 @@ cmFileCommand::HandleRPathChangeCommand(std::vector const& args) { cmOStringStream e; e << "RPATH_CHANGE given FILE \"" << file << "\" that does not exist."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } bool success = true; @@ -2157,7 +2157,7 @@ cmFileCommand::HandleRPathChangeCommand(std::vector const& args) << "to the file:\n" << " " << file << "\n" << emsg; - this->SetError(e.str().c_str()); + this->SetError(e.str()); success = false; } if(success) @@ -2203,7 +2203,7 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector const& args) { cmOStringStream e; e << "RPATH_REMOVE given unknown argument " << args[i]; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -2216,7 +2216,7 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector const& args) { cmOStringStream e; e << "RPATH_REMOVE given FILE \"" << file << "\" that does not exist."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } bool success = true; @@ -2230,7 +2230,7 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector const& args) e << "RPATH_REMOVE could not remove RPATH from file:\n" << " " << file << "\n" << emsg; - this->SetError(e.str().c_str()); + this->SetError(e.str()); success = false; } if(success) @@ -2284,7 +2284,7 @@ cmFileCommand::HandleRPathCheckCommand(std::vector const& args) { cmOStringStream e; e << "RPATH_CHECK given unknown argument " << args[i]; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -2337,7 +2337,7 @@ bool cmFileCommand::HandleRelativePathCommand( std::string errstring = "RELATIVE_PATH must be passed a full path to the directory: " + directoryName; - this->SetError(errstring.c_str()); + this->SetError(errstring); return false; } if(!cmSystemTools::FileIsFullPath(fileName.c_str())) @@ -2345,13 +2345,13 @@ bool cmFileCommand::HandleRelativePathCommand( std::string errstring = "RELATIVE_PATH must be passed a full path to the file: " + fileName; - this->SetError(errstring.c_str()); + this->SetError(errstring); return false; } std::string res = cmSystemTools::RelativePath(directoryName.c_str(), fileName.c_str()); - this->Makefile->AddDefinition(outVar.c_str(), + this->Makefile->AddDefinition(outVar, res.c_str()); return true; } @@ -2389,7 +2389,7 @@ bool cmFileCommand::HandleRename(std::vector const& args) << "to\n" << " " << newname << "\n" << "because: " << err << "\n"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } return true; @@ -2649,7 +2649,7 @@ namespace { { \ std::string e(errstr); \ e += ::curl_easy_strerror(result); \ - this->SetError(e.c_str()); \ + this->SetError(e); \ return false; \ } @@ -2785,7 +2785,7 @@ cmFileCommand::HandleDownloadCommand(std::vector const& args) std::string err = "DOWNLOAD EXPECTED_HASH expects ALGO=value but got: "; err += *i; - this->SetError(err.c_str()); + this->SetError(err); return false; } std::string algo = i->substr(0, pos); @@ -2795,7 +2795,7 @@ cmFileCommand::HandleDownloadCommand(std::vector const& args) { std::string err = "DOWNLOAD EXPECTED_HASH given unknown ALGO: "; err += algo; - this->SetError(err.c_str()); + this->SetError(err); return false; } hashMatchMSG = algo + " hash"; @@ -2809,7 +2809,7 @@ cmFileCommand::HandleDownloadCommand(std::vector const& args) if(cmSystemTools::FileExists(file.c_str()) && hash.get()) { std::string msg; - std::string actualHash = hash->HashFile(file.c_str()); + std::string actualHash = hash->HashFile(file); if(actualHash == expectedHash) { msg = "returning early; file already exists with expected "; @@ -2819,7 +2819,7 @@ cmFileCommand::HandleDownloadCommand(std::vector const& args) { cmOStringStream result; result << (int)0 << ";\"" << msg; - this->Makefile->AddDefinition(statusVar.c_str(), + this->Makefile->AddDefinition(statusVar, result.str().c_str()); } return true; @@ -2828,14 +2828,14 @@ cmFileCommand::HandleDownloadCommand(std::vector const& args) // Make sure parent directory exists so we can write to the file // as we receive downloaded bits from curl... // - std::string dir = cmSystemTools::GetFilenamePath(file.c_str()); + std::string dir = cmSystemTools::GetFilenamePath(file); if(!cmSystemTools::FileExists(dir.c_str()) && !cmSystemTools::MakeDirectory(dir.c_str())) { std::string errstring = "DOWNLOAD error: cannot create directory '" + dir + "' - Specify file by full path name and verify that you " "have directory creation and file write privileges."; - this->SetError(errstring.c_str()); + this->SetError(errstring); return false; } @@ -2954,7 +2954,7 @@ cmFileCommand::HandleDownloadCommand(std::vector const& args) { cmOStringStream result; result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\""; - this->Makefile->AddDefinition(statusVar.c_str(), + this->Makefile->AddDefinition(statusVar, result.str().c_str()); } @@ -2969,7 +2969,7 @@ cmFileCommand::HandleDownloadCommand(std::vector const& args) // if (hash.get()) { - std::string actualHash = hash->HashFile(file.c_str()); + std::string actualHash = hash->HashFile(file); if (actualHash.size() == 0) { this->SetError("DOWNLOAD cannot compute hash on downloaded file"); @@ -2986,7 +2986,7 @@ cmFileCommand::HandleDownloadCommand(std::vector const& args) << " status: [" << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"]" << std::endl ; - this->SetError(oss.str().c_str()); + this->SetError(oss.str()); return false; } } @@ -3000,12 +3000,12 @@ cmFileCommand::HandleDownloadCommand(std::vector const& args) if(verboseLog.size()) { - this->Makefile->AddDefinition(verboseLog.c_str(), + this->Makefile->AddDefinition(verboseLog, &*chunkDebug.begin()); } } - this->Makefile->AddDefinition(verboseLog.c_str(), + this->Makefile->AddDefinition(verboseLog, &*chunkDebug.begin()); } @@ -3102,7 +3102,7 @@ cmFileCommand::HandleUploadCommand(std::vector const& args) { std::string errStr = "UPLOAD cannot open file '"; errStr += filename + "' for reading."; - this->SetError(errStr.c_str()); + this->SetError(errStr); return false; } @@ -3111,7 +3111,7 @@ cmFileCommand::HandleUploadCommand(std::vector const& args) { std::string errStr = "UPLOAD cannot stat file '"; errStr += filename + "'."; - this->SetError(errStr.c_str()); + this->SetError(errStr); fclose(fin); return false; } @@ -3217,7 +3217,7 @@ cmFileCommand::HandleUploadCommand(std::vector const& args) { cmOStringStream result; result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\""; - this->Makefile->AddDefinition(statusVar.c_str(), + this->Makefile->AddDefinition(statusVar, result.str().c_str()); } @@ -3246,7 +3246,7 @@ cmFileCommand::HandleUploadCommand(std::vector const& args) log += "\n"; } - this->Makefile->AddDefinition(logVar.c_str(), log.c_str()); + this->Makefile->AddDefinition(logVar, log.c_str()); } return true; @@ -3368,7 +3368,7 @@ bool cmFileCommand::HandleTimestampCommand( { std::string e = " TIMESTAMP sub-command does not recognize option " + args[argsIndex] + "."; - this->SetError(e.c_str()); + this->SetError(e); return false; } } @@ -3376,7 +3376,7 @@ bool cmFileCommand::HandleTimestampCommand( cmTimestamp timestamp; std::string result = timestamp.FileModificationTime( filename.c_str(), formatString, utcFlag); - this->Makefile->AddDefinition(outputVariable.c_str(), result.c_str()); + this->Makefile->AddDefinition(outputVariable, result.c_str()); return true; } diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index 86fd54b..e4e819a 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -237,7 +237,7 @@ void cmFindBase::AddPrefixPaths(std::vector const& in_paths, for(std::vector::const_iterator it = in_paths.begin(); it != in_paths.end(); ++it) { - std::string dir = it->c_str(); + std::string dir = *it; if(!subdir.empty() && !dir.empty() && dir[dir.size()-1] != '/') { dir += "/"; @@ -323,7 +323,7 @@ void cmFindBase::AddCMakeVariablePath() var += this->CMakePathName; var += "_PATH"; this->AddCMakePrefixPath("CMAKE_PREFIX_PATH"); - this->AddCMakePath(var.c_str()); + this->AddCMakePath(var); if(this->CMakePathName == "PROGRAM") { @@ -360,7 +360,7 @@ void cmFindBase::AddCMakeSystemVariablePath() var += this->CMakePathName; var += "_PATH"; this->AddCMakePrefixPath("CMAKE_SYSTEM_PREFIX_PATH"); - this->AddCMakePath(var.c_str()); + this->AddCMakePath(var); if(this->CMakePathName == "PROGRAM") { @@ -466,7 +466,7 @@ void cmFindBase::PrintFindStuff() bool cmFindBase::CheckForVariableInCache() { if(const char* cacheValue = - this->Makefile->GetDefinition(this->VariableName.c_str())) + this->Makefile->GetDefinition(this->VariableName)) { cmCacheManager::CacheIterator it = this->Makefile->GetCacheManager()-> diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index bd75e10..10241f2 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -51,7 +51,7 @@ void cmFindCommon::SelectDefaultRootPathMode() std::string findRootPathVar = "CMAKE_FIND_ROOT_PATH_MODE_"; findRootPathVar += this->CMakePathName; std::string rootPathMode = - this->Makefile->GetSafeDefinition(findRootPathVar.c_str()); + this->Makefile->GetSafeDefinition(findRootPathVar); if (rootPathMode=="NEVER") { this->FindRootPathMode = RootPathModeNoRootPath; @@ -361,7 +361,7 @@ void cmFindCommon::AddUserPath(std::string const& p, // Expand using the view of the target application. std::string expanded = p; cmSystemTools::ExpandRegistryValues(expanded, view); - cmSystemTools::GlobDirs(expanded.c_str(), paths); + cmSystemTools::GlobDirs(expanded, paths); // Executables can be either 32-bit or 64-bit, so expand using the // alternative view. @@ -369,7 +369,7 @@ void cmFindCommon::AddUserPath(std::string const& p, { expanded = p; cmSystemTools::ExpandRegistryValues(expanded, other_view); - cmSystemTools::GlobDirs(expanded.c_str(), paths); + cmSystemTools::GlobDirs(expanded, paths); } } @@ -433,7 +433,7 @@ void cmFindCommon::AddPathInternal(std::string const& in_path, // Insert the path if has not already been emitted. if(this->SearchPathsEmitted.insert(fullPath).second) { - this->SearchPaths.push_back(fullPath.c_str()); + this->SearchPaths.push_back(fullPath); } } diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 9345d15..fe5e45f 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -37,7 +37,7 @@ bool cmFindLibraryCommand // value. if(this->AlreadyInCacheWithoutMetaInfo) { - this->Makefile->AddCacheDefinition(this->VariableName.c_str(), "", + this->Makefile->AddCacheDefinition(this->VariableName, "", this->VariableDocumentation.c_str(), cmCacheManager::FILEPATH); } @@ -69,14 +69,14 @@ bool cmFindLibraryCommand if(library != "") { // Save the value in the cache - this->Makefile->AddCacheDefinition(this->VariableName.c_str(), + this->Makefile->AddCacheDefinition(this->VariableName, library.c_str(), this->VariableDocumentation.c_str(), cmCacheManager::FILEPATH); return true; } std::string notfound = this->VariableName + "-NOTFOUND"; - this->Makefile->AddCacheDefinition(this->VariableName.c_str(), + this->Makefile->AddCacheDefinition(this->VariableName, notfound.c_str(), this->VariableDocumentation.c_str(), cmCacheManager::FILEPATH); diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 7a4e7f4..1d4e30c 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -223,7 +223,7 @@ bool cmFindPackageCommand } std::string req_var = this->Name + "_FIND_REQUIRED_" + args[i]; - this->AddFindDefinition(req_var.c_str(), isRequired); + this->AddFindDefinition(req_var, isRequired); // Append to the list of required components. components += components_sep; @@ -255,7 +255,7 @@ bool cmFindPackageCommand e << "given CONFIGS option followed by invalid file name \"" << args[i] << "\". The names given must be file names without " << "a path and with a \".cmake\" extension."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } this->Configs.push_back(args[i]); @@ -269,7 +269,7 @@ bool cmFindPackageCommand { cmOStringStream e; e << "called with invalid argument \"" << args[i].c_str() << "\""; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -286,7 +286,7 @@ bool cmFindPackageCommand { e << " " << doubledComponents[i] << "\n"; } - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -309,7 +309,7 @@ bool cmFindPackageCommand e << " " << args[*si] << "\n"; } e << "The options are incompatible."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -327,7 +327,7 @@ bool cmFindPackageCommand // another find_package() call. std::string mod = this->Name; mod += "_FIND_MODULE"; - if(this->Makefile->IsOn(mod.c_str())) + if(this->Makefile->IsOn(mod)) { if(this->Version.empty()) { @@ -335,17 +335,17 @@ bool cmFindPackageCommand // Requested version string. std::string ver = this->Name; ver += "_FIND_VERSION"; - this->Version = this->Makefile->GetSafeDefinition(ver.c_str()); + this->Version = this->Makefile->GetSafeDefinition(ver); // Whether an exact version is required. std::string exact = this->Name; exact += "_FIND_VERSION_EXACT"; - this->VersionExact = this->Makefile->IsOn(exact.c_str()); + this->VersionExact = this->Makefile->IsOn(exact); } if(components.empty()) { std::string components_var = this->Name + "_FIND_COMPONENTS"; - components = this->Makefile->GetSafeDefinition(components_var.c_str()); + components = this->Makefile->GetSafeDefinition(components_var); } } } @@ -373,7 +373,7 @@ bool cmFindPackageCommand std::string disableFindPackageVar = "CMAKE_DISABLE_FIND_PACKAGE_"; disableFindPackageVar += this->Name; - if(this->Makefile->IsOn(disableFindPackageVar.c_str())) + if(this->Makefile->IsOn(disableFindPackageVar)) { if (this->Required) { @@ -381,7 +381,7 @@ bool cmFindPackageCommand e << "for module " << this->Name << " called with REQUIRED, but " << disableFindPackageVar << " is enabled. A REQUIRED package cannot be disabled."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -488,7 +488,7 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components) // Store the list of components. std::string components_var = this->Name + "_FIND_COMPONENTS"; - this->AddFindDefinition(components_var.c_str(), components.c_str()); + this->AddFindDefinition(components_var, components.c_str()); if(this->Quiet) { @@ -496,7 +496,7 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components) // quietly. std::string quietly = this->Name; quietly += "_FIND_QUIETLY"; - this->AddFindDefinition(quietly.c_str(), "1"); + this->AddFindDefinition(quietly, "1"); } if(this->Required) @@ -505,7 +505,7 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components) // a fatal error if the package is not found. std::string req = this->Name; req += "_FIND_REQUIRED"; - this->AddFindDefinition(req.c_str(), "1"); + this->AddFindDefinition(req, "1"); } if(!this->Version.empty()) @@ -514,23 +514,23 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components) // package has been requested. std::string ver = this->Name; ver += "_FIND_VERSION"; - this->AddFindDefinition(ver.c_str(), this->Version.c_str()); + this->AddFindDefinition(ver, this->Version.c_str()); char buf[64]; sprintf(buf, "%u", this->VersionMajor); - this->AddFindDefinition((ver+"_MAJOR").c_str(), buf); + this->AddFindDefinition(ver+"_MAJOR", buf); sprintf(buf, "%u", this->VersionMinor); - this->AddFindDefinition((ver+"_MINOR").c_str(), buf); + this->AddFindDefinition(ver+"_MINOR", buf); sprintf(buf, "%u", this->VersionPatch); - this->AddFindDefinition((ver+"_PATCH").c_str(), buf); + this->AddFindDefinition(ver+"_PATCH", buf); sprintf(buf, "%u", this->VersionTweak); - this->AddFindDefinition((ver+"_TWEAK").c_str(), buf); + this->AddFindDefinition(ver+"_TWEAK", buf); sprintf(buf, "%u", this->VersionCount); - this->AddFindDefinition((ver+"_COUNT").c_str(), buf); + this->AddFindDefinition(ver+"_COUNT", buf); // Tell the module whether an exact version has been requested. std::string exact = this->Name; exact += "_FIND_VERSION_EXACT"; - this->AddFindDefinition(exact.c_str(), this->VersionExact? "1":"0"); + this->AddFindDefinition(exact, this->VersionExact? "1":"0"); } } @@ -559,11 +559,11 @@ void cmFindPackageCommand::RestoreFindDefinitions() OriginalDef const& od = i->second; if(od.exists) { - this->Makefile->AddDefinition(i->first.c_str(), od.value.c_str()); + this->Makefile->AddDefinition(i->first, od.value.c_str()); } else { - this->Makefile->RemoveDefinition(i->first.c_str()); + this->Makefile->RemoveDefinition(i->first); } } } @@ -582,9 +582,9 @@ bool cmFindPackageCommand::FindModule(bool& found) found = true; std::string var = this->Name; var += "_FIND_MODULE"; - this->Makefile->AddDefinition(var.c_str(), "1"); + this->Makefile->AddDefinition(var, "1"); bool result = this->ReadListFile(mfile.c_str(), DoPolicyScope); - this->Makefile->RemoveDefinition(var.c_str()); + this->Makefile->RemoveDefinition(var); return result; } return true; @@ -602,7 +602,7 @@ bool cmFindPackageCommand::HandlePackageMode() upperFound += "_FOUND"; // Try to find the config file. - const char* def = this->Makefile->GetDefinition(this->Variable.c_str()); + const char* def = this->Makefile->GetDefinition(this->Variable); // Try to load the config file if the directory is known bool fileFound = false; @@ -627,14 +627,14 @@ bool cmFindPackageCommand::HandlePackageMode() this->FileFound = file; fileFound = true; } - def = this->Makefile->GetDefinition(this->Variable.c_str()); + def = this->Makefile->GetDefinition(this->Variable); } // Search for the config file if it is not already found. if(cmSystemTools::IsOff(def) || !fileFound) { fileFound = this->FindConfig(); - def = this->Makefile->GetDefinition(this->Variable.c_str()); + def = this->Makefile->GetDefinition(this->Variable); } // Sanity check. @@ -659,16 +659,16 @@ bool cmFindPackageCommand::HandlePackageMode() if(fileFound) { - if ((this->Makefile->IsDefinitionSet(foundVar.c_str())) - && (this->Makefile->IsOn(foundVar.c_str()) == false)) + if ((this->Makefile->IsDefinitionSet(foundVar)) + && (this->Makefile->IsOn(foundVar) == false)) { // by removing Foo_FOUND here if it is FALSE, we don't really change // the situation for the Config file which is about to be included, // but we make it possible to detect later on whether the Config file // has set Foo_FOUND to FALSE itself: - this->Makefile->RemoveDefinition(foundVar.c_str()); + this->Makefile->RemoveDefinition(foundVar); } - this->Makefile->RemoveDefinition(notFoundMessageVar.c_str()); + this->Makefile->RemoveDefinition(notFoundMessageVar); // Set the version variables before loading the config file. // It may override them. @@ -681,14 +681,14 @@ bool cmFindPackageCommand::HandlePackageMode() found = true; // Check whether the Config file has set Foo_FOUND to FALSE: - if ((this->Makefile->IsDefinitionSet(foundVar.c_str())) - && (this->Makefile->IsOn(foundVar.c_str()) == false)) + if ((this->Makefile->IsDefinitionSet(foundVar)) + && (this->Makefile->IsOn(foundVar) == false)) { // we get here if the Config file has set Foo_FOUND actively to FALSE found = false; configFileSetFOUNDFalse = true; notFoundMessage = this->Makefile->GetSafeDefinition( - notFoundMessageVar.c_str()); + notFoundMessageVar); } } else @@ -810,18 +810,18 @@ bool cmFindPackageCommand::HandlePackageMode() } // Set a variable marking whether the package was found. - this->Makefile->AddDefinition(foundVar.c_str(), found? "1":"0"); + this->Makefile->AddDefinition(foundVar, found? "1":"0"); // Set a variable naming the configuration file that was found. std::string fileVar = this->Name; fileVar += "_CONFIG"; if(found) { - this->Makefile->AddDefinition(fileVar.c_str(), this->FileFound.c_str()); + this->Makefile->AddDefinition(fileVar, this->FileFound.c_str()); } else { - this->Makefile->RemoveDefinition(fileVar.c_str()); + this->Makefile->RemoveDefinition(fileVar); } std::string consideredConfigsVar = this->Name; @@ -843,10 +843,10 @@ bool cmFindPackageCommand::HandlePackageMode() sep = ";"; } - this->Makefile->AddDefinition(consideredConfigsVar.c_str(), + this->Makefile->AddDefinition(consideredConfigsVar, consideredConfigFiles.c_str()); - this->Makefile->AddDefinition(consideredVersionsVar.c_str(), + this->Makefile->AddDefinition(consideredVersionsVar, consideredVersions.c_str()); return result; @@ -906,7 +906,7 @@ bool cmFindPackageCommand::FindConfig() help += this->Name; help += "."; // We force the value since we do not get here if it was already set. - this->Makefile->AddCacheDefinition(this->Variable.c_str(), + this->Makefile->AddCacheDefinition(this->Variable, init.c_str(), help.c_str(), cmCacheManager::PATH, true); return found; @@ -968,7 +968,7 @@ bool cmFindPackageCommand::ReadListFile(const char* f, PolicyScopeRule psr) std::string e = "Error reading CMake code from \""; e += f; e += "\"."; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -1048,14 +1048,14 @@ void cmFindPackageCommand::AppendSuccessInformation() std::string transitivePropName = "_CMAKE_"; transitivePropName += this->Name + "_TRANSITIVE_DEPENDENCY"; this->Makefile->GetCMakeInstance() - ->SetProperty(transitivePropName.c_str(), "False"); + ->SetProperty(transitivePropName, "False"); } std::string found = this->Name; found += "_FOUND"; std::string upperFound = cmSystemTools::UpperCase(found); - const char* upperResult = this->Makefile->GetDefinition(upperFound.c_str()); - const char* result = this->Makefile->GetDefinition(found.c_str()); + const char* upperResult = this->Makefile->GetDefinition(upperFound); + const char* result = this->Makefile->GetDefinition(found); bool packageFound = ((cmSystemTools::IsOn(result)) || (cmSystemTools::IsOn(upperResult))); @@ -1066,7 +1066,7 @@ void cmFindPackageCommand::AppendSuccessInformation() std::string quietInfoPropName = "_CMAKE_"; quietInfoPropName += this->Name; quietInfoPropName += "_QUIET"; - this->Makefile->GetCMakeInstance()->SetProperty(quietInfoPropName.c_str(), + this->Makefile->GetCMakeInstance()->SetProperty(quietInfoPropName, this->Quiet ? "TRUE" : "FALSE"); // set a global property to record the required version of this package @@ -1080,7 +1080,7 @@ void cmFindPackageCommand::AppendSuccessInformation() versionInfo += " "; versionInfo += this->Version; } - this->Makefile->GetCMakeInstance()->SetProperty(versionInfoPropName.c_str(), + this->Makefile->GetCMakeInstance()->SetProperty(versionInfoPropName, versionInfo.c_str()); if (this->Required) { @@ -1088,7 +1088,7 @@ void cmFindPackageCommand::AppendSuccessInformation() requiredInfoPropName += this->Name; requiredInfoPropName += "_TYPE"; this->Makefile->GetCMakeInstance()->SetProperty( - requiredInfoPropName.c_str(), "REQUIRED"); + requiredInfoPropName, "REQUIRED"); } @@ -1648,25 +1648,25 @@ void cmFindPackageCommand::StoreVersionFound() ver += "_VERSION"; if(this->VersionFound.empty()) { - this->Makefile->RemoveDefinition(ver.c_str()); + this->Makefile->RemoveDefinition(ver); } else { - this->Makefile->AddDefinition(ver.c_str(), this->VersionFound.c_str()); + this->Makefile->AddDefinition(ver, this->VersionFound.c_str()); } // Store the version components. char buf[64]; sprintf(buf, "%u", this->VersionFoundMajor); - this->Makefile->AddDefinition((ver+"_MAJOR").c_str(), buf); + this->Makefile->AddDefinition(ver+"_MAJOR", buf); sprintf(buf, "%u", this->VersionFoundMinor); - this->Makefile->AddDefinition((ver+"_MINOR").c_str(), buf); + this->Makefile->AddDefinition(ver+"_MINOR", buf); sprintf(buf, "%u", this->VersionFoundPatch); - this->Makefile->AddDefinition((ver+"_PATCH").c_str(), buf); + this->Makefile->AddDefinition(ver+"_PATCH", buf); sprintf(buf, "%u", this->VersionFoundTweak); - this->Makefile->AddDefinition((ver+"_TWEAK").c_str(), buf); + this->Makefile->AddDefinition(ver+"_TWEAK", buf); sprintf(buf, "%u", this->VersionFoundCount); - this->Makefile->AddDefinition((ver+"_COUNT").c_str(), buf); + this->Makefile->AddDefinition(ver+"_COUNT", buf); } //---------------------------------------------------------------------------- diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index caaf1d3..5531cdf 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -38,7 +38,7 @@ bool cmFindPathCommand if(this->AlreadyInCacheWithoutMetaInfo) { this->Makefile->AddCacheDefinition( - this->VariableName.c_str(), "", + this->VariableName, "", this->VariableDocumentation.c_str(), (this->IncludeFileInPath ? cmCacheManager::FILEPATH :cmCacheManager::PATH) @@ -51,14 +51,14 @@ bool cmFindPathCommand if(result.size() != 0) { this->Makefile->AddCacheDefinition - (this->VariableName.c_str(), result.c_str(), + (this->VariableName, result.c_str(), this->VariableDocumentation.c_str(), (this->IncludeFileInPath) ? cmCacheManager::FILEPATH :cmCacheManager::PATH); return true; } this->Makefile->AddCacheDefinition - (this->VariableName.c_str(), + (this->VariableName, (this->VariableName + "-NOTFOUND").c_str(), this->VariableDocumentation.c_str(), (this->IncludeFileInPath) ? diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index bb27753..f6e37f6 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -35,7 +35,7 @@ bool cmFindProgramCommand // value. if(this->AlreadyInCacheWithoutMetaInfo) { - this->Makefile->AddCacheDefinition(this->VariableName.c_str(), "", + this->Makefile->AddCacheDefinition(this->VariableName, "", this->VariableDocumentation.c_str(), cmCacheManager::FILEPATH); } @@ -46,14 +46,14 @@ bool cmFindProgramCommand if(result != "") { // Save the value in the cache - this->Makefile->AddCacheDefinition(this->VariableName.c_str(), + this->Makefile->AddCacheDefinition(this->VariableName, result.c_str(), this->VariableDocumentation.c_str(), cmCacheManager::FILEPATH); return true; } - this->Makefile->AddCacheDefinition(this->VariableName.c_str(), + this->Makefile->AddCacheDefinition(this->VariableName, (this->VariableName + "-NOTFOUND").c_str(), this->VariableDocumentation.c_str(), cmCacheManager::FILEPATH); diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index d697067..e3f66c1 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -35,9 +35,9 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, // at end of for each execute recorded commands // store the old value std::string oldDef; - if (mf.GetDefinition(this->Args[0].c_str())) + if (mf.GetDefinition(this->Args[0])) { - oldDef = mf.GetDefinition(this->Args[0].c_str()); + oldDef = mf.GetDefinition(this->Args[0]); } std::vector::const_iterator j = this->Args.begin(); ++j; @@ -47,7 +47,7 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, for( ; j != this->Args.end(); ++j) { // set the variable to the loop value - mf.AddDefinition(this->Args[0].c_str(),j->c_str()); + mf.AddDefinition(this->Args[0],j->c_str()); // Invoke all the functions that were collected in the block. cmExecutionStatus status; for(unsigned int c = 0; c < this->Functions.size(); ++c) @@ -58,13 +58,13 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, { inStatus.SetReturnInvoked(true); // restore the variable to its prior value - mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str()); + mf.AddDefinition(this->Args[0],oldDef.c_str()); return true; } if (status.GetBreakInvoked()) { // restore the variable to its prior value - mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str()); + mf.AddDefinition(this->Args[0],oldDef.c_str()); return true; } if(cmSystemTools::GetFatalErrorOccured() ) @@ -74,7 +74,7 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, } } // restore the variable to its prior value - mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str()); + mf.AddDefinition(this->Args[0],oldDef.c_str()); return true; } else @@ -166,7 +166,7 @@ bool cmForEachCommand cmOStringStream str; str << "called with incorrect range specification: start "; str << start << ", stop " << stop << ", step " << step; - this->SetError(str.str().c_str()); + this->SetError(str.str()); return false; } std::vector range; @@ -226,7 +226,7 @@ bool cmForEachCommand::HandleInMode(std::vector const& args) } else if(doing == DoingLists) { - const char* value = this->Makefile->GetDefinition(args[i].c_str()); + const char* value = this->Makefile->GetDefinition(args[i]); if(value && *value) { cmSystemTools::ExpandListArgument(value, f->Args, true); diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 9b981a3..3ff527d 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -89,7 +89,7 @@ bool cmFunctionHelperCommand::InvokeInitialPass std::string errorMsg = "Function invoked with incorrect arguments for function named: "; errorMsg += this->Args[0]; - this->SetError(errorMsg.c_str()); + this->SetError(errorMsg); return false; } @@ -113,15 +113,15 @@ bool cmFunctionHelperCommand::InvokeInitialPass { cmOStringStream tmpStream; tmpStream << "ARGV" << t; - this->Makefile->AddDefinition(tmpStream.str().c_str(), + this->Makefile->AddDefinition(tmpStream.str(), expandedArgs[t].c_str()); - this->Makefile->MarkVariableAsUsed(tmpStream.str().c_str()); + this->Makefile->MarkVariableAsUsed(tmpStream.str()); } // define the formal arguments for (unsigned int j = 1; j < this->Args.size(); ++j) { - this->Makefile->AddDefinition(this->Args[j].c_str(), + this->Makefile->AddDefinition(this->Args[j], expandedArgs[j-1].c_str()); } @@ -219,8 +219,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, } std::string newName = "_" + this->Args[0]; - mf.GetCMakeInstance()->RenameCommand(this->Args[0].c_str(), - newName.c_str()); + mf.GetCMakeInstance()->RenameCommand(this->Args[0], + newName); mf.AddCommand(f); // remove the function blocker now that the function is defined diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index e4187d2..e127f3a 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -379,7 +379,7 @@ void cmGeneratorExpression::Split(const std::string &input, } if(!part.empty()) { - cmSystemTools::ExpandListArgument(part.c_str(), output); + cmSystemTools::ExpandListArgument(part, output); } } pos += 2; diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 04f36b4..07efba9 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -92,7 +92,7 @@ void cmGeneratorExpressionDAGChecker::ReportError( << "Self reference on target \"" << context->HeadTarget->GetName() << "\".\n"; context->Makefile->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), + ->IssueMessage(cmake::FATAL_ERROR, e.str(), parent->Backtrace); return; } @@ -103,7 +103,7 @@ void cmGeneratorExpressionDAGChecker::ReportError( << " " << expr << "\n" << "Dependency loop found."; context->Makefile->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), + ->IssueMessage(cmake::FATAL_ERROR, e.str(), context->Backtrace); } @@ -116,7 +116,7 @@ void cmGeneratorExpressionDAGChecker::ReportError( << (parent->Content ? parent->Content->GetOriginalExpression() : expr) << "\n"; context->Makefile->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), + ->IssueMessage(cmake::FATAL_ERROR, e.str(), parent->Backtrace); parent = parent->Parent; ++loopStep; diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index 90ce27c..d41285d 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -50,7 +50,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, cmOStringStream e; e << "Evaluation file condition \"" << rawCondition << "\" did " "not evaluate to valid content. Got \"" << condResult << "\"."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } } @@ -72,7 +72,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, cmOStringStream e; e << "Evaluation file to be written multiple times for different " "configurations with different content:\n " << outputFileName; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } @@ -85,7 +85,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, { cmOStringStream e; e << "Evaluation file \"" << outputFileName << "\" cannot be written."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } @@ -109,7 +109,7 @@ void cmGeneratorExpressionEvaluationFile::Generate() { cmOStringStream e; e << "Evaluation file \"" << this->Input << "\" cannot be read."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } @@ -142,7 +142,7 @@ void cmGeneratorExpressionEvaluationFile::Generate() for(std::vector::const_iterator li = allConfigs.begin(); li != allConfigs.end(); ++li) { - this->Generate(li->c_str(), inputExpression.get(), outputFiles); + this->Generate(*li, inputExpression.get(), outputFiles); if(cmSystemTools::GetFatalErrorOccured()) { return; diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 43c1794..14b2a1a 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -39,7 +39,7 @@ void reportError(cmGeneratorExpressionContext *context, << " " << expr << "\n" << result; context->Makefile->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), + ->IssueMessage(cmake::FATAL_ERROR, e.str(), context->Backtrace); } @@ -393,8 +393,8 @@ struct CompilerIdNode : public cmGeneratorExpressionNode const std::string &lang) const { const char *compilerId = context->Makefile ? - context->Makefile->GetSafeDefinition(( - "CMAKE_" + lang + "_COMPILER_ID").c_str()) : ""; + context->Makefile->GetSafeDefinition( + "CMAKE_" + lang + "_COMPILER_ID") : ""; if (parameters.size() == 0) { return compilerId ? compilerId : ""; @@ -428,7 +428,7 @@ struct CompilerIdNode : public cmGeneratorExpressionNode ->GetPolicyWarning(cmPolicies::CMP0044); context->Makefile->GetCMakeInstance() ->IssueMessage(cmake::AUTHOR_WARNING, - e.str().c_str(), context->Backtrace); + e.str(), context->Backtrace); } case cmPolicies::OLD: return "1"; @@ -500,8 +500,8 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode const std::string &lang) const { const char *compilerVersion = context->Makefile ? - context->Makefile->GetSafeDefinition(( - "CMAKE_" + lang + "_COMPILER_VERSION").c_str()) : ""; + context->Makefile->GetSafeDefinition( + "CMAKE_" + lang + "_COMPILER_VERSION") : ""; if (parameters.size() == 0) { return compilerVersion ? compilerVersion : ""; @@ -747,7 +747,7 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode std::string mapProp = "MAP_IMPORTED_CONFIG_"; mapProp += cmSystemTools::UpperCase(context->Config); if(const char* mapValue = - context->CurrentTarget->GetProperty(mapProp.c_str())) + context->CurrentTarget->GetProperty(mapProp)) { cmSystemTools::ExpandListArgument(cmSystemTools::UpperCase(mapValue), mappedConfigs); @@ -1022,7 +1022,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode break; } - const char *prop = target->GetProperty(propertyName.c_str()); + const char *prop = target->GetProperty(propertyName); if (dagCheckerParent) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index eb67f91..db88749 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -688,7 +688,7 @@ void cmTargetTraceDependencies::FollowName(std::string const& name) if(i == this->NameMap.end()) { // Check if we know how to generate this file. - cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name.c_str()); + cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name); NameMapType::value_type entry(name, sf); i = this->NameMap.insert(entry).first; } @@ -750,7 +750,7 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str()); if(depLocation == tLocation) { - this->Target->AddUtility(util.c_str()); + this->Target->AddUtility(util); return true; } } @@ -759,7 +759,7 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) { // The original name of the dependency was not a full path. It // must name a target, so add the target-level dependency. - this->Target->AddUtility(util.c_str()); + this->Target->AddUtility(util); return true; } } @@ -793,7 +793,7 @@ cmTargetTraceDependencies // this project. Add the target-level dependency to make // sure the executable is up to date before this custom // command possibly runs. - this->Target->AddUtility(command.c_str()); + this->Target->AddUtility(command); } } @@ -872,7 +872,7 @@ void cmGeneratorTarget::GetAppleArchs(const std::string& config, { std::string defVarName = "OSX_ARCHITECTURES_"; defVarName += cmSystemTools::UpperCase(config); - archs = this->Target->GetProperty(defVarName.c_str()); + archs = this->Target->GetProperty(defVarName); } if(!archs) { @@ -1048,7 +1048,7 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const for(std::vector::iterator it = relFiles.begin(); it != relFiles.end(); ++it) { - if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str())) + if(cmSourceFile* sf = this->Makefile->GetSource(*it)) { SourceFileFlags& flags = this->SourceFlagsMap[sf]; flags.MacFolder = "Headers"; @@ -1066,7 +1066,7 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const for(std::vector::iterator it = relFiles.begin(); it != relFiles.end(); ++it) { - if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str())) + if(cmSourceFile* sf = this->Makefile->GetSource(*it)) { SourceFileFlags& flags = this->SourceFlagsMap[sf]; flags.MacFolder = "PrivateHeaders"; @@ -1083,7 +1083,7 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const for(std::vector::iterator it = relFiles.begin(); it != relFiles.end(); ++it) { - if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str())) + if(cmSourceFile* sf = this->Makefile->GetSource(*it)) { SourceFileFlags& flags = this->SourceFlagsMap[sf]; flags.MacFolder = "Resources"; diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx index 5aaf1c6..e88f498 100644 --- a/Source/cmGetCMakePropertyCommand.cxx +++ b/Source/cmGetCMakePropertyCommand.cxx @@ -66,14 +66,14 @@ bool cmGetCMakePropertyCommand else { const char *prop = - this->Makefile->GetCMakeInstance()->GetProperty(args[1].c_str()); + this->Makefile->GetCMakeInstance()->GetProperty(args[1]); if (prop) { output = prop; } } - this->Makefile->AddDefinition(variable.c_str(), output.c_str()); + this->Makefile->AddDefinition(variable, output.c_str()); return true; } diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx index 9e76e1b..fcc3da1 100644 --- a/Source/cmGetDirectoryPropertyCommand.cxx +++ b/Source/cmGetDirectoryPropertyCommand.cxx @@ -54,7 +54,7 @@ bool cmGetDirectoryPropertyCommand // lookup the makefile from the directory name cmLocalGenerator *lg = this->Makefile->GetLocalGenerator()->GetGlobalGenerator()-> - FindLocalGenerator(sd.c_str()); + FindLocalGenerator(sd); if (!lg) { this->SetError @@ -79,18 +79,18 @@ bool cmGetDirectoryPropertyCommand "providing the name of the variable to get."); return false; } - output = dir->GetSafeDefinition(i->c_str()); - this->Makefile->AddDefinition(variable.c_str(), output.c_str()); + output = dir->GetSafeDefinition(*i); + this->Makefile->AddDefinition(variable, output.c_str()); return true; } - const char *prop = dir->GetProperty(i->c_str()); + const char *prop = dir->GetProperty(*i); if (prop) { - this->Makefile->AddDefinition(variable.c_str(), prop); + this->Makefile->AddDefinition(variable, prop); return true; } - this->Makefile->AddDefinition(variable.c_str(), ""); + this->Makefile->AddDefinition(variable, ""); return true; } diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx index 1d7fefc..10406d2 100644 --- a/Source/cmGetFilenameComponentCommand.cxx +++ b/Source/cmGetFilenameComponentCommand.cxx @@ -26,7 +26,7 @@ bool cmGetFilenameComponentCommand // already, if so use that value if(args.size() == 4 && args[3] == "CACHE") { - const char* cacheValue = this->Makefile->GetDefinition(args[0].c_str()); + const char* cacheValue = this->Makefile->GetDefinition(args[0]); if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue)) { return true; @@ -107,7 +107,7 @@ bool cmGetFilenameComponentCommand else { std::string err = "unknown component " + args[2]; - this->SetError(err.c_str()); + this->SetError(err); return false; } @@ -116,12 +116,12 @@ bool cmGetFilenameComponentCommand if(programArgs.size() && storeArgs.size()) { this->Makefile->AddCacheDefinition - (storeArgs.c_str(), programArgs.c_str(), + (storeArgs, programArgs.c_str(), "", args[2] == "PATH" ? cmCacheManager::FILEPATH : cmCacheManager::STRING); } this->Makefile->AddCacheDefinition - (args[0].c_str(), result.c_str(), "", + (args[0], result.c_str(), "", args[2] == "PATH" ? cmCacheManager::FILEPATH : cmCacheManager::STRING); } @@ -129,9 +129,9 @@ bool cmGetFilenameComponentCommand { if(programArgs.size() && storeArgs.size()) { - this->Makefile->AddDefinition(storeArgs.c_str(), programArgs.c_str()); + this->Makefile->AddDefinition(storeArgs, programArgs.c_str()); } - this->Makefile->AddDefinition(args[0].c_str(), result.c_str()); + this->Makefile->AddDefinition(args[0], result.c_str()); } return true; diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index 30bec16..6dd40c9 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -73,7 +73,7 @@ bool cmGetPropertyCommand e << "given invalid scope " << args[1] << ". " << "Valid scopes are " << "GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE, CACHE."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -120,7 +120,7 @@ bool cmGetPropertyCommand { cmOStringStream e; e << "given invalid argument \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -139,7 +139,7 @@ bool cmGetPropertyCommand std::string output; if(cmPropertyDefinition* def = this->Makefile->GetCMakeInstance()-> - GetPropertyDefinition(this->PropertyName.c_str(), scope)) + GetPropertyDefinition(this->PropertyName, scope)) { output = def->GetShortDescription(); } @@ -147,7 +147,7 @@ bool cmGetPropertyCommand { output = "NOTFOUND"; } - this->Makefile->AddDefinition(this->Variable.c_str(), output.c_str()); + this->Makefile->AddDefinition(this->Variable, output.c_str()); } else if(this->InfoType == OutFullDoc) { @@ -155,7 +155,7 @@ bool cmGetPropertyCommand std::string output; if(cmPropertyDefinition* def = this->Makefile->GetCMakeInstance()-> - GetPropertyDefinition(this->PropertyName.c_str(), scope)) + GetPropertyDefinition(this->PropertyName, scope)) { output = def->GetFullDescription(); } @@ -163,19 +163,19 @@ bool cmGetPropertyCommand { output = "NOTFOUND"; } - this->Makefile->AddDefinition(this->Variable.c_str(), output.c_str()); + this->Makefile->AddDefinition(this->Variable, output.c_str()); } else if(this->InfoType == OutDefined) { // Lookup if the property is defined if(this->Makefile->GetCMakeInstance()-> - GetPropertyDefinition(this->PropertyName.c_str(), scope)) + GetPropertyDefinition(this->PropertyName, scope)) { - this->Makefile->AddDefinition(this->Variable.c_str(), "1"); + this->Makefile->AddDefinition(this->Variable, "1"); } else { - this->Makefile->AddDefinition(this->Variable.c_str(), "0"); + this->Makefile->AddDefinition(this->Variable, "0"); } } else @@ -204,17 +204,17 @@ bool cmGetPropertyCommand::StoreResult(const char* value) { if(this->InfoType == OutSet) { - this->Makefile->AddDefinition(this->Variable.c_str(), value? "1":"0"); + this->Makefile->AddDefinition(this->Variable, value? "1":"0"); } else // if(this->InfoType == OutValue) { if(value) { - this->Makefile->AddDefinition(this->Variable.c_str(), value); + this->Makefile->AddDefinition(this->Variable, value); } else { - this->Makefile->RemoveDefinition(this->Variable.c_str()); + this->Makefile->RemoveDefinition(this->Variable); } } return true; @@ -231,7 +231,7 @@ bool cmGetPropertyCommand::HandleGlobalMode() // Get the property. cmake* cm = this->Makefile->GetCMakeInstance(); - return this->StoreResult(cm->GetProperty(this->PropertyName.c_str())); + return this->StoreResult(cm->GetProperty(this->PropertyName)); } //---------------------------------------------------------------------------- @@ -259,7 +259,7 @@ bool cmGetPropertyCommand::HandleDirectoryMode() // Lookup the generator. if(cmLocalGenerator* lg = (this->Makefile->GetLocalGenerator() - ->GetGlobalGenerator()->FindLocalGenerator(dir.c_str()))) + ->GetGlobalGenerator()->FindLocalGenerator(dir))) { // Use the makefile for the directory found. mf = lg->GetMakefile(); @@ -276,7 +276,7 @@ bool cmGetPropertyCommand::HandleDirectoryMode() } // Get the property. - return this->StoreResult(mf->GetProperty(this->PropertyName.c_str())); + return this->StoreResult(mf->GetProperty(this->PropertyName)); } //---------------------------------------------------------------------------- @@ -302,14 +302,14 @@ bool cmGetPropertyCommand::HandleTargetMode() } if(cmTarget* target = this->Makefile->FindTargetToUse(this->Name)) { - return this->StoreResult(target->GetProperty(this->PropertyName.c_str())); + return this->StoreResult(target->GetProperty(this->PropertyName)); } else { cmOStringStream e; e << "could not find TARGET " << this->Name << ". Perhaps it has not yet been created."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -325,17 +325,17 @@ bool cmGetPropertyCommand::HandleSourceMode() // Get the source file. if(cmSourceFile* sf = - this->Makefile->GetOrCreateSource(this->Name.c_str())) + this->Makefile->GetOrCreateSource(this->Name)) { return - this->StoreResult(sf->GetPropertyForUser(this->PropertyName.c_str())); + this->StoreResult(sf->GetPropertyForUser(this->PropertyName)); } else { cmOStringStream e; e << "given SOURCE name that could not be found or created: " << this->Name; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -350,15 +350,15 @@ bool cmGetPropertyCommand::HandleTestMode() } // Loop over all tests looking for matching names. - if(cmTest* test = this->Makefile->GetTest(this->Name.c_str())) + if(cmTest* test = this->Makefile->GetTest(this->Name)) { - return this->StoreResult(test->GetProperty(this->PropertyName.c_str())); + return this->StoreResult(test->GetProperty(this->PropertyName)); } // If not found it is an error. cmOStringStream e; e << "given TEST name that does not exist: " << this->Name; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -372,7 +372,7 @@ bool cmGetPropertyCommand::HandleVariableMode() } return this->StoreResult - (this->Makefile->GetDefinition(this->PropertyName.c_str())); + (this->Makefile->GetDefinition(this->PropertyName)); } //---------------------------------------------------------------------------- @@ -389,7 +389,7 @@ bool cmGetPropertyCommand::HandleCacheMode() this->Makefile->GetCacheManager()->GetCacheIterator(this->Name.c_str()); if(!it.IsAtEnd()) { - value = it.GetProperty(this->PropertyName.c_str()); + value = it.GetProperty(this->PropertyName); } this->StoreResult(value); return true; diff --git a/Source/cmGetSourceFilePropertyCommand.cxx b/Source/cmGetSourceFilePropertyCommand.cxx index a6e4fcc..8a96289 100644 --- a/Source/cmGetSourceFilePropertyCommand.cxx +++ b/Source/cmGetSourceFilePropertyCommand.cxx @@ -38,7 +38,7 @@ bool cmGetSourceFilePropertyCommand this->Makefile->AddDefinition(var, sf->GetLanguage().c_str()); return true; } - const char *prop = sf->GetPropertyForUser(args[2].c_str()); + const char *prop = sf->GetPropertyForUser(args[2]); if (prop) { this->Makefile->AddDefinition(var, prop); diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx index b64f847..e3ec0bc 100644 --- a/Source/cmGetTargetPropertyCommand.cxx +++ b/Source/cmGetTargetPropertyCommand.cxx @@ -20,7 +20,7 @@ bool cmGetTargetPropertyCommand this->SetError("called with incorrect number of arguments"); return false; } - std::string var = args[0].c_str(); + std::string var = args[0]; const std::string& targetName = args[1]; std::string prop; @@ -38,7 +38,7 @@ bool cmGetTargetPropertyCommand else if(cmTarget* tgt = this->Makefile->FindTargetToUse(targetName)) { cmTarget& target = *tgt; - const char* prop_cstr = target.GetProperty(args[2].c_str()); + const char* prop_cstr = target.GetProperty(args[2]); if(prop_cstr) { prop = prop_cstr; @@ -67,7 +67,7 @@ bool cmGetTargetPropertyCommand { e << "get_target_property() called with non-existent target \"" << targetName << "\"."; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { return false; @@ -76,10 +76,10 @@ bool cmGetTargetPropertyCommand } if (!prop.empty()) { - this->Makefile->AddDefinition(var.c_str(), prop.c_str()); + this->Makefile->AddDefinition(var, prop.c_str()); return true; } - this->Makefile->AddDefinition(var.c_str(), (var+"-NOTFOUND").c_str()); + this->Makefile->AddDefinition(var, (var+"-NOTFOUND").c_str()); return true; } diff --git a/Source/cmGetTestPropertyCommand.cxx b/Source/cmGetTestPropertyCommand.cxx index 0e0e2c0..b3df4c3 100644 --- a/Source/cmGetTestPropertyCommand.cxx +++ b/Source/cmGetTestPropertyCommand.cxx @@ -26,17 +26,17 @@ bool cmGetTestPropertyCommand std::string testName = args[0]; std::string var = args[2]; - cmTest *test = this->Makefile->GetTest(testName.c_str()); + cmTest *test = this->Makefile->GetTest(testName); if (test) { - const char *prop = test->GetProperty(args[1].c_str()); + const char *prop = test->GetProperty(args[1]); if (prop) { - this->Makefile->AddDefinition(var.c_str(), prop); + this->Makefile->AddDefinition(var, prop); return true; } } - this->Makefile->AddDefinition(var.c_str(), "NOTFOUND"); + this->Makefile->AddDefinition(var, "NOTFOUND"); return true; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index faed66a..b67da5b 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -123,7 +123,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, langComp += lang; langComp += "_COMPILER"; - if(!mf->GetDefinition(langComp.c_str())) + if(!mf->GetDefinition(langComp)) { if(!optional) { @@ -132,7 +132,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, } return; } - const char* name = mf->GetRequiredDefinition(langComp.c_str()); + const char* name = mf->GetRequiredDefinition(langComp); std::string path; if(!cmSystemTools::FileIsFullPath(name)) { @@ -150,7 +150,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, std::string doc = lang; doc += " compiler."; const char* cname = this->GetCMakeInstance()-> - GetCacheManager()->GetCacheValue(langComp.c_str()); + GetCacheManager()->GetCacheValue(langComp); std::string changeVars; if(cname && !optional) { @@ -185,7 +185,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, changeVars.c_str()); } } - mf->AddCacheDefinition(langComp.c_str(), path.c_str(), + mf->AddCacheDefinition(langComp, path.c_str(), doc.c_str(), cmCacheManager::FILEPATH); } @@ -457,7 +457,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, std::string loadedLang = "CMAKE_"; loadedLang += lang; loadedLang += "_COMPILER_LOADED"; - if(!mf->GetDefinition(loadedLang.c_str())) + if(!mf->GetDefinition(loadedLang)) { fpath = rootBin; fpath += "/CMake"; @@ -518,9 +518,9 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, std::string compilerEnv = "CMAKE_"; compilerEnv += lang; compilerEnv += "_COMPILER_ENV_VAR"; - std::string envVar = mf->GetRequiredDefinition(compilerEnv.c_str()); + std::string envVar = mf->GetRequiredDefinition(compilerEnv); std::string envVarValue = - mf->GetRequiredDefinition(compilerName.c_str()); + mf->GetRequiredDefinition(compilerName); std::string env = envVar; env += "="; env += envVarValue; @@ -578,7 +578,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, compilerEnv += lang; compilerEnv += "_COMPILER_ENV_VAR"; cmOStringStream noCompiler; - const char* compilerFile = mf->GetDefinition(compilerName.c_str()); + const char* compilerFile = mf->GetDefinition(compilerName); if(!compilerFile || !*compilerFile || cmSystemTools::IsNOTFOUND(compilerFile)) { @@ -621,7 +621,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, if(!this->CMakeInstance->GetIsInTryCompile()) { this->PrintCompilerAdvice(noCompiler, lang, - mf->GetDefinition(compilerEnv.c_str())); + mf->GetDefinition(compilerEnv)); mf->IssueMessage(cmake::FATAL_ERROR, noCompiler.str()); fatalError = true; } @@ -631,7 +631,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, std::string langLoadedVar = "CMAKE_"; langLoadedVar += lang; langLoadedVar += "_INFORMATION_LOADED"; - if (!mf->GetDefinition(langLoadedVar.c_str())) + if (!mf->GetDefinition(langLoadedVar)) { fpath = "CMake"; fpath += lang; @@ -678,7 +678,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, // if the compiler did not work, then remove the // CMake(LANG)Compiler.cmake file so that it will get tested the // next time cmake is run - if(!mf->IsOn(compilerWorks.c_str())) + if(!mf->IsOn(compilerWorks)) { std::string compilerLangFile = rootBin; compilerLangFile += "/CMake"; @@ -693,7 +693,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, sharedLibFlagsVar += lang; sharedLibFlagsVar += "_FLAGS"; const char* sharedLibFlags = - mf->GetSafeDefinition(sharedLibFlagsVar.c_str()); + mf->GetSafeDefinition(sharedLibFlagsVar); if (sharedLibFlags) { this->LanguageToOriginalSharedLibFlags[lang] = sharedLibFlags; @@ -753,7 +753,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, std::string const& lang) const { std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID"; - const char* compilerId = mf->GetDefinition(compilerIdVar.c_str()); + const char* compilerId = mf->GetDefinition(compilerIdVar); if(!compilerId) { return; @@ -776,7 +776,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, } case cmPolicies::OLD: // OLD behavior is to convert AppleClang to Clang. - mf->AddDefinition(compilerIdVar.c_str(), "Clang"); + mf->AddDefinition(compilerIdVar, "Clang"); break; case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: @@ -807,7 +807,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, } case cmPolicies::OLD: // OLD behavior is to convert QCC to GNU. - mf->AddDefinition(compilerIdVar.c_str(), "GNU"); + mf->AddDefinition(compilerIdVar, "GNU"); break; case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: @@ -917,7 +917,7 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l, std::string linkerPrefVar = std::string("CMAKE_") + std::string(l) + std::string("_LINKER_PREFERENCE"); - const char* linkerPref = mf->GetDefinition(linkerPrefVar.c_str()); + const char* linkerPref = mf->GetDefinition(linkerPrefVar); int preference = 0; if(linkerPref) { @@ -950,7 +950,7 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l, std::string outputExtensionVar = std::string("CMAKE_") + std::string(l) + std::string("_OUTPUT_EXTENSION"); - const char* outputExtension = mf->GetDefinition(outputExtensionVar.c_str()); + const char* outputExtension = mf->GetDefinition(outputExtensionVar); if(outputExtension) { this->LanguageToOutputExtension[l] = outputExtension; @@ -968,7 +968,7 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l, std::string ignoreExtensionsVar = std::string("CMAKE_") + std::string(l) + std::string("_IGNORE_EXTENSIONS"); - std::string ignoreExts = mf->GetSafeDefinition(ignoreExtensionsVar.c_str()); + std::string ignoreExts = mf->GetSafeDefinition(ignoreExtensionsVar); std::vector extensionList; cmSystemTools::ExpandListArgument(ignoreExts, extensionList); for(std::vector::iterator i = extensionList.begin(); @@ -984,7 +984,7 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const std::string& l, { std::string extensionsVar = std::string("CMAKE_") + std::string(l) + std::string("_SOURCE_FILE_EXTENSIONS"); - std::string exts = mf->GetSafeDefinition(extensionsVar.c_str()); + std::string exts = mf->GetSafeDefinition(extensionsVar); std::vector extensionList; cmSystemTools::ExpandListArgument(exts, extensionList); for(std::vector::iterator i = extensionList.begin(); @@ -1389,8 +1389,8 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() { std::string defPropName = "COMPILE_DEFINITIONS_"; defPropName += cmSystemTools::UpperCase(*ci); - t->AppendProperty(defPropName.c_str(), - mf->GetProperty(defPropName.c_str())); + t->AppendProperty(defPropName, + mf->GetProperty(defPropName)); } } } @@ -1572,7 +1572,7 @@ void cmGlobalGenerator::CheckLocalGenerators() std::string incDirs = cmGeneratorExpression::Preprocess(incDirProp, cmGeneratorExpression::StripAllGeneratorExpressions); - cmSystemTools::ExpandListArgument(incDirs.c_str(), incs); + cmSystemTools::ExpandListArgument(incDirs, incs); for( std::vector::const_iterator incDir = incs.begin(); incDir != incs.end(); ++incDir) @@ -1665,7 +1665,7 @@ int cmGlobalGenerator::TryCompile(const std::string& srcdir, std::string config = mf->GetSafeDefinition("CMAKE_TRY_COMPILE_CONFIGURATION"); return this->Build(srcdir,bindir,projectName, - newTarget.c_str(), + newTarget, output,"",config,false,fast, this->TryCompileTimeout); } @@ -2115,7 +2115,7 @@ cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) const return true; } - if(cmTarget* tgt = this->FindTarget(libname.c_str())) + if(cmTarget* tgt = this->FindTarget(libname)) { if(tgt->IsFrameworkOnApple()) { @@ -2325,7 +2325,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) { ostr << "Only default component available"; } - singleLine.push_back(ostr.str().c_str()); + singleLine.push_back(ostr.str()); (*targets)["list_install_components"] = this->CreateGlobalTarget("list_install_components", ostr.str().c_str(), @@ -2356,7 +2356,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) // automatically convert this name to the build-time location. cmd = "cmake"; } - singleLine.push_back(cmd.c_str()); + singleLine.push_back(cmd); if ( cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.' ) { std::string cfgArg = "-DBUILD_TYPE="; @@ -2494,7 +2494,7 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget( std::vector::iterator dit; for ( dit = depends.begin(); dit != depends.end(); ++ dit ) { - target.AddUtility(dit->c_str()); + target.AddUtility(*dit); } // Organize in the "predefined targets" folder: @@ -2754,7 +2754,7 @@ cmGlobalGenerator::AddRuleHash(const std::vector& outputs, // Shorten the output name (in expected use case). cmLocalGenerator* lg = this->GetLocalGenerators()[0]; - std::string fname = lg->Convert(outputs[0].c_str(), + std::string fname = lg->Convert(outputs[0], cmLocalGenerator::HOME_OUTPUT); // Associate the hash with this output. diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 71e08cc..2e856ba 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -183,7 +183,7 @@ bool cmGlobalKdevelopGenerator (strstr(tmp.c_str(), cmake::GetCMakeFilesDirectoryPostSlash())==0)) { - files.insert(tmp.c_str()); + files.insert(tmp); } } } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 785b902..0a05f5a 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1159,7 +1159,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) { WriteRule(*this->RulesFileStream, "CLEAN", - (ninjaCmd() + " -t clean").c_str(), + ninjaCmd() + " -t clean", "Cleaning all built files...", "Rule for cleaning all built files.", /*depfile=*/ "", @@ -1182,7 +1182,7 @@ void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os) { WriteRule(*this->RulesFileStream, "HELP", - (ninjaCmd() + " -t targets").c_str(), + ninjaCmd() + " -t targets", "All primary targets available:", "Rule for printing all primary targets available.", /*depfile=*/ "", diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 2cdc976..4a19c0c 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -356,14 +356,14 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() << "# The top level Makefile was generated from the following files:\n" << "set(CMAKE_MAKEFILE_DEPENDS\n" << " \"" - << lg->Convert(cache.c_str(), + << lg->Convert(cache, cmLocalGenerator::START_OUTPUT).c_str() << "\"\n"; for(std::vector::const_iterator i = lfiles.begin(); i != lfiles.end(); ++i) { cmakefileStream << " \"" - << lg->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT).c_str() + << lg->Convert(*i, cmLocalGenerator::START_OUTPUT).c_str() << "\"\n"; } cmakefileStream @@ -379,10 +379,10 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() << "# The corresponding makefile is:\n" << "set(CMAKE_MAKEFILE_OUTPUTS\n" << " \"" - << lg->Convert(makefileName.c_str(), + << lg->Convert(makefileName, cmLocalGenerator::START_OUTPUT).c_str() << "\"\n" << " \"" - << lg->Convert(check.c_str(), + << lg->Convert(check, cmLocalGenerator::START_OUTPUT).c_str() << "\"\n"; cmakefileStream << " )\n\n"; @@ -397,7 +397,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() k != outfiles.end(); ++k) { cmakefileStream << " \"" << - lg->Convert(k->c_str(),cmLocalGenerator::HOME_OUTPUT).c_str() + lg->Convert(*k,cmLocalGenerator::HOME_OUTPUT).c_str() << "\"\n"; } @@ -411,7 +411,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() tmpStr += cmake::GetCMakeFilesDirectory(); tmpStr += "/CMakeDirectoryInformation.cmake"; cmakefileStream << " \"" << - lg->Convert(tmpStr.c_str(),cmLocalGenerator::HOME_OUTPUT).c_str() + lg->Convert(tmpStr,cmLocalGenerator::HOME_OUTPUT).c_str() << "\"\n"; } cmakefileStream << " )\n\n"; @@ -494,7 +494,7 @@ cmGlobalUnixMakefileGenerator3 if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && (!check_relink || gtarget->Target - ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str()))) + ->NeedRelinkBeforeInstall(lg->ConfigurationName))) { std::string tname = lg->GetRelativeTargetDirectory(*gtarget->Target); tname += "/"; @@ -530,7 +530,7 @@ cmGlobalUnixMakefileGenerator3 doc += "\" pass in the directory."; std::vector no_commands; lg->WriteMakeRule(ruleFileStream, doc.c_str(), - makeTarget.c_str(), depends, no_commands, true); + makeTarget, depends, no_commands, true); } //---------------------------------------------------------------------------- @@ -547,7 +547,7 @@ cmGlobalUnixMakefileGenerator3 // Begin the directory-level rules section. std::string dir = lg->GetMakefile()->GetStartOutputDirectory(); - dir = lg->Convert(dir.c_str(), cmLocalGenerator::HOME_OUTPUT, + dir = lg->Convert(dir, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE); lg->WriteDivider(ruleFileStream); ruleFileStream @@ -612,7 +612,7 @@ void cmGlobalUnixMakefileGenerator3 { tname += "/fast"; } - tname = lg->Convert(tname.c_str(),cmLocalGenerator::HOME_OUTPUT); + tname = lg->Convert(tname,cmLocalGenerator::HOME_OUTPUT); cmSystemTools::ConvertToOutputSlashes(tname); makeCommand.push_back(tname); if (!this->LocalGenerators.size()) @@ -697,14 +697,14 @@ cmGlobalUnixMakefileGenerator3 localName = name; localName += "/fast"; commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(), makeTargetName.c_str())); + (makefileName.c_str(), makeTargetName)); lg->WriteMakeRule(ruleFileStream, "fast build rule for target.", - localName.c_str(), depends, commands, true); + localName, depends, commands, true); // Add a local name for the rule to relink the target before // installation. if(gtarget->Target - ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str())) + ->NeedRelinkBeforeInstall(lg->ConfigurationName)) { makeTargetName = lg->GetRelativeTargetDirectory(*gtarget->Target); makeTargetName += "/preinstall"; @@ -713,10 +713,10 @@ cmGlobalUnixMakefileGenerator3 depends.clear(); commands.clear(); commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(), makeTargetName.c_str())); + (makefileName.c_str(), makeTargetName)); lg->WriteMakeRule(ruleFileStream, "Manual pre-install relink rule for target.", - localName.c_str(), depends, commands, true); + localName, depends, commands, true); } } } @@ -778,7 +778,7 @@ cmGlobalUnixMakefileGenerator3 makeTargetName = localName; makeTargetName += "/depend"; commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(),makeTargetName.c_str())); + (makefileName.c_str(),makeTargetName)); // add requires if we need it for this generator if (needRequiresStep) @@ -786,12 +786,12 @@ cmGlobalUnixMakefileGenerator3 makeTargetName = localName; makeTargetName += "/requires"; commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(),makeTargetName.c_str())); + (makefileName.c_str(),makeTargetName)); } makeTargetName = localName; makeTargetName += "/build"; commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(),makeTargetName.c_str())); + (makefileName.c_str(),makeTargetName)); // Write the rule. localName += "/all"; @@ -804,7 +804,7 @@ cmGlobalUnixMakefileGenerator3 cmOStringStream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report "; // all target counts - progCmd << lg->Convert(progressDir.c_str(), + progCmd << lg->Convert(progressDir, cmLocalGenerator::FULL, cmLocalGenerator::SHELL); progCmd << " "; @@ -823,7 +823,7 @@ cmGlobalUnixMakefileGenerator3 this->AppendGlobalTargetDepends(depends,*gtarget->Target); lg->WriteMakeRule(ruleFileStream, "All Build rule for target.", - localName.c_str(), depends, commands, true); + localName, depends, commands, true); // add the all/all dependency if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) @@ -845,7 +845,7 @@ cmGlobalUnixMakefileGenerator3 cmOStringStream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # in target - progCmd << lg->Convert(progressDir.c_str(), + progCmd << lg->Convert(progressDir, cmLocalGenerator::FULL, cmLocalGenerator::SHELL); // @@ -857,11 +857,11 @@ cmGlobalUnixMakefileGenerator3 std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash(); tmp += "Makefile2"; commands.push_back(lg->GetRecursiveMakeCall - (tmp.c_str(),localName.c_str())); + (tmp.c_str(),localName)); { cmOStringStream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0 - progCmd << lg->Convert(progressDir.c_str(), + progCmd << lg->Convert(progressDir, cmLocalGenerator::FULL, cmLocalGenerator::SHELL); progCmd << " 0"; @@ -873,7 +873,7 @@ cmGlobalUnixMakefileGenerator3 localName += "/rule"; lg->WriteMakeRule(ruleFileStream, "Build rule for subdir invocation for target.", - localName.c_str(), depends, commands, true); + localName, depends, commands, true); // Add a target with the canonical name (no prefix, suffix or path). commands.clear(); @@ -884,17 +884,17 @@ cmGlobalUnixMakefileGenerator3 // Add rules to prepare the target for installation. if(gtarget->Target - ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str())) + ->NeedRelinkBeforeInstall(lg->ConfigurationName)) { localName = lg->GetRelativeTargetDirectory(*gtarget->Target); localName += "/preinstall"; depends.clear(); commands.clear(); commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(), localName.c_str())); + (makefileName.c_str(), localName)); lg->WriteMakeRule(ruleFileStream, "Pre-install relink rule for target.", - localName.c_str(), depends, commands, true); + localName, depends, commands, true); if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) { @@ -913,9 +913,9 @@ cmGlobalUnixMakefileGenerator3 depends.clear(); commands.clear(); commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(), makeTargetName.c_str())); + (makefileName.c_str(), makeTargetName)); lg->WriteMakeRule(ruleFileStream, "clean rule for target.", - makeTargetName.c_str(), depends, commands, true); + makeTargetName, depends, commands, true); commands.clear(); depends.push_back(makeTargetName); lg->WriteMakeRule(ruleFileStream, "clean rule for target.", @@ -1121,7 +1121,7 @@ bool cmGlobalUnixMakefileGenerator3 std::string var = "CMAKE_NEEDS_REQUIRES_STEP_"; var += *l; var += "_FLAG"; - if(target.GetMakefile()->GetDefinition(var.c_str())) + if(target.GetMakefile()->GetDefinition(var)) { return true; } diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 22cba89..824e9e7 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -192,7 +192,7 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName) std::cout << "Writing " << currentFilename << "..." << std::endl; this->WriteHeader(str); - this->WriteDependerConnections(ptrIt->first.c_str(), + this->WriteDependerConnections(ptrIt->first, insertedNodes, insertedConnections, str); this->WriteFooter(str); @@ -241,7 +241,7 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName) std::cout << "Writing " << currentFilename << "..." << std::endl; this->WriteHeader(str); - this->WriteConnections(ptrIt->first.c_str(), + this->WriteConnections(ptrIt->first, insertedNodes, insertedConnections, str); this->WriteFooter(str); } @@ -280,7 +280,7 @@ void cmGraphVizWriter::WriteGlobalFile(const char* fileName) continue; } - this->WriteConnections(ptrIt->first.c_str(), + this->WriteConnections(ptrIt->first, insertedNodes, insertedConnections, str); } this->WriteFooter(str); @@ -407,7 +407,7 @@ void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName, llit != ll->end(); ++ llit ) { - std::string libName = llit->first.c_str(); + std::string libName = llit->first; if (libName == targetName) { // So this target links against targetName. @@ -424,13 +424,13 @@ void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName, insertedConnections.end()) { insertedConnections.insert(connectionName); - this->WriteNode(dependerIt->first.c_str(), dependerIt->second, + this->WriteNode(dependerIt->first, dependerIt->second, insertedNodes, str); str << " \"" << dependerNodeNameIt->second << "\" -> \"" << myNodeName << "\""; str << " // " < " <first<WriteDependerConnections(dependerIt->first.c_str(), + this->WriteDependerConnections(dependerIt->first, insertedNodes, insertedConnections, str); } diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index bd12327..06c4b89 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -26,7 +26,7 @@ static std::string cmIfCommandError( i != args.end(); ++i) { err += " "; - err += lg->EscapeForCMake(i->c_str()); + err += lg->EscapeForCMake(*i); } err += "\n"; return err; @@ -199,7 +199,7 @@ bool cmIfCommand err += errorString; if (status == cmake::FATAL_ERROR) { - this->SetError(err.c_str()); + this->SetError(err); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -261,7 +261,7 @@ namespace } // Check definition. - const char* def = mf->GetDefinition(arg.c_str()); + const char* def = mf->GetDefinition(arg); return !cmSystemTools::IsOff(def); } @@ -277,12 +277,12 @@ namespace else if(arg == "1") { return true; } else - { return !cmSystemTools::IsOff(mf->GetDefinition(arg.c_str())); } + { return !cmSystemTools::IsOff(mf->GetDefinition(arg)); } } else { // Old GetVariableOrNumber behavior. - const char* def = mf->GetDefinition(arg.c_str()); + const char* def = mf->GetDefinition(arg); if(!def && atoi(arg.c_str())) { def = arg.c_str(); @@ -559,7 +559,7 @@ namespace } else { - bdef = makefile->IsDefinitionSet((argP1)->c_str()); + bdef = makefile->IsDefinitionSet(*(argP1)); } HandlePredicate(bdef, reducible, arg, newArgs, argP1, argP2); } diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index e8ee33f..4d9935c 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -65,7 +65,7 @@ bool cmIncludeCommand { std::string errorText = "called with invalid argument: "; errorText += args[i]; - this->SetError(errorText.c_str()); + this->SetError(errorText); return false; } } @@ -121,7 +121,7 @@ bool cmIncludeCommand "command. It " << modal << " not be used as the argument to the " "include() command. Use ALIAS targets instead to refer to targets " "by alternative names.\n"; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { return false; @@ -139,7 +139,7 @@ bool cmIncludeCommand // add the location of the included file if a result variable was given if (resultVarName.size()) { - this->Makefile->AddDefinition(resultVarName.c_str(), + this->Makefile->AddDefinition(resultVarName, readit?fullFilePath.c_str():"NOTFOUND"); } @@ -149,7 +149,7 @@ bool cmIncludeCommand "could not find load file:\n" " "; m += fname; - this->SetError(m.c_str()); + this->SetError(m); return false; } return true; diff --git a/Source/cmIncludeRegularExpressionCommand.cxx b/Source/cmIncludeRegularExpressionCommand.cxx index ef6e8c6..d6dfdd2 100644 --- a/Source/cmIncludeRegularExpressionCommand.cxx +++ b/Source/cmIncludeRegularExpressionCommand.cxx @@ -24,7 +24,7 @@ bool cmIncludeRegularExpressionCommand if(args.size() > 1) { - this->Makefile->SetComplainRegularExpression(args[1].c_str()); + this->Makefile->SetComplainRegularExpression(args[1]); } return true; diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 94d2091..0041122 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -99,7 +99,7 @@ bool cmInstallCommand::InitialPass(std::vector const& args, // Unknown mode. std::string e = "called with unknown mode "; e += args[0]; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -269,7 +269,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) // Unknown argument. cmOStringStream e; e << "TARGETS given unknown argument \"" << unknownArgs[0] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -370,7 +370,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) cmOStringStream e; e << "TARGETS given target \"" << (*targetIt) << "\" which is an alias."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } // Lookup this target in the current directory. @@ -387,7 +387,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) cmOStringStream e; e << "TARGETS given target \"" << (*targetIt) << "\" which is not an executable, library, or module."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } else if(target->GetType() == cmTarget::OBJECT_LIBRARY) @@ -395,7 +395,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) cmOStringStream e; e << "TARGETS given OBJECT library \"" << (*targetIt) << "\" which may not be installed."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } // Store the target in the list to be installed. @@ -407,7 +407,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) cmOStringStream e; e << "TARGETS given target \"" << (*targetIt) << "\" which does not exist in this directory."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -499,7 +499,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) cmOStringStream e; e << "TARGETS given no FRAMEWORK DESTINATION for shared library " "FRAMEWORK target \"" << target.GetName() << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -519,7 +519,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) cmOStringStream e; e << "TARGETS given no LIBRARY DESTINATION for shared library " "target \"" << target.GetName() << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -539,7 +539,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) cmOStringStream e; e << "TARGETS given no ARCHIVE DESTINATION for static library " "target \"" << target.GetName() << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -560,7 +560,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) cmOStringStream e; e << "TARGETS given no LIBRARY DESTINATION for module target \"" << target.GetName() << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -595,7 +595,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) cmOStringStream e; e << "TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE " "executable target \"" << target.GetName() << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -612,7 +612,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) cmOStringStream e; e << "TARGETS given no RUNTIME DESTINATION for executable " "target \"" << target.GetName() << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -851,7 +851,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) // Unknown argument. cmOStringStream e; e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -866,7 +866,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) // The rename option works only with one file. cmOStringStream e; e << args[0] << " given RENAME option with more than one file."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -886,7 +886,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) // A destination is required. cmOStringStream e; e << args[0] << " given no DESTINATION!"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -927,7 +927,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" after PATTERN or REGEX."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -941,7 +941,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" after PATTERN or REGEX."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -969,7 +969,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" before a PATTERN or REGEX is given."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } literal_args += " EXCLUDE"; @@ -982,7 +982,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" before a PATTERN or REGEX is given."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -997,7 +997,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" after PATTERN or REGEX."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1011,7 +1011,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" after PATTERN or REGEX."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1025,7 +1025,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" after PATTERN or REGEX."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1040,7 +1040,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" after PATTERN or REGEX."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1055,7 +1055,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" after PATTERN or REGEX."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1069,7 +1069,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" after PATTERN or REGEX."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1094,7 +1094,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) cmOStringStream e; e << args[0] << " given non-directory \"" << args[i] << "\" to install."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1150,7 +1150,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) cmOStringStream e; e << args[0] << " given invalid file permission \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -1162,7 +1162,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) cmOStringStream e; e << args[0] << " given invalid directory permission \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -1174,7 +1174,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) cmOStringStream e; e << args[0] << " given invalid permission \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -1183,7 +1183,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) // Unknown argument. cmOStringStream e; e << args[0] << " given unknown argument \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -1204,7 +1204,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector const& args) // A destination is required. cmOStringStream e; e << args[0] << " given no DESTINATION!"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1247,7 +1247,7 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) // Unknown argument. cmOStringStream e; e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1262,7 +1262,7 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) // A destination is required. cmOStringStream e; e << args[0] << " given no DESTINATION!"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1274,7 +1274,7 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) e << args[0] << " given invalid export file name \"" << fname << "\". " << "The FILE argument may not contain a path. " << "Specify the path in the DESTINATION argument."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1285,7 +1285,7 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) cmOStringStream e; e << args[0] << " given invalid export file name \"" << fname << "\". " << "The FILE argument must specify a name ending in \".cmake\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1302,7 +1302,7 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) << "This name cannot be safely converted to a file name. " << "Specify a different export name or use the FILE option to set " << "a file name explicitly."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -1327,7 +1327,7 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) << "EXPORT_LINK_INTERFACE_LIBRARIES" << "\", but target \"" << te->Target->GetName() << "\" does not have policy CMP0022 set to NEW."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -1368,7 +1368,7 @@ bool cmInstallCommand::MakeFilesFullPath(const char* modeName, { cmOStringStream e; e << modeName << " given directory \"" << (*fileIt) << "\" to install."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } // Store the file for installation. diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index d2737a1..9a17052 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -94,7 +94,7 @@ void cmInstallExportGenerator::ComputeTempDir() { // Replace the destination path with a hash to keep it short. this->TempDir += - cmSystemTools::ComputeStringMD5(this->Destination.c_str()); + cmSystemTools::ComputeStringMD5(this->Destination); } else { @@ -138,7 +138,7 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os) // Generate the import file for this export set. this->EFGen->SetExportFile(this->MainImportFile.c_str()); - this->EFGen->SetNamespace(this->Namespace.c_str()); + this->EFGen->SetNamespace(this->Namespace); this->EFGen->SetExportOld(this->ExportOld); if(this->ConfigurationTypes->empty()) { @@ -157,7 +157,7 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os) ci = this->ConfigurationTypes->begin(); ci != this->ConfigurationTypes->end(); ++ci) { - this->EFGen->AddConfiguration(ci->c_str()); + this->EFGen->AddConfiguration(*ci); } } this->EFGen->GenerateImportFile(); @@ -182,7 +182,7 @@ cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os, i != this->EFGen->GetConfigImportFiles().end(); ++i) { files.push_back(i->second); - std::string config_test = this->CreateConfigTest(i->first.c_str()); + std::string config_test = this->CreateConfigTest(i->first); os << indent << "if(" << config_test << ")\n"; this->AddInstallRule(os, cmInstallType_FILES, files, false, this->FilePermissions.c_str(), 0, 0, 0, diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 488d486..7eabbef 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -100,9 +100,9 @@ void cmInstallFilesCommand::FinalPass() else // reg exp list { std::vector files; - std::string regex = this->FinalArgs[0].c_str(); + std::string regex = this->FinalArgs[0]; cmSystemTools::Glob(this->Makefile->GetCurrentDirectory(), - regex.c_str(), files); + regex, files); std::vector::iterator s = files.begin(); // for each argument, get the files diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 54d903a..597f7ee 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -68,7 +68,7 @@ void cmInstallProgramsCommand::FinalPass() { std::vector programs; cmSystemTools::Glob(this->Makefile->GetCurrentDirectory(), - this->FinalArgs[0].c_str(), programs); + this->FinalArgs[0], programs); std::vector::iterator s = programs.begin(); // for each argument, get the programs diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx index 277ccea..b738844 100644 --- a/Source/cmInstallTargetsCommand.cxx +++ b/Source/cmInstallTargetsCommand.cxx @@ -52,7 +52,7 @@ bool cmInstallTargetsCommand else { std::string str = "Cannot find target: \"" + *s + "\" to install."; - this->SetError(str.c_str()); + this->SetError(str); return false; } } diff --git a/Source/cmLinkDirectoriesCommand.cxx b/Source/cmLinkDirectoriesCommand.cxx index 4412414..3644d93 100644 --- a/Source/cmLinkDirectoriesCommand.cxx +++ b/Source/cmLinkDirectoriesCommand.cxx @@ -66,5 +66,5 @@ void cmLinkDirectoriesCommand::AddLinkDir(std::string const& dir) unixPath = tmp; } } - this->Makefile->AddLinkDirectory(unixPath.c_str()); + this->Makefile->AddLinkDirectory(unixPath); } diff --git a/Source/cmLinkLibrariesCommand.cxx b/Source/cmLinkLibrariesCommand.cxx index 2f1db2a..996b538 100644 --- a/Source/cmLinkLibrariesCommand.cxx +++ b/Source/cmLinkLibrariesCommand.cxx @@ -33,7 +33,7 @@ bool cmLinkLibrariesCommand "a library"); return false; } - this->Makefile->AddLinkLibrary(i->c_str(), + this->Makefile->AddLinkLibrary(*i, cmTarget::DEBUG); } else if (*i == "optimized") @@ -45,12 +45,12 @@ bool cmLinkLibrariesCommand "a library"); return false; } - this->Makefile->AddLinkLibrary(i->c_str(), + this->Makefile->AddLinkLibrary(*i, cmTarget::OPTIMIZED); } else { - this->Makefile->AddLinkLibrary(i->c_str()); + this->Makefile->AddLinkLibrary(*i); } } diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 20e760a..f1ea088 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -69,7 +69,7 @@ bool cmListCommand } std::string e = "does not recognize sub-command "+subCommand; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -176,12 +176,12 @@ bool cmListCommand::HandleLengthCommand(std::vector const& args) // do not check the return value here // if the list var is not found varArgsExpanded will have size 0 // and we will return 0 - this->GetList(varArgsExpanded, listName.c_str()); + this->GetList(varArgsExpanded, listName); size_t length = varArgsExpanded.size(); char buffer[1024]; sprintf(buffer, "%d", static_cast(length)); - this->Makefile->AddDefinition(variableName.c_str(), buffer); + this->Makefile->AddDefinition(variableName, buffer); return true; } @@ -198,9 +198,9 @@ bool cmListCommand::HandleGetCommand(std::vector const& args) const std::string& variableName = args[args.size() - 1]; // expand the variable std::vector varArgsExpanded; - if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + if ( !this->GetList(varArgsExpanded, listName) ) { - this->Makefile->AddDefinition(variableName.c_str(), "NOTFOUND"); + this->Makefile->AddDefinition(variableName, "NOTFOUND"); return true; } // FIXME: Add policy to make non-existing lists an error like empty lists. @@ -229,13 +229,13 @@ bool cmListCommand::HandleGetCommand(std::vector const& args) str << "index: " << item << " out of range (-" << varArgsExpanded.size() << ", " << varArgsExpanded.size()-1 << ")"; - this->SetError(str.str().c_str()); + this->SetError(str.str()); return false; } value += varArgsExpanded[item]; } - this->Makefile->AddDefinition(variableName.c_str(), value.c_str()); + this->Makefile->AddDefinition(variableName, value.c_str()); return true; } @@ -253,7 +253,7 @@ bool cmListCommand::HandleAppendCommand(std::vector const& args) const std::string& listName = args[1]; // expand the variable std::string listString; - this->GetListString(listString, listName.c_str()); + this->GetListString(listString, listName); size_t cc; for ( cc = 2; cc < args.size(); ++ cc ) { @@ -264,7 +264,7 @@ bool cmListCommand::HandleAppendCommand(std::vector const& args) listString += args[cc]; } - this->Makefile->AddDefinition(listName.c_str(), listString.c_str()); + this->Makefile->AddDefinition(listName, listString.c_str()); return true; } @@ -281,9 +281,9 @@ bool cmListCommand::HandleFindCommand(std::vector const& args) const std::string& variableName = args[args.size() - 1]; // expand the variable std::vector varArgsExpanded; - if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + if ( !this->GetList(varArgsExpanded, listName) ) { - this->Makefile->AddDefinition(variableName.c_str(), "-1"); + this->Makefile->AddDefinition(variableName, "-1"); return true; } @@ -295,13 +295,13 @@ bool cmListCommand::HandleFindCommand(std::vector const& args) { char indexString[32]; sprintf(indexString, "%d", index); - this->Makefile->AddDefinition(variableName.c_str(), indexString); + this->Makefile->AddDefinition(variableName, indexString); return true; } index++; } - this->Makefile->AddDefinition(variableName.c_str(), "-1"); + this->Makefile->AddDefinition(variableName, "-1"); return true; } @@ -319,12 +319,12 @@ bool cmListCommand::HandleInsertCommand(std::vector const& args) // expand the variable int item = atoi(args[2].c_str()); std::vector varArgsExpanded; - if((!this->GetList(varArgsExpanded, listName.c_str()) + if((!this->GetList(varArgsExpanded, listName) || varArgsExpanded.empty()) && item != 0) { cmOStringStream str; str << "index: " << item << " out of range (0, 0)"; - this->SetError(str.str().c_str()); + this->SetError(str.str()); return false; } @@ -341,7 +341,7 @@ bool cmListCommand::HandleInsertCommand(std::vector const& args) str << "index: " << item << " out of range (-" << varArgsExpanded.size() << ", " << (varArgsExpanded.size() == 0?0:(varArgsExpanded.size()-1)) << ")"; - this->SetError(str.str().c_str()); + this->SetError(str.str()); return false; } } @@ -362,7 +362,7 @@ bool cmListCommand::HandleInsertCommand(std::vector const& args) sep = ";"; } - this->Makefile->AddDefinition(listName.c_str(), value.c_str()); + this->Makefile->AddDefinition(listName, value.c_str()); return true; } @@ -379,7 +379,7 @@ bool cmListCommand const std::string& listName = args[1]; // expand the variable std::vector varArgsExpanded; - if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + if ( !this->GetList(varArgsExpanded, listName) ) { this->SetError("sub-command REMOVE_ITEM requires list to be present."); return false; @@ -411,7 +411,7 @@ bool cmListCommand sep = ";"; } - this->Makefile->AddDefinition(listName.c_str(), value.c_str()); + this->Makefile->AddDefinition(listName, value.c_str()); return true; } @@ -430,7 +430,7 @@ bool cmListCommand const std::string& listName = args[1]; // expand the variable std::vector varArgsExpanded; - if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + if ( !this->GetList(varArgsExpanded, listName) ) { this->SetError("sub-command REVERSE requires list to be present."); return false; @@ -446,7 +446,7 @@ bool cmListCommand sep = ";"; } - this->Makefile->AddDefinition(listName.c_str(), value.c_str()); + this->Makefile->AddDefinition(listName, value.c_str()); return true; } @@ -465,7 +465,7 @@ bool cmListCommand const std::string& listName = args[1]; // expand the variable std::vector varArgsExpanded; - if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + if ( !this->GetList(varArgsExpanded, listName) ) { this->SetError( "sub-command REMOVE_DUPLICATES requires list to be present."); @@ -491,7 +491,7 @@ bool cmListCommand } - this->Makefile->AddDefinition(listName.c_str(), value.c_str()); + this->Makefile->AddDefinition(listName, value.c_str()); return true; } @@ -510,7 +510,7 @@ bool cmListCommand const std::string& listName = args[1]; // expand the variable std::vector varArgsExpanded; - if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + if ( !this->GetList(varArgsExpanded, listName) ) { this->SetError("sub-command SORT requires list to be present."); return false; @@ -528,7 +528,7 @@ bool cmListCommand sep = ";"; } - this->Makefile->AddDefinition(listName.c_str(), value.c_str()); + this->Makefile->AddDefinition(listName, value.c_str()); return true; } @@ -546,7 +546,7 @@ bool cmListCommand::HandleRemoveAtCommand( const std::string& listName = args[1]; // expand the variable std::vector varArgsExpanded; - if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + if ( !this->GetList(varArgsExpanded, listName) ) { this->SetError("sub-command REMOVE_AT requires list to be present."); return false; @@ -574,7 +574,7 @@ bool cmListCommand::HandleRemoveAtCommand( str << "index: " << item << " out of range (-" << varArgsExpanded.size() << ", " << varArgsExpanded.size()-1 << ")"; - this->SetError(str.str().c_str()); + this->SetError(str.str()); return false; } removed.push_back(static_cast(item)); @@ -602,7 +602,7 @@ bool cmListCommand::HandleRemoveAtCommand( } } - this->Makefile->AddDefinition(listName.c_str(), value.c_str()); + this->Makefile->AddDefinition(listName, value.c_str()); return true; } diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 7461d37..34781d3 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -397,12 +397,12 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token, << "Argument not separated from preceding token by whitespace."; if(isError) { - this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str()); return false; } else { - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str().c_str()); + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str()); return true; } } diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx index 806d821..427e29d 100644 --- a/Source/cmLoadCacheCommand.cxx +++ b/Source/cmLoadCacheCommand.cxx @@ -81,7 +81,7 @@ bool cmLoadCacheCommand { break; } - this->Makefile->GetCacheManager()->LoadCache(args[i].c_str(), false, + this->Makefile->GetCacheManager()->LoadCache(args[i], false, excludes, includes); } @@ -104,7 +104,7 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector const& args) if(!cmSystemTools::FileExists(cacheFile.c_str())) { std::string e = "Cannot load cache file from " + cacheFile; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -186,11 +186,11 @@ void cmLoadCacheCommand::CheckLine(const char* line) var = this->Prefix + var; if(value.length()) { - this->Makefile->AddDefinition(var.c_str(), value.c_str()); + this->Makefile->AddDefinition(var, value.c_str()); } else { - this->Makefile->RemoveDefinition(var.c_str()); + this->Makefile->RemoveDefinition(var); } } } diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index 36e9980..a4063a6 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -201,7 +201,7 @@ bool cmLoadCommandCommand // Start by removing the definition in case of failure. std::string reportVar = "CMAKE_LOADED_COMMAND_"; reportVar += args[0]; - this->Makefile->RemoveDefinition(reportVar.c_str()); + this->Makefile->RemoveDefinition(reportVar); // the file must exist std::string moduleName = @@ -219,7 +219,7 @@ bool cmLoadCommandCommand cmSystemTools::ExpandRegistryValues(exp); // Glob the entry in case of wildcards. - cmSystemTools::GlobDirs(exp.c_str(), path); + cmSystemTools::GlobDirs(exp, path); } // Try to find the program. @@ -229,7 +229,7 @@ bool cmLoadCommandCommand cmOStringStream e; e << "Attempt to load command failed from file \"" << moduleName << "\""; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -246,12 +246,12 @@ bool cmLoadCommandCommand err += " Additional error info is:\n"; err += error; } - this->SetError(err.c_str()); + this->SetError(err); return false; } // Report what file was loaded for this command. - this->Makefile->AddDefinition(reportVar.c_str(), fullPath.c_str()); + this->Makefile->AddDefinition(reportVar, fullPath.c_str()); // find the init function std::string initFuncName = args[0] + "Init"; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 761db48..21957f9 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -325,7 +325,7 @@ void cmLocalGenerator::GenerateTestFiles() fout << "subdirs("; std::string outP = this->Children[i]->GetMakefile()->GetStartOutputDirectory(); - fout << this->Convert(outP.c_str(),START_OUTPUT); + fout << this->Convert(outP,START_OUTPUT); fout << ")" << std::endl; } } @@ -577,20 +577,20 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, cmGeneratorTarget& target) { std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname)); - objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL); + objectDir = this->Convert(objectDir,START_OUTPUT,SHELL); std::string objectFile = this->Convert(ofname,START_OUTPUT,SHELL); std::string sourceFile = - this->Convert(source.GetFullPath().c_str(),START_OUTPUT,SHELL,true); + this->Convert(source.GetFullPath(),START_OUTPUT,SHELL,true); std::string varString = "CMAKE_"; varString += lang; varString += "_COMPILE_OBJECT"; std::vector rules; - rules.push_back(this->Makefile->GetRequiredDefinition(varString.c_str())); + rules.push_back(this->Makefile->GetRequiredDefinition(varString)); varString = "CMAKE_"; varString += lang; varString += "_FLAGS"; std::string flags; - flags += this->Makefile->GetSafeDefinition(varString.c_str()); + flags += this->Makefile->GetSafeDefinition(varString); flags += " "; { std::vector includes; @@ -646,7 +646,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, this->Makefile->AddCustomCommandToOutput( ofname, depends, - source.GetFullPath().c_str(), + source.GetFullPath(), commandLines, comment.c_str(), this->Makefile->GetStartOutputDirectory() @@ -681,7 +681,7 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, objVector.push_back(ofname); this->AddCustomCommandToCreateObject(ofname.c_str(), llang, *(*i), target); - objs += this->Convert(ofname.c_str(),START_OUTPUT,MAKEFILE); + objs += this->Convert(ofname,START_OUTPUT,MAKEFILE); objs += " "; } } @@ -718,7 +718,7 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, cmCustomCommandLines commandLines; std::vector rules; - rules.push_back(this->Makefile->GetRequiredDefinition(createRule.c_str())); + rules.push_back(this->Makefile->GetRequiredDefinition(createRule)); std::vector commands; cmSystemTools::ExpandList(rules, commands); for(std::vector::iterator i = commands.begin(); @@ -743,9 +743,9 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, std::string comment = "Linking "; comment += llang; comment += " target "; - comment += this->Convert(targetFullPath.c_str(), START_OUTPUT); + comment += this->Convert(targetFullPath, START_OUTPUT); this->Makefile->AddCustomCommandToOutput( - targetFullPath.c_str(), + targetFullPath, objVector, "", commandLines, @@ -753,7 +753,7 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, this->Makefile->GetStartOutputDirectory() ); target.Target->AddSourceFile - (this->Makefile->GetSource(targetFullPath.c_str())); + (this->Makefile->GetSource(targetFullPath)); } @@ -1081,28 +1081,28 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, { std::string arg1 = actualReplace + "_ARG1"; cmSystemTools::ReplaceString(arg1, "${LANG}", lang); - compilerArg1 = this->Makefile->GetDefinition(arg1.c_str()); + compilerArg1 = this->Makefile->GetDefinition(arg1); compilerTarget = this->Makefile->GetDefinition( - (std::string("CMAKE_") + lang + "_COMPILER_TARGET").c_str()); + std::string("CMAKE_") + lang + "_COMPILER_TARGET"); compilerOptionTarget = this->Makefile->GetDefinition( - (std::string("CMAKE_") + lang + - "_COMPILE_OPTIONS_TARGET").c_str()); + std::string("CMAKE_") + lang + + "_COMPILE_OPTIONS_TARGET"); compilerExternalToolchain = this->Makefile->GetDefinition( - (std::string("CMAKE_") + lang + - "_COMPILER_EXTERNAL_TOOLCHAIN").c_str()); + std::string("CMAKE_") + lang + + "_COMPILER_EXTERNAL_TOOLCHAIN"); compilerOptionExternalToolchain = this->Makefile->GetDefinition( - (std::string("CMAKE_") + lang + - "_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN").c_str()); + std::string("CMAKE_") + lang + + "_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN"); compilerSysroot = this->Makefile->GetDefinition("CMAKE_SYSROOT"); compilerOptionSysroot = this->Makefile->GetDefinition( - (std::string("CMAKE_") + lang + - "_COMPILE_OPTIONS_SYSROOT").c_str()); + std::string("CMAKE_") + lang + + "_COMPILE_OPTIONS_SYSROOT"); } if(actualReplace.find("${LANG}") != actualReplace.npos) { @@ -1111,11 +1111,11 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, if(actualReplace == variable) { std::string replace = - this->Makefile->GetSafeDefinition(variable.c_str()); + this->Makefile->GetSafeDefinition(variable); // if the variable is not a FLAG then treat it like a path if(variable.find("_FLAG") == variable.npos) { - std::string ret = this->ConvertToOutputForExisting(replace.c_str()); + std::string ret = this->ConvertToOutputForExisting(replace); // if there is a required first argument to the compiler add it // to the compiler string if(compilerArg1) @@ -1243,7 +1243,7 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const std::string& remote, std::string tmp; if(cmSystemTools::GetShortPath(remote.c_str(), tmp)) { - return this->Convert(tmp.c_str(), NONE, format, true); + return this->Convert(tmp, NONE, format, true); } } @@ -1283,7 +1283,7 @@ std::string cmLocalGenerator::ConvertToIncludeReference(std::string const& path, OutputFormat format) { - return this->ConvertToOutputForExisting(path.c_str(), START_OUTPUT, format); + return this->ConvertToOutputForExisting(path, START_OUTPUT, format); } //---------------------------------------------------------------------------- @@ -1305,10 +1305,10 @@ std::string cmLocalGenerator::GetIncludeFlags( std::string flagVar = "CMAKE_INCLUDE_FLAG_"; flagVar += lang; const char* includeFlag = - this->Makefile->GetSafeDefinition(flagVar.c_str()); + this->Makefile->GetSafeDefinition(flagVar); flagVar = "CMAKE_INCLUDE_FLAG_SEP_"; flagVar += lang; - const char* sep = this->Makefile->GetDefinition(flagVar.c_str()); + const char* sep = this->Makefile->GetDefinition(flagVar); bool quotePaths = false; if(this->Makefile->GetDefinition("CMAKE_QUOTE_INCLUDE_PATHS")) { @@ -1334,14 +1334,14 @@ std::string cmLocalGenerator::GetIncludeFlags( const char* sysIncludeFlag = 0; if(repeatFlag) { - sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar.c_str()); + sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar); } std::string fwSearchFlagVar = "CMAKE_"; fwSearchFlagVar += lang; fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG"; const char* fwSearchFlag = - this->Makefile->GetDefinition(fwSearchFlagVar.c_str()); + this->Makefile->GetDefinition(fwSearchFlagVar); bool flagUsed = false; std::set emitted; @@ -1360,7 +1360,7 @@ std::string cmLocalGenerator::GetIncludeFlags( if(emitted.insert(frameworkDir).second) { includeFlags - << fwSearchFlag << this->Convert(frameworkDir.c_str(), + << fwSearchFlag << this->Convert(frameworkDir, START_OUTPUT, shellFormat, true) << " "; } @@ -1421,7 +1421,7 @@ void cmLocalGenerator::AddCompileOptions( { std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX"; if(const char* langFlagRegexStr = - this->Makefile->GetDefinition(langFlagRegexVar.c_str())) + this->Makefile->GetDefinition(langFlagRegexVar)) { // Filter flags acceptable to this language. cmsys::RegularExpression r(langFlagRegexStr); @@ -1438,7 +1438,7 @@ void cmLocalGenerator::AddCompileOptions( { // (Re-)Escape this flag. COMPILE_FLAGS were already parsed // as a command line above, and COMPILE_OPTIONS are escaped. - this->AppendFlagEscape(flags, i->c_str()); + this->AppendFlagEscape(flags, *i); } } } @@ -1456,7 +1456,7 @@ void cmLocalGenerator::AddCompileOptions( i != opts.end(); ++i) { // COMPILE_OPTIONS are escaped. - this->AppendFlagEscape(flags, i->c_str()); + this->AppendFlagEscape(flags, *i); } } } @@ -1521,7 +1521,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector& dirs, std::string impDirVar = "CMAKE_"; impDirVar += lang; impDirVar += "_IMPLICIT_INCLUDE_DIRECTORIES"; - if(const char* value = this->Makefile->GetDefinition(impDirVar.c_str())) + if(const char* value = this->Makefile->GetDefinition(impDirVar)) { std::vector impDirVec; cmSystemTools::ExpandListArgument(value, impDirVec); @@ -1596,13 +1596,13 @@ void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, if(!config.empty()) { std::string name = "CMAKE_STATIC_LINKER_FLAGS_" + config; - this->AppendFlags(flags, this->Makefile->GetSafeDefinition(name.c_str())); + this->AppendFlags(flags, this->Makefile->GetSafeDefinition(name)); } this->AppendFlags(flags, target->GetProperty("STATIC_LIBRARY_FLAGS")); if(!config.empty()) { std::string name = "STATIC_LIBRARY_FLAGS_" + config; - this->AppendFlags(flags, target->GetProperty(name.c_str())); + this->AppendFlags(flags, target->GetProperty(name)); } } @@ -1635,7 +1635,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, std::string build = libraryLinkVariable; build += "_"; build += buildType; - linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); + linkFlags += this->Makefile->GetSafeDefinition(build); linkFlags += " "; } if(this->Makefile->IsOn("WIN32") && @@ -1651,7 +1651,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { linkFlags += this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); - linkFlags += this->Convert(sf->GetFullPath().c_str(), + linkFlags += this->Convert(sf->GetFullPath(), FULL, SHELL); linkFlags += " "; } @@ -1667,7 +1667,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { std::string configLinkFlags = "LINK_FLAGS_"; configLinkFlags += buildType; - targetLinkFlags = target->GetProperty(configLinkFlags.c_str()); + targetLinkFlags = target->GetProperty(configLinkFlags); if(targetLinkFlags) { linkFlags += targetLinkFlags; @@ -1687,7 +1687,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { std::string build = "CMAKE_EXE_LINKER_FLAGS_"; build += buildType; - linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); + linkFlags += this->Makefile->GetSafeDefinition(build); linkFlags += " "; } std::string linkLanguage = target->Target->GetLinkerLanguage(); @@ -1706,7 +1706,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") + linkLanguage + std::string("_FLAGS"); - linkFlags += this->Makefile->GetSafeDefinition(sFlagVar.c_str()); + linkFlags += this->Makefile->GetSafeDefinition(sFlagVar); linkFlags += " "; } if ( target->GetPropertyAsBool("WIN32_EXECUTABLE") ) @@ -1728,7 +1728,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, exportFlagVar += "_FLAG"; linkFlags += - this->Makefile->GetSafeDefinition(exportFlagVar.c_str()); + this->Makefile->GetSafeDefinition(exportFlagVar); linkFlags += " "; } const char* targetLinkFlags = target->GetProperty("LINK_FLAGS"); @@ -1741,7 +1741,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { std::string configLinkFlags = "LINK_FLAGS_"; configLinkFlags += buildType; - targetLinkFlags = target->GetProperty(configLinkFlags.c_str()); + targetLinkFlags = target->GetProperty(configLinkFlags); if(targetLinkFlags) { linkFlags += targetLinkFlags; @@ -1785,7 +1785,7 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib, #endif // Normal behavior. - return this->Convert(lib.c_str(), START_OUTPUT, format); + return this->Convert(lib, START_OUTPUT, format); } /** @@ -1827,7 +1827,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, linkFlagsVar += "_FLAGS"; if( tgt.GetType() == cmTarget::EXECUTABLE ) { - linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar.c_str()); + linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar); linkLibs += " "; } @@ -1836,7 +1836,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, fwSearchFlagVar += linkLanguage; fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG"; const char* fwSearchFlag = - this->Makefile->GetDefinition(fwSearchFlagVar.c_str()); + this->Makefile->GetDefinition(fwSearchFlagVar); if(fwSearchFlag && *fwSearchFlag) { std::vector const& fwDirs = cli.GetFrameworkPaths(); @@ -1844,7 +1844,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, fdi != fwDirs.end(); ++fdi) { frameworkPath += fwSearchFlag; - frameworkPath += this->Convert(fdi->c_str(), NONE, shellFormat, false); + frameworkPath += this->Convert(*fdi, NONE, shellFormat, false); frameworkPath += " "; } } @@ -1854,7 +1854,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, for(std::vector::const_iterator libDir = libDirs.begin(); libDir != libDirs.end(); ++libDir) { - std::string libpath = this->ConvertToOutputForExisting(libDir->c_str(), + std::string libpath = this->ConvertToOutputForExisting(*libDir, START_OUTPUT, shellFormat); linkPath += " " + libPathFlag; @@ -1899,7 +1899,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, ri != runtimeDirs.end(); ++ri) { rpath += cli.GetRuntimeFlag(); - rpath += this->Convert(ri->c_str(), NONE, shellFormat, false); + rpath += this->Convert(*ri, NONE, shellFormat, false); rpath += " "; } fout << rpath; @@ -1913,7 +1913,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, if(!rpath.empty()) { fout << cli.GetRuntimeFlag(); - fout << this->EscapeForShell(rpath.c_str(), escapeAllowMakeVars); + fout << this->EscapeForShell(rpath, escapeAllowMakeVars); fout << " "; } } @@ -1923,7 +1923,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, if(!cli.GetRPathLinkFlag().empty() && !rpath_link.empty()) { fout << cli.GetRPathLinkFlag(); - fout << this->EscapeForShell(rpath_link.c_str(), escapeAllowMakeVars); + fout << this->EscapeForShell(rpath_link, escapeAllowMakeVars); fout << " "; } @@ -1932,7 +1932,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, standardLibsVar += cli.GetLinkLanguage(); standardLibsVar += "_STANDARD_LIBRARIES"; if(const char* stdLibs = - this->Makefile->GetDefinition(standardLibsVar.c_str())) + this->Makefile->GetDefinition(standardLibsVar)) { fout << stdLibs << " "; } @@ -1963,13 +1963,13 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, std::string sysrootFlagVar = std::string("CMAKE_") + lang + "_SYSROOT_FLAG"; const char* sysrootFlag = - this->Makefile->GetDefinition(sysrootFlagVar.c_str()); + this->Makefile->GetDefinition(sysrootFlagVar); const char* deploymentTarget = this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); std::string deploymentTargetFlagVar = std::string("CMAKE_") + lang + "_OSX_DEPLOYMENT_TARGET_FLAG"; const char* deploymentTargetFlag = - this->Makefile->GetDefinition(deploymentTargetFlagVar.c_str()); + this->Makefile->GetDefinition(deploymentTargetFlagVar); if(!archs.empty() && !lang.empty() && (lang[0] =='C' || lang[0] == 'F')) { for(std::vector::iterator i = archs.begin(); @@ -2008,7 +2008,7 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, std::string flagsVar = "CMAKE_"; flagsVar += lang; flagsVar += "_FLAGS"; - this->AddConfigVariableFlags(flags, flagsVar.c_str(), config); + this->AddConfigVariableFlags(flags, flagsVar, config); } //---------------------------------------------------------------------------- @@ -2124,7 +2124,7 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags, flagsVar = "CMAKE_SHARED_LIBRARY_"; flagsVar += lang; flagsVar += "_FLAGS"; - this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str())); + this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar)); } } @@ -2134,14 +2134,14 @@ static void AddVisibilityCompileOption(std::string &flags, cmTarget* target, { std::string l(lang); std::string compileOption = "CMAKE_" + l + "_COMPILE_OPTIONS_VISIBILITY"; - const char *opt = lg->GetMakefile()->GetDefinition(compileOption.c_str()); + const char *opt = lg->GetMakefile()->GetDefinition(compileOption); if (!opt) { return; } std::string flagDefine = l + "_VISIBILITY_PRESET"; - const char *prop = target->GetProperty(flagDefine.c_str()); + const char *prop = target->GetProperty(flagDefine); if (!prop) { return; @@ -2167,7 +2167,7 @@ static void AddInlineVisibilityCompileOption(std::string &flags, { std::string compileOption = "CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN"; - const char *opt = lg->GetMakefile()->GetDefinition(compileOption.c_str()); + const char *opt = lg->GetMakefile()->GetDefinition(compileOption); if (!opt) { return; @@ -2220,7 +2220,7 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, cmTarget* target, if (this->GetShouldUseOldFlags(shared, lang)) { - this->AddSharedFlags(flags, lang.c_str(), shared); + this->AddSharedFlags(flags, lang, shared); } else { @@ -2241,7 +2241,7 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, cmTarget* target, } if (shared) { - this->AppendFeatureOptions(flags, lang.c_str(), "DLL"); + this->AppendFeatureOptions(flags, lang, "DLL"); } } } @@ -2258,7 +2258,7 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared, flagsVar += lang; flagsVar += "_FLAGS"; const char* flags = - this->Makefile->GetSafeDefinition(flagsVar.c_str()); + this->Makefile->GetSafeDefinition(flagsVar); if (flags && flags != originalFlags) { @@ -2303,14 +2303,14 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags, std::string flagsVar = "CMAKE_"; flagsVar += lang; flagsVar += "_COMPILE_OPTIONS_PIE"; - picFlags = this->Makefile->GetSafeDefinition(flagsVar.c_str()); + picFlags = this->Makefile->GetSafeDefinition(flagsVar); } if (!picFlags) { std::string flagsVar = "CMAKE_"; flagsVar += lang; flagsVar += "_COMPILE_OPTIONS_PIC"; - picFlags = this->Makefile->GetSafeDefinition(flagsVar.c_str()); + picFlags = this->Makefile->GetSafeDefinition(flagsVar); } if (picFlags) { @@ -2319,7 +2319,7 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags, for(std::vector::const_iterator oi = options.begin(); oi != options.end(); ++oi) { - this->AppendFlagEscape(flags, oi->c_str()); + this->AppendFlagEscape(flags, *oi); } } } @@ -2331,13 +2331,13 @@ void cmLocalGenerator::AddConfigVariableFlags(std::string& flags, { // Add the flags from the variable itself. std::string flagsVar = var; - this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str())); + this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar)); // Add the flags from the build-type specific variable. if(!config.empty()) { flagsVar += "_"; flagsVar += cmSystemTools::UpperCase(config); - this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str())); + this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar)); } } @@ -2407,7 +2407,7 @@ void cmLocalGenerator::JoinDefines(const std::set& defines, std::string defineFlagVar = "CMAKE_"; defineFlagVar += lang; defineFlagVar += "_DEFINE_FLAG"; - const char* df = this->Makefile->GetDefinition(defineFlagVar.c_str()); + const char* df = this->Makefile->GetDefinition(defineFlagVar); if(df && *df) { dflag = df; @@ -2468,14 +2468,14 @@ void cmLocalGenerator::AppendFeatureOptions( optVar += lang; optVar += "_COMPILE_OPTIONS_"; optVar += feature; - if(const char* optionList = this->Makefile->GetDefinition(optVar.c_str())) + if(const char* optionList = this->Makefile->GetDefinition(optVar)) { std::vector options; cmSystemTools::ExpandListArgument(optionList, options); for(std::vector::const_iterator oi = options.begin(); oi != options.end(); ++oi) { - this->AppendFlagEscape(flags, oi->c_str()); + this->AppendFlagEscape(flags, *oi); } } } @@ -2501,7 +2501,7 @@ cmLocalGenerator::ConstructComment(const cmCustomCommand& cc, o != cc.GetOutputs().end(); ++o) { comment += sep; - comment += this->Convert(o->c_str(), cmLocalGenerator::START_OUTPUT); + comment += this->Convert(*o, cmLocalGenerator::START_OUTPUT); sep = ", "; } return comment; @@ -2556,24 +2556,24 @@ std::string cmLocalGenerator::Convert(const std::string& source, case HOME: //result = cmSystemTools::CollapseFullPath(result.c_str()); result = this->ConvertToRelativePath(this->HomeDirectoryComponents, - result.c_str()); + result); break; case START: //result = cmSystemTools::CollapseFullPath(result.c_str()); result = this->ConvertToRelativePath(this->StartDirectoryComponents, - result.c_str()); + result); break; case HOME_OUTPUT: //result = cmSystemTools::CollapseFullPath(result.c_str()); result = this->ConvertToRelativePath(this->HomeOutputDirectoryComponents, - result.c_str()); + result); break; case START_OUTPUT: //result = cmSystemTools::CollapseFullPath(result.c_str()); result = this->ConvertToRelativePath(this->StartOutputDirectoryComponents, - result.c_str()); + result); break; case FULL: result = cmSystemTools::CollapseFullPath(result.c_str()); @@ -2582,7 +2582,7 @@ std::string cmLocalGenerator::Convert(const std::string& source, break; } } - return this->ConvertToOutputFormat(result.c_str(), output); + return this->ConvertToOutputFormat(result, output); } //---------------------------------------------------------------------------- @@ -2617,11 +2617,11 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const std::string& source, pos++; } } - result = this->EscapeForShell(result.c_str(), true, false); + result = this->EscapeForShell(result, true, false); } else if(output == RESPONSE) { - result = this->EscapeForShell(result.c_str(), false, false); + result = this->EscapeForShell(result, false, false); } return result; } @@ -2642,7 +2642,7 @@ std::string cmLocalGenerator::Convert(RelativeRoot remote, std::vector components; cmSystemTools::SplitPath(local.c_str(), components); std::string result = this->ConvertToRelativePath(components, remotePath); - return this->ConvertToOutputFormat(result.c_str(), output); + return this->ConvertToOutputFormat(result, output); } else { @@ -3150,7 +3150,7 @@ cmLocalGenerator std::string repVar = "CMAKE_"; repVar += lang; repVar += "_OUTPUT_EXTENSION_REPLACE"; - replaceExt = this->Makefile->IsOn(repVar.c_str()); + replaceExt = this->Makefile->IsOn(repVar); } } @@ -3175,7 +3175,7 @@ cmLocalGenerator } // Convert to a safe name. - return this->CreateSafeUniqueObjectFileName(objectName.c_str(), dir_max); + return this->CreateSafeUniqueObjectFileName(objectName, dir_max); } //---------------------------------------------------------------------------- @@ -3470,7 +3470,7 @@ static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, { if(const char* val = target->GetProperty(prop)) { - mf->AddDefinition(prop.c_str(), val); + mf->AddDefinition(prop, val); } } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 862823f..acaacdd 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -146,14 +146,14 @@ std::string cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib, OutputFormat format) { - return this->Convert(lib.c_str(), HOME_OUTPUT, format); + return this->Convert(lib, HOME_OUTPUT, format); } std::string cmLocalNinjaGenerator::ConvertToIncludeReference(std::string const& path, OutputFormat format) { - return this->Convert(path.c_str(), HOME_OUTPUT, format); + return this->Convert(path, HOME_OUTPUT, format); } //---------------------------------------------------------------------------- @@ -310,7 +310,7 @@ void cmLocalNinjaGenerator::AppendCustomCommandDeps(const cmCustomCommand *cc, for (std::vector::const_iterator i = deps.begin(); i != deps.end(); ++i) { std::string dep; - if (this->GetRealDependency(i->c_str(), this->GetConfigName(), dep)) + if (this->GetRealDependency(*i, this->GetConfigName(), dep)) ninjaDeps.push_back(ConvertToNinjaPath(dep.c_str())); } } @@ -382,7 +382,7 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) { cmdLines.push_back(launcher + - this->ConvertToOutputFormat(ccg.GetCommand(i).c_str(), SHELL)); + this->ConvertToOutputFormat(ccg.GetCommand(i), SHELL)); std::string& cmd = cmdLines.back(); ccg.AppendArguments(i, cmd); @@ -493,7 +493,7 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher( RelativeRoot relative_root = cc.GetWorkingDirectory() ? NONE : START_OUTPUT; - output = this->Convert(outputs[0].c_str(), relative_root, SHELL); + output = this->Convert(outputs[0], relative_root, SHELL); } vars.Output = output.c_str(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index f7088c2..5dd2bb1 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -339,7 +339,7 @@ cmLocalUnixMakefileGenerator3 depends.push_back(output); std::vector no_commands; this->WriteMakeRule(ruleFileStream, 0, - outNoExt.c_str(), depends, no_commands, true, true); + outNoExt, depends, no_commands, true, true); inHelp = false; } @@ -355,7 +355,7 @@ cmLocalUnixMakefileGenerator3 targetName += "/"; targetName += output; commands.push_back( - this->GetRecursiveMakeCall(tgtMakefileName.c_str(), targetName.c_str()) + this->GetRecursiveMakeCall(tgtMakefileName.c_str(), targetName) ); } this->CreateCDCommand(commands, @@ -407,12 +407,12 @@ void cmLocalUnixMakefileGenerator3 std::string makefile2 = cmake::GetCMakeFilesDirectoryPostSlash(); makefile2 += "Makefile2"; commands.push_back(this->GetRecursiveMakeCall - (makefile2.c_str(),localName.c_str())); + (makefile2.c_str(),localName)); this->CreateCDCommand(commands, this->Makefile->GetHomeOutputDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "Convenience name for target.", - localName.c_str(), depends, commands, true); + localName, depends, commands, true); // Add a target with the canonical name (no prefix, suffix or path). if(localName != t->second->GetName()) @@ -436,17 +436,17 @@ void cmLocalUnixMakefileGenerator3 depends.clear(); commands.clear(); commands.push_back(this->GetRecursiveMakeCall - (makefileName.c_str(), makeTargetName.c_str())); + (makefileName.c_str(), makeTargetName)); this->CreateCDCommand(commands, this->Makefile->GetHomeOutputDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "fast build rule for target.", - localName.c_str(), depends, commands, true); + localName, depends, commands, true); // Add a local name for the rule to relink the target before // installation. if(t->second->Target - ->NeedRelinkBeforeInstall(this->ConfigurationName.c_str())) + ->NeedRelinkBeforeInstall(this->ConfigurationName)) { makeTargetName = this->GetRelativeTargetDirectory(*t->second->Target); makeTargetName += "/preinstall"; @@ -455,13 +455,13 @@ void cmLocalUnixMakefileGenerator3 depends.clear(); commands.clear(); commands.push_back(this->GetRecursiveMakeCall - (makefile2.c_str(), makeTargetName.c_str())); + (makefile2.c_str(), makeTargetName)); this->CreateCDCommand(commands, this->Makefile->GetHomeOutputDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "Manual pre-install relink rule for target.", - localName.c_str(), depends, commands, true); + localName, depends, commands, true); } } } @@ -582,7 +582,7 @@ cmLocalUnixMakefileGenerator3 // Construct the left hand side of the rule. replace = target; - std::string tgt = this->Convert(replace.c_str(),HOME_OUTPUT,MAKEFILE); + std::string tgt = this->Convert(replace,HOME_OUTPUT,MAKEFILE); const char* space = ""; if(tgt.size() == 1) { @@ -615,7 +615,7 @@ cmLocalUnixMakefileGenerator3 dep != depends.end(); ++dep) { replace = *dep; - replace = this->Convert(replace.c_str(),HOME_OUTPUT,MAKEFILE); + replace = this->Convert(replace,HOME_OUTPUT,MAKEFILE); os << cmMakeSafe(tgt) << space << ": " << cmMakeSafe(replace) << "\n"; } } @@ -654,10 +654,10 @@ cmLocalUnixMakefileGenerator3 std::string scmd; if(cmSystemTools::GetShortPath(cmd.c_str(), scmd)) { - return this->Convert(scmd.c_str(), NONE, SHELL); + return this->Convert(scmd, NONE, SHELL); } } - return this->Convert(cmd.c_str(), root, SHELL); + return this->Convert(cmd, root, SHELL); } //---------------------------------------------------------------------------- @@ -829,7 +829,7 @@ void cmLocalUnixMakefileGenerator3 std::string runRule = "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"; runRule += " --check-build-system "; - runRule += this->Convert(cmakefileName.c_str(),NONE,SHELL); + runRule += this->Convert(cmakefileName,NONE,SHELL); runRule += " 0"; std::vector no_depends; @@ -886,7 +886,7 @@ cmLocalUnixMakefileGenerator3 { std::string dir = this->HomeRelativeOutputPath; dir += this->GetTargetDirectory(target); - return this->Convert(dir.c_str(),NONE,UNCHANGED); + return this->Convert(dir,NONE,UNCHANGED); } @@ -962,7 +962,7 @@ cmLocalUnixMakefileGenerator3 { // Lookup the real name of the dependency in case it is a CMake target. std::string dep; - if(this->GetRealDependency(d->c_str(), this->ConfigurationName.c_str(), + if(this->GetRealDependency(*d, this->ConfigurationName, dep)) { depends.push_back(dep); @@ -1020,7 +1020,7 @@ cmLocalUnixMakefileGenerator3 { *content << dir; } - cmCustomCommandGenerator ccg(cc, this->ConfigurationName.c_str(), + cmCustomCommandGenerator ccg(cc, this->ConfigurationName, this->Makefile); // Add each command line to the set of commands. @@ -1055,7 +1055,7 @@ cmLocalUnixMakefileGenerator3 bool had_slash = cmd.find("/") != cmd.npos; if(!workingDir) { - cmd = this->Convert(cmd.c_str(),START_OUTPUT); + cmd = this->Convert(cmd,START_OUTPUT); } bool has_slash = cmd.find("/") != cmd.npos; if(had_slash && !has_slash) @@ -1141,7 +1141,7 @@ cmLocalUnixMakefileGenerator3::MakeLauncher(const cmCustomCommand& cc, const std::vector& outputs = cc.GetOutputs(); if(!outputs.empty()) { - output = this->Convert(outputs[0].c_str(), relative, SHELL); + output = this->Convert(outputs[0], relative, SHELL); } vars.Output = output.c_str(); @@ -1171,7 +1171,7 @@ cmLocalUnixMakefileGenerator3 cleanfile += filename; } cleanfile += ".cmake"; - std::string cleanfilePath = this->Convert(cleanfile.c_str(), FULL); + std::string cleanfilePath = this->Convert(cleanfile, FULL); cmsys::ofstream fout(cleanfilePath.c_str()); if(!fout) { @@ -1183,13 +1183,13 @@ cmLocalUnixMakefileGenerator3 for(std::vector::const_iterator f = files.begin(); f != files.end(); ++f) { - std::string fc = this->Convert(f->c_str(),START_OUTPUT,UNCHANGED); - fout << " " << this->EscapeForCMake(fc.c_str()) << "\n"; + std::string fc = this->Convert(*f,START_OUTPUT,UNCHANGED); + fout << " " << this->EscapeForCMake(fc) << "\n"; } fout << ")\n"; } std::string remove = "$(CMAKE_COMMAND) -P "; - remove += this->Convert(cleanfile.c_str(), START_OUTPUT, SHELL); + remove += this->Convert(cleanfile, START_OUTPUT, SHELL); commands.push_back(remove); // For the main clean rule add per-language cleaning. @@ -1267,14 +1267,14 @@ cmLocalUnixMakefileGenerator3::AppendEcho(std::vector& commands, { // Use the native echo command. cmd = "@echo "; - cmd += this->EscapeForShell(line.c_str(), false, true); + cmd += this->EscapeForShell(line, false, true); } else { // Use cmake to echo the text in color. cmd = "@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) "; cmd += color_name; - cmd += this->EscapeForShell(line.c_str()); + cmd += this->EscapeForShell(line); } commands.push_back(cmd); } @@ -1588,14 +1588,14 @@ cmLocalUnixMakefileGenerator3 langs.begin(); li != langs.end(); ++li) { // construct the checker - std::string lang = li->c_str(); + std::string lang = *li; // Create the scanner for this language cmDepends *scanner = 0; if(lang == "C" || lang == "CXX" || lang == "RC" || lang == "ASM") { // TODO: Handle RC (resource files) dependencies correctly. - scanner = new cmDependsC(this, targetDir, lang.c_str(), &validDeps); + scanner = new cmDependsC(this, targetDir, lang, &validDeps); } #ifdef CMAKE_BUILD_WITH_CMAKE else if(lang == "Fortran") @@ -1613,7 +1613,7 @@ cmLocalUnixMakefileGenerator3 scanner->SetLocalGenerator(this); scanner->SetFileComparison (this->GlobalGenerator->GetCMakeInstance()->GetFileComparison()); - scanner->SetLanguage(lang.c_str()); + scanner->SetLanguage(lang); scanner->SetTargetDirectory(dir.c_str()); scanner->Write(ruleFileStream, internalRuleFileStream); @@ -1726,7 +1726,7 @@ void cmLocalUnixMakefileGenerator3 dit != glIt->second.GetUtilities().end(); ++ dit ) { - depends.push_back(dit->c_str()); + depends.push_back(*dit); } this->AppendEcho(commands, text, cmLocalUnixMakefileGenerator3::EchoGlobal); @@ -1746,7 +1746,7 @@ void cmLocalUnixMakefileGenerator3 cmLocalGenerator::START_OUTPUT); std::string targetName = glIt->second.GetName(); this->WriteMakeRule(ruleFileStream, targetString.c_str(), - targetName.c_str(), depends, commands, true); + targetName, depends, commands, true); // Provide a "/fast" version of the target. depends.clear(); @@ -1766,7 +1766,7 @@ void cmLocalUnixMakefileGenerator3 } targetName += "/fast"; this->WriteMakeRule(ruleFileStream, targetString.c_str(), - targetName.c_str(), depends, commands, true); + targetName, depends, commands, true); } } @@ -1786,15 +1786,15 @@ void cmLocalUnixMakefileGenerator3 cmOStringStream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; - progCmd << this->Convert(progressDir.c_str(), + progCmd << this->Convert(progressDir, cmLocalGenerator::FULL, cmLocalGenerator::SHELL); std::string progressFile = cmake::GetCMakeFilesDirectory(); progressFile += "/progress.marks"; std::string progressFileNameFull = - this->ConvertToFullPath(progressFile.c_str()); - progCmd << " " << this->Convert(progressFileNameFull.c_str(), + this->ConvertToFullPath(progressFile); + progCmd << " " << this->Convert(progressFileNameFull, cmLocalGenerator::FULL, cmLocalGenerator::SHELL); commands.push_back(progCmd.str()); @@ -1802,14 +1802,14 @@ void cmLocalUnixMakefileGenerator3 std::string mf2Dir = cmake::GetCMakeFilesDirectoryPostSlash(); mf2Dir += "Makefile2"; commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(), - recursiveTarget.c_str())); + recursiveTarget)); this->CreateCDCommand(commands, this->Makefile->GetHomeOutputDirectory(), cmLocalGenerator::START_OUTPUT); { cmOStringStream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0 - progCmd << this->Convert(progressDir.c_str(), + progCmd << this->Convert(progressDir, cmLocalGenerator::FULL, cmLocalGenerator::SHELL); progCmd << " 0"; @@ -1824,7 +1824,7 @@ void cmLocalUnixMakefileGenerator3 commands.clear(); depends.clear(); commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(), - recursiveTarget.c_str())); + recursiveTarget)); this->CreateCDCommand(commands, this->Makefile->GetHomeOutputDirectory(), cmLocalGenerator::START_OUTPUT); @@ -1854,7 +1854,7 @@ void cmLocalUnixMakefileGenerator3 depends.push_back("cmake_check_build_system"); } commands.push_back - (this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget.c_str())); + (this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); this->CreateCDCommand(commands, this->Makefile->GetHomeOutputDirectory(), cmLocalGenerator::START_OUTPUT); @@ -1872,7 +1872,7 @@ void cmLocalUnixMakefileGenerator3 std::string runRule = "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"; runRule += " --check-build-system "; - runRule += this->Convert(cmakefileName.c_str(),cmLocalGenerator::NONE, + runRule += this->Convert(cmakefileName,cmLocalGenerator::NONE, cmLocalGenerator::SHELL); runRule += " 1"; commands.push_back(runRule); @@ -1905,7 +1905,7 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf, for(std::vector::iterator l = files.begin(); l != files.end(); ++l) { - std::string dir = cmSystemTools::GetFilenamePath(l->c_str()); + std::string dir = cmSystemTools::GetFilenamePath(*l); // Clear the implicit dependency makefile. std::string dependFile = dir + "/depend.make"; @@ -1964,7 +1964,7 @@ void cmLocalUnixMakefileGenerator3 std::string cidVar = "CMAKE_"; cidVar += l->first; cidVar += "_COMPILER_ID"; - const char* cid = this->Makefile->GetDefinition(cidVar.c_str()); + const char* cid = this->Makefile->GetDefinition(cidVar); if(cid && *cid) { cmakefileStream @@ -1976,7 +1976,7 @@ void cmLocalUnixMakefileGenerator3 // Build a list of preprocessor definitions for the target. std::set defines; this->AddCompileDefinitions(defines, &target, - this->ConfigurationName.c_str()); + this->ConfigurationName); if(!defines.empty()) { cmakefileStream @@ -1987,7 +1987,7 @@ void cmLocalUnixMakefileGenerator3 di != defines.end(); ++di) { cmakefileStream - << " " << this->EscapeForCMake(di->c_str()) << "\n"; + << " " << this->EscapeForCMake(*di) << "\n"; } cmakefileStream << " )\n"; @@ -2013,7 +2013,7 @@ void cmLocalUnixMakefileGenerator3 for(std::vector::const_iterator tri = transformRules.begin(); tri != transformRules.end(); ++tri) { - cmakefileStream << " " << this->EscapeForCMake(tri->c_str()) << "\n"; + cmakefileStream << " " << this->EscapeForCMake(*tri) << "\n"; } cmakefileStream << " )\n"; @@ -2070,12 +2070,12 @@ cmLocalUnixMakefileGenerator3 // Escape one extra time if the make tool requires it. if(this->MakeCommandEscapeTargetTwice) { - tgt2 = this->EscapeForShell(tgt2.c_str(), true, false); + tgt2 = this->EscapeForShell(tgt2, true, false); } // The target name is now a string that should be passed verbatim // on the command line. - cmd += this->EscapeForShell(tgt2.c_str(), true, false); + cmd += this->EscapeForShell(tgt2, true, false); } return cmd; } diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 9d253b8..9f569e1 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -95,7 +95,7 @@ bool cmMacroHelperCommand::InvokeInitialPass std::string errorMsg = "Macro invoked with incorrect arguments for macro named: "; errorMsg += this->Args[0]; - this->SetError(errorMsg.c_str()); + this->SetError(errorMsg); return false; } @@ -276,8 +276,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, f->Functions = this->Functions; mf.RecordPolicies(f->Policies); std::string newName = "_" + this->Args[0]; - mf.GetCMakeInstance()->RenameCommand(this->Args[0].c_str(), - newName.c_str()); + mf.GetCMakeInstance()->RenameCommand(this->Args[0], + newName); mf.AddCommand(f); // remove the function blocker now that the macro is defined diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx index 03ad37c..52832db 100644 --- a/Source/cmMakeDepend.cxx +++ b/Source/cmMakeDepend.cxx @@ -74,7 +74,7 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile) cmGeneratorExpression::StripAllGeneratorExpressions); std::vector includes; - cmSystemTools::ExpandListArgument(incDirs.c_str(), includes); + cmSystemTools::ExpandListArgument(incDirs, includes); for(std::vector::const_iterator j = includes.begin(); j != includes.end(); ++j) @@ -93,7 +93,7 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile) it != orderedAndUniqueIncludes.end(); ++it) { - this->AddSearchPath(it->c_str()); + this->AddSearchPath(*it); } } @@ -165,7 +165,7 @@ void cmMakeDepend::GenerateDependInformation(cmDependInformation* info) { // Try to find the file amongst the sources cmSourceFile *srcFile = this->Makefile->GetSource - (cmSystemTools::GetFilenameWithoutExtension(path).c_str()); + (cmSystemTools::GetFilenameWithoutExtension(path)); if (srcFile) { if (srcFile->GetFullPath() == path) @@ -281,7 +281,7 @@ cmDependInformation* cmMakeDepend::GetDependInformation(const char* file, // Didn't find an instance. Create a new one and save it. cmDependInformation* info = new cmDependInformation; info->FullPath = fullPath; - info->PathOnly = cmSystemTools::GetFilenamePath(fullPath.c_str()); + info->PathOnly = cmSystemTools::GetFilenamePath(fullPath); info->IncludeName = file; this->DependInformationMap[fullPath] = info; return info; diff --git a/Source/cmMakeDirectoryCommand.cxx b/Source/cmMakeDirectoryCommand.cxx index 63be627..cc871c9 100644 --- a/Source/cmMakeDirectoryCommand.cxx +++ b/Source/cmMakeDirectoryCommand.cxx @@ -24,7 +24,7 @@ bool cmMakeDirectoryCommand { std::string e = "attempted to create a directory: " + args[0] + " into a source directory."; - this->SetError(e.c_str()); + this->SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 92177c8..6fef371 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -330,7 +330,7 @@ void cmMakefile::IssueMessage(cmake::MessageType t, lfc.Line = 0; if(!this->GetCMakeInstance()->GetIsInTryCompile()) { - lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath.c_str(), + lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath, cmLocalGenerator::HOME); } backtrace.push_back(lfc); @@ -351,7 +351,7 @@ bool cmMakefile::GetBacktrace(cmListFileBacktrace& backtrace) const i != this->CallStack.rend(); ++i) { cmListFileContext lfc = *(*i).Context; - lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath.c_str(), + lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath, cmLocalGenerator::HOME); backtrace.push_back(lfc); } @@ -394,7 +394,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, static_cast(stack_manager); // Lookup the command prototype. - if(cmCommand* proto = this->GetCMakeInstance()->GetCommand(name.c_str())) + if(cmCommand* proto = this->GetCMakeInstance()->GetCommand(name)) { // Clone the prototype. cmsys::auto_ptr pcmd(proto->Clone()); @@ -756,7 +756,7 @@ void cmMakefile::EnforceDirectoryLevelRules() const case cmPolicies::WARN: // Warn because the user did not provide a mimimum required // version. - this->IssueMessage(cmake::AUTHOR_WARNING, msg.str().c_str()); + this->IssueMessage(cmake::AUTHOR_WARNING, msg.str()); case cmPolicies::OLD: // OLD behavior is to use policy version 2.4 set in // cmListFileCache. @@ -765,7 +765,7 @@ void cmMakefile::EnforceDirectoryLevelRules() const case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::NEW: // NEW behavior is to issue an error. - this->IssueMessage(cmake::FATAL_ERROR, msg.str().c_str()); + this->IssueMessage(cmake::FATAL_ERROR, msg.str()); cmSystemTools::SetFatalErrorOccured(); return; } @@ -912,7 +912,7 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target, e << (this->GetPolicies() ->GetPolicyWarning(cmPolicies::CMP0040)) << "\n"; e << "The target name \"" << target << "\" is unknown in this context."; - IssueMessage(messageType, e.str().c_str()); + IssueMessage(messageType, e.str()); } return; @@ -1018,7 +1018,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector& outputs, std::string outName = gg->GenerateRuleFile(outputs[0]); // Check if the rule file already exists. - file = this->GetSource(outName.c_str()); + file = this->GetSource(outName); if(file && file->GetCustomCommand() && !replace) { // The rule file already exists. @@ -1032,7 +1032,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector& outputs, } // Create a cmSourceFile for the rule file. - file = this->GetOrCreateSource(outName.c_str(), true); + file = this->GetOrCreateSource(outName, true); file->SetProperty("__CMAKE_RULE", "1"); } @@ -1040,7 +1040,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector& outputs, for(std::vector::const_iterator o = outputs.begin(); o != outputs.end(); ++o) { - if(cmSourceFile* out = this->GetOrCreateSource(o->c_str(), true)) + if(cmSourceFile* out = this->GetOrCreateSource(*o, true)) { out->SetProperty("GENERATED", "1"); } @@ -1253,12 +1253,12 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName, force += utilityName; std::string no_main_dependency = ""; bool no_replace = false; - this->AddCustomCommandToOutput(force.c_str(), depends, + this->AddCustomCommandToOutput(force, depends, no_main_dependency, commandLines, comment, workingDirectory, no_replace, escapeOldStyle); - cmSourceFile* sf = target->AddSource(force.c_str()); + cmSourceFile* sf = target->AddSource(force); // The output is not actually created so mark it symbolic. if(sf) @@ -1486,7 +1486,7 @@ void cmMakefile::AddLinkLibraryForTarget(const std::string& target, << " may not be linked into another target. " << "One may link only to STATIC or SHARED libraries, or " << "to executables with the ENABLE_EXPORTS property set."; - this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->IssueMessage(cmake::FATAL_ERROR, e.str()); } } i->second.AddLinkLibrary( *this, target, lib, llt ); @@ -1497,7 +1497,7 @@ void cmMakefile::AddLinkLibraryForTarget(const std::string& target, e << "Attempt to add link library \"" << lib << "\" to target \"" << target << "\" which is not built in this directory."; - this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->IssueMessage(cmake::FATAL_ERROR, e.str()); } } @@ -1512,7 +1512,7 @@ void cmMakefile::AddLinkDirectoryForTarget(const std::string& target, cmOStringStream e; e << "ALIAS target \"" << target << "\" " << "may not be linked into another target."; - this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } i->second.AddLinkDirectory( d ); @@ -1605,8 +1605,8 @@ void cmMakefile::InitializeFromParent() { std::string defPropName = "COMPILE_DEFINITIONS_"; defPropName += cmSystemTools::UpperCase(*ci); - const char* prop = parent->GetProperty(defPropName.c_str()); - this->SetProperty(defPropName.c_str(), prop); + const char* prop = parent->GetProperty(defPropName); + this->SetProperty(defPropName, prop); } } @@ -1670,7 +1670,7 @@ void cmMakefile::AddSubDirectory(const std::string& sub, } - this->AddSubDirectory(srcPath.c_str(), binPath.c_str(), + this->AddSubDirectory(srcPath, binPath, excludeFromAll, preorder, false); } @@ -1873,7 +1873,7 @@ void cmMakefile::CheckForUnusedVariables() const std::set::const_iterator it = locals.begin(); for (; it != locals.end(); ++it) { - this->CheckForUnused("out of scope", it->c_str()); + this->CheckForUnused("out of scope", *it); } } @@ -1935,7 +1935,7 @@ void cmMakefile::CheckForUnused(const char* reason, cmOStringStream msg; msg << "unused variable (" << reason << ") \'" << name << "\'"; this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, - msg.str().c_str(), + msg.str(), bt); } } @@ -1988,7 +1988,7 @@ void cmMakefile::AddGlobalLinkInformation(const std::string& name, for(j = this->LinkDirectories.begin(); j != this->LinkDirectories.end(); ++j) { - target.AddLinkDirectory(j->c_str()); + target.AddLinkDirectory(*j); } target.MergeLinkLibraries( *this, name, this->LinkLibraries ); } @@ -2101,7 +2101,7 @@ cmSourceFile *cmMakefile::GetSourceFileWithOutput( // linear-time search for an output with a matching suffix. if(!cmSystemTools::FileIsFullPath(name.c_str())) { - return LinearGetSourceFileWithOutput(name.c_str()); + return LinearGetSourceFileWithOutput(name); } // Otherwise we use an efficient lookup map. OutputToSourceMap::const_iterator o = this->OutputToSource.find(name); @@ -2199,7 +2199,7 @@ void cmMakefile::AddSourceGroup(const std::vector& name, { std::string guidName = "SG_Filter_"; guidName += fullname; - gg->CreateGUID(guidName.c_str()); + gg->CreateGUID(guidName); } for(++i; i<=lastElement; ++i) { @@ -2210,7 +2210,7 @@ void cmMakefile::AddSourceGroup(const std::vector& name, { std::string guidName = "SG_Filter_"; guidName += fullname; - gg->CreateGUID(guidName.c_str()); + gg->CreateGUID(guidName); } } @@ -2369,7 +2369,7 @@ const char* cmMakefile::GetSONameFlag(const std::string& language) const name += language; } name += "_FLAG"; - return GetDefinition(name.c_str()); + return GetDefinition(name); } bool cmMakefile::CanIWriteThisFile(const char* fileName) const @@ -2564,7 +2564,7 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source, // Lookup the definition of VAR. std::string var(first+1, last-first-2); - if(const char* val = this->GetDefinition(var.c_str())) + if(const char* val = this->GetDefinition(var)) { // Store the value in the output escaping as requested. if(escapeQuotes) @@ -2999,7 +2999,7 @@ void cmMakefile::SetArgcArgv(const std::vector& args) { cmOStringStream tmpStream; tmpStream << "CMAKE_ARGV" << t; - this->AddDefinition(tmpStream.str().c_str(), args[t].c_str()); + this->AddDefinition(tmpStream.str(), args[t].c_str()); //this->MarkVariableAsUsed(tmpStream.str().c_str()); } } @@ -3007,7 +3007,7 @@ void cmMakefile::SetArgcArgv(const std::vector& args) //---------------------------------------------------------------------------- cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const { - cmSourceFileLocation sfl(this, sourceName.c_str()); + cmSourceFileLocation sfl(this, sourceName); for(std::vector::const_iterator sfi = this->SourceFiles.begin(); sfi != this->SourceFiles.end(); ++sfi) @@ -3031,7 +3031,7 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName, } else { - cmSourceFile* sf = new cmSourceFile(this, sourceName.c_str()); + cmSourceFile* sf = new cmSourceFile(this, sourceName); if(generated) { sf->SetProperty("GENERATED", "1"); @@ -3396,7 +3396,7 @@ void cmMakefile::ConfigureString(const std::string& input, if(this->cmDefineRegex.find(line)) { const char* def = - this->GetDefinition(this->cmDefineRegex.match(1).c_str()); + this->GetDefinition(this->cmDefineRegex.match(1)); if(!cmSystemTools::IsOff(def)) { cmSystemTools::ReplaceString(line, "#cmakedefine", "#define"); @@ -3412,7 +3412,7 @@ void cmMakefile::ConfigureString(const std::string& input, else if(this->cmDefine01Regex.find(line)) { const char* def = - this->GetDefinition(this->cmDefine01Regex.match(1).c_str()); + this->GetDefinition(this->cmDefine01Regex.match(1)); cmSystemTools::ReplaceString(line, "#cmakedefine01", "#define"); output += line; if(!cmSystemTools::IsOff(def)) @@ -3650,7 +3650,7 @@ void cmMakefile::AppendProperty(const std::string& prop, for(std::vector::const_iterator vi = varArgsExpanded.begin(); vi != varArgsExpanded.end(); ++vi) { - this->AddLinkDirectory(vi->c_str()); + this->AddLinkDirectory(*vi); } return; } @@ -3816,7 +3816,7 @@ const char* cmMakefile::GetFeature(const std::string& feature, std::string featureConfig = feature; featureConfig += "_"; featureConfig += cmSystemTools::UpperCase(config); - if(const char* value = this->GetProperty(featureConfig.c_str())) + if(const char* value = this->GetProperty(featureConfig)) { return value; } @@ -3862,7 +3862,7 @@ cmTest* cmMakefile::CreateTest(const std::string& testName) return test; } test = new cmTest(this); - test->SetName(testName.c_str()); + test->SetName(testName); this->Tests[testName] = test; return test; } @@ -3951,9 +3951,9 @@ void cmMakefile::PopScope() for (; it != locals.end(); ++it) { init.erase(*it); - if (!this->VariableUsed(it->c_str())) + if (!this->VariableUsed(*it)) { - this->CheckForUnused("out of scope", it->c_str()); + this->CheckForUnused("out of scope", *it); } else { @@ -3987,10 +3987,10 @@ void cmMakefile::RaiseScope(const std::string& var, const char *varDef) if(cmDefinitions* up = cur.GetParent()) { // First localize the definition in the current scope. - cur.Get(var.c_str()); + cur.Get(var); // Now update the definition in the parent scope. - up->Set(var.c_str(), varDef); + up->Set(var, varDef); } else if(cmLocalGenerator* plg = this->LocalGenerator->GetParent()) { @@ -4000,11 +4000,11 @@ void cmMakefile::RaiseScope(const std::string& var, const char *varDef) cmMakefile* parent = plg->GetMakefile(); if (varDef) { - parent->AddDefinition(var.c_str(), varDef); + parent->AddDefinition(var, varDef); } else { - parent->RemoveDefinition(var.c_str()); + parent->RemoveDefinition(var); } } else @@ -4074,7 +4074,7 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name, } // Look for a target built in this project. - return this->LocalGenerator->GetGlobalGenerator()->FindTarget(name.c_str(), + return this->LocalGenerator->GetGlobalGenerator()->FindTarget(name, excludeAliases); } @@ -4084,7 +4084,7 @@ bool cmMakefile::IsAlias(const std::string& name) const if (this->AliasTargets.find(name) != this->AliasTargets.end()) return true; return this->GetLocalGenerator()->GetGlobalGenerator()->IsAlias( - name.c_str()); + name); } //---------------------------------------------------------------------------- @@ -4330,7 +4330,7 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, { std::string msg = this->GetPolicies()->GetRequiredAlwaysPolicyError(id); - this->IssueMessage(cmake::FATAL_ERROR, msg.c_str()); + this->IssueMessage(cmake::FATAL_ERROR, msg); return false; } diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index ca8ff06..a61005b 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -142,20 +142,20 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string targetFullPathPDB = pdbOutputPath + targetNamePDB; std::string targetFullPathImport = outpathImp + targetNameImport; std::string targetOutPathPDB = - this->Convert(targetFullPathPDB.c_str(), + this->Convert(targetFullPathPDB, cmLocalGenerator::NONE, cmLocalGenerator::SHELL); // Convert to the output path to use in constructing commands. std::string targetOutPath = - this->Convert(targetFullPath.c_str(), + this->Convert(targetFullPath, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); std::string targetOutPathReal = - this->Convert(targetFullPathReal.c_str(), + this->Convert(targetFullPathReal, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); std::string targetOutPathImport = - this->Convert(targetFullPathImport.c_str(), + this->Convert(targetFullPathImport, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); @@ -210,7 +210,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) export_flag_var += linkLanguage; export_flag_var += "_FLAG"; this->LocalGenerator->AppendFlags - (linkFlags, this->Makefile->GetDefinition(export_flag_var.c_str())); + (linkFlags, this->Makefile->GetDefinition(export_flag_var)); } // Add language feature flags. @@ -225,14 +225,14 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string linkFlagsConfig = "LINK_FLAGS_"; linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName); this->LocalGenerator->AppendFlags - (linkFlags, this->Target->GetProperty(linkFlagsConfig.c_str())); + (linkFlags, this->Target->GetProperty(linkFlagsConfig)); this->AddModuleDefinitionFlag(linkFlags); // Construct a list of files associated with this executable that // may need to be cleaned. std::vector exeCleanFiles; - exeCleanFiles.push_back(this->Convert(targetFullPath.c_str(), + exeCleanFiles.push_back(this->Convert(targetFullPath, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); #ifdef _WIN32 @@ -244,19 +244,19 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) #endif if(targetNameReal != targetName) { - exeCleanFiles.push_back(this->Convert(targetFullPathReal.c_str(), + exeCleanFiles.push_back(this->Convert(targetFullPathReal, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); } if(!targetNameImport.empty()) { - exeCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(), + exeCleanFiles.push_back(this->Convert(targetFullPathImport, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); std::string implib; if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib)) { - exeCleanFiles.push_back(this->Convert(implib.c_str(), + exeCleanFiles.push_back(this->Convert(implib, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); } @@ -266,7 +266,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // cleaned. We do not want to delete the .pdb file just before // linking the target. this->CleanFiles.push_back - (this->Convert(targetFullPathPDB.c_str(), + (this->Convert(targetFullPathPDB, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); @@ -289,7 +289,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_LINK_EXECUTABLE"; - std::string linkRule = this->GetLinkRule(linkRuleVar.c_str()); + std::string linkRule = this->GetLinkRule(linkRuleVar); std::vector commands1; cmSystemTools::ExpandListArgument(linkRule, real_link_commands); if(this->Target->IsExecutableWithExports()) @@ -300,7 +300,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) implibRuleVar += linkLanguage; implibRuleVar += "_CREATE_IMPORT_LIBRARY"; if(const char* rule = - this->Makefile->GetDefinition(implibRuleVar.c_str())) + this->Makefile->GetDefinition(implibRuleVar)) { cmSystemTools::ExpandListArgument(rule, real_link_commands); } @@ -312,7 +312,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string responseVar = "CMAKE_"; responseVar += linkLanguage; responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS"; - if(this->Makefile->IsOn(responseVar.c_str())) + if(this->Makefile->IsOn(responseVar)) { useResponseFileForObjects = true; } @@ -324,7 +324,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string responseVar = "CMAKE_"; responseVar += linkLanguage; responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES"; - if(this->Makefile->IsOn(responseVar.c_str())) + if(this->Makefile->IsOn(responseVar)) { useResponseFileForLibs = true; } @@ -351,7 +351,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) vars.Language = linkLanguage.c_str(); vars.Objects = buildObjs.c_str(); std::string objectDir = this->Target->GetSupportDirectory(); - objectDir = this->Convert(objectDir.c_str(), + objectDir = this->Convert(objectDir, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); vars.ObjectDir = objectDir.c_str(); @@ -437,7 +437,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Write the build rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - targetFullPathReal.c_str(), + targetFullPathReal, depends, commands, false); // The symlink name for the target should depend on the real target @@ -447,14 +447,14 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) { depends.clear(); commands.clear(); - depends.push_back(targetFullPathReal.c_str()); + depends.push_back(targetFullPathReal); this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - targetFullPath.c_str(), + targetFullPath, depends, commands, false); } // Write the main driver rule to build everything in this target. - this->WriteTargetDriverRule(targetFullPath.c_str(), relink); + this->WriteTargetDriverRule(targetFullPath, relink); // Clean all the possible executable names and symlinks. this->CleanFiles.insert(this->CleanFiles.end(), diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index d9425e6..02469d1 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -125,7 +125,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() depends, commands, true); // Write the main driver rule to build everything in this target. - this->WriteTargetDriverRule(this->Target->GetName().c_str(), false); + this->WriteTargetDriverRule(this->Target->GetName(), false); } //---------------------------------------------------------------------------- @@ -138,7 +138,7 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() linkRuleVar += "_CREATE_STATIC_LIBRARY"; if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION") && - this->Makefile->GetDefinition((linkRuleVar+"_IPO").c_str())) + this->Makefile->GetDefinition(linkRuleVar+"_IPO")) { linkRuleVar += "_IPO"; } @@ -146,7 +146,7 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() std::string extraFlags; this->LocalGenerator->GetStaticLibraryFlags(extraFlags, cmSystemTools::UpperCase(this->ConfigName), this->Target); - this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), false); + this->WriteLibraryRules(linkRuleVar, extraFlags, false); } //---------------------------------------------------------------------------- @@ -169,13 +169,13 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) std::string linkFlagsConfig = "LINK_FLAGS_"; linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName); this->LocalGenerator->AppendFlags - (extraFlags, this->Target->GetProperty(linkFlagsConfig.c_str())); + (extraFlags, this->Target->GetProperty(linkFlagsConfig)); this->LocalGenerator->AddConfigVariableFlags (extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName); this->AddModuleDefinitionFlag(extraFlags); - this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink); + this->WriteLibraryRules(linkRuleVar, extraFlags, relink); } //---------------------------------------------------------------------------- @@ -193,12 +193,12 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) std::string linkFlagsConfig = "LINK_FLAGS_"; linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName); this->LocalGenerator->AppendFlags - (extraFlags, this->Target->GetProperty(linkFlagsConfig.c_str())); + (extraFlags, this->Target->GetProperty(linkFlagsConfig)); this->LocalGenerator->AddConfigVariableFlags (extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->ConfigName); this->AddModuleDefinitionFlag(extraFlags); - this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink); + this->WriteLibraryRules(linkRuleVar, extraFlags, relink); } //---------------------------------------------------------------------------- @@ -216,11 +216,11 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) std::string linkFlagsConfig = "LINK_FLAGS_"; linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName); this->LocalGenerator->AppendFlags - (extraFlags, this->Target->GetProperty(linkFlagsConfig.c_str())); + (extraFlags, this->Target->GetProperty(linkFlagsConfig)); this->LocalGenerator->AddConfigVariableFlags (extraFlags, "CMAKE_MACOSX_FRAMEWORK_LINKER_FLAGS", this->ConfigName); - this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink); + this->WriteLibraryRules(linkRuleVar, extraFlags, relink); } //---------------------------------------------------------------------------- @@ -326,19 +326,19 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Construct the output path version of the names for use in command // arguments. std::string targetOutPathPDB = - this->Convert(targetFullPathPDB.c_str(),cmLocalGenerator::NONE, + this->Convert(targetFullPathPDB,cmLocalGenerator::NONE, cmLocalGenerator::SHELL); std::string targetOutPath = - this->Convert(targetFullPath.c_str(),cmLocalGenerator::START_OUTPUT, + this->Convert(targetFullPath,cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); std::string targetOutPathSO = - this->Convert(targetFullPathSO.c_str(),cmLocalGenerator::START_OUTPUT, + this->Convert(targetFullPathSO,cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); std::string targetOutPathReal = - this->Convert(targetFullPathReal.c_str(),cmLocalGenerator::START_OUTPUT, + this->Convert(targetFullPathReal,cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); std::string targetOutPathImport = - this->Convert(targetFullPathImport.c_str(),cmLocalGenerator::START_OUTPUT, + this->Convert(targetFullPathImport,cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); if(!this->NoRuleMessages) @@ -382,31 +382,31 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Clean files associated with this library. std::vector libCleanFiles; - libCleanFiles.push_back(this->Convert(targetFullPath.c_str(), + libCleanFiles.push_back(this->Convert(targetFullPath, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); if(targetNameReal != targetName) { - libCleanFiles.push_back(this->Convert(targetFullPathReal.c_str(), + libCleanFiles.push_back(this->Convert(targetFullPathReal, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); } if(targetNameSO != targetName && targetNameSO != targetNameReal) { - libCleanFiles.push_back(this->Convert(targetFullPathSO.c_str(), + libCleanFiles.push_back(this->Convert(targetFullPathSO, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); } if(!targetNameImport.empty()) { - libCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(), + libCleanFiles.push_back(this->Convert(targetFullPathImport, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); std::string implib; if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib)) { - libCleanFiles.push_back(this->Convert(implib.c_str(), + libCleanFiles.push_back(this->Convert(implib, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); } @@ -416,7 +416,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // cleaned. We do not want to delete the .pdb file just before // linking the target. this->CleanFiles.push_back - (this->Convert(targetFullPathPDB.c_str(), + (this->Convert(targetFullPathPDB, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); @@ -467,7 +467,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string responseVar = "CMAKE_"; responseVar += linkLanguage; responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS"; - if(this->Makefile->IsOn(responseVar.c_str())) + if(this->Makefile->IsOn(responseVar)) { useResponseFileForObjects = true; } @@ -479,7 +479,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string responseVar = "CMAKE_"; responseVar += linkLanguage; responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES"; - if(this->Makefile->IsOn(responseVar.c_str())) + if(this->Makefile->IsOn(responseVar)) { useResponseFileForLibs = true; } @@ -498,21 +498,21 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string arCreateVar = "CMAKE_"; arCreateVar += linkLanguage; arCreateVar += "_ARCHIVE_CREATE"; - if(const char* rule = this->Makefile->GetDefinition(arCreateVar.c_str())) + if(const char* rule = this->Makefile->GetDefinition(arCreateVar)) { cmSystemTools::ExpandListArgument(rule, archiveCreateCommands); } std::string arAppendVar = "CMAKE_"; arAppendVar += linkLanguage; arAppendVar += "_ARCHIVE_APPEND"; - if(const char* rule = this->Makefile->GetDefinition(arAppendVar.c_str())) + if(const char* rule = this->Makefile->GetDefinition(arAppendVar)) { cmSystemTools::ExpandListArgument(rule, archiveAppendCommands); } std::string arFinishVar = "CMAKE_"; arFinishVar += linkLanguage; arFinishVar += "_ARCHIVE_FINISH"; - if(const char* rule = this->Makefile->GetDefinition(arFinishVar.c_str())) + if(const char* rule = this->Makefile->GetDefinition(arFinishVar)) { cmSystemTools::ExpandListArgument(rule, archiveFinishCommands); } @@ -580,7 +580,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules vars.Language = linkLanguage.c_str(); vars.Objects = buildObjs.c_str(); std::string objectDir = this->Target->GetSupportDirectory(); - objectDir = this->Convert(objectDir.c_str(), + objectDir = this->Convert(objectDir, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); vars.ObjectDir = objectDir.c_str(); @@ -611,7 +611,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules { // Convert to a path for the native build tool. install_name_dir = - this->LocalGenerator->Convert(install_name_dir.c_str(), + this->LocalGenerator->Convert(install_name_dir, cmLocalGenerator::NONE, cmLocalGenerator::SHELL, false); vars.TargetInstallNameDir = install_name_dir.c_str(); @@ -745,7 +745,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Write the build rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - targetFullPathReal.c_str(), + targetFullPathReal, depends, commands, false); // Some targets have more than one output file. Create rules to @@ -764,7 +764,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } // Write the main driver rule to build everything in this target. - this->WriteTargetDriverRule(targetFullPath.c_str(), relink); + this->WriteTargetDriverRule(targetFullPath, relink); // Clean all the possible library names and symlinks. this->CleanFiles.insert(this->CleanFiles.end(), @@ -783,7 +783,7 @@ cmMakefileLibraryTargetGenerator fvar += "_OSX_"; fvar += name; fvar += "_VERSION_FLAG"; - const char* flag = this->Makefile->GetDefinition(fvar.c_str()); + const char* flag = this->Makefile->GetDefinition(fvar); // Skip if no such flag. if(!flag) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 28a8f04..0730bc3 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -167,7 +167,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() o != outputs.end(); ++o) { this->CleanFiles.push_back - (this->Convert(o->c_str(), + (this->Convert(*o, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); } @@ -216,7 +216,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() *this->BuildFileStream << "# Include any dependencies generated for this target.\n" << this->LocalGenerator->IncludeDirective << " " << root - << this->Convert(dependFileNameFull.c_str(), + << this->Convert(dependFileNameFull, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE) << "\n\n"; @@ -227,7 +227,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() *this->BuildFileStream << "# Include the progress variables for this target.\n" << this->LocalGenerator->IncludeDirective << " " << root - << this->Convert(this->ProgressFileNameFull.c_str(), + << this->Convert(this->ProgressFileNameFull, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE) << "\n\n"; @@ -260,7 +260,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() *this->BuildFileStream << "# Include the compile flags for this target's objects.\n" << this->LocalGenerator->IncludeDirective << " " << root - << this->Convert(this->FlagFileNameFull.c_str(), + << this->Convert(this->FlagFileNameFull, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE) << "\n\n"; @@ -329,7 +329,7 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) // Add preprocessor definitions for this target and configuration. this->LocalGenerator->AddCompileDefinitions(defines, this->Target, - this->LocalGenerator->ConfigurationName.c_str()); + this->LocalGenerator->ConfigurationName); std::string definesString; this->LocalGenerator->JoinDefines(defines, definesString, lang); @@ -354,7 +354,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() compiler += *l; compiler += "_COMPILER"; *this->FlagFileStream << "# compile " << l->c_str() << " with " << - this->Makefile->GetSafeDefinition(compiler.c_str()) << "\n"; + this->Makefile->GetSafeDefinition(compiler) << "\n"; } for(std::set::const_iterator l = languages.begin(); @@ -389,9 +389,9 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() output += "/"; output += cmSystemTools::GetFilenameName(input); this->Generator->CleanFiles.push_back( - this->Generator->Convert(output.c_str(), + this->Generator->Convert(output, cmLocalGenerator::START_OUTPUT)); - output = this->Generator->Convert(output.c_str(), + output = this->Generator->Convert(output, cmLocalGenerator::HOME_OUTPUT); // Create a rule to copy the content into the bundle. @@ -404,17 +404,17 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() commands, copyEcho.c_str(), cmLocalUnixMakefileGenerator3::EchoBuild); std::string copyCommand = "$(CMAKE_COMMAND) -E copy "; - copyCommand += this->Generator->Convert(input.c_str(), + copyCommand += this->Generator->Convert(input, cmLocalGenerator::NONE, cmLocalGenerator::SHELL); copyCommand += " "; - copyCommand += this->Generator->Convert(output.c_str(), + copyCommand += this->Generator->Convert(output, cmLocalGenerator::NONE, cmLocalGenerator::SHELL); commands.push_back(copyCommand); this->Generator->LocalGenerator->WriteMakeRule( *this->Generator->BuildFileStream, 0, - output.c_str(), + output, depends, commands, false); this->Generator->ExtraFiles.insert(output); } @@ -457,7 +457,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) // Create the directory containing the object file. This may be a // subdirectory under the target's directory. - std::string dir = cmSystemTools::GetFilenamePath(obj.c_str()); + std::string dir = cmSystemTools::GetFilenamePath(obj); cmSystemTools::MakeDirectory (this->LocalGenerator->ConvertToFullPath(dir).c_str()); @@ -483,9 +483,9 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) objFullPath += "/"; objFullPath += obj; objFullPath = - this->Convert(objFullPath.c_str(), cmLocalGenerator::FULL); + this->Convert(objFullPath, cmLocalGenerator::FULL); std::string srcFullPath = - this->Convert(source.GetFullPath().c_str(), cmLocalGenerator::FULL); + this->Convert(source.GetFullPath(), cmLocalGenerator::FULL); this->LocalGenerator-> AddImplicitDepends(*this->Target, lang, objFullPath.c_str(), @@ -586,7 +586,7 @@ cmMakefileTargetGenerator std::string defPropName = "COMPILE_DEFINITIONS_"; defPropName += configUpper; if(const char* config_compile_defs = - source.GetProperty(defPropName.c_str())) + source.GetProperty(defPropName)) { this->LocalGenerator->AppendDefines(defines, config_compile_defs); *this->FlagFileStream @@ -600,10 +600,10 @@ cmMakefileTargetGenerator std::string sourceFile = source.GetFullPath(); if(this->LocalGenerator->UseRelativePaths) { - sourceFile = this->Convert(sourceFile.c_str(), + sourceFile = this->Convert(sourceFile, cmLocalGenerator::START_OUTPUT); } - sourceFile = this->Convert(sourceFile.c_str(), + sourceFile = this->Convert(sourceFile, cmLocalGenerator::NONE, cmLocalGenerator::SHELL); @@ -652,14 +652,14 @@ cmMakefileTargetGenerator } } - targetOutPathReal = this->Convert(targetFullPathReal.c_str(), + targetOutPathReal = this->Convert(targetFullPathReal, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); targetOutPathPDB = - this->Convert(targetFullPathPDB.c_str(),cmLocalGenerator::NONE, + this->Convert(targetFullPathPDB,cmLocalGenerator::NONE, cmLocalGenerator::SHELL); targetOutPathCompilePDB = - this->Convert(targetFullPathCompilePDB.c_str(), + this->Convert(targetFullPathCompilePDB, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); } @@ -672,12 +672,12 @@ cmMakefileTargetGenerator vars.TargetCompilePDB = targetOutPathCompilePDB.c_str(); vars.Source = sourceFile.c_str(); std::string shellObj = - this->Convert(obj.c_str(), + this->Convert(obj, cmLocalGenerator::NONE, - cmLocalGenerator::SHELL).c_str(); + cmLocalGenerator::SHELL); vars.Object = shellObj.c_str(); std::string objectDir = this->Target->GetSupportDirectory(); - objectDir = this->Convert(objectDir.c_str(), + objectDir = this->Convert(objectDir, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); vars.ObjectDir = objectDir.c_str(); @@ -699,7 +699,7 @@ cmMakefileTargetGenerator compileRuleVar += lang; compileRuleVar += "_COMPILE_OBJECT"; std::string compileRule = - this->Makefile->GetRequiredDefinition(compileRuleVar.c_str()); + this->Makefile->GetRequiredDefinition(compileRuleVar); std::vector compileCommands; cmSystemTools::ExpandListArgument(compileRule, compileCommands); @@ -738,7 +738,7 @@ cmMakefileTargetGenerator // Write the rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - relativeObj.c_str(), + relativeObj, depends, commands, false); // Check for extra outputs created by the compilation. @@ -756,7 +756,7 @@ cmMakefileTargetGenerator this->GenerateExtraOutput(eoi->c_str(), relativeObj.c_str(), false); // Register this as an extra file to clean. - this->CleanFiles.push_back(eoi->c_str()); + this->CleanFiles.push_back(*eoi); } } @@ -792,15 +792,15 @@ cmMakefileTargetGenerator preprocessRuleVar += lang; preprocessRuleVar += "_CREATE_PREPROCESSED_SOURCE"; if(const char* preprocessRule = - this->Makefile->GetDefinition(preprocessRuleVar.c_str())) + this->Makefile->GetDefinition(preprocessRuleVar)) { std::vector preprocessCommands; cmSystemTools::ExpandListArgument(preprocessRule, preprocessCommands); std::string shellObjI = - this->Convert(objI.c_str(), + this->Convert(objI, cmLocalGenerator::NONE, - cmLocalGenerator::SHELL).c_str(); + cmLocalGenerator::SHELL); vars.PreprocessedSource = shellObjI.c_str(); // Expand placeholders in the commands. @@ -826,7 +826,7 @@ cmMakefileTargetGenerator } this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - relativeObjI.c_str(), + relativeObjI, force_depends, commands, false); } @@ -849,15 +849,15 @@ cmMakefileTargetGenerator assemblyRuleVar += lang; assemblyRuleVar += "_CREATE_ASSEMBLY_SOURCE"; if(const char* assemblyRule = - this->Makefile->GetDefinition(assemblyRuleVar.c_str())) + this->Makefile->GetDefinition(assemblyRuleVar)) { std::vector assemblyCommands; cmSystemTools::ExpandListArgument(assemblyRule, assemblyCommands); std::string shellObjS = - this->Convert(objS.c_str(), + this->Convert(objS, cmLocalGenerator::NONE, - cmLocalGenerator::SHELL).c_str(); + cmLocalGenerator::SHELL); vars.AssemblySource = shellObjS.c_str(); // Expand placeholders in the commands. @@ -883,7 +883,7 @@ cmMakefileTargetGenerator } this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - relativeObjS.c_str(), + relativeObjS, force_depends, commands, false); } } @@ -895,7 +895,7 @@ cmMakefileTargetGenerator std::vector p_depends; // always provide an empty requires target this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - objectRequires.c_str(), p_depends, + objectRequires, p_depends, no_commands, true); // write a build rule to recursively build what this obj provides @@ -909,19 +909,19 @@ cmMakefileTargetGenerator tgtMakefileName += "/build.make"; r_commands.push_back (this->LocalGenerator->GetRecursiveMakeCall(tgtMakefileName.c_str(), - temp.c_str())); + temp)); p_depends.clear(); p_depends.push_back(objectRequires); this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - objectProvides.c_str(), p_depends, + objectProvides, p_depends, r_commands, true); // write the provides.build rule dependency on the obj file p_depends.clear(); p_depends.push_back(relativeObj); this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - temp.c_str(), p_depends, no_commands, + temp, p_depends, no_commands, false); } @@ -950,7 +950,7 @@ void cmMakefileTargetGenerator::WriteTargetRequiresRules() // Write the rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - depTarget.c_str(), + depTarget, depends, no_commands, true); } @@ -975,7 +975,7 @@ void cmMakefileTargetGenerator::WriteTargetCleanRules() // Write the rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - cleanTarget.c_str(), + cleanTarget, depends, commands, true); } @@ -1011,8 +1011,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() pi != this->MultipleOutputPairs.end(); ++pi) { *this->InfoFileStream - << " " << this->LocalGenerator->EscapeForCMake(pi->first.c_str()) - << " " << this->LocalGenerator->EscapeForCMake(pi->second.c_str()) + << " " << this->LocalGenerator->EscapeForCMake(pi->first) + << " " << this->LocalGenerator->EscapeForCMake(pi->second) << "\n"; } *this->InfoFileStream << " )\n\n"; @@ -1081,7 +1081,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() { *this->InfoFileStream << " \"" - << this->LocalGenerator->Convert(i->c_str(), + << this->LocalGenerator->Convert(*i, cmLocalGenerator::HOME_OUTPUT) << "\"\n"; } @@ -1145,7 +1145,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() << this->Convert(this->Makefile->GetStartOutputDirectory(), cmLocalGenerator::FULL, cmLocalGenerator::SHELL) << " " - << this->Convert(this->InfoFileNameFull.c_str(), + << this->Convert(this->InfoFileNameFull, cmLocalGenerator::FULL, cmLocalGenerator::SHELL); if(this->LocalGenerator->GetColorMakefile()) { @@ -1161,7 +1161,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() // Write the rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - depTarget.c_str(), + depTarget, depends, commands, true); } @@ -1203,7 +1203,7 @@ void cmMakefileTargetGenerator for(std::vector::iterator i = deps.begin(); i != deps.end(); ++i) { - depends.push_back(i->c_str()); + depends.push_back(*i); } } } @@ -1247,13 +1247,13 @@ void cmMakefileTargetGenerator bool symbolic = false; if(need_symbolic) { - if(cmSourceFile* sf = this->Makefile->GetSource(o->c_str())) + if(cmSourceFile* sf = this->Makefile->GetSource(*o)) { symbolic = sf->GetPropertyAsBool("SYMBOLIC"); } } this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - o->c_str(), depends, commands, + *o, depends, commands, symbolic); // If the rule has changed make sure the output is rebuilt. @@ -1270,7 +1270,7 @@ void cmMakefileTargetGenerator bool symbolic = false; if(need_symbolic) { - if(cmSourceFile* sf = this->Makefile->GetSource(o->c_str())) + if(cmSourceFile* sf = this->Makefile->GetSource(*o)) { symbolic = sf->GetPropertyAsBool("SYMBOLIC"); } @@ -1284,11 +1284,11 @@ void cmMakefileTargetGenerator idi != cc.GetImplicitDepends().end(); ++idi) { std::string objFullPath = - this->Convert(outputs[0].c_str(), cmLocalGenerator::FULL); + this->Convert(outputs[0], cmLocalGenerator::FULL); std::string srcFullPath = - this->Convert(idi->second.c_str(), cmLocalGenerator::FULL); + this->Convert(idi->second, cmLocalGenerator::FULL); this->LocalGenerator-> - AddImplicitDepends(*this->Target, idi->first.c_str(), + AddImplicitDepends(*this->Target, idi->first, objFullPath.c_str(), srcFullPath.c_str()); } @@ -1333,7 +1333,7 @@ cmMakefileTargetGenerator::AppendProgress(std::vector& commands) progressDir += cmake::GetCMakeFilesDirectory(); cmOStringStream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report "; - progCmd << this->LocalGenerator->Convert(progressDir.c_str(), + progCmd << this->LocalGenerator->Convert(progressDir, cmLocalGenerator::FULL, cmLocalGenerator::SHELL); progCmd << " $(CMAKE_PROGRESS_" << this->NumberOfProgressActions << ")"; @@ -1349,7 +1349,7 @@ cmMakefileTargetGenerator // Write a make variable assignment that lists all objects for the // target. variableName = - this->LocalGenerator->CreateMakeVariable(this->Target->GetName().c_str(), + this->LocalGenerator->CreateMakeVariable(this->Target->GetName(), "_OBJECTS"); *this->BuildFileStream << "# Object files for target " << this->Target->GetName() << "\n" @@ -1370,7 +1370,7 @@ cmMakefileTargetGenerator if(objName) { *this->BuildFileStream << - this->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT, + this->Convert(*i, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::MAKEFILE); } else @@ -1384,7 +1384,7 @@ cmMakefileTargetGenerator // Write a make variable assignment that lists all external objects // for the target. variableNameExternal = - this->LocalGenerator->CreateMakeVariable(this->Target->GetName().c_str(), + this->LocalGenerator->CreateMakeVariable(this->Target->GetName(), "_EXTERNAL_OBJECTS"); *this->BuildFileStream << "\n" @@ -1395,14 +1395,14 @@ cmMakefileTargetGenerator this->ExternalObjects.begin(); i != this->ExternalObjects.end(); ++i) { - object = this->Convert(i->c_str(),cmLocalGenerator::START_OUTPUT); + object = this->Convert(*i,cmLocalGenerator::START_OUTPUT); *this->BuildFileStream << " " << lineContinue << "\n" << this->Makefile->GetSafeDefinition("CMAKE_OBJECT_NAME"); if(objName) { *this->BuildFileStream << - this->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT, + this->Convert(*i, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::MAKEFILE); } else @@ -1439,7 +1439,7 @@ public: { // Construct the name of the next object. this->NextObject = - this->LocalGenerator->Convert(obj.c_str(), + this->LocalGenerator->Convert(obj, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::RESPONSE); @@ -1505,7 +1505,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule( this->LocalGenerator->GetRelativeTargetDirectory(*this->Target); std::string buildTargetRuleName = dir; buildTargetRuleName += relink?"/preinstall":"/build"; - buildTargetRuleName = this->Convert(buildTargetRuleName.c_str(), + buildTargetRuleName = this->Convert(buildTargetRuleName, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::UNCHANGED); @@ -1541,7 +1541,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule( // Write the driver rule. std::vector no_commands; this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, comment, - buildTargetRuleName.c_str(), + buildTargetRuleName, depends, no_commands, true); } @@ -1555,7 +1555,7 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l) std::string fwSearchFlagVar = "CMAKE_" + l + "_FRAMEWORK_SEARCH_FLAG"; const char* fwSearchFlag = - this->Makefile->GetDefinition(fwSearchFlagVar.c_str()); + this->Makefile->GetDefinition(fwSearchFlagVar); if(!(fwSearchFlag && *fwSearchFlag)) { return std::string(); @@ -1577,7 +1577,7 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l) for(std::vector::iterator i = includes.begin(); i != includes.end(); ++i) { - if(this->Target->NameResolvesToFramework(i->c_str())) + if(this->Target->NameResolvesToFramework(*i)) { std::string frameworkDir = *i; frameworkDir += "/../"; @@ -1597,7 +1597,7 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l) if(emitted.insert(*i).second) { flags += fwSearchFlag; - flags += this->Convert(i->c_str(), + flags += this->Convert(*i, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL, true); flags += " "; @@ -1692,7 +1692,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule( std::string ruleVar = "CMAKE_"; ruleVar += this->Target->GetLinkerLanguage(this->ConfigName); ruleVar += "_GNUtoMS_RULE"; - if(const char* rule = this->Makefile->GetDefinition(ruleVar.c_str())) + if(const char* rule = this->Makefile->GetDefinition(ruleVar)) { linkRule += rule; } @@ -1721,7 +1721,7 @@ void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar, removeFlags += linkLang; removeFlags += flagVar; std::string removeflags = - this->Makefile->GetSafeDefinition(removeFlags.c_str()); + this->Makefile->GetSafeDefinition(removeFlags); std::vector removeList; cmSystemTools::ExpandListArgument(removeflags, removeList); @@ -1799,7 +1799,7 @@ cmMakefileTargetGenerator // Create the makefile command to invoke the link script. std::string link_command = "$(CMAKE_COMMAND) -E cmake_link_script "; - link_command += this->Convert(linkScriptName.c_str(), + link_command += this->Convert(linkScriptName, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); link_command += " --verbose=$(VERBOSE)"; @@ -1854,7 +1854,7 @@ cmMakefileTargetGenerator responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = - this->Makefile->GetDefinition(responseFlagVar.c_str()); + this->Makefile->GetDefinition(responseFlagVar); if(!responseFlag) { responseFlag = "@"; @@ -1866,7 +1866,7 @@ cmMakefileTargetGenerator // Reference the response file. linkLibs = responseFlag; - linkLibs += this->Convert(link_rsp.c_str(), + linkLibs += this->Convert(link_rsp, cmLocalGenerator::NONE, cmLocalGenerator::SHELL); } @@ -1896,7 +1896,7 @@ cmMakefileTargetGenerator responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = - this->Makefile->GetDefinition(responseFlagVar.c_str()); + this->Makefile->GetDefinition(responseFlagVar); if(!responseFlag) { responseFlag = "@"; @@ -1920,7 +1920,7 @@ cmMakefileTargetGenerator // Reference the response file. buildObjs += responseFlag; - buildObjs += this->Convert(objects_rsp.c_str(), + buildObjs += this->Convert(objects_rsp, cmLocalGenerator::NONE, cmLocalGenerator::SHELL); } @@ -1949,7 +1949,7 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags, std::string responseVar = "CMAKE_"; responseVar += lang; responseVar += "_USE_RESPONSE_FILE_FOR_INCLUDES"; - bool useResponseFile = this->Makefile->IsOn(responseVar.c_str()); + bool useResponseFile = this->Makefile->IsOn(responseVar); std::vector includes; @@ -2070,7 +2070,7 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags) idi != includes.end(); ++idi) { std::string flg = modpath_flag; - flg += this->Convert(idi->c_str(), + flg += this->Convert(*idi, cmLocalGenerator::NONE, cmLocalGenerator::SHELL); this->LocalGenerator->AppendFlags(flags, flg.c_str()); @@ -2098,7 +2098,7 @@ void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags) // Append the flag and value. Use ConvertToLinkReference to help // vs6's "cl -link" pass it to the linker. std::string flag = defFileFlag; - flag += (this->LocalGenerator->ConvertToLinkReference(def.c_str())); + flag += (this->LocalGenerator->ConvertToLinkReference(def)); this->LocalGenerator->AppendFlags(flags, flag.c_str()); } diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index 2066fc2..6b039bb 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -52,7 +52,7 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() *this->BuildFileStream << "# Include the progress variables for this target.\n" << this->LocalGenerator->IncludeDirective << " " << root - << this->Convert(this->ProgressFileNameFull.c_str(), + << this->Convert(this->ProgressFileNameFull, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE) << "\n\n"; @@ -105,7 +105,7 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() depends, commands, true); // Write the main driver rule to build everything in this target. - this->WriteTargetDriverRule(this->Target->GetName().c_str(), false); + this->WriteTargetDriverRule(this->Target->GetName(), false); // Write clean target this->WriteTargetCleanRules(); diff --git a/Source/cmMarkAsAdvancedCommand.cxx b/Source/cmMarkAsAdvancedCommand.cxx index 4236d10..f6a2c26 100644 --- a/Source/cmMarkAsAdvancedCommand.cxx +++ b/Source/cmMarkAsAdvancedCommand.cxx @@ -42,11 +42,11 @@ bool cmMarkAsAdvancedCommand if ( it.IsAtEnd() ) { this->Makefile->GetCacheManager() - ->AddCacheEntry(variable.c_str(), 0, 0, + ->AddCacheEntry(variable, 0, 0, cmCacheManager::UNINITIALIZED); overwrite = true; } - it.Find(variable.c_str()); + it.Find(variable); if ( it.IsAtEnd() ) { cmSystemTools::Error("This should never happen..."); diff --git a/Source/cmMathCommand.cxx b/Source/cmMathCommand.cxx index 9fc4265..f1942c5 100644 --- a/Source/cmMathCommand.cxx +++ b/Source/cmMathCommand.cxx @@ -28,7 +28,7 @@ bool cmMathCommand return this->HandleExprCommand(args); } std::string e = "does not recognize sub-command "+subCommand; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -49,13 +49,13 @@ bool cmMathCommand::HandleExprCommand(std::vector const& args) { std::string e = "cannot parse the expression: \""+expression+"\": "; e += helper.GetError(); - this->SetError(e.c_str()); + this->SetError(e); return false; } char buffer[1024]; sprintf(buffer, "%d", helper.GetResult()); - this->Makefile->AddDefinition(outputVariable.c_str(), buffer); + this->Makefile->AddDefinition(outputVariable, buffer); return true; } diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx index d85e720..88d6a77 100644 --- a/Source/cmMessageCommand.cxx +++ b/Source/cmMessageCommand.cxx @@ -77,7 +77,7 @@ bool cmMessageCommand if (type != cmake::MESSAGE) { - this->Makefile->IssueMessage(type, message.c_str()); + this->Makefile->IssueMessage(type, message); } else { diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index a49fc2d..686ec81 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -175,7 +175,7 @@ cmNinjaNormalTargetGenerator // build response file name std::string cmakeLinkVar = cmakeVarLang + "_RESPONSE_FILE_LINK_FLAG"; - const char * flag = GetMakefile()->GetDefinition(cmakeLinkVar.c_str()); + const char * flag = GetMakefile()->GetDefinition(cmakeLinkVar); if(flag) { responseFlag = flag; } else { @@ -189,7 +189,7 @@ cmNinjaNormalTargetGenerator linkOptionVar += "_COMPILER_LINKER_OPTION_FLAG_"; linkOptionVar += cmTarget::GetTargetTypeName(targetType); const std::string linkOption = - GetMakefile()->GetSafeDefinition(linkOptionVar.c_str()); + GetMakefile()->GetSafeDefinition(linkOptionVar); rspcontent = "$in_newline "+linkOption+" $LINK_PATH $LINK_LIBRARIES"; vars.Objects = responseFlag.c_str(); vars.LinkLibraries = ""; @@ -321,7 +321,7 @@ cmNinjaNormalTargetGenerator linkCmdVar += this->TargetLinkLanguage; linkCmdVar += "_CREATE_STATIC_LIBRARY"; if (const char *linkCmd = - this->GetMakefile()->GetDefinition(linkCmdVar.c_str())) + this->GetMakefile()->GetDefinition(linkCmdVar)) { cmSystemTools::ExpandListArgument(linkCmd, linkCmds); return linkCmds; @@ -341,7 +341,7 @@ cmNinjaNormalTargetGenerator linkCmdVar += this->TargetLinkLanguage; linkCmdVar += "_ARCHIVE_CREATE"; const char *linkCmd = - this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + this->GetMakefile()->GetRequiredDefinition(linkCmdVar); cmSystemTools::ExpandListArgument(linkCmd, linkCmds); } { @@ -349,7 +349,7 @@ cmNinjaNormalTargetGenerator linkCmdVar += this->TargetLinkLanguage; linkCmdVar += "_ARCHIVE_FINISH"; const char *linkCmd = - this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + this->GetMakefile()->GetRequiredDefinition(linkCmdVar); cmSystemTools::ExpandListArgument(linkCmd, linkCmds); } return linkCmds; @@ -374,7 +374,7 @@ cmNinjaNormalTargetGenerator } const char *linkCmd = - this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + this->GetMakefile()->GetRequiredDefinition(linkCmdVar); cmSystemTools::ExpandListArgument(linkCmd, linkCmds); return linkCmds; } @@ -497,7 +497,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() if (!install_name_dir.empty()) { vars["INSTALLNAME_DIR"] = - this->GetLocalGenerator()->Convert(install_name_dir.c_str(), + this->GetLocalGenerator()->Convert(install_name_dir, cmLocalGenerator::NONE, cmLocalGenerator::SHELL, false); } @@ -506,7 +506,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() if (!this->TargetNameImport.empty()) { const std::string impLibPath = this->GetLocalGenerator() - ->ConvertToOutputFormat(targetOutputImplib.c_str(), + ->ConvertToOutputFormat(targetOutputImplib, cmLocalGenerator::SHELL); vars["TARGET_IMPLIB"] = impLibPath; EnsureParentDirectoryExists(impLibPath); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 3ef236a..d652018 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -140,11 +140,11 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, std::string& languageFlags = this->LanguageFlags[language]; if(!hasLangCached) { - this->AddFeatureFlags(languageFlags, language.c_str()); + this->AddFeatureFlags(languageFlags, language); this->GetLocalGenerator()->AddArchitectureFlags(languageFlags, this->GeneratorTarget, - language.c_str(), + language, this->GetConfigName()); // Add shared-library flags if needed. @@ -153,17 +153,17 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, this->GetConfigName()); this->LocalGenerator->AddVisibilityPresetFlags(languageFlags, this->Target, - language.c_str()); + language); std::vector includes; this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, - language.c_str(), + language, this->GetConfigName()); // Add include directory flags. std::string includeFlags = this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget, - language.c_str(), + language, language == "RC" ? true : false); // full include paths for RC // needed by cmcldeps if(cmGlobalNinjaGenerator::IsMinGW()) @@ -177,7 +177,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, // Add target-specific flags. this->LocalGenerator->AddCompileOptions(languageFlags, this->Target, - language.c_str(), + language, this->GetConfigName()); } @@ -232,12 +232,12 @@ ComputeDefines(cmSourceFile *source, const std::string& language) defPropName += cmSystemTools::UpperCase(this->GetConfigName()); this->LocalGenerator->AppendDefines (defines, - source->GetProperty(defPropName.c_str())); + source->GetProperty(defPropName)); } std::string definesString; this->LocalGenerator->JoinDefines(defines, definesString, - language.c_str()); + language); return definesString; } @@ -340,11 +340,11 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const } vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat( - ConvertToNinjaPath(pdbPath.c_str()).c_str(), + ConvertToNinjaPath(pdbPath.c_str()), cmLocalGenerator::SHELL); vars["TARGET_COMPILE_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat( - ConvertToNinjaPath(compilePdbPath.c_str()).c_str(), + ConvertToNinjaPath(compilePdbPath.c_str()), cmLocalGenerator::SHELL); EnsureParentDirectoryExists(pdbPath); @@ -420,7 +420,7 @@ cmNinjaTargetGenerator deptype = "gcc"; depfile = "$DEP_FILE"; const std::string flagsName = "CMAKE_DEPFILE_FLAGS_" + lang; - std::string depfileFlags = mf->GetSafeDefinition(flagsName.c_str()); + std::string depfileFlags = mf->GetSafeDefinition(flagsName); if (!depfileFlags.empty()) { cmSystemTools::ReplaceString(depfileFlags, "", "$DEP_FILE"); @@ -436,7 +436,7 @@ cmNinjaTargetGenerator // Rule for compiling object file. const std::string cmdVar = std::string("CMAKE_") + lang + "_COMPILE_OBJECT"; - std::string compileCmd = mf->GetRequiredDefinition(cmdVar.c_str()); + std::string compileCmd = mf->GetRequiredDefinition(cmdVar); std::vector compileCmds; cmSystemTools::ExpandListArgument(compileCmd, compileCmds); @@ -603,7 +603,7 @@ cmNinjaTargetGenerator std::string objectDir = this->Target->GetSupportDirectory(); vars["OBJECT_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat( - ConvertToNinjaPath(objectDir.c_str()).c_str(), + ConvertToNinjaPath(objectDir.c_str()), cmLocalGenerator::SHELL); this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetTarget(), vars); @@ -628,7 +628,7 @@ cmNinjaTargetGenerator escapedSourceFileName = this->LocalGenerator->ConvertToOutputFormat( - escapedSourceFileName.c_str(), cmLocalGenerator::SHELL); + escapedSourceFileName, cmLocalGenerator::SHELL); compileObjectVars.Source = escapedSourceFileName.c_str(); compileObjectVars.Object = objectFileName.c_str(); @@ -641,7 +641,7 @@ cmNinjaTargetGenerator compileCmdVar += language; compileCmdVar += "_COMPILE_OBJECT"; std::string compileCmd = - this->GetMakefile()->GetRequiredDefinition(compileCmdVar.c_str()); + this->GetMakefile()->GetRequiredDefinition(compileCmdVar); std::vector compileCmds; cmSystemTools::ExpandListArgument(compileCmd, compileCmds); @@ -699,7 +699,7 @@ cmNinjaTargetGenerator // vs6's "cl -link" pass it to the linker. std::string flag = defFileFlag; flag += (this->LocalGenerator->ConvertToLinkReference( - this->ModuleDefinitionFile.c_str())); + this->ModuleDefinitionFile)); this->LocalGenerator->AppendFlags(flags, flag.c_str()); } diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 449f923..835f892 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -60,7 +60,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, plist += this->GT->Target->GetAppBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, - targetName.c_str(), + targetName, plist.c_str()); this->Makefile->AddCMakeOutputFile(plist); outpath = newoutpath; @@ -91,7 +91,7 @@ void cmOSXBundleGenerator::CreateFramework( plist += "/Resources/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); this->LocalGenerator->GenerateFrameworkInfoPList(this->GT->Target, - name.c_str(), + name, plist.c_str()); // TODO: Use the cmMakefileTargetGenerator::ExtraFiles vector to @@ -182,7 +182,7 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, this->GT->Target->GetCFBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, - targetName.c_str(), + targetName, plist.c_str()); this->Makefile->AddCMakeOutputFile(plist); } diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx index dbe2478..e505440 100644 --- a/Source/cmOptionCommand.cxx +++ b/Source/cmOptionCommand.cxx @@ -39,7 +39,7 @@ bool cmOptionCommand m += args[i]; m += " "; } - this->SetError(m.c_str()); + this->SetError(m); return false; } @@ -62,7 +62,7 @@ bool cmOptionCommand initialValue = args[2]; } bool init = cmSystemTools::IsOn(initialValue.c_str()); - this->Makefile->AddCacheDefinition(args[0].c_str(), init? "ON":"OFF", + this->Makefile->AddCacheDefinition(args[0], init? "ON":"OFF", args[1].c_str(), cmCacheManager::BOOL); return true; } diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 79677e3..ec671fc 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -261,7 +261,7 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) { std::string fname = lib; fname += *i; - if(this->FileMayConflict(dir, fname.c_str())) + if(this->FileMayConflict(dir, fname)) { return true; } diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index c0d9e99..5016493 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -202,7 +202,7 @@ bool cmOutputRequiredFilesCommand { std::string err = "Can not open output file: "; err += this->OutputFile; - this->SetError(err.c_str()); + this->SetError(err); return false; } std::set visited; diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 93072f5..2bd553f 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -488,7 +488,7 @@ bool cmPolicies::GetPolicyDefault(cmMakefile* mf, std::string const& policy, cmPolicies::PolicyStatus* defaultSetting) { std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy; - std::string defaultValue = mf->GetSafeDefinition(defaultVar.c_str()); + std::string defaultValue = mf->GetSafeDefinition(defaultVar); if(defaultValue == "NEW") { *defaultSetting = cmPolicies::NEW; @@ -506,7 +506,7 @@ bool cmPolicies::GetPolicyDefault(cmMakefile* mf, std::string const& policy, cmOStringStream e; e << defaultVar << " has value \"" << defaultValue << "\" but must be \"OLD\", \"NEW\", or \"\" (empty)."; - mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); return false; } @@ -651,5 +651,5 @@ cmPolicies::DiagnoseAncientPolicies(std::vector const& ancient, << "Please either update your CMakeLists.txt files to conform to " << "the new behavior or use an older version of CMake that still " << "supports the old behavior."; - mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); } diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index a9ce0cc..12318c8 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -28,20 +28,20 @@ bool cmProjectCommand srcdir += "_SOURCE_DIR"; this->Makefile->AddCacheDefinition - (bindir.c_str(), + (bindir, this->Makefile->GetCurrentOutputDirectory(), "Value Computed by CMake", cmCacheManager::STATIC); this->Makefile->AddCacheDefinition - (srcdir.c_str(), + (srcdir, this->Makefile->GetCurrentDirectory(), "Value Computed by CMake", cmCacheManager::STATIC); bindir = "PROJECT_BINARY_DIR"; srcdir = "PROJECT_SOURCE_DIR"; - this->Makefile->AddDefinition(bindir.c_str(), + this->Makefile->AddDefinition(bindir, this->Makefile->GetCurrentOutputDirectory()); - this->Makefile->AddDefinition(srcdir.c_str(), + this->Makefile->AddDefinition(srcdir, this->Makefile->GetCurrentDirectory()); this->Makefile->AddDefinition("PROJECT_NAME", args[0].c_str()); @@ -167,19 +167,19 @@ bool cmProjectCommand std::string vv; vv = args[0] + "_VERSION"; this->Makefile->AddDefinition("PROJECT_VERSION", vs.c_str()); - this->Makefile->AddDefinition(vv.c_str(), vs.c_str()); + this->Makefile->AddDefinition(vv, vs.c_str()); vv = args[0] + "_VERSION_MAJOR"; this->Makefile->AddDefinition("PROJECT_VERSION_MAJOR", vb[0]); - this->Makefile->AddDefinition(vv.c_str(), vb[0]); + this->Makefile->AddDefinition(vv, vb[0]); vv = args[0] + "_VERSION_MINOR"; this->Makefile->AddDefinition("PROJECT_VERSION_MINOR", vb[1]); - this->Makefile->AddDefinition(vv.c_str(), vb[1]); + this->Makefile->AddDefinition(vv, vb[1]); vv = args[0] + "_VERSION_PATCH"; this->Makefile->AddDefinition("PROJECT_VERSION_PATCH", vb[2]); - this->Makefile->AddDefinition(vv.c_str(), vb[2]); + this->Makefile->AddDefinition(vv, vb[2]); vv = args[0] + "_VERSION_TWEAK"; this->Makefile->AddDefinition("PROJECT_VERSION_TWEAK", vb[3]); - this->Makefile->AddDefinition(vv.c_str(), vb[3]); + this->Makefile->AddDefinition(vv, vb[3]); } else if(cmp0048 != cmPolicies::OLD) { @@ -199,7 +199,7 @@ bool cmProjectCommand for(std::vector::iterator i = vv.begin(); i != vv.end(); ++i) { - const char* v = this->Makefile->GetDefinition(i->c_str()); + const char* v = this->Makefile->GetDefinition(*i); if(v && *v) { if(cmp0048 == cmPolicies::WARN) @@ -209,7 +209,7 @@ bool cmProjectCommand } else { - this->Makefile->AddDefinition(i->c_str(), ""); + this->Makefile->AddDefinition(*i, ""); } } } @@ -231,7 +231,7 @@ bool cmProjectCommand } this->Makefile->EnableLanguage(languages, false); std::string extraInclude = "CMAKE_PROJECT_" + args[0] + "_INCLUDE"; - const char* include = this->Makefile->GetDefinition(extraInclude.c_str()); + const char* include = this->Makefile->GetDefinition(extraInclude); if(include) { std::string fullFilePath; @@ -244,7 +244,7 @@ bool cmProjectCommand "could not find file:\n" " "; m += include; - this->SetError(m.c_str()); + this->SetError(m); return false; } } diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx index ca007cb..a984260 100644 --- a/Source/cmQTWrapCPPCommand.cxx +++ b/Source/cmQTWrapCPPCommand.cxx @@ -32,13 +32,13 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector const& argsIn, // Get the variable holding the list of sources. std::string const& sourceList = args[1]; std::string sourceListValue = - this->Makefile->GetSafeDefinition(sourceList.c_str()); + this->Makefile->GetSafeDefinition(sourceList); // Create a rule for all sources listed. for(std::vector::iterator j = (args.begin() + 2); j != args.end(); ++j) { - cmSourceFile *curr = this->Makefile->GetSource(j->c_str()); + cmSourceFile *curr = this->Makefile->GetSource(*j); // if we should wrap the class if(!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE"))) { @@ -50,7 +50,7 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector const& argsIn, newName += srcName; newName += ".cxx"; cmSourceFile* sf = - this->Makefile->GetOrCreateSource(newName.c_str(), true); + this->Makefile->GetOrCreateSource(newName, true); if (curr) { sf->SetProperty("ABSTRACT", curr->GetProperty("ABSTRACT")); @@ -99,7 +99,7 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector const& argsIn, std::string no_main_dependency = ""; const char* no_working_dir = 0; - this->Makefile->AddCustomCommandToOutput(newName.c_str(), + this->Makefile->AddCustomCommandToOutput(newName, depends, no_main_dependency, commandLines, @@ -109,7 +109,7 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector const& argsIn, } // Store the final list of source files. - this->Makefile->AddDefinition(sourceList.c_str(), + this->Makefile->AddDefinition(sourceList, sourceListValue.c_str()); return true; } diff --git a/Source/cmQTWrapUICommand.cxx b/Source/cmQTWrapUICommand.cxx index 2a1129d..dce59ef 100644 --- a/Source/cmQTWrapUICommand.cxx +++ b/Source/cmQTWrapUICommand.cxx @@ -35,15 +35,15 @@ bool cmQTWrapUICommand::InitialPass(std::vector const& argsIn, std::string const& headerList = args[1]; std::string const& sourceList = args[2]; std::string headerListValue = - this->Makefile->GetSafeDefinition(headerList.c_str()); + this->Makefile->GetSafeDefinition(headerList); std::string sourceListValue = - this->Makefile->GetSafeDefinition(sourceList.c_str()); + this->Makefile->GetSafeDefinition(sourceList); // Create rules for all sources listed. for(std::vector::iterator j = (args.begin() + 3); j != args.end(); ++j) { - cmSourceFile *curr = this->Makefile->GetSource(j->c_str()); + cmSourceFile *curr = this->Makefile->GetSource(*j); // if we should wrap the class if(!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE"))) { @@ -131,7 +131,7 @@ bool cmQTWrapUICommand::InitialPass(std::vector const& argsIn, std::string no_main_dependency = ""; const char* no_comment = 0; const char* no_working_dir = 0; - this->Makefile->AddCustomCommandToOutput(hName.c_str(), + this->Makefile->AddCustomCommandToOutput(hName, depends, no_main_dependency, hCommandLines, @@ -139,7 +139,7 @@ bool cmQTWrapUICommand::InitialPass(std::vector const& argsIn, no_working_dir); depends.push_back(hName); - this->Makefile->AddCustomCommandToOutput(cxxName.c_str(), + this->Makefile->AddCustomCommandToOutput(cxxName, depends, no_main_dependency, cxxCommandLines, @@ -148,7 +148,7 @@ bool cmQTWrapUICommand::InitialPass(std::vector const& argsIn, depends.clear(); depends.push_back(hName); - this->Makefile->AddCustomCommandToOutput(mocName.c_str(), + this->Makefile->AddCustomCommandToOutput(mocName, depends, no_main_dependency, mocCommandLines, @@ -158,9 +158,9 @@ bool cmQTWrapUICommand::InitialPass(std::vector const& argsIn, } // Store the final list of source files and headers. - this->Makefile->AddDefinition(sourceList.c_str(), + this->Makefile->AddDefinition(sourceList, sourceListValue.c_str()); - this->Makefile->AddDefinition(headerList.c_str(), + this->Makefile->AddDefinition(headerList, headerListValue.c_str()); return true; } diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index c32f624..aa106c7 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -188,7 +188,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) mocCppFile += automocTargetName; mocCppFile += ".cpp"; cmSourceFile* mocCppSource = makefile->GetOrCreateSource( - mocCppFile.c_str(), + mocCppFile, true); makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", mocCppFile.c_str(), false); @@ -278,7 +278,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) #endif { cmTarget* autogenTarget = makefile->AddUtilityCommand( - autogenTargetName.c_str(), true, + autogenTargetName, true, workingDirectory.c_str(), depends, commandLines, false, autogenComment.c_str()); // Set target folder @@ -299,7 +299,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) copyTargetProperty(autogenTarget, target, "FOLDER"); } - target->AddUtility(autogenTargetName.c_str()); + target->AddUtility(autogenTargetName); } return true; @@ -356,7 +356,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) std::string autogenTargetName = getAutogenTargetName(target); makefile->AddDefinition("_moc_target_name", - cmLocalGenerator::EscapeForCMake(autogenTargetName.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(autogenTargetName).c_str()); std::string targetDir = getAutogenTargetDir(target); @@ -385,7 +385,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) this->SetupSourceFiles(target); } makefile->AddDefinition("_cpp_files", - cmLocalGenerator::EscapeForCMake(this->Sources.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(this->Sources).c_str()); if (target->GetPropertyAsBool("AUTOMOC")) { this->SetupAutoMocTarget(target, autogenTargetName, @@ -501,7 +501,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", rcc_output_file.c_str(), false); cmSourceFile* rccCppSource - = makefile->GetOrCreateSource(rcc_output_file.c_str(), true); + = makefile->GetOrCreateSource(rcc_output_file, true); newRccFiles.push_back(rccCppSource); } } @@ -552,11 +552,11 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, const char* tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS"); std::string _moc_options = (tmp!=0 ? tmp : ""); makefile->AddDefinition("_moc_options", - cmLocalGenerator::EscapeForCMake(_moc_options.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(_moc_options).c_str()); makefile->AddDefinition("_skip_moc", - cmLocalGenerator::EscapeForCMake(this->SkipMoc.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(this->SkipMoc).c_str()); makefile->AddDefinition("_moc_headers", - cmLocalGenerator::EscapeForCMake(this->Headers.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(this->Headers).c_str()); bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE"); makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE"); @@ -568,22 +568,22 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, _moc_incs, _moc_compile_defs); makefile->AddDefinition("_moc_incs", - cmLocalGenerator::EscapeForCMake(_moc_incs.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(_moc_incs).c_str()); makefile->AddDefinition("_moc_compile_defs", - cmLocalGenerator::EscapeForCMake(_moc_compile_defs.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(_moc_compile_defs).c_str()); for (std::vector::const_iterator li = configs.begin(); li != configs.end(); ++li) { std::string config_moc_incs; std::string config_moc_compile_defs; - GetCompileDefinitionsAndDirectories(target, li->c_str(), + GetCompileDefinitionsAndDirectories(target, *li, config_moc_incs, config_moc_compile_defs); if (config_moc_incs != _moc_incs) { configIncludes[*li] = - cmLocalGenerator::EscapeForCMake(config_moc_incs.c_str()); + cmLocalGenerator::EscapeForCMake(config_moc_incs); if(_moc_incs.empty()) { _moc_incs = config_moc_incs; @@ -592,7 +592,7 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, if (config_moc_compile_defs != _moc_compile_defs) { configDefines[*li] = - cmLocalGenerator::EscapeForCMake(config_moc_compile_defs.c_str()); + cmLocalGenerator::EscapeForCMake(config_moc_compile_defs); if(_moc_compile_defs.empty()) { _moc_compile_defs = config_moc_compile_defs; @@ -699,7 +699,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, std::set skipped; std::vector skipVec; - cmSystemTools::ExpandListArgument(this->SkipUic.c_str(), skipVec); + cmSystemTools::ExpandListArgument(this->SkipUic, skipVec); for (std::vector::const_iterator li = skipVec.begin(); li != skipVec.end(); ++li) @@ -708,7 +708,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, } makefile->AddDefinition("_skip_uic", - cmLocalGenerator::EscapeForCMake(this->SkipUic.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(this->SkipUic).c_str()); std::vector uiFilesWithOptions = makefile->GetQtUiFilesWithOptions(); @@ -722,18 +722,18 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, if (!_uic_opts.empty()) { - _uic_opts = cmLocalGenerator::EscapeForCMake(_uic_opts.c_str()); + _uic_opts = cmLocalGenerator::EscapeForCMake(_uic_opts); makefile->AddDefinition("_uic_target_options", _uic_opts.c_str()); } for (std::vector::const_iterator li = configs.begin(); li != configs.end(); ++li) { std::string config_uic_opts; - GetUicOpts(target, li->c_str(), config_uic_opts); + GetUicOpts(target, *li, config_uic_opts); if (config_uic_opts != _uic_opts) { configUicOptions[*li] = - cmLocalGenerator::EscapeForCMake(config_uic_opts.c_str()); + cmLocalGenerator::EscapeForCMake(config_uic_opts); if(_uic_opts.empty()) { _uic_opts = config_uic_opts; @@ -768,9 +768,9 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, } makefile->AddDefinition("_qt_uic_options_files", - cmLocalGenerator::EscapeForCMake(uiFileFiles.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(uiFileFiles).c_str()); makefile->AddDefinition("_qt_uic_options_options", - cmLocalGenerator::EscapeForCMake(uiFileOptions.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(uiFileOptions).c_str()); std::string targetName = target->GetName(); if (strcmp(qtVersion, "5") == 0) @@ -914,12 +914,12 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) } makefile->AddDefinition("_rcc_files", - cmLocalGenerator::EscapeForCMake(_rcc_files.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(_rcc_files).c_str()); makefile->AddDefinition("_qt_rcc_options_files", - cmLocalGenerator::EscapeForCMake(rccFileFiles.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(rccFileFiles).c_str()); makefile->AddDefinition("_qt_rcc_options_options", - cmLocalGenerator::EscapeForCMake(rccFileOptions.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(rccFileOptions).c_str()); std::string targetName = target->GetName(); if (strcmp(qtVersion, "5") == 0) @@ -1034,9 +1034,9 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, compileDefsProp += "_"; compileDefsProp += config; } - const char *compileDefs = makefile->GetDefinition(compileDefsProp.c_str()); + const char *compileDefs = makefile->GetDefinition(compileDefsProp); this->MocCompileDefinitionsStr = compileDefs ? compileDefs - : makefile->GetSafeDefinition(compileDefsPropOrig.c_str()); + : makefile->GetSafeDefinition(compileDefsPropOrig); } { std::string includesPropOrig = "AM_MOC_INCLUDES"; @@ -1046,9 +1046,9 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, includesProp += "_"; includesProp += config; } - const char *includes = makefile->GetDefinition(includesProp.c_str()); + const char *includes = makefile->GetDefinition(includesProp); this->MocIncludesStr = includes ? includes - : makefile->GetSafeDefinition(includesPropOrig.c_str()); + : makefile->GetSafeDefinition(includesPropOrig); } this->MocOptionsStr = makefile->GetSafeDefinition("AM_MOC_OPTIONS"); this->ProjectBinaryDir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR"); @@ -1066,10 +1066,10 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, uicOptionsProp += config; } const char *uicTargetOptions - = makefile->GetSafeDefinition(uicOptionsProp.c_str()); + = makefile->GetSafeDefinition(uicOptionsProp); cmSystemTools::ExpandListArgument( uicTargetOptions ? uicTargetOptions - : makefile->GetSafeDefinition(uicOptionsPropOrig.c_str()), + : makefile->GetSafeDefinition(uicOptionsPropOrig), this->UicTargetOptions); const char *uicOptionsOptions = makefile->GetSafeDefinition("AM_UIC_OPTIONS_OPTIONS"); @@ -1168,7 +1168,7 @@ cmQtAutoGenerators::WriteOldMocDefinitionsFile( std::ios::out | std::ios::trunc); outfile << "set(AM_OLD_COMPILE_SETTINGS " << cmLocalGenerator::EscapeForCMake( - this->CurrentCompileSettingsStr.c_str()) << ")\n"; + this->CurrentCompileSettingsStr) << ")\n"; outfile.close(); } diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx index 7685d40..e44b236 100644 --- a/Source/cmScriptGenerator.cxx +++ b/Source/cmScriptGenerator.cxx @@ -99,7 +99,7 @@ cmScriptGenerator::CreateConfigTest(std::vector const& configs) { result += sep; sep = "|"; - cmScriptGeneratorEncodeConfig(ci->c_str(), result); + cmScriptGeneratorEncodeConfig(*ci, result); } result += ")$\""; return result; diff --git a/Source/cmSeparateArgumentsCommand.cxx b/Source/cmSeparateArgumentsCommand.cxx index 6f62091..1ee3f29 100644 --- a/Source/cmSeparateArgumentsCommand.cxx +++ b/Source/cmSeparateArgumentsCommand.cxx @@ -53,7 +53,7 @@ bool cmSeparateArgumentsCommand { cmOStringStream e; e << "given unknown argument " << args[i]; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -61,11 +61,11 @@ bool cmSeparateArgumentsCommand if(mode == ModeOld) { // Original space-replacement version of command. - if(const char* def = this->Makefile->GetDefinition(var.c_str())) + if(const char* def = this->Makefile->GetDefinition(var)) { std::string value = def; cmSystemTools::ReplaceString(value, " ", ";"); - this->Makefile->AddDefinition(var.c_str(), value.c_str()); + this->Makefile->AddDefinition(var, value.c_str()); } } else @@ -102,7 +102,7 @@ bool cmSeparateArgumentsCommand value += *si; } } - this->Makefile->AddDefinition(var.c_str(), value.c_str()); + this->Makefile->AddDefinition(var, value.c_str()); } return true; diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 36363a1..0ca36eb 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -59,7 +59,7 @@ bool cmSetCommand // SET (VAR) // Removes the definition of VAR. if (args.size() == 1) { - this->Makefile->RemoveDefinition(args[0].c_str()); + this->Makefile->RemoveDefinition(args[0]); return true; } // SET (VAR PARENT_SCOPE) // Removes the definition of VAR diff --git a/Source/cmSetDirectoryPropertiesCommand.cxx b/Source/cmSetDirectoryPropertiesCommand.cxx index 62c9b87..3d4b7a9 100644 --- a/Source/cmSetDirectoryPropertiesCommand.cxx +++ b/Source/cmSetDirectoryPropertiesCommand.cxx @@ -30,7 +30,7 @@ bool cmSetDirectoryPropertiesCommand args.end(), errors); if (!ret) { - this->SetError(errors.c_str()); + this->SetError(errors); } return ret; } @@ -62,7 +62,7 @@ bool cmSetDirectoryPropertiesCommand "Commands and macros cannot be set using SET_CMAKE_PROPERTIES"; return false; } - mf->SetProperty(prop.c_str(), value.c_str()); + mf->SetProperty(prop, value.c_str()); } return true; diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 84c7610..5f970f8 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -66,7 +66,7 @@ bool cmSetPropertyCommand cmOStringStream e; e << "given invalid scope " << *arg << ". " << "Valid scopes are GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, CACHE."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -114,7 +114,7 @@ bool cmSetPropertyCommand { cmOStringStream e; e << "given invalid argument \"" << *arg << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -262,7 +262,7 @@ bool cmSetPropertyCommand::HandleTargetMode() cmOStringStream e; e << "could not find TARGET " << *ni << ". Perhaps it has not yet been created."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -301,7 +301,7 @@ bool cmSetPropertyCommand::HandleSourceMode() ni != this->Names.end(); ++ni) { // Get the source file. - if(cmSourceFile* sf = this->Makefile->GetOrCreateSource(ni->c_str())) + if(cmSourceFile* sf = this->Makefile->GetOrCreateSource(*ni)) { if(!this->HandleSource(sf)) { @@ -312,7 +312,7 @@ bool cmSetPropertyCommand::HandleSourceMode() { cmOStringStream e; e << "given SOURCE name that could not be found or created: " << *ni; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -351,7 +351,7 @@ bool cmSetPropertyCommand::HandleTestMode() { next = ni; ++next; - if(cmTest* test = this->Makefile->GetTest(ni->c_str())) + if(cmTest* test = this->Makefile->GetTest(*ni)) { if(this->HandleTest(test)) { @@ -374,7 +374,7 @@ bool cmSetPropertyCommand::HandleTestMode() { e << " " << *ni << "\n"; } - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } return true; @@ -414,7 +414,7 @@ bool cmSetPropertyCommand::HandleCacheMode() cmOStringStream e; e << "given non-boolean value \"" << this->PropertyValue << "\" for CACHE property \"ADVANCED\". "; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -424,7 +424,7 @@ bool cmSetPropertyCommand::HandleCacheMode() { cmOStringStream e; e << "given invalid CACHE entry TYPE \"" << this->PropertyValue << "\""; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -436,7 +436,7 @@ bool cmSetPropertyCommand::HandleCacheMode() e << "given invalid CACHE property " << this->PropertyName << ". " << "Settable CACHE properties are: " << "ADVANCED, HELPSTRING, STRINGS, TYPE, and VALUE."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -460,7 +460,7 @@ bool cmSetPropertyCommand::HandleCacheMode() cmOStringStream e; e << "could not find CACHE variable " << *ni << ". Perhaps it has not yet been created."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } diff --git a/Source/cmSetSourceFilesPropertiesCommand.cxx b/Source/cmSetSourceFilesPropertiesCommand.cxx index 619dfc5..19c6819 100644 --- a/Source/cmSetSourceFilesPropertiesCommand.cxx +++ b/Source/cmSetSourceFilesPropertiesCommand.cxx @@ -51,7 +51,7 @@ bool cmSetSourceFilesPropertiesCommand args.end(), errors); if (!ret) { - this->SetError(errors.c_str()); + this->SetError(errors); } return ret; } @@ -154,14 +154,14 @@ bool cmSetSourceFilesPropertiesCommand { // get the source file cmSourceFile* sf = - mf->GetOrCreateSource(j->c_str(), generated); + mf->GetOrCreateSource(*j, generated); if(sf) { // now loop through all the props and set them unsigned int k; for (k = 0; k < propertyPairs.size(); k = k + 2) { - sf->SetProperty(propertyPairs[k].c_str(),propertyPairs[k+1].c_str()); + sf->SetProperty(propertyPairs[k],propertyPairs[k+1].c_str()); } } } diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx index fa5aafe..bf3519c 100644 --- a/Source/cmSetTargetPropertiesCommand.cxx +++ b/Source/cmSetTargetPropertiesCommand.cxx @@ -78,12 +78,12 @@ bool cmSetTargetPropertiesCommand return false; } bool ret = cmSetTargetPropertiesCommand::SetOneTarget - (args[i].c_str(),propertyPairs,this->Makefile); + (args[i],propertyPairs,this->Makefile); if (!ret) { std::string message = "Can not find target to add properties to: "; message += args[i]; - this->SetError(message.c_str()); + this->SetError(message); return false; } } @@ -101,9 +101,9 @@ bool cmSetTargetPropertiesCommand unsigned int k; for (k = 0; k < propertyPairs.size(); k = k + 2) { - target->SetProperty(propertyPairs[k].c_str(), + target->SetProperty(propertyPairs[k], propertyPairs[k+1].c_str()); - target->CheckProperty(propertyPairs[k].c_str(), mf); + target->CheckProperty(propertyPairs[k], mf); } } // if file is not already in the makefile, then add it diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx index c725d35..b026ff3 100644 --- a/Source/cmSetTestsPropertiesCommand.cxx +++ b/Source/cmSetTestsPropertiesCommand.cxx @@ -76,12 +76,12 @@ bool cmSetTestsPropertiesCommand { std::string errors; bool ret = - cmSetTestsPropertiesCommand::SetOneTest(args[i].c_str(), + cmSetTestsPropertiesCommand::SetOneTest(args[i], propertyPairs, this->Makefile, errors); if (!ret) { - this->SetError(errors.c_str()); + this->SetError(errors); return ret; } } @@ -101,7 +101,7 @@ bool cmSetTestsPropertiesCommand unsigned int k; for (k = 0; k < propertyPairs.size(); k = k + 2) { - test->SetProperty(propertyPairs[k].c_str(), + test->SetProperty(propertyPairs[k], propertyPairs[k+1].c_str()); } } diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx index 2bdd1ad..e61caab 100644 --- a/Source/cmSiteNameCommand.cxx +++ b/Source/cmSiteNameCommand.cxx @@ -31,7 +31,7 @@ bool cmSiteNameCommand paths.push_back("/usr/local/bin"); const char* cacheValue - = this->Makefile->GetDefinition(args[0].c_str()); + = this->Makefile->GetDefinition(args[0]); if(cacheValue) { return true; @@ -85,7 +85,7 @@ bool cmSiteNameCommand } #endif this->Makefile-> - AddCacheDefinition(args[0].c_str(), + AddCacheDefinition(args[0], siteName.c_str(), "Name of the computer/site where compile is being run", cmCacheManager::STRING); diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 0d37205..b9b6251 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -164,14 +164,14 @@ bool cmSourceFile::FindFullPath(std::string* error) } tryPath += this->Location.GetName(); tryPath = cmSystemTools::CollapseFullPath(tryPath.c_str(), *di); - if(this->TryFullPath(tryPath.c_str(), "")) + if(this->TryFullPath(tryPath, "")) { return true; } for(std::vector::const_iterator ei = srcExts.begin(); ei != srcExts.end(); ++ei) { - if(this->TryFullPath(tryPath.c_str(), ei->c_str())) + if(this->TryFullPath(tryPath, *ei)) { return true; } @@ -179,7 +179,7 @@ bool cmSourceFile::FindFullPath(std::string* error) for(std::vector::const_iterator ei = hdrExts.begin(); ei != hdrExts.end(); ++ei) { - if(this->TryFullPath(tryPath.c_str(), ei->c_str())) + if(this->TryFullPath(tryPath, *ei)) { return true; } diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index 9cb80f6..365665d 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -78,7 +78,7 @@ bool cmSourceGroupCommand else if(doingFiles) { // Convert name to full path and add to the group's list. - std::string src = args[i].c_str(); + std::string src = args[i]; if(!cmSystemTools::FileIsFullPath(src.c_str())) { src = this->Makefile->GetCurrentDirectory(); @@ -86,14 +86,14 @@ bool cmSourceGroupCommand src += args[i]; } src = cmSystemTools::CollapseFullPath(src.c_str()); - sg->AddGroupFile(src.c_str()); + sg->AddGroupFile(src); } else { cmOStringStream err; err << "Unknown argument \"" << args[i].c_str() << "\". " << "Perhaps the FILES keyword is missing.\n"; - this->SetError(err.str().c_str()); + this->SetError(err.str()); return false; } } diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index f9b69e3..7bc7b05 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -103,7 +103,7 @@ bool cmStringCommand } std::string e = "does not recognize sub-command "+subCommand; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -115,15 +115,15 @@ bool cmStringCommand::HandleHashCommand(std::vector const& args) { cmOStringStream e; e << args[0] << " requires an output variable and an input string"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } cmsys::auto_ptr hash(cmCryptoHash::New(args[0].c_str())); if(hash.get()) { - std::string out = hash->HashString(args[2].c_str()); - this->Makefile->AddDefinition(args[1].c_str(), out.c_str()); + std::string out = hash->HashString(args[2]); + this->Makefile->AddDefinition(args[1], out.c_str()); return true; } return false; @@ -158,7 +158,7 @@ bool cmStringCommand::HandleToUpperLowerCommand( } // Store the output in the provided variable. - this->Makefile->AddDefinition(outvar.c_str(), output.c_str()); + this->Makefile->AddDefinition(outvar, output.c_str()); return true; } @@ -185,12 +185,12 @@ bool cmStringCommand::HandleAsciiCommand(std::vector const& args) std::string error = "Character with code "; error += args[cc]; error += " does not exist."; - this->SetError(error.c_str()); + this->SetError(error); return false; } } // Store the output in the provided variable. - this->Makefile->AddDefinition(outvar.c_str(), output.c_str()); + this->Makefile->AddDefinition(outvar, output.c_str()); return true; } @@ -226,7 +226,7 @@ bool cmStringCommand::HandleConfigureCommand( { cmOStringStream err; err << "Unrecognized argument \"" << args[i] << "\""; - this->SetError(err.str().c_str()); + this->SetError(err.str()); return false; } } @@ -236,7 +236,7 @@ bool cmStringCommand::HandleConfigureCommand( this->Makefile->ConfigureString(args[1], output, atOnly, escapeQuotes); // Store the output in the provided variable. - this->Makefile->AddDefinition(args[2].c_str(), output.c_str()); + this->Makefile->AddDefinition(args[2], output.c_str()); return true; } @@ -282,7 +282,7 @@ bool cmStringCommand::HandleRegexCommand(std::vector const& args) } std::string e = "sub-command REGEX does not recognize mode "+mode; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -308,7 +308,7 @@ bool cmStringCommand::RegexMatch(std::vector const& args) { std::string e = "sub-command REGEX, mode MATCH failed to compile regex \""+regex+"\"."; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -324,14 +324,14 @@ bool cmStringCommand::RegexMatch(std::vector const& args) std::string e = "sub-command REGEX, mode MATCH regex \""+regex+ "\" matched an empty string."; - this->SetError(e.c_str()); + this->SetError(e); return false; } output = input.substr(l, r-l); } // Store the output in the provided variable. - this->Makefile->AddDefinition(outvar.c_str(), output.c_str()); + this->Makefile->AddDefinition(outvar, output.c_str()); return true; } @@ -358,7 +358,7 @@ bool cmStringCommand::RegexMatchAll(std::vector const& args) std::string e = "sub-command REGEX, mode MATCHALL failed to compile regex \""+ regex+"\"."; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -374,7 +374,7 @@ bool cmStringCommand::RegexMatchAll(std::vector const& args) { std::string e = "sub-command REGEX, mode MATCHALL regex \""+ regex+"\" matched an empty string."; - this->SetError(e.c_str()); + this->SetError(e); return false; } if(output.length() > 0) @@ -386,7 +386,7 @@ bool cmStringCommand::RegexMatchAll(std::vector const& args) } // Store the output in the provided variable. - this->Makefile->AddDefinition(outvar.c_str(), output.c_str()); + this->Makefile->AddDefinition(outvar, output.c_str()); return true; } @@ -439,7 +439,7 @@ bool cmStringCommand::RegexReplace(std::vector const& args) std::string e = "sub-command REGEX, mode REPLACE: Unknown escape \""; e += replace.substr(r, 2); e += "\" in replace-expression."; - this->SetError(e.c_str()); + this->SetError(e); return false; } r += 2; @@ -462,7 +462,7 @@ bool cmStringCommand::RegexReplace(std::vector const& args) std::string e = "sub-command REGEX, mode REPLACE failed to compile regex \""+ regex+"\"."; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -483,7 +483,7 @@ bool cmStringCommand::RegexReplace(std::vector const& args) { std::string e = "sub-command REGEX, mode REPLACE regex \""+ regex+"\" matched an empty string."; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -513,7 +513,7 @@ bool cmStringCommand::RegexReplace(std::vector const& args) "sub-command REGEX, mode REPLACE: replace expression \""+ replace+"\" contains an out-of-range escape for regex \""+ regex+"\"."; - this->SetError(e.c_str()); + this->SetError(e); return false; } } @@ -527,7 +527,7 @@ bool cmStringCommand::RegexReplace(std::vector const& args) output += input.substr(base, input.length()-base); // Store the output in the provided variable. - this->Makefile->AddDefinition(outvar.c_str(), output.c_str()); + this->Makefile->AddDefinition(outvar, output.c_str()); return true; } @@ -616,12 +616,12 @@ bool cmStringCommand::HandleFindCommand(std::vector const& { cmOStringStream s; s << pos; - this->Makefile->AddDefinition(outvar.c_str(), s.str().c_str()); + this->Makefile->AddDefinition(outvar, s.str().c_str()); return true; } // the character was not found, but this is not really an error - this->Makefile->AddDefinition(outvar.c_str(), "-1"); + this->Makefile->AddDefinition(outvar, "-1"); return true; } @@ -643,7 +643,7 @@ bool cmStringCommand::HandleCompareCommand(std::vector const& std::string e = "sub-command COMPARE, mode "; e += mode; e += " needs at least 5 arguments total to command."; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -669,16 +669,16 @@ bool cmStringCommand::HandleCompareCommand(std::vector const& } if(result) { - this->Makefile->AddDefinition(outvar.c_str(), "1"); + this->Makefile->AddDefinition(outvar, "1"); } else { - this->Makefile->AddDefinition(outvar.c_str(), "0"); + this->Makefile->AddDefinition(outvar, "0"); } return true; } std::string e = "sub-command COMPARE does not recognize mode "+mode; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -705,7 +705,7 @@ bool cmStringCommand::HandleReplaceCommand(std::vector const& cmsys::SystemTools::ReplaceString(input, matchExpression.c_str(), replaceExpression.c_str()); - this->Makefile->AddDefinition(variableName.c_str(), input.c_str()); + this->Makefile->AddDefinition(variableName, input.c_str()); return true; } @@ -731,7 +731,7 @@ bool cmStringCommand::HandleSubstringCommand(std::vector const& cmOStringStream ostr; ostr << "begin index: " << begin << " is out of range 0 - " << stringLength; - this->SetError(ostr.str().c_str()); + this->SetError(ostr.str()); return false; } int leftOverLength = intStringLength - begin; @@ -740,11 +740,11 @@ bool cmStringCommand::HandleSubstringCommand(std::vector const& cmOStringStream ostr; ostr << "end index: " << end << " is out of range -1 - " << leftOverLength; - this->SetError(ostr.str().c_str()); + this->SetError(ostr.str()); return false; } - this->Makefile->AddDefinition(variableName.c_str(), + this->Makefile->AddDefinition(variableName, stringValue.substr(begin, end).c_str()); return true; } @@ -766,7 +766,7 @@ bool cmStringCommand char buffer[1024]; sprintf(buffer, "%d", static_cast(length)); - this->Makefile->AddDefinition(variableName.c_str(), buffer); + this->Makefile->AddDefinition(variableName, buffer); return true; } @@ -787,7 +787,7 @@ bool cmStringCommand value += args[i]; } - this->Makefile->AddDefinition(variableName.c_str(), value.c_str()); + this->Makefile->AddDefinition(variableName, value.c_str()); return true; } @@ -804,7 +804,7 @@ bool cmStringCommand const std::string& input = args[1]; const std::string& variableName = args[2]; - this->Makefile->AddDefinition(variableName.c_str(), + this->Makefile->AddDefinition(variableName, cmSystemTools::MakeCidentifier(input.c_str()).c_str()); return true; } @@ -853,7 +853,7 @@ bool cmStringCommand::HandleStripCommand( outLength=endPos - startPos + 1; } - this->Makefile->AddDefinition(variableName.c_str(), + this->Makefile->AddDefinition(variableName, stringValue.substr(startPos, outLength).c_str()); return true; } @@ -937,7 +937,7 @@ bool cmStringCommand } result.push_back(0); - this->Makefile->AddDefinition(variableName.c_str(), &*result.begin()); + this->Makefile->AddDefinition(variableName, &*result.begin()); return true; } @@ -977,14 +977,14 @@ bool cmStringCommand { std::string e = " TIMESTAMP sub-command does not recognize option " + args[argsIndex] + "."; - this->SetError(e.c_str()); + this->SetError(e); return false; } } cmTimestamp timestamp; std::string result = timestamp.CurrentTime(formatString, utcFlag); - this->Makefile->AddDefinition(outputVariable.c_str(), result.c_str()); + this->Makefile->AddDefinition(outputVariable, result.c_str()); return true; } diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx index e497b46..cdde916 100644 --- a/Source/cmSubdirCommand.cxx +++ b/Source/cmSubdirCommand.cxx @@ -47,7 +47,7 @@ bool cmSubdirCommand std::string binPath = std::string(this->Makefile->GetCurrentOutputDirectory()) + "/" + i->c_str(); - this->Makefile->AddSubDirectory(srcPath.c_str(), binPath.c_str(), + this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, preorder, false); } // otherwise it is a full path @@ -57,15 +57,15 @@ bool cmSubdirCommand // element from the source path and use that std::string binPath = std::string(this->Makefile->GetCurrentOutputDirectory()) + - "/" + cmSystemTools::GetFilenameName(i->c_str()); - this->Makefile->AddSubDirectory(i->c_str(), binPath.c_str(), + "/" + cmSystemTools::GetFilenameName(*i); + this->Makefile->AddSubDirectory(*i, binPath, excludeFromAll, preorder, false); } else { std::string error = "Incorrect SUBDIRS command. Directory: "; error += *i + " does not exist."; - this->SetError(error.c_str()); + this->SetError(error); res = false; } } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 39b53bf..ef1e37b 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -990,7 +990,7 @@ void cmSystemTools::GlobDirs(const std::string& path, if(cmSystemTools::FileIsDirectory(fname.c_str())) { fname += finishPath; - cmSystemTools::GlobDirs(fname.c_str(), files); + cmSystemTools::GlobDirs(fname, files); } } } @@ -2105,7 +2105,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0) // remove symlinks exe = cmSystemTools::GetRealPath(exe.c_str()); exe_dir = - cmSystemTools::GetFilenamePath(exe.c_str()); + cmSystemTools::GetFilenamePath(exe); } else { @@ -2288,7 +2288,7 @@ bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath, std::vector cmds; cmds.push_back("otool"); cmds.push_back("-D"); - cmds.push_back(fullPath.c_str()); + cmds.push_back(fullPath); std::string output; if(!RunSingleCommand(cmds, &output, 0, 0, OUTPUT_NONE)) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 4432244..c785192 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -325,7 +325,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) } std::string property = *p; property += configUpper; - this->SetPropertyDefault(property.c_str(), 0); + this->SetPropertyDefault(property, 0); } // Initialize per-configuration name postfix property from the @@ -338,7 +338,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) { std::string property = cmSystemTools::UpperCase(*ci); property += "_POSTFIX"; - this->SetPropertyDefault(property.c_str(), 0); + this->SetPropertyDefault(property, 0); } } @@ -626,7 +626,7 @@ cmSourceFile* cmTarget::AddSource(const std::string& s) << s << "\" expanded to \"" << src << "\" in target \"" << this->GetName() << "\". This behavior will be removed in a " "future version of CMake."; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { return 0; @@ -634,7 +634,7 @@ cmSourceFile* cmTarget::AddSource(const std::string& s) } } - cmSourceFile* sf = this->Makefile->GetOrCreateSource(src.c_str()); + cmSourceFile* sf = this->Makefile->GetOrCreateSource(src); this->AddSourceFile(sf); return sf; } @@ -669,9 +669,9 @@ void cmTarget::MergeLinkLibraries( cmMakefile& mf, for( ; i != libs.end(); ++i ) { // This is equivalent to the target_link_libraries plain signature. - this->AddLinkLibrary( mf, selfname, i->first.c_str(), i->second ); + this->AddLinkLibrary( mf, selfname, i->first, i->second ); this->AppendProperty("INTERFACE_LINK_LIBRARIES", - this->GetDebugGeneratorExpressions(i->first.c_str(), i->second).c_str()); + this->GetDebugGeneratorExpressions(i->first, i->second).c_str()); } this->PrevLinkedLibraries = libs; } @@ -731,12 +731,12 @@ void cmTarget::ClearDependencyInformation( cmMakefile& mf, depname += "_LIB_DEPENDS"; if (this->RecordDependencies) { - mf.AddCacheDefinition(depname.c_str(), "", + mf.AddCacheDefinition(depname, "", "Dependencies for target", cmCacheManager::STATIC); } else { - if (mf.GetDefinition( depname.c_str() )) + if (mf.GetDefinition( depname )) { std::string message = "Target "; message += target; @@ -782,7 +782,7 @@ void cmTarget::GetDirectLinkLibraries(const std::string& config, for (std::set::const_iterator it = seenProps.begin(); it != seenProps.end(); ++it) { - if (!this->GetProperty(it->c_str())) + if (!this->GetProperty(*it)) { this->LinkImplicitNullProperties.insert(*it); } @@ -954,7 +954,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, std::string targetEntry = target; targetEntry += "_LIB_DEPENDS"; std::string dependencies; - const char* old_val = mf.GetDefinition( targetEntry.c_str() ); + const char* old_val = mf.GetDefinition( targetEntry ); if( old_val ) { dependencies += old_val; @@ -974,7 +974,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, dependencies += ";"; dependencies += lib; dependencies += ";"; - mf.AddCacheDefinition( targetEntry.c_str(), dependencies.c_str(), + mf.AddCacheDefinition( targetEntry, dependencies.c_str(), "Dependencies for the target", cmCacheManager::STATIC ); } @@ -1248,7 +1248,7 @@ void cmTarget::GatherDependencies( const cmMakefile& mf, return; } - const char* deps = mf.GetDefinition( (lib.first+"_LIB_DEPENDS").c_str() ); + const char* deps = mf.GetDefinition( lib.first+"_LIB_DEPENDS" ); if( deps && strcmp(deps,"") != 0 ) { // Make sure this library is in the map, even if it has an empty @@ -1340,7 +1340,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) cmOStringStream e; e << "INTERFACE_LIBRARY targets may only have whitelisted properties. " "The property \"" << prop << "\" is not allowed."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } @@ -1348,7 +1348,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) { cmOStringStream e; e << "NAME property is read-only\n"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } if(prop == "INCLUDE_DIRECTORIES") @@ -1389,7 +1389,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) cmOStringStream e; e << "EXPORT_NAME property can't be set on imported targets (\"" << this->Name << "\")\n"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } if (prop == "LINK_LIBRARIES") @@ -1415,14 +1415,14 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, cmOStringStream e; e << "INTERFACE_LIBRARY targets may only have whitelisted properties. " "The property \"" << prop << "\" is not allowed."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } if (prop == "NAME") { cmOStringStream e; e << "NAME property is read-only\n"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } if(prop == "INCLUDE_DIRECTORIES") @@ -1457,7 +1457,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, cmOStringStream e; e << "EXPORT_NAME property can't be set on imported targets (\"" << this->Name << "\")\n"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } if (prop == "LINK_LIBRARIES") @@ -1654,7 +1654,7 @@ static void processIncludeDirectories(cmTarget const* tgt, "successfully.\n" "* The installation package was faulty and references files it " "does not provide.\n"; - tgt->GetMakefile()->IssueMessage(messageType, e.str().c_str()); + tgt->GetMakefile()->IssueMessage(messageType, e.str()); return; } @@ -1693,7 +1693,7 @@ static void processIncludeDirectories(cmTarget const* tgt, } if (!noMessage) { - tgt->GetMakefile()->IssueMessage(messageType, e.str().c_str()); + tgt->GetMakefile()->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { return; @@ -2154,7 +2154,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, { std::string configPropName = "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config); - const char *configProp = this->GetProperty(configPropName.c_str()); + const char *configProp = this->GetProperty(configPropName); if (configProp) { switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) @@ -2165,7 +2165,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, e << this->Makefile->GetCMakeInstance()->GetPolicies() ->GetPolicyWarning(cmPolicies::CMP0043); this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, - e.str().c_str()); + e.str()); } case cmPolicies::OLD: { @@ -2557,7 +2557,7 @@ const char* cmTarget::GetFeature(const std::string& feature, std::string featureConfig = feature; featureConfig += "_"; featureConfig += cmSystemTools::UpperCase(config); - if(const char* value = this->GetProperty(featureConfig.c_str())) + if(const char* value = this->GetProperty(featureConfig)) { return value; } @@ -2606,7 +2606,7 @@ bool cmTarget::HandleLocationPropertyPolicy() const << this->GetName() << "\". Use the target name directly with " "add_custom_command, or use the generator expression $, " "as appropriate.\n"; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); } return messageType != cmake::FATAL_ERROR; @@ -2622,7 +2622,7 @@ const char *cmTarget::GetProperty(const std::string& prop, cmOStringStream e; e << "INTERFACE_LIBRARY targets may only have whitelisted properties. " "The property \"" << prop << "\" is not allowed."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return 0; } @@ -3007,7 +3007,7 @@ void cmTarget::ComputeLinkClosure(const std::string& config, LinkClosure& lc, for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) { - tsl.Consider(li->c_str()); + tsl.Consider(*li); } // Now consider languages that propagate from linked targets. @@ -3015,9 +3015,9 @@ void cmTarget::ComputeLinkClosure(const std::string& config, LinkClosure& lc, sit != languages.end(); ++sit) { std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; - if(this->Makefile->IsOn(propagates.c_str())) + if(this->Makefile->IsOn(propagates)) { - tsl.Consider(sit->c_str()); + tsl.Consider(*sit); } } @@ -3096,7 +3096,7 @@ std::string cmTarget::GetPDBName(const std::string& config) const for(std::vector::const_iterator i = props.begin(); i != props.end(); ++i) { - if(const char* outName = this->GetProperty(i->c_str())) + if(const char* outName = this->GetProperty(*i)) { base = outName; break; @@ -3117,7 +3117,7 @@ std::string cmTarget::GetCompilePDBName(const std::string& config) const std::string configUpper = cmSystemTools::UpperCase(config); std::string configProp = "COMPILE_PDB_NAME_"; configProp += configUpper; - const char* config_name = this->GetProperty(configProp.c_str()); + const char* config_name = this->GetProperty(configProp); if(config_name && *config_name) { return prefix + config_name + ".pdb"; @@ -3340,7 +3340,7 @@ std::string cmTarget::NormalGetRealName(const std::string& config) const msg += this->GetName(); this->GetMakefile()-> IssueMessage(cmake::INTERNAL_ERROR, - msg.c_str()); + msg); } if(this->GetType() == cmTarget::EXECUTABLE) @@ -3518,7 +3518,7 @@ void cmTarget::GetFullNameInternal(const std::string& config, { std::string configProp = cmSystemTools::UpperCase(config); configProp += "_POSTFIX"; - configPostfix = this->GetProperty(configProp.c_str()); + configPostfix = this->GetProperty(configProp); // Mac application bundles and frameworks have no postfix. if(configPostfix && (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) @@ -3536,12 +3536,12 @@ void cmTarget::GetFullNameInternal(const std::string& config, if(!targetSuffix && suffixVar && *suffixVar) { std::string langSuff = suffixVar + std::string("_") + ll; - targetSuffix = this->Makefile->GetDefinition(langSuff.c_str()); + targetSuffix = this->Makefile->GetDefinition(langSuff); } if(!targetPrefix && prefixVar && *prefixVar) { std::string langPrefix = prefixVar + std::string("_") + ll; - targetPrefix = this->Makefile->GetDefinition(langPrefix.c_str()); + targetPrefix = this->Makefile->GetDefinition(langPrefix); } } @@ -3621,7 +3621,7 @@ void cmTarget::GetLibraryNames(std::string& name, std::string msg = "GetLibraryNames called on imported target: "; msg += this->GetName(); this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, - msg.c_str()); + msg); return; } @@ -3725,7 +3725,7 @@ void cmTarget::GetExecutableNames(std::string& name, std::string msg = "GetExecutableNames called on imported target: "; msg += this->GetName(); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg.c_str()); + this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); } // This versioning is supported only for executables and then only @@ -3800,7 +3800,7 @@ void cmTarget::SetPropertyDefault(const std::string& property, std::string var = "CMAKE_"; var += property; - if(const char* value = this->Makefile->GetDefinition(var.c_str())) + if(const char* value = this->Makefile->GetDefinition(var)) { this->SetProperty(property, value); } @@ -3874,7 +3874,7 @@ bool cmTarget::NeedRelinkBeforeInstall(const std::string& config) const std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; flagVar += ll; flagVar += "_FLAG"; - if(!this->Makefile->IsSet(flagVar.c_str())) + if(!this->Makefile->IsSet(flagVar)) { // There is no rpath support on this platform so nothing needs // relinking. @@ -4093,7 +4093,7 @@ bool cmTarget::ComputeOutputDir(const std::string& config, std::string suffix = usesDefaultOutputDir && platforms ? "$(EFFECTIVE_PLATFORM_NAME)" : ""; this->Makefile->GetLocalGenerator()->GetGlobalGenerator()-> - AppendDirectoryForConfig("/", conf, suffix.c_str(), out); + AppendDirectoryForConfig("/", conf, suffix, out); } return usesDefaultOutputDir; @@ -4198,7 +4198,7 @@ std::string cmTarget::GetOutputName(const std::string& config, for(std::vector::const_iterator i = props.begin(); i != props.end(); ++i) { - if(const char* outName = this->GetProperty(i->c_str())) + if(const char* outName = this->GetProperty(*i)) { return outName; } @@ -4516,7 +4516,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, PropertyType propContent = getTypedProperty(tgt, p.c_str(), 0); const bool explicitlySet = tgt->GetProperties() - .find(p.c_str()) + .find(p) != tgt->GetProperties().end(); const bool impliedByUse = tgt->IsNullImpliedByLinkLibraries(p); @@ -4891,7 +4891,7 @@ bool cmTarget::IsChrpathUsed(const std::string& config) const std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; sepVar += ll; sepVar += "_FLAG_SEP"; - const char* sep = this->Makefile->GetDefinition(sepVar.c_str()); + const char* sep = this->Makefile->GetDefinition(sepVar); if(sep && *sep) { // TODO: Add ELF check to ABI detection and get rid of @@ -4980,7 +4980,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, { std::string mapProp = "MAP_IMPORTED_CONFIG_"; mapProp += desired_config; - if(const char* mapValue = this->GetProperty(mapProp.c_str())) + if(const char* mapValue = this->GetProperty(mapProp)) { cmSystemTools::ExpandListArgument(mapValue, mappedConfigs); } @@ -4996,15 +4996,15 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, !*loc && !*imp && mci != mappedConfigs.end(); ++mci) { // Look for this configuration. - std::string mcUpper = cmSystemTools::UpperCase(mci->c_str()); + std::string mcUpper = cmSystemTools::UpperCase(*mci); std::string locProp = "IMPORTED_LOCATION_"; locProp += mcUpper; - *loc = this->GetProperty(locProp.c_str()); + *loc = this->GetProperty(locProp); if(allowImp) { std::string impProp = "IMPORTED_IMPLIB_"; impProp += mcUpper; - *imp = this->GetProperty(impProp.c_str()); + *imp = this->GetProperty(impProp); } // If it was found, use it for all properties below. @@ -5029,12 +5029,12 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, { std::string locProp = "IMPORTED_LOCATION"; locProp += suffix; - *loc = this->GetProperty(locProp.c_str()); + *loc = this->GetProperty(locProp); if(allowImp) { std::string impProp = "IMPORTED_IMPLIB"; impProp += suffix; - *imp = this->GetProperty(impProp.c_str()); + *imp = this->GetProperty(impProp); } } @@ -5071,12 +5071,12 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, suffix += cmSystemTools::UpperCase(*aci); std::string locProp = "IMPORTED_LOCATION"; locProp += suffix; - *loc = this->GetProperty(locProp.c_str()); + *loc = this->GetProperty(locProp); if(allowImp) { std::string impProp = "IMPORTED_IMPLIB"; impProp += suffix; - *imp = this->GetProperty(impProp.c_str()); + *imp = this->GetProperty(impProp); } } } @@ -5112,7 +5112,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, // Get the link interface. { std::string linkProp = "INTERFACE_LINK_LIBRARIES"; - const char *propertyLibs = this->GetProperty(linkProp.c_str()); + const char *propertyLibs = this->GetProperty(linkProp); if (this->GetType() != INTERFACE_LIBRARY) { @@ -5120,13 +5120,13 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, { linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; linkProp += suffix; - propertyLibs = this->GetProperty(linkProp.c_str()); + propertyLibs = this->GetProperty(linkProp); } if(!propertyLibs) { linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; - propertyLibs = this->GetProperty(linkProp.c_str()); + propertyLibs = this->GetProperty(linkProp); } } if(propertyLibs) @@ -5139,7 +5139,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, linkProp, 0, 0); cmSystemTools::ExpandListArgument(ge.Parse(propertyLibs) ->Evaluate(this->Makefile, - desired_config.c_str(), + desired_config, false, headTarget, this, @@ -5164,7 +5164,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, { std::string impProp = "IMPORTED_LOCATION"; impProp += suffix; - if(const char* config_location = this->GetProperty(impProp.c_str())) + if(const char* config_location = this->GetProperty(impProp)) { info.Location = config_location; } @@ -5179,7 +5179,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, { std::string soProp = "IMPORTED_SONAME"; soProp += suffix; - if(const char* config_soname = this->GetProperty(soProp.c_str())) + if(const char* config_soname = this->GetProperty(soProp)) { info.SOName = config_soname; } @@ -5194,7 +5194,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, { std::string soProp = "IMPORTED_NO_SONAME"; soProp += suffix; - if(const char* config_no_soname = this->GetProperty(soProp.c_str())) + if(const char* config_no_soname = this->GetProperty(soProp)) { info.NoSOName = cmSystemTools::IsOn(config_no_soname); } @@ -5214,7 +5214,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, { std::string impProp = "IMPORTED_IMPLIB"; impProp += suffix; - if(const char* config_implib = this->GetProperty(impProp.c_str())) + if(const char* config_implib = this->GetProperty(impProp)) { info.ImportLibrary = config_implib; } @@ -5228,7 +5228,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, { std::string linkProp = "IMPORTED_LINK_DEPENDENT_LIBRARIES"; linkProp += suffix; - if(const char* config_libs = this->GetProperty(linkProp.c_str())) + if(const char* config_libs = this->GetProperty(linkProp)) { cmSystemTools::ExpandListArgument(config_libs, info.LinkInterface.SharedDeps); @@ -5245,7 +5245,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, { std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES"; linkProp += suffix; - if(const char* config_libs = this->GetProperty(linkProp.c_str())) + if(const char* config_libs = this->GetProperty(linkProp)) { cmSystemTools::ExpandListArgument(config_libs, info.LinkInterface.Languages); @@ -5263,7 +5263,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, { std::string linkProp = "IMPORTED_LINK_INTERFACE_MULTIPLICITY"; linkProp += suffix; - if(const char* config_reps = this->GetProperty(linkProp.c_str())) + if(const char* config_reps = this->GetProperty(linkProp)) { sscanf(config_reps, "%u", &info.LinkInterface.Multiplicity); } @@ -5380,7 +5380,7 @@ void processILibs(const std::string& config, std::vector& tgts, std::set& emitted) { if (cmTarget* tgt = headTarget->GetMakefile() - ->FindTargetToUse(name.c_str())) + ->FindTargetToUse(name)) { if (emitted.insert(tgt).second) { @@ -5437,7 +5437,7 @@ void cmTarget::GetTransitivePropertyTargets(const std::string& config, it != iface->Libraries.end(); ++it) { if (cmTarget* tgt = headTarget->GetMakefile() - ->FindTargetToUse(it->c_str())) + ->FindTargetToUse(*it)) { tgts.push_back(tgt); } @@ -5471,7 +5471,7 @@ void cmTarget::GetTransitivePropertyTargets(const std::string& config, it != libs.end(); ++it) { if (cmTarget* tgt = headTarget->GetMakefile() - ->FindTargetToUse(it->c_str())) + ->FindTargetToUse(*it)) { tgts.push_back(tgt); } @@ -5504,7 +5504,7 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, { // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - explicitLibraries = this->GetProperty(linkIfaceProp.c_str()); + explicitLibraries = this->GetProperty(linkIfaceProp); } else if(this->GetType() == cmTarget::SHARED_LIBRARY || this->IsExecutableWithExports()) @@ -5515,13 +5515,13 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, // Lookup the per-configuration property. linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; linkIfaceProp += suffix; - explicitLibraries = this->GetProperty(linkIfaceProp.c_str()); + explicitLibraries = this->GetProperty(linkIfaceProp); // If not set, try the generic property. if(!explicitLibraries) { linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - explicitLibraries = this->GetProperty(linkIfaceProp.c_str()); + explicitLibraries = this->GetProperty(linkIfaceProp); } } @@ -5742,7 +5742,7 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, // dependencies? std::string propName = "LINK_INTERFACE_MULTIPLICITY"; propName += suffix; - if(const char* config_reps = thisTarget->GetProperty(propName.c_str())) + if(const char* config_reps = thisTarget->GetProperty(propName)) { sscanf(config_reps, "%u", &iface.Multiplicity); } diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 8dc407b..115a988 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -39,7 +39,7 @@ bool cmTargetLinkLibrariesCommand // Lookup the target for which libraries are specified. this->Target = this->Makefile->GetCMakeInstance() - ->GetGlobalGenerator()->FindTarget(args[0].c_str()); + ->GetGlobalGenerator()->FindTarget(args[0]); if(!this->Target) { cmake::MessageType t = cmake::FATAL_ERROR; // fail by default @@ -124,7 +124,7 @@ bool cmTargetLinkLibrariesCommand ->GetPolicyWarning(cmPolicies::CMP0039) << "\n" "Utility target \"" << this->Target->GetName() << "\" " << modal << " not be used as the target of a target_link_libraries call."; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if(messageType == cmake::FATAL_ERROR) { return false; @@ -289,7 +289,7 @@ bool cmTargetLinkLibrariesCommand std::string linkType = args[0]; linkType += "_LINK_TYPE"; const char* linkTypeString = - this->Makefile->GetDefinition( linkType.c_str() ); + this->Makefile->GetDefinition( linkType ); if(linkTypeString) { if(strcmp(linkTypeString, "debug") == 0) @@ -407,7 +407,7 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, sig == cmTarget::KeywordTLLSignature ? cmTarget::PlainTLLSignature : cmTarget::KeywordTLLSignature); - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if(messageType == cmake::FATAL_ERROR) { return false; @@ -479,7 +479,7 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, { prop = "LINK_INTERFACE_LIBRARIES_"; prop += *i; - this->Target->AppendProperty(prop.c_str(), lib.c_str()); + this->Target->AppendProperty(prop, lib.c_str()); } } if(llt == cmTarget::OPTIMIZED || llt == cmTarget::GENERAL) @@ -494,9 +494,9 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, { prop = "LINK_INTERFACE_LIBRARIES_"; prop += *i; - if(!this->Target->GetProperty(prop.c_str())) + if(!this->Target->GetProperty(prop)) { - this->Target->SetProperty(prop.c_str(), ""); + this->Target->SetProperty(prop, ""); } } } diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 1a1cfa0..d356611 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -34,7 +34,7 @@ bool cmTargetPropCommandBase } this->Target = this->Makefile->GetCMakeInstance() - ->GetGlobalGenerator()->FindTarget(args[0].c_str()); + ->GetGlobalGenerator()->FindTarget(args[0]); if(!this->Target) { this->Target = this->Makefile->FindTargetToUse(args[0]); @@ -165,15 +165,15 @@ void cmTargetPropCommandBase::HandleInterfaceContent(cmTarget *tgt, if (prepend) { const std::string propName = std::string("INTERFACE_") + this->Property; - const char *propValue = tgt->GetProperty(propName.c_str()); + const char *propValue = tgt->GetProperty(propName); const std::string totalContent = this->Join(content) + (propValue ? std::string(";") + propValue : std::string()); - tgt->SetProperty(propName.c_str(), totalContent.c_str()); + tgt->SetProperty(propName, totalContent.c_str()); } else { - tgt->AppendProperty(("INTERFACE_" + this->Property).c_str(), + tgt->AppendProperty("INTERFACE_" + this->Property, this->Join(content).c_str()); } } diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index a21e1aa..c1b1f8b 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -97,7 +97,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // Generate the command line with full escapes. cmLocalGenerator* lg = mf->GetLocalGenerator(); - os << lg->EscapeForCMake(exe.c_str()); + os << lg->EscapeForCMake(exe); for(std::vector::const_iterator ci = command.begin()+1; ci != command.end(); ++ci) { diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index cfedaa5..cc6e139 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -162,7 +162,7 @@ bool cmTryRunCommand // now put the output into the variables if(this->RunOutputVariable.size()) { - this->Makefile->AddDefinition(this->RunOutputVariable.c_str(), + this->Makefile->AddDefinition(this->RunOutputVariable, runOutputContents.c_str()); } @@ -171,12 +171,12 @@ bool cmTryRunCommand // if the TryCompileCore saved output in this outputVariable then // prepend that output to this output const char* compileOutput - = this->Makefile->GetDefinition(this->OutputVariable.c_str()); + = this->Makefile->GetDefinition(this->OutputVariable); if (compileOutput) { runOutputContents = std::string(compileOutput) + runOutputContents; } - this->Makefile->AddDefinition(this->OutputVariable.c_str(), + this->Makefile->AddDefinition(this->OutputVariable, runOutputContents.c_str()); } } @@ -214,7 +214,7 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, { strcpy(retChar, "FAILED_TO_RUN"); } - this->Makefile->AddCacheDefinition(this->RunResultVariable.c_str(), retChar, + this->Makefile->AddCacheDefinition(this->RunResultVariable, retChar, "Result of TRY_RUN", cmCacheManager::INTERNAL); } @@ -235,10 +235,10 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, copyDest += cmake::GetCMakeFilesDirectory(); copyDest += "/"; copyDest += cmSystemTools::GetFilenameWithoutExtension( - this->OutputFile.c_str()); + this->OutputFile); copyDest += "-"; copyDest += this->RunResultVariable; - copyDest += cmSystemTools::GetFilenameExtension(this->OutputFile.c_str()); + copyDest += cmSystemTools::GetFilenameExtension(this->OutputFile); cmSystemTools::CopyFileAlways(this->OutputFile.c_str(), copyDest.c_str()); std::string resultFileName = this->Makefile->GetHomeOutputDirectory(); @@ -250,7 +250,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, std::string internalRunOutputName=this->RunResultVariable+"__TRYRUN_OUTPUT"; bool error = false; - if (this->Makefile->GetDefinition(this->RunResultVariable.c_str()) == 0) + if (this->Makefile->GetDefinition(this->RunResultVariable) == 0) { // if the variables doesn't exist, create it with a helpful error text // and mark it as advanced @@ -258,7 +258,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, comment += "Run result of TRY_RUN(), indicates whether the executable " "would have been able to run on its target platform.\n"; comment += detailsString; - this->Makefile->AddCacheDefinition(this->RunResultVariable.c_str(), + this->Makefile->AddCacheDefinition(this->RunResultVariable, "PLEASE_FILL_OUT-FAILED_TO_RUN", comment.c_str(), cmCacheManager::STRING); @@ -276,7 +276,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, // is the output from the executable used ? if (out!=0) { - if (this->Makefile->GetDefinition(internalRunOutputName.c_str()) == 0) + if (this->Makefile->GetDefinition(internalRunOutputName) == 0) { // if the variables doesn't exist, create it with a helpful error text // and mark it as advanced @@ -285,7 +285,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, "would have printed on stdout and stderr on its target platform.\n"; comment += detailsString; - this->Makefile->AddCacheDefinition(internalRunOutputName.c_str(), + this->Makefile->AddCacheDefinition(internalRunOutputName, "PLEASE_FILL_OUT-NOTFOUND", comment.c_str(), cmCacheManager::STRING); @@ -355,13 +355,13 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, file << comment << "\n\n"; file << "set( " << this->RunResultVariable << " \n \"" - << this->Makefile->GetDefinition(this->RunResultVariable.c_str()) + << this->Makefile->GetDefinition(this->RunResultVariable) << "\"\n CACHE STRING \"Result from TRY_RUN\" FORCE)\n\n"; if (out!=0) { file << "set( " << internalRunOutputName << " \n \"" - << this->Makefile->GetDefinition(internalRunOutputName.c_str()) + << this->Makefile->GetDefinition(internalRunOutputName) << "\"\n CACHE STRING \"Output from TRY_RUN\" FORCE)\n\n"; } file.close(); @@ -383,6 +383,6 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, if (out!=0) { - (*out) = this->Makefile->GetDefinition(internalRunOutputName.c_str()); + (*out) = this->Makefile->GetDefinition(internalRunOutputName); } } diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx index d4ec20f..60796ec 100644 --- a/Source/cmUseMangledMesaCommand.cxx +++ b/Source/cmUseMangledMesaCommand.cxx @@ -38,7 +38,7 @@ bool cmUseMangledMesaCommand std::string e = "Bad path to Mesa, could not find: "; e += glh; e += " "; - this->SetError(e.c_str()); + this->SetError(e); return false; } const char* destDir = args[1].c_str(); diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index 11e5108..ba6b4ac 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -29,7 +29,7 @@ bool cmUtilitySourceCommand // The first argument is the cache entry name. std::string cacheEntry = *arg++; const char* cacheValue = - this->Makefile->GetDefinition(cacheEntry.c_str()); + this->Makefile->GetDefinition(cacheEntry); // If it exists already and appears up to date then we are done. If // the string contains "(IntDir)" but that is not the // CMAKE_CFG_INTDIR setting then the value is out of date. @@ -113,14 +113,14 @@ bool cmUtilitySourceCommand cmSystemTools::ReplaceString(utilityExecutable, "/./", "/"); // Enter the value into the cache. - this->Makefile->AddCacheDefinition(cacheEntry.c_str(), + this->Makefile->AddCacheDefinition(cacheEntry, utilityExecutable.c_str(), "Path to an internal program.", cmCacheManager::FILEPATH); // add a value into the cache that maps from the // full path to the name of the project cmSystemTools::ConvertToUnixSlashes(utilityExecutable); - this->Makefile->AddCacheDefinition(utilityExecutable.c_str(), + this->Makefile->AddCacheDefinition(utilityExecutable, utilityName.c_str(), "Executable to project name.", cmCacheManager::INTERNAL); diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx index ddb4003..80c1286 100644 --- a/Source/cmVariableRequiresCommand.cxx +++ b/Source/cmVariableRequiresCommand.cxx @@ -26,7 +26,7 @@ bool cmVariableRequiresCommand } std::string testVariable = args[0]; - if(!this->Makefile->IsOn(testVariable.c_str())) + if(!this->Makefile->IsOn(testVariable)) { return true; } @@ -36,7 +36,7 @@ bool cmVariableRequiresCommand bool hasAdvanced = false; for(unsigned int i = 2; i < args.size(); ++i) { - if(!this->Makefile->IsOn(args[i].c_str())) + if(!this->Makefile->IsOn(args[i])) { requirementsMet = false; notSet += args[i]; @@ -49,13 +49,13 @@ bool cmVariableRequiresCommand } } } - const char* reqVar = this->Makefile->GetDefinition(resultVariable.c_str()); + const char* reqVar = this->Makefile->GetDefinition(resultVariable); // if reqVar is unset, then set it to requirementsMet // if reqVar is set to true, but requirementsMet is false , then // set reqVar to false. if(!reqVar || (!requirementsMet && this->Makefile->IsOn(reqVar))) { - this->Makefile->AddDefinition(resultVariable.c_str(), requirementsMet); + this->Makefile->AddDefinition(resultVariable, requirementsMet); } if(!requirementsMet) diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx index 33e159b..3c1fe46 100644 --- a/Source/cmVariableWatchCommand.cxx +++ b/Source/cmVariableWatchCommand.cxx @@ -137,7 +137,7 @@ bool cmVariableWatchCommand { cmOStringStream ostr; ostr << "cannot be set on the variable: " << variable.c_str(); - this->SetError(ostr.str().c_str()); + this->SetError(ostr.str()); return false; } diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx index aa6b9f8..af955ec 100644 --- a/Source/cmWriteFileCommand.cxx +++ b/Source/cmWriteFileCommand.cxx @@ -47,7 +47,7 @@ bool cmWriteFileCommand { std::string e = "attempted to write a file: " + fileName + " into a source directory."; - this->SetError(e.c_str()); + this->SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -79,7 +79,7 @@ bool cmWriteFileCommand std::string error = "Internal CMake error when trying to open file: "; error += fileName.c_str(); error += " for writing."; - this->SetError(error.c_str()); + this->SetError(error); return false; } file << message << std::endl; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index d37bd94..ad8e5e6 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -306,7 +306,7 @@ void cmake::RemoveUnscriptableCommands() it != unscriptableCommands.end(); ++it) { - this->RemoveCommand(it->c_str()); + this->RemoveCommand(*it); } } @@ -335,23 +335,23 @@ bool cmake::SetCacheArgs(const std::vector& args) } std::string var, value; cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED; - if(cmCacheManager::ParseEntry(entry.c_str(), var, value, type)) + if(cmCacheManager::ParseEntry(entry, var, value, type)) { // The value is transformed if it is a filepath for example, so // we can't compare whether the value is already in the cache until // after we call AddCacheEntry. const char *cachedValue = - this->CacheManager->GetCacheValue(var.c_str()); + this->CacheManager->GetCacheValue(var); - this->CacheManager->AddCacheEntry(var.c_str(), value.c_str(), + this->CacheManager->AddCacheEntry(var, value.c_str(), "No help, variable specified on the command line.", type); if(this->WarnUnusedCli) { if (!cachedValue - || strcmp(this->CacheManager->GetCacheValue(var.c_str()), + || strcmp(this->CacheManager->GetCacheValue(var), cachedValue) != 0) { - this->WatchUnusedCli(var.c_str()); + this->WatchUnusedCli(var); } } } @@ -390,7 +390,7 @@ bool cmake::SetCacheArgs(const std::vector& args) } } cmsys::RegularExpression regex( - cmsys::Glob::PatternToRegex(entryPattern.c_str(), true, true).c_str()); + cmsys::Glob::PatternToRegex(entryPattern, true, true).c_str()); //go through all cache entries and collect the vars which will be removed std::vector entriesToDelete; cmCacheManager::CacheIterator it = @@ -414,7 +414,7 @@ bool cmake::SetCacheArgs(const std::vector& args) currentEntry != entriesToDelete.end(); ++currentEntry) { - this->CacheManager->RemoveCacheEntry(currentEntry->c_str()); + this->CacheManager->RemoveCacheEntry(*currentEntry); } } else if(arg.find("-C",0) == 0) @@ -486,13 +486,13 @@ void cmake::ReadListFile(const std::vector& args, { cmsys::auto_ptr lg(gg->CreateLocalGenerator()); lg->GetMakefile()->SetHomeOutputDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); lg->GetMakefile()->SetStartOutputDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); lg->GetMakefile()->SetHomeDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); lg->GetMakefile()->SetStartDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); if (this->GetWorkingMode() != NORMAL_MODE) { std::string file(cmSystemTools::CollapseFullPath(path)); @@ -526,13 +526,13 @@ bool cmake::FindPackage(const std::vector& args) cmsys::auto_ptr lg(gg->CreateLocalGenerator()); cmMakefile* mf = lg->GetMakefile(); mf->SetHomeOutputDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); mf->SetStartOutputDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); mf->SetHomeDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); mf->SetStartDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); mf->SetArgcArgv(args); @@ -566,7 +566,7 @@ bool cmake::FindPackage(const std::vector& args) cmSystemTools::ExpandListArgument(includes, includeDirs); std::string includeFlags = lg->GetIncludeFlags(includeDirs, 0, - language.c_str(), false); + language, false); std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS"); printf("%s %s\n", includeFlags.c_str(), definitions.c_str()); @@ -585,7 +585,7 @@ bool cmake::FindPackage(const std::vector& args) libIt != libList.end(); ++libIt) { - mf->AddLinkLibraryForTarget(targetName, libIt->c_str(), + mf->AddLinkLibraryForTarget(targetName, *libIt, cmTarget::GENERAL); } @@ -636,7 +636,7 @@ void cmake::SetArgs(const std::vector& args, std::string path = arg.substr(2); path = cmSystemTools::CollapseFullPath(path.c_str()); cmSystemTools::ConvertToUnixSlashes(path); - this->SetHomeDirectory(path.c_str()); + this->SetHomeDirectory(path); } else if(arg.find("-S",0) == 0) { @@ -652,7 +652,7 @@ void cmake::SetArgs(const std::vector& args, std::string path = arg.substr(2); path = cmSystemTools::CollapseFullPath(path.c_str()); cmSystemTools::ConvertToUnixSlashes(path); - this->SetHomeOutputDirectory(path.c_str()); + this->SetHomeOutputDirectory(path); } else if((i < args.size()-2) && (arg.find("--check-build-system",0) == 0)) { @@ -790,7 +790,7 @@ void cmake::SetArgs(const std::vector& args, value = args[i]; } cmGlobalGenerator* gen = - this->CreateGlobalGenerator(value.c_str()); + this->CreateGlobalGenerator(value); if(!gen) { cmSystemTools::Error("Could not create named generator ", @@ -811,13 +811,13 @@ void cmake::SetArgs(const std::vector& args, if(!directoriesSet) { this->SetHomeOutputDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); this->SetStartOutputDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); this->SetStartDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); } this->SetStartDirectory(this->GetHomeDirectory()); @@ -853,15 +853,15 @@ void cmake::SetDirectoriesFromFile(const char* arg) { argIsFile = true; std::string fullPath = cmSystemTools::CollapseFullPath(arg); - std::string name = cmSystemTools::GetFilenameName(fullPath.c_str()); + std::string name = cmSystemTools::GetFilenameName(fullPath); name = cmSystemTools::LowerCase(name); if(name == "cmakecache.txt") { - cachePath = cmSystemTools::GetFilenamePath(fullPath.c_str()); + cachePath = cmSystemTools::GetFilenamePath(fullPath); } else if(name == "cmakelists.txt") { - listPath = cmSystemTools::GetFilenamePath(fullPath.c_str()); + listPath = cmSystemTools::GetFilenamePath(fullPath); } } else @@ -869,12 +869,12 @@ void cmake::SetDirectoriesFromFile(const char* arg) // Specified file or directory does not exist. Try to set things // up to produce a meaningful error message. std::string fullPath = cmSystemTools::CollapseFullPath(arg); - std::string name = cmSystemTools::GetFilenameName(fullPath.c_str()); + std::string name = cmSystemTools::GetFilenameName(fullPath); name = cmSystemTools::LowerCase(name); if(name == "cmakecache.txt" || name == "cmakelists.txt") { argIsFile = true; - listPath = cmSystemTools::GetFilenamePath(fullPath.c_str()); + listPath = cmSystemTools::GetFilenamePath(fullPath); } else { @@ -887,11 +887,11 @@ void cmake::SetDirectoriesFromFile(const char* arg) { cmCacheManager* cachem = this->GetCacheManager(); cmCacheManager::CacheIterator it = cachem->NewIterator(); - if(cachem->LoadCache(cachePath.c_str()) && + if(cachem->LoadCache(cachePath) && it.Find("CMAKE_HOME_DIRECTORY")) { - this->SetHomeOutputDirectory(cachePath.c_str()); - this->SetStartOutputDirectory(cachePath.c_str()); + this->SetHomeOutputDirectory(cachePath); + this->SetStartOutputDirectory(cachePath); this->SetHomeDirectory(it.GetValue()); this->SetStartDirectory(it.GetValue()); return; @@ -901,23 +901,23 @@ void cmake::SetDirectoriesFromFile(const char* arg) // If there is a CMakeLists.txt file, use it as the source tree. if(listPath.length() > 0) { - this->SetHomeDirectory(listPath.c_str()); - this->SetStartDirectory(listPath.c_str()); + this->SetHomeDirectory(listPath); + this->SetStartDirectory(listPath); if(argIsFile) { // Source CMakeLists.txt file given. It was probably dropped // onto the executable in a GUI. Default to an in-source build. - this->SetHomeOutputDirectory(listPath.c_str()); - this->SetStartOutputDirectory(listPath.c_str()); + this->SetHomeOutputDirectory(listPath); + this->SetStartOutputDirectory(listPath); } else { // Source directory given on command line. Use current working // directory as build tree. std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - this->SetHomeOutputDirectory(cwd.c_str()); - this->SetStartOutputDirectory(cwd.c_str()); + this->SetHomeOutputDirectory(cwd); + this->SetStartOutputDirectory(cwd); } return; } @@ -927,10 +927,10 @@ void cmake::SetDirectoriesFromFile(const char* arg) // current working directory as the build tree. std::string full = cmSystemTools::CollapseFullPath(arg); std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - this->SetHomeDirectory(full.c_str()); - this->SetStartDirectory(full.c_str()); - this->SetHomeOutputDirectory(cwd.c_str()); - this->SetStartOutputDirectory(cwd.c_str()); + this->SetHomeDirectory(full); + this->SetStartDirectory(full); + this->SetHomeOutputDirectory(cwd); + this->SetStartOutputDirectory(cwd); } // at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the @@ -979,8 +979,8 @@ void cmake::AddExtraGenerator(const std::string& name, ++it ) { std::string fullName = cmExternalMakefileProjectGenerator:: - CreateFullGeneratorName(it->c_str(), name); - this->ExtraGenerators[fullName.c_str()] = newFunction; + CreateFullGeneratorName(*it, name); + this->ExtraGenerators[fullName] = newFunction; } delete extraGenerator; } @@ -1230,7 +1230,7 @@ int cmake::HandleDeleteCacheVariables(const std::string& var) i++; save.value = *i; warning << *i << "\n"; - if(ci.Find(save.key.c_str())) + if(ci.Find(save.key)) { save.type = ci.GetType(); save.help = ci.GetProperty("HELPSTRING"); @@ -1246,7 +1246,7 @@ int cmake::HandleDeleteCacheVariables(const std::string& var) for(std::vector::iterator i = saved.begin(); i != saved.end(); ++i) { - this->AddCacheEntry(i->key.c_str(), i->value.c_str(), + this->AddCacheEntry(i->key, i->value.c_str(), i->help.c_str(), i->type); } cmSystemTools::Message(warning.str().c_str()); @@ -1328,7 +1328,7 @@ int cmake::ActualConfigure() std::string fullName = cmExternalMakefileProjectGenerator:: CreateFullGeneratorName(genName, extraGenName ? extraGenName : ""); - this->GlobalGenerator = this->CreateGlobalGenerator(fullName.c_str()); + this->GlobalGenerator = this->CreateGlobalGenerator(fullName); } if(this->GlobalGenerator) { @@ -1692,8 +1692,8 @@ int cmake::Run(const std::vector& args, bool noconfigure) { return ret; } - this->SetStartDirectory(oldstartdir.c_str()); - this->SetStartOutputDirectory(oldstartoutputdir.c_str()); + this->SetStartDirectory(oldstartdir); + this->SetStartOutputDirectory(oldstartoutputdir); return ret; } @@ -1854,7 +1854,7 @@ void cmake::GetGeneratorDocumentation(std::vector& v) { cmDocumentationEntry e; cmExternalMakefileProjectGenerator* generator = (i->second)(); - generator->GetDocumentation(e, i->first.c_str()); + generator->GetDocumentation(e, i->first); e.Name = i->first; delete generator; v.push_back(e); @@ -2313,7 +2313,7 @@ int cmake::GetSystemInformation(std::vector& args) value = args[i]; } cmGlobalGenerator* gen = - this->CreateGlobalGenerator(value.c_str()); + this->CreateGlobalGenerator(value); if(!gen) { cmSystemTools::Error("Could not create named generator ", @@ -2650,7 +2650,7 @@ int cmake::Build(const std::string& dir, cmSystemTools::ConvertToUnixSlashes(cachePath); cmCacheManager* cachem = this->GetCacheManager(); cmCacheManager::CacheIterator it = cachem->NewIterator(); - if(!cachem->LoadCache(cachePath.c_str())) + if(!cachem->LoadCache(cachePath)) { std::cerr << "Error: could not load cache\n"; return 1; @@ -2670,11 +2670,11 @@ int cmake::Build(const std::string& dir, return 1; } projName = it.GetValue(); - return gen->Build("", dir.c_str(), - projName.c_str(), target.c_str(), + return gen->Build("", dir, + projName, target, &output, "", - config.c_str(), clean, false, 0, + config, clean, false, 0, cmSystemTools::OUTPUT_PASSTHROUGH, nativeOptions); } diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 047f09d..ad1f2a5 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -613,16 +613,16 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) startDir = cmSystemTools::CollapseFullPath(startDir.c_str()); homeOutDir = cmSystemTools::CollapseFullPath(homeOutDir.c_str()); startOutDir = cmSystemTools::CollapseFullPath(startOutDir.c_str()); - cm.SetHomeDirectory(homeDir.c_str()); - cm.SetStartDirectory(startDir.c_str()); - cm.SetHomeOutputDirectory(homeOutDir.c_str()); - cm.SetStartOutputDirectory(startOutDir.c_str()); - if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen.c_str())) + cm.SetHomeDirectory(homeDir); + cm.SetStartDirectory(startDir); + cm.SetHomeOutputDirectory(homeOutDir); + cm.SetStartOutputDirectory(startOutDir); + if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen)) { cm.SetGlobalGenerator(ggd); cmsys::auto_ptr lgd(ggd->CreateLocalGenerator()); - lgd->GetMakefile()->SetStartDirectory(startDir.c_str()); - lgd->GetMakefile()->SetStartOutputDirectory(startOutDir.c_str()); + lgd->GetMakefile()->SetStartDirectory(startDir); + lgd->GetMakefile()->SetStartOutputDirectory(startOutDir); lgd->GetMakefile()->MakeStartDirectoriesCurrent(); // Actually scan dependencies. @@ -667,7 +667,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) { cmQtAutoGenerators autogen; std::string const& config = args[3]; - bool autogenSuccess = autogen.Run(args[2].c_str(), config); + bool autogenSuccess = autogen.Run(args[2], config); return autogenSuccess ? 0 : 1; } #endif diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index b6a2437..32e79e6 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -4918,8 +4918,8 @@ void SystemTools::ClassInitialize() // Strip off one directory level and see if the logical // mapping still works. - pwd_str = SystemTools::GetFilenamePath(pwd_str.c_str()); - cwd_str = SystemTools::GetFilenamePath(cwd_str.c_str()); + pwd_str = SystemTools::GetFilenamePath(pwd_str); + cwd_str = SystemTools::GetFilenamePath(cwd_str); Realpath(pwd_str.c_str(), pwd_path); } -- cgit v0.12 From af8a1643c1a42aa3b276a50bca10a4faab176764 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 11 Mar 2014 13:35:32 +0100 Subject: Remove c_str calls when using stream APIs. Use an ad-hoc clang tool for matching the calls which should be ported. --- Source/CPack/cmCPackDebGenerator.cxx | 16 ++-- Source/CPack/cmCPackGenerator.cxx | 32 ++++---- Source/CPack/cmCPackLog.cxx | 12 +-- Source/CPack/cmCPackNSISGenerator.cxx | 42 +++++------ Source/CPack/cmCPackSTGZGenerator.cxx | 4 +- Source/CPack/cpack.cxx | 10 +-- Source/CTest/cmCTestBuildCommand.cxx | 2 +- Source/CTest/cmCTestBuildHandler.cxx | 2 +- Source/CTest/cmCTestConfigureHandler.cxx | 4 +- Source/CTest/cmCTestCoverageHandler.cxx | 88 +++++++++++----------- .../CTest/cmCTestEmptyBinaryDirectoryCommand.cxx | 2 +- Source/CTest/cmCTestGenericHandler.cxx | 4 +- Source/CTest/cmCTestMemCheckHandler.cxx | 16 ++-- Source/CTest/cmCTestMultiProcessHandler.cxx | 2 +- Source/CTest/cmCTestRunTest.cxx | 28 +++---- Source/CTest/cmCTestScriptHandler.cxx | 20 ++--- Source/CTest/cmCTestSubmitHandler.cxx | 46 +++++------ Source/CTest/cmCTestTestHandler.cxx | 14 ++-- Source/CTest/cmCTestUpdateHandler.cxx | 2 +- Source/CTest/cmCTestUploadHandler.cxx | 2 +- Source/cmAddCustomCommandCommand.cxx | 2 +- Source/cmCMakeMinimumRequired.cxx | 4 +- Source/cmCTest.cxx | 48 ++++++------ Source/cmCacheManager.cxx | 4 +- Source/cmCommandArgumentParserHelper.cxx | 2 +- Source/cmCoreTryCompile.cxx | 6 +- Source/cmDependsC.cxx | 2 +- Source/cmDependsFortran.cxx | 12 +-- Source/cmDependsJavaParserHelper.cxx | 8 +- Source/cmDocumentation.cxx | 12 +-- Source/cmExportInstallFileGenerator.cxx | 2 +- Source/cmExtraCodeBlocksGenerator.cxx | 4 +- Source/cmExtraCodeLiteGenerator.cxx | 4 +- Source/cmExtraEclipseCDT4Generator.cxx | 2 +- Source/cmFindPackageCommand.cxx | 2 +- Source/cmGlobalGenerator.cxx | 2 +- Source/cmGlobalKdevelopGenerator.cxx | 22 +++--- Source/cmGlobalUnixMakefileGenerator3.cxx | 14 ++-- Source/cmGraphVizWriter.cxx | 6 +- Source/cmInstallGenerator.cxx | 2 +- Source/cmLocalGenerator.cxx | 6 +- Source/cmLocalUnixMakefileGenerator3.cxx | 8 +- Source/cmMakefile.cxx | 16 ++-- Source/cmMakefileTargetGenerator.cxx | 6 +- Source/cmSourceGroupCommand.cxx | 2 +- Source/cmUseMangledMesaCommand.cxx | 4 +- Source/cmVariableWatchCommand.cxx | 4 +- Source/cmake.cxx | 14 ++-- Source/cmcmd.cxx | 26 +++---- 49 files changed, 297 insertions(+), 297 deletions(-) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 9ae5839..27e9d9f 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -444,13 +444,13 @@ int cmCPackDebGenerator::createDeb() std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/Deb.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << cmd.c_str() << std::endl + ofs << "# Run command: " << cmd << std::endl << "# Working directory: " << toplevel << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: " - << cmd.c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + << cmd << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } @@ -528,13 +528,13 @@ int cmCPackDebGenerator::createDeb() std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/Deb.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << cmd.c_str() << std::endl + ofs << "# Run command: " << cmd << std::endl << "# Working directory: " << toplevel << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: " - << cmd.c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + << cmd << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index cf514aa..9cdf5aa 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -285,7 +285,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( it != installCommandsVector.end(); ++it ) { - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << it->c_str() + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << *it << std::endl); std::string output; int retVal = 1; @@ -296,12 +296,12 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/InstallOutput.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << it->c_str() << std::endl + ofs << "# Run command: " << *it << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, - "Problem running install command: " << it->c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" + "Problem running install command: " << *it << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } @@ -329,7 +329,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( ++it ) { cmCPackLogger(cmCPackLog::LOG_VERBOSE, - "Create ignore files regex for: " << it->c_str() << std::endl); + "Create ignore files regex for: " << *it << std::endl); ignoreFilesRegex.push_back(it->c_str()); } } @@ -385,7 +385,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( if ( regIt->find(inFile.c_str()) ) { cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Ignore file: " - << inFile.c_str() << std::endl); + << inFile << std::endl); skip = true; } } @@ -397,7 +397,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( filePath += "/" + subdir + "/" + cmSystemTools::RelativePath(top.c_str(), gfit->c_str()); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: " - << inFile.c_str() << " -> " << filePath.c_str() << std::endl); + << inFile << " -> " << filePath << std::endl); /* If the file is a symlink we will have to re-create it */ if ( cmSystemTools::FileIsSymlink(inFile.c_str())) { @@ -416,7 +416,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( ) ) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: " - << inFile.c_str() << " -> " << filePath.c_str() << std::endl); + << inFile << " -> " << filePath << std::endl); return 0; } } @@ -663,14 +663,14 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/PreinstallOutput.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << buildCommandStr.c_str() << std::endl - << "# Directory: " << installDirectory.c_str() << std::endl + ofs << "# Run command: " << buildCommandStr << std::endl + << "# Directory: " << installDirectory << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, - "Problem running install command: " << buildCommandStr.c_str() + "Problem running install command: " << buildCommandStr << std::endl - << "Please check " << tmpFile.c_str() << " for errors" + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } @@ -1001,7 +1001,7 @@ void cmCPackGenerator::SetOption(const std::string& op, const char* value) int cmCPackGenerator::DoPackage() { cmCPackLogger(cmCPackLog::LOG_OUTPUT, - "Create package using " << this->Name.c_str() << std::endl); + "Create package using " << this->Name << std::endl); // Prepare CPack internal name and check // values for many CPACK_xxx vars @@ -1269,7 +1269,7 @@ std::string cmCPackGenerator::FindTemplate(const char* name) << (name ? name : "(NULL)") << std::endl); std::string ffile = this->MakefileMap->GetModulesFile(name); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: " - << ffile.c_str() << std::endl); + << ffile << std::endl); return ffile; } diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx index 4e8bf0f..7befca0 100644 --- a/Source/CPack/cmCPackLog.cxx +++ b/Source/CPack/cmCPackLog.cxx @@ -169,27 +169,27 @@ void cmCPackLog::Log(int tag, const char* file, int line, { if ( error && !this->ErrorPrefix.empty() ) { - *this->DefaultError << this->ErrorPrefix.c_str(); + *this->DefaultError << this->ErrorPrefix; } else if ( warning && !this->WarningPrefix.empty() ) { - *this->DefaultError << this->WarningPrefix.c_str(); + *this->DefaultError << this->WarningPrefix; } else if ( output && !this->OutputPrefix.empty() ) { - *this->DefaultOutput << this->OutputPrefix.c_str(); + *this->DefaultOutput << this->OutputPrefix; } else if ( verbose && !this->VerbosePrefix.empty() ) { - *this->DefaultOutput << this->VerbosePrefix.c_str(); + *this->DefaultOutput << this->VerbosePrefix; } else if ( debug && !this->DebugPrefix.empty() ) { - *this->DefaultOutput << this->DebugPrefix.c_str(); + *this->DefaultOutput << this->DebugPrefix; } else if ( !this->Prefix.empty() ) { - *this->DefaultOutput << this->Prefix.c_str(); + *this->DefaultOutput << this->Prefix; } if ( useFileAndLine ) { diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index f433834..0113698 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -83,10 +83,10 @@ int cmCPackNSISGenerator::PackageFiles() fileN = fileN.substr(fileN.find('/')+1, std::string::npos); } cmSystemTools::ReplaceString(fileN, "/", "\\"); - str << " Delete \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl; + str << " Delete \"$INSTDIR\\" << fileN << "\"" << std::endl; } cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: " - << str.str().c_str() << std::endl); + << str.str() << std::endl); this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str().c_str()); std::vector dirs; this->GetListOfSubdirectories(toplevel.c_str(), dirs); @@ -117,14 +117,14 @@ int cmCPackNSISGenerator::PackageFiles() } } cmSystemTools::ReplaceString(fileN, "/", "\\"); - dstr << " RMDir \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl; + dstr << " RMDir \"$INSTDIR\\" << fileN << "\"" << std::endl; if (!componentName.empty()) { this->Components[componentName].Directories.push_back(fileN); } } cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: " - << dstr.str().c_str() << std::endl); + << dstr.str() << std::endl); this->SetOptionIfNotSet("CPACK_NSIS_DELETE_DIRECTORIES", dstr.str().c_str()); @@ -320,7 +320,7 @@ int cmCPackNSISGenerator::PackageFiles() std::string nsisCmd = "\""; nsisCmd += this->GetOption("CPACK_INSTALLER_PROGRAM"); nsisCmd += "\" \"" + nsisFileName + "\""; - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd.c_str() + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd << std::endl); std::string output; int retVal = 1; @@ -329,12 +329,12 @@ int cmCPackNSISGenerator::PackageFiles() if ( !res || retVal ) { cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << nsisCmd.c_str() << std::endl + ofs << "# Run command: " << nsisCmd << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running NSIS command: " - << nsisCmd.c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + << nsisCmd << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } return 1; @@ -427,7 +427,7 @@ int cmCPackNSISGenerator::InitializeInternal() std::string nsisCmd = "\"" + nsisPath + "\" " NSIS_OPT "VERSION"; cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Test NSIS version: " - << nsisCmd.c_str() << std::endl); + << nsisCmd << std::endl); std::string output; int retVal = 1; bool resS = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), @@ -442,13 +442,13 @@ int cmCPackNSISGenerator::InitializeInternal() std::string tmpFile = topDir ? topDir : "."; tmpFile += "/NSISOutput.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << nsisCmd.c_str() << std::endl + ofs << "# Run command: " << nsisCmd << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem checking NSIS version with command: " - << nsisCmd.c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + << nsisCmd << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } if ( versionRex.find(output)) @@ -470,7 +470,7 @@ int cmCPackNSISGenerator::InitializeInternal() { // No version check for NSIS cvs build cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: CVS " - << versionRexCVS.match(1).c_str() << std::endl); + << versionRexCVS.match(1) << std::endl); } this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", nsisPath.c_str()); this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLES_DIRECTORY", "bin"); @@ -844,12 +844,12 @@ CreateComponentDescription(cmCPackComponent *component, std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/CompressZip.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << cmd.c_str() << std::endl + ofs << "# Run command: " << cmd << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running zip command: " - << cmd.c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + << cmd << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return ""; } @@ -891,7 +891,7 @@ CreateComponentDescription(cmCPackComponent *component, path = *pathIt; cmSystemTools::ReplaceString(path, "/", "\\"); macrosOut << " Delete \"$INSTDIR\\" - << path.c_str() + << path << "\"\n"; } for (pathIt = component->Directories.begin(); @@ -901,7 +901,7 @@ CreateComponentDescription(cmCPackComponent *component, path = *pathIt; cmSystemTools::ReplaceString(path, "/", "\\"); macrosOut << " RMDir \"$INSTDIR\\" - << path.c_str() + << path << "\"\n"; } macrosOut << " noremove_" << component->Name << ":\n"; diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index 8342fee..6c1d201 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -43,7 +43,7 @@ int cmCPackSTGZGenerator::InitializeInternal() if ( inFile.empty() ) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find template file: " - << inFile.c_str() << std::endl); + << inFile << std::endl); return 0; } this->SetOptionIfNotSet("CPACK_STGZ_HEADER_FILE", inFile.c_str()); @@ -134,6 +134,6 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os) cmSystemTools::ReplaceString(res, headerLengthTag, buffer); // Write in file - *os << res.c_str(); + *os << res; return this->Superclass::GenerateHeader(os); } diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index d1a16f0..7ebfeda 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -91,7 +91,7 @@ int cpackDefinitionArgument(const char* argument, const char* cValue, value = value.c_str() + pos + 1; def->Map[key] = value; cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: " - << key.c_str() << " to \"" << value.c_str() << "\"" << std::endl); + << key << " to \"" << value << "\"" << std::endl); return 1; } @@ -195,7 +195,7 @@ int main (int argc, char const* const* argv) } cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, - "Read CPack config file: " << cpackConfigFile.c_str() << std::endl); + "Read CPack config file: " << cpackConfigFile << std::endl); cmake cminst; cminst.RemoveUnscriptableCommands(); @@ -262,20 +262,20 @@ int main (int argc, char const* const* argv) cpackConfigFile = cmSystemTools::CollapseFullPath(cpackConfigFile.c_str()); cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, - "Read CPack configuration file: " << cpackConfigFile.c_str() + "Read CPack configuration file: " << cpackConfigFile << std::endl); if ( !globalMF->ReadListFile(0, cpackConfigFile.c_str()) ) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Problem reading CPack config file: \"" - << cpackConfigFile.c_str() << "\"" << std::endl); + << cpackConfigFile << "\"" << std::endl); return 1; } } else if ( cpackConfigFileSpecified ) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, - "Cannot find CPack config file: \"" << cpackConfigFile.c_str() + "Cannot find CPack config file: \"" << cpackConfigFile << "\"" << std::endl); return 1; } diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index de42e2b..f81083a 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -134,7 +134,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() cmakeBuildAdditionalFlags ? cmakeBuildAdditionalFlags : "", true); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SetMakeCommand:" - << buildCommand.c_str() << "\n"); + << buildCommand << "\n"); this->CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str()); } else diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 291c70a..7922c9a 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -409,7 +409,7 @@ int cmCTestBuildHandler::ProcessHandler() for ( it = strings.begin(); it != strings.end(); ++it ) \ { \ cmCTestLog(this->CTest, DEBUG, "Add " #strings ": " \ - << it->c_str() << std::endl); \ + << *it << std::endl); \ regexes.push_back(it->c_str()); \ } cmCTestBuildHandlerPopulateRegexVector( diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx index 7c41298..a6e39a4 100644 --- a/Source/CTest/cmCTestConfigureHandler.cxx +++ b/Source/CTest/cmCTestConfigureHandler.cxx @@ -76,7 +76,7 @@ int cmCTestConfigureHandler::ProcessHandler() cmGeneratedFileStream ofs; this->StartLogFile("Configure", ofs); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: " - << cCommand.c_str() << std::endl); + << cCommand << std::endl); res = this->CTest->RunMakeCommand(cCommand.c_str(), &output, &retVal, buildDirectory.c_str(), 0, ofs); @@ -99,7 +99,7 @@ int cmCTestConfigureHandler::ProcessHandler() { os << retVal; } - os << "" << cCommand.c_str() << "" + os << "" << cCommand << "" << std::endl; cmCTestLog(this->CTest, DEBUG, "End" << std::endl); os << "" << cmXMLSafe(output) << "" << std::endl; diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 2c21a13..f0b1124 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -269,7 +269,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, fFile.c_str(), checkDir.c_str()); if ( ndc.size() ) { - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str() + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc << " so skip coverage of " << file << std::endl); return false; } @@ -308,7 +308,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, fFile.c_str(), checkDir.c_str()); if ( ndc.size() ) { - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str() + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc << " so skip coverage of: " << file << std::endl); return false; } @@ -477,7 +477,7 @@ int cmCTestCoverageHandler::ProcessHandler() { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, ".NoDartCoverage found, so skip coverage check for: " - << fullFileName.c_str() + << fullFileName << std::endl); continue; } @@ -488,7 +488,7 @@ int cmCTestCoverageHandler::ProcessHandler() if ( !cmSystemTools::FileExists(fullFileName.c_str()) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: " - << fullFileName.c_str() << std::endl); + << fullFileName << std::endl); continue; } @@ -516,7 +516,7 @@ int cmCTestCoverageHandler::ProcessHandler() if ( !ifs) { cmOStringStream ostr; - ostr << "Cannot open source file: " << fullFileName.c_str(); + ostr << "Cannot open source file: " << fullFileName; errorsWhileAccumulating.push_back(ostr.str()); error ++; continue; @@ -535,7 +535,7 @@ int cmCTestCoverageHandler::ProcessHandler() cc != fcov.size() -1 ) { cmOStringStream ostr; - ostr << "Problem reading source file: " << fullFileName.c_str() + ostr << "Problem reading source file: " << fullFileName << " line:" << cc << " out total: " << fcov.size()-1; errorsWhileAccumulating.push_back(ostr.str()); error ++; @@ -605,7 +605,7 @@ int cmCTestCoverageHandler::ProcessHandler() if (!ifs) { cmOStringStream ostr; - ostr << "Cannot open source file: " << fullPath.c_str(); + ostr << "Cannot open source file: " << fullPath; errorsWhileAccumulating.push_back(ostr.str()); error ++; continue; @@ -613,7 +613,7 @@ int cmCTestCoverageHandler::ProcessHandler() int untested = 0; std::string line; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Actually performing coverage for: " << i->c_str() << std::endl); + "Actually performing coverage for: " << *i << std::endl); while (cmSystemTools::GetLineFromStream(ifs, line)) { covLogFile << "\t\t" @@ -647,7 +647,7 @@ int cmCTestCoverageHandler::ProcessHandler() ++ erIt ) { cmCTestLog(this->CTest, ERROR_MESSAGE, - " " << erIt->c_str() << std::endl); + " " << *erIt << std::endl); } } @@ -719,13 +719,13 @@ void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf) ++ it ) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage exclude: " - << it->c_str() << std::endl); + << *it << std::endl); } for ( it = this->ExtraCoverageGlobs.begin(); it != this->ExtraCoverageGlobs.end(); ++it) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage glob: " - << it->c_str() << std::endl); + << *it << std::endl); } } @@ -959,17 +959,17 @@ int cmCTestCoverageHandler::HandleGCovCoverage( std::string output = ""; std::string errors = ""; int retVal = 0; - *cont->OFS << "* Run coverage for: " << fileDir.c_str() << std::endl; - *cont->OFS << " Command: " << command.c_str() << std::endl; + *cont->OFS << "* Run coverage for: " << fileDir << std::endl; + *cont->OFS << " Command: " << command << std::endl; int res = this->CTest->RunCommand(command.c_str(), &output, &errors, &retVal, tempDir.c_str(), 0 /*this->TimeOut*/); - *cont->OFS << " Output: " << output.c_str() << std::endl; - *cont->OFS << " Errors: " << errors.c_str() << std::endl; + *cont->OFS << " Output: " << output << std::endl; + *cont->OFS << " Errors: " << errors << std::endl; if ( ! res ) { cmCTestLog(this->CTest, ERROR_MESSAGE, - "Problem running coverage on file: " << it->c_str() << std::endl); + "Problem running coverage on file: " << *it << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, "Command produced error: " << errors << std::endl); cont->Error ++; @@ -978,7 +978,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( if ( retVal != 0 ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: " - << retVal << " while processing: " << it->c_str() << std::endl); + << retVal << " while processing: " << *it << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, "Command produced error: " << cont->Error << std::endl); } @@ -999,7 +999,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( std::string sourceFile; std::string gcovFile; - cmCTestLog(this->CTest, DEBUG, "Line: [" << line->c_str() << "]" + cmCTestLog(this->CTest, DEBUG, "Line: [" << *line << "]" << std::endl); if ( line->size() == 0 ) @@ -1145,7 +1145,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( !cmSystemTools::StringStartsWith(line->c_str(), "Removing ")) { cmCTestLog(this->CTest, ERROR_MESSAGE, - "Unknown gcov output line: [" << line->c_str() << "]" + "Unknown gcov output line: [" << *line << "]" << std::endl); cont->Error ++; //abort(); @@ -1238,8 +1238,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage( if ( IsFileInDir(sourceFile, cont->SourceDir) ) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " produced s: " - << sourceFile.c_str() << std::endl); - *cont->OFS << " produced in source dir: " << sourceFile.c_str() + << sourceFile << std::endl); + *cont->OFS << " produced in source dir: " << sourceFile << std::endl; actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile.c_str()); @@ -1247,8 +1247,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage( else if ( IsFileInDir(sourceFile, cont->BinaryDir) ) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " produced b: " - << sourceFile.c_str() << std::endl); - *cont->OFS << " produced in binary dir: " << sourceFile.c_str() + << sourceFile << std::endl); + *cont->OFS << " produced in binary dir: " << sourceFile << std::endl; actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile.c_str()); @@ -1262,19 +1262,19 @@ int cmCTestCoverageHandler::HandleGCovCoverage( "Something went wrong" << std::endl); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Cannot find file: [" - << sourceFile.c_str() << "]" << std::endl); + << sourceFile << "]" << std::endl); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " in source dir: [" - << cont->SourceDir.c_str() << "]" + << cont->SourceDir << "]" << std::endl); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " or binary dir: [" << cont->BinaryDir.size() << "]" << std::endl); *cont->OFS << " Something went wrong. Cannot find file: " - << sourceFile.c_str() - << " in source dir: " << cont->SourceDir.c_str() - << " or binary dir: " << cont->BinaryDir.c_str() << std::endl; + << sourceFile + << " in source dir: " << cont->SourceDir + << " or binary dir: " << cont->BinaryDir << std::endl; missingFiles.insert(sourceFile); } @@ -1364,24 +1364,24 @@ int cmCTestCoverageHandler::HandleTracePyCoverage( { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find source Python file corresponding to: " - << fileIt->c_str() << std::endl); + << *fileIt << std::endl); continue; } std::string actualSourceFile = cmSystemTools::CollapseFullPath(fileName.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - " Check coverage for file: " << actualSourceFile.c_str() + " Check coverage for file: " << actualSourceFile << std::endl); cmCTestCoverageHandlerContainer::SingleFileCoverageVector* vec = &cont->TotalCoverage[actualSourceFile]; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - " in file: " << fileIt->c_str() << std::endl); + " in file: " << *fileIt << std::endl); cmsys::ifstream ifile(fileIt->c_str()); if ( ! ifile ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: " - << fileIt->c_str() << std::endl); + << *fileIt << std::endl); } else { @@ -1429,7 +1429,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage( // So, this will be set to 0. cov = 0; } - cmCTestLog(this->CTest, DEBUG, "Prefix: " << prefix.c_str() + cmCTestLog(this->CTest, DEBUG, "Prefix: " << prefix << " cov: " << cov << std::endl); // Read the line number starting at the 10th character of the gcov @@ -1542,7 +1542,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open coverage file: " << - outputFile.c_str() << std::endl); + outputFile << std::endl); return 0; } std::map fileMap; @@ -1602,7 +1602,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( count++; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Produce coverage for file: " - << file.c_str() << " " << count + << file << " " << count << std::endl); // start the file output covLogFile << "\tCTest, HANDLER_VERBOSE_OUTPUT, - "Run : " << program.c_str() << " " << arg << "\n"); + "Run : " << program << " " << arg << "\n"); } else { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Run : " << program.c_str() << "\n"); + "Run : " << program << "\n"); } // create a process object and start it cmCTestRunProcess runCoverageSrc; @@ -1686,7 +1686,7 @@ int cmCTestCoverageHandler::RunBullseyeCommand( if(!runCoverageSrc.StartProcess()) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Could not run : " - << program.c_str() << " " << arg << "\n" + << program << " " << arg << "\n" << "kwsys process state : " << runCoverageSrc.GetProcessState()); return 0; @@ -1755,7 +1755,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open coverage summary file: " << - outputFile.c_str() << std::endl); + outputFile << std::endl); return 0; } std::set coveredFileNames; @@ -1796,14 +1796,14 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, ".NoDartCoverage found, so skip coverage check for: " - << file.c_str() + << file << std::endl); continue; } cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Doing coverage for: " - << file.c_str() + << file << std::endl); coveredFiles.push_back(sourceFile); @@ -1830,7 +1830,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( cmet /= 2.0f; } cmet /= 100.0f; - tmpLog << stdline.c_str() << "\n"; + tmpLog << stdline << "\n"; tmpLog << fileName << "\n"; tmpLog << "functionsCalled: " << functionsCalled/100 << "\n"; tmpLog << "totalFunctions: " << totalFunctions/100 << "\n"; @@ -1957,7 +1957,7 @@ bool cmCTestCoverageHandler::ParseBullsEyeCovsrcLine( if(pos == inputLine.npos) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing string : " - << inputLine.c_str() << "\n"); + << inputLine << "\n"); return false; } // the source file has "" around it so extract out the file name @@ -1991,7 +1991,7 @@ bool cmCTestCoverageHandler::ParseBullsEyeCovsrcLine( if(pos != inputLine.npos) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing input : " - << inputLine.c_str() << " last pos not npos = " << pos << + << inputLine << " last pos not npos = " << pos << "\n"); } return true; diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx index a470b3b..5ddef01 100644 --- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx +++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx @@ -25,7 +25,7 @@ bool cmCTestEmptyBinaryDirectoryCommand if ( !cmCTestScriptHandler::EmptyBinaryDirectory(args[0].c_str()) ) { cmOStringStream ostr; - ostr << "problem removing the binary directory: " << args[0].c_str(); + ostr << "problem removing the binary directory: " << args[0]; this->SetError(ostr.str()); return false; } diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index 08cfaec..2df2229 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -124,7 +124,7 @@ bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part, ostr.str(), xofs, true) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, - "Cannot create resulting XML file: " << ostr.str().c_str() + "Cannot create resulting XML file: " << ostr.str() << std::endl); return false; } @@ -156,7 +156,7 @@ bool cmCTestGenericHandler::StartLogFile(const char* name, if( !this->CTest->OpenOutputFile("Temporary", ostr.str(), xofs) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create log file: " - << ostr.str().c_str() << std::endl); + << ostr.str() << std::endl); return false; } return true; diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index f27dbc0..ecaa474 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -514,7 +514,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find memory checker suppression file: " << this->CTest->GetCTestConfiguration( - "MemoryCheckSuppressionFile").c_str() << std::endl); + "MemoryCheckSuppressionFile") << std::endl); return false; } std::string suppressions = "--suppressions=" @@ -569,7 +569,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() } default: cmCTestLog(this->CTest, ERROR_MESSAGE, - "Do not understand memory checker: " << this->MemoryTester.c_str() + "Do not understand memory checker: " << this->MemoryTester << std::endl); return false; } @@ -885,7 +885,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput( else if(!parser.ParseChunk(theLine.c_str(), theLine.size())) { cmCTestLog(this->CTest, ERROR_MESSAGE, - "Error in ParseChunk: " << theLine.c_str() + "Error in ParseChunk: " << theLine << std::endl); } } @@ -916,7 +916,7 @@ cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res, { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "PostProcessBoundsCheckerTest for : " - << res.Name.c_str() << std::endl); + << res.Name << std::endl); std::string ofile = testOutputFileName(test); if ( ofile.empty() ) { @@ -943,10 +943,10 @@ cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res, cmSystemTools::Delay(1000); cmSystemTools::RemoveFile(this->BoundsCheckerDPBDFile.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: " - << this->BoundsCheckerDPBDFile.c_str() << std::endl); + << this->BoundsCheckerDPBDFile << std::endl); cmSystemTools::RemoveFile(this->BoundsCheckerXMLFile.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: " - << this->BoundsCheckerXMLFile.c_str() << std::endl); + << this->BoundsCheckerXMLFile << std::endl); } void @@ -955,7 +955,7 @@ cmCTestMemCheckHandler::PostProcessPurifyTest(cmCTestTestResult& res, { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "PostProcessPurifyTest for : " - << res.Name.c_str() << std::endl); + << res.Name << std::endl); appendMemTesterOutput(res, test); } @@ -965,7 +965,7 @@ cmCTestMemCheckHandler::PostProcessValgrindTest(cmCTestTestResult& res, { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "PostProcessValgrindTest for : " - << res.Name.c_str() << std::endl); + << res.Name << std::endl); appendMemTesterOutput(res, test); } diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index c979be3..b9e6721 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -672,7 +672,7 @@ void cmCTestMultiProcessHandler::PrintTestList() indexStr << " #" << p.Index << ":"; cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex())) - << indexStr.str().c_str()); + << indexStr.str()); cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); cmCTestLog(this->CTest, HANDLER_OUTPUT, p.Name.c_str() << std::endl); //pop working dir diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index cdf90b9..385388d 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -334,9 +334,9 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) *this->TestHandler->LogFile << "Test Failed.\n"; } } - *this->TestHandler->LogFile << "\"" << this->TestProperties->Name.c_str() + *this->TestHandler->LogFile << "\"" << this->TestProperties->Name << "\" end time: " << this->CTest->CurrentTime() << std::endl - << "\"" << this->TestProperties->Name.c_str() << "\" time elapsed: " + << "\"" << this->TestProperties->Name << "\" time elapsed: " << buffer << std::endl << "----------------------------------------------------------" << std::endl << std::endl; @@ -388,8 +388,8 @@ void cmCTestRunTest::MemCheckPostProcess() } cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": process test output now: " - << this->TestProperties->Name.c_str() << " " - << this->TestResult.Name.c_str() << std::endl); + << this->TestProperties->Name << " " + << this->TestResult.Name << std::endl); cmCTestMemCheckHandler * handler = static_cast (this->TestHandler); switch ( handler->MemoryTesterStyle ) @@ -465,9 +465,9 @@ bool cmCTestRunTest::StartTest(size_t total) //Required file was not found this->TestProcess = new cmProcess; *this->TestHandler->LogFile << "Unable to find required file: " - << file.c_str() << std::endl; + << file << std::endl; cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find required file: " - << file.c_str() << std::endl); + << file << std::endl); this->TestResult.Output = "Unable to find required file: " + file; this->TestResult.FullCommandLine = ""; this->TestResult.CompletionStatus = "Not Run"; @@ -482,9 +482,9 @@ bool cmCTestRunTest::StartTest(size_t total) // that has that information this->TestProcess = new cmProcess; *this->TestHandler->LogFile << "Unable to find executable: " - << args[1].c_str() << std::endl; + << args[1] << std::endl; cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find executable: " - << args[1].c_str() << std::endl); + << args[1] << std::endl); this->TestResult.Output = "Unable to find executable: " + args[1]; this->TestResult.FullCommandLine = ""; this->TestResult.CompletionStatus = "Not Run"; @@ -711,7 +711,7 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total) indexStr << " #" << this->Index << ":"; cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex())) - << indexStr.str().c_str()); + << indexStr.str()); cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); const int maxTestNameWidth = this->CTest->GetMaxTestNameWidth(); std::string outname = this->TestProperties->Name + " "; @@ -722,18 +722,18 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total) << this->TestProperties->Name << std::endl; *this->TestHandler->LogFile << this->TestProperties->Index << "/" << this->TestHandler->TotalNumberOfTests - << " Test: " << this->TestProperties->Name.c_str() << std::endl; + << " Test: " << this->TestProperties->Name << std::endl; *this->TestHandler->LogFile << "Command: \"" << this->ActualCommand << "\""; for (std::vector::iterator i = this->Arguments.begin(); i != this->Arguments.end(); ++i) { *this->TestHandler->LogFile - << " \"" << i->c_str() << "\""; + << " \"" << *i << "\""; } *this->TestHandler->LogFile << std::endl << "Directory: " << this->TestProperties->Directory << std::endl - << "\"" << this->TestProperties->Name.c_str() << "\" start time: " + << "\"" << this->TestProperties->Name << "\" start time: " << this->StartTime << std::endl; *this->TestHandler->LogFile @@ -741,9 +741,9 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total) << "----------------------------------------------------------" << std::endl; *this->TestHandler->LogFile - << this->ProcessOutput.c_str() << "" << std::endl; + << this->ProcessOutput << "" << std::endl; cmCTestLog(this->CTest, HANDLER_OUTPUT, outname.c_str()); cmCTestLog(this->CTest, DEBUG, "Testing " - << this->TestProperties->Name.c_str() << " ... "); + << this->TestProperties->Name << " ... "); } diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 4d419c2..567acfc 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -426,7 +426,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) cmSystemTools::GetErrorOccuredFlag()) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read:" - << systemFile.c_str() << "\n"); + << systemFile << "\n"); return 2; } @@ -444,7 +444,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) cmSystemTools::GetErrorOccuredFlag()) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read script: " - << script.c_str() + << script << std::endl); // Reset the error flag so that it can run more than // one script with an error when you @@ -781,7 +781,7 @@ int cmCTestScriptHandler::PerformExtraUpdates() output = ""; retVal = 0; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run Update: " - << fullCommand.c_str() << std::endl); + << fullCommand << std::endl); res = cmSystemTools::RunSingleCommand(fullCommand.c_str(), &output, &retVal, cvsArgs[0].c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/); @@ -902,7 +902,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() command += "\""; retVal = 0; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: " - << command.c_str() << std::endl); + << command << std::endl); res = cmSystemTools::RunSingleCommand(command.c_str(), &output, &retVal, this->BinaryDir.c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/); @@ -916,7 +916,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() } cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Write CMake output to file: " << cmakeOutputFile.c_str() + "Write CMake output to file: " << cmakeOutputFile << std::endl); cmGeneratedFileStream fout(cmakeOutputFile.c_str()); if ( fout ) @@ -927,7 +927,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open CMake output file: " - << cmakeOutputFile.c_str() << " for writing" << std::endl); + << cmakeOutputFile << " for writing" << std::endl); } } if (!res || retVal != 0) @@ -948,7 +948,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() output = ""; retVal = 0; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: " - << command.c_str() << std::endl); + << command << std::endl); res = cmSystemTools::RunSingleCommand(command.c_str(), &output, &retVal, this->BinaryDir.c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/); @@ -962,13 +962,13 @@ int cmCTestScriptHandler::RunConfigurationDashboard() { cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to run cmake:" << std::endl - << cmakeFailedOuput.c_str() << std::endl); + << cmakeFailedOuput << std::endl); return 10; } cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to run ctest:" << std::endl - << "command: " << command.c_str() << std::endl - << "output: " << output.c_str() << std::endl); + << "command: " << command << std::endl + << "output: " << output << std::endl); if (!res) { return 11; diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index bc3c333..7c72cba 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -229,18 +229,18 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix, if ( ::stat(local_file.c_str(), &st) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: " - << local_file.c_str() << std::endl); + << local_file << std::endl); ::curl_easy_cleanup(curl); ::curl_global_cleanup(); return false; } ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb"); - *this->LogFile << "\tUpload file: " << local_file.c_str() << " to " - << upload_as.c_str() << std::endl; + *this->LogFile << "\tUpload file: " << local_file << " to " + << upload_as << std::endl; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " - << local_file.c_str() << " to " - << upload_as.c_str() << std::endl); + << local_file << " to " + << upload_as << std::endl); ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); @@ -290,11 +290,11 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix, { cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when uploading file: " - << local_file.c_str() << std::endl); + << local_file << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); *this->LogFile << " Error when uploading file: " - << local_file.c_str() + << local_file << std::endl << " Error message was: " << error_buffer << std::endl @@ -422,8 +422,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, std::string remote_file = remoteprefix + cmSystemTools::GetFilenameName(*file); - *this->LogFile << "\tUpload file: " << local_file.c_str() << " to " - << remote_file.c_str() << std::endl; + *this->LogFile << "\tUpload file: " << local_file << " to " + << remote_file << std::endl; std::string ofile = ""; for ( kk = 0; kk < remote_file.size(); kk ++ ) @@ -470,7 +470,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, if ( ::stat(local_file.c_str(), &st) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: " - << local_file.c_str() << std::endl); + << local_file << std::endl); ::curl_easy_cleanup(curl); ::curl_global_cleanup(); return false; @@ -478,8 +478,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb"); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " - << local_file.c_str() << " to " - << upload_as.c_str() << " Size: " << st.st_size << std::endl); + << local_file << " to " + << upload_as << " Size: " << st.st_size << std::endl); // specify target ::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str()); @@ -595,11 +595,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, { cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when uploading file: " - << local_file.c_str() << std::endl); + << local_file << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); *this->LogFile << " Error when uploading file: " - << local_file.c_str() + << local_file << std::endl << " Error message was: " << error_buffer << std::endl; @@ -750,15 +750,15 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP( std::string turl = url + ((url.find("?",0) == std::string::npos) ? "?" : "&") + "xmlfile=" + ofile; - *this->LogFile << "Trigger url: " << turl.c_str() << std::endl; + *this->LogFile << "Trigger url: " << turl << std::endl; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Trigger url: " - << turl.c_str() << std::endl); + << turl << std::endl); curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_easy_setopt(curl, CURLOPT_URL, turl.c_str()); if ( curl_easy_perform(curl) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when triggering: " - << turl.c_str() << std::endl); + << turl << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); *this->LogFile << "\tTriggering failed with error: " << error_buffer @@ -932,8 +932,8 @@ bool cmCTestSubmitHandler::SubmitUsingCP( std::string rfname = destination + "/" + remoteprefix + *file; cmSystemTools::CopyFileAlways(lfname.c_str(), rfname.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Copy file: " - << lfname.c_str() << " to " - << rfname.c_str() << std::endl); + << lfname << " to " + << rfname << std::endl); } std::string tagDoneFile = destination + "/" + remoteprefix + "DONE"; cmSystemTools::Touch(tagDoneFile.c_str(), true); @@ -1183,7 +1183,7 @@ int cmCTestSubmitHandler::ProcessHandler() = buildDirectory + "/Testing/" + this->CTest->GetCurrentTag(); std::string::size_type glen = gpath.size() + 1; gpath = gpath + "/CoverageLog*"; - cmCTestLog(this->CTest, DEBUG, "Globbing for: " << gpath.c_str() + cmCTestLog(this->CTest, DEBUG, "Globbing for: " << gpath << std::endl); if ( cmSystemTools::SimpleGlob(gpath, gfiles, 1) ) { @@ -1191,7 +1191,7 @@ int cmCTestSubmitHandler::ProcessHandler() for ( cc = 0; cc < gfiles.size(); cc ++ ) { gfiles[cc] = gfiles[cc].substr(glen); - cmCTestLog(this->CTest, DEBUG, "Glob file: " << gfiles[cc].c_str() + cmCTestLog(this->CTest, DEBUG, "Glob file: " << gfiles[cc] << std::endl); this->CTest->AddSubmitFile(cmCTest::PartCoverage, gfiles[cc].c_str()); } @@ -1232,7 +1232,7 @@ int cmCTestSubmitHandler::ProcessHandler() cmCTest::SetOfStrings::iterator it; for ( it = files.begin(); it != files.end(); ++ it ) { - ofs << cnt << "\t" << it->c_str() << std::endl; + ofs << cnt << "\t" << *it << std::endl; cnt ++; } } @@ -1448,7 +1448,7 @@ int cmCTestSubmitHandler::ProcessHandler() oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory(); cmSystemTools::ChangeDirectory(buildDirectory.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Change directory: " - << buildDirectory.c_str() << std::endl); + << buildDirectory << std::endl); if ( !this->SubmitUsingCP( "Testing/"+this->CTest->GetCurrentTag(), diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index efeb658..1d1dde4 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -616,7 +616,7 @@ int cmCTestTestHandler::ProcessHandler() ofs << ftit->TestCount << ":" << ftit->Name << std::endl; cmCTestLog(this->CTest, HANDLER_OUTPUT, "\t" << std::setw(3) << ftit->TestCount << " - " - << ftit->Name.c_str() << " (" + << ftit->Name << " (" << this->GetTestStatus(ftit->Status) << ")" << std::endl); } @@ -1022,7 +1022,7 @@ bool cmCTestTestHandler::GetValue(const char* tag, { cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: " - << tag << " found [" << line.c_str() << "]" << std::endl); + << tag << " found [" << line << "]" << std::endl); ret = false; } return ret; @@ -1223,7 +1223,7 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os) { os << "\t\t\tfirst.c_str() << "\">" + << "name=\"" << measureIt->first << "\">" << cmXMLSafe(measureIt->second) << "\n"; } @@ -1820,7 +1820,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed() else if ( !this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels() ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem reading file: " - << lastTestsFailedLog.c_str() << + << lastTestsFailedLog << " while generating list of previously failed tests." << std::endl); } } @@ -1960,7 +1960,7 @@ std::string cmCTestTestHandler::GenerateRegressionImages( << " " << k1 << "=\"" << v1 << "\"" << " " << k2 << "=\"" << v2 << "\"" << " encoding=\"none\"" - << ">Image " << filename.c_str() + << ">Image " << filename << " is empty"; } else @@ -2014,10 +2014,10 @@ std::string cmCTestTestHandler::GenerateRegressionImages( << "\t\t\tFile " << filename.c_str() + << ">File " << filename << " not found" << std::endl; - cmCTestLog(this->CTest, HANDLER_OUTPUT, "File \"" << filename.c_str() + cmCTestLog(this->CTest, HANDLER_OUTPUT, "File \"" << filename << "\" not found." << std::endl); } cxml.erase(measurementfile.start(), diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index 11474ec..fda61ea 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -331,7 +331,7 @@ int cmCTestUpdateHandler::DetectVCS(const char* dir) { std::string sourceDirectory = dir; cmCTestLog(this->CTest, DEBUG, "Check directory: " - << sourceDirectory.c_str() << std::endl); + << sourceDirectory << std::endl); sourceDirectory += "/.svn"; if ( cmSystemTools::FileExists(sourceDirectory.c_str()) ) { diff --git a/Source/CTest/cmCTestUploadHandler.cxx b/Source/CTest/cmCTestUploadHandler.cxx index caf2e53..4c3f81b 100644 --- a/Source/CTest/cmCTestUploadHandler.cxx +++ b/Source/CTest/cmCTestUploadHandler.cxx @@ -64,7 +64,7 @@ int cmCTestUploadHandler::ProcessHandler() for ( it = this->Files.begin(); it != this->Files.end(); it ++ ) { cmCTestLog(this->CTest, OUTPUT, - "\tUpload file: " << it->c_str() << std::endl); + "\tUpload file: " << *it << std::endl); ofs << "\n" << "\n"; ofs << this->CTest->Base64EncodeFile(*it); diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index c3a9a16..d5f00ff 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -286,7 +286,7 @@ bool cmAddCustomCommandCommand // No command for this output exists. cmOStringStream e; - e << "given APPEND option with output \"" << output[0].c_str() + e << "given APPEND option with output \"" << output[0] << "\" which is not already a custom command output."; this->SetError(e.str()); return false; diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx index ba3a832..58b61de 100644 --- a/Source/cmCMakeMinimumRequired.cxx +++ b/Source/cmCMakeMinimumRequired.cxx @@ -79,7 +79,7 @@ bool cmCMakeMinimumRequired &required_patch, &required_tweak) < 2) { cmOStringStream e; - e << "could not parse VERSION \"" << version_string.c_str() << "\"."; + e << "could not parse VERSION \"" << version_string << "\"."; this->SetError(e.str()); return false; } @@ -98,7 +98,7 @@ bool cmCMakeMinimumRequired { // The current version is too low. cmOStringStream e; - e << "CMake " << version_string.c_str() + e << "CMake " << version_string << " or higher is required. You are running version " << cmVersion::GetCMakeVersion(); this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 678b497..9f711b7 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -78,7 +78,7 @@ struct tm* cmCTest::GetNightlyTime(std::string str, lctime->tm_mday, str.c_str()); cmCTestLog(this, OUTPUT, "Determine Nightly Start Time" << std::endl - << " Specified time: " << str.c_str() << std::endl); + << " Specified time: " << str << std::endl); //Convert the nightly start time to seconds. Since we are //providing only a time and a timezone, the current date of //the local machine is assumed. Consequently, nightlySeconds @@ -681,7 +681,7 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) if ( !fname.empty() ) { cmCTestLog(this, OUTPUT, " Reading ctest configuration file: " - << fname.c_str() << std::endl); + << fname << std::endl); bool readit = mf->ReadListFile(mf->GetCurrentListFile(), fname.c_str() ); if(!readit) @@ -696,10 +696,10 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) { cmCTestLog(this, WARNING, "Cannot locate CTest configuration: in BuildDirectory: " - << bld_dir_fname.c_str() << std::endl); + << bld_dir_fname << std::endl); cmCTestLog(this, WARNING, "Cannot locate CTest configuration: in SourceDirectory: " - << src_dir_fname.c_str() << std::endl); + << src_dir_fname << std::endl); } this->SetCTestConfigurationFromCMakeVariable(mf, "NightlyStartTime", @@ -748,13 +748,13 @@ bool cmCTest::UpdateCTestConfiguration() } } cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "UpdateCTestConfiguration from :" - << fileName.c_str() << "\n"); + << fileName << "\n"); if ( !cmSystemTools::FileExists(fileName.c_str()) ) { // No need to exit if we are not producing XML if ( this->ProduceXML ) { - cmCTestLog(this, ERROR_MESSAGE, "Cannot find file: " << fileName.c_str() + cmCTestLog(this, ERROR_MESSAGE, "Cannot find file: " << fileName << std::endl); return false; } @@ -762,7 +762,7 @@ bool cmCTest::UpdateCTestConfiguration() else { cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Parse Config file:" - << fileName.c_str() << "\n"); + << fileName << "\n"); // parse the dart test file cmsys::ifstream fin(fileName.c_str()); @@ -1346,7 +1346,7 @@ int cmCTest::RunTest(std::vector argv, *output += oss.str(); if ( log ) { - *log << output->c_str(); + *log << *output; } cmSystemTools::ChangeDirectory(oldpath.c_str()); @@ -1562,7 +1562,7 @@ void cmCTest::AddSiteProperties(std::ostream& ostr) for(std::vector::iterator i = args.begin(); i != args.end(); ++i) { - ostr << " \n"; + ostr << " \n"; } ostr << " \n"; } @@ -1606,7 +1606,7 @@ int cmCTest::GenerateCTestNotesOutput(std::ostream& os, for ( it = files.begin(); it != files.end(); it ++ ) { - cmCTestLog(this, OUTPUT, "\tAdd file: " << it->c_str() << std::endl); + cmCTestLog(this, OUTPUT, "\tAdd file: " << *it << std::endl); std::string note_time = this->CurrentTime(); os << "\n" << "\n" @@ -1624,8 +1624,8 @@ int cmCTest::GenerateCTestNotesOutput(std::ostream& os, } else { - os << "Problem reading file: " << it->c_str() << std::endl; - cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: " << it->c_str() + os << "Problem reading file: " << *it << std::endl; + cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: " << *it << " while creating notes" << std::endl); } os << "\n" @@ -1732,7 +1732,7 @@ bool cmCTest::SubmitExtraFiles(const VectorOfStrings &files) if ( !cmSystemTools::FileExists(it->c_str()) ) { cmCTestLog(this, ERROR_MESSAGE, "Cannot find extra file: " - << it->c_str() << " to submit." + << *it << " to submit." << std::endl;); return false; } @@ -2319,7 +2319,7 @@ int cmCTest::Run(std::vector &args, std::string* output) executeTests = false; cmCTestLog(this, ERROR_MESSAGE, "CTest -T called with incorrect option: " - << args[i].c_str() << std::endl); + << args[i] << std::endl); cmCTestLog(this, ERROR_MESSAGE, "Available options are:" << std::endl << " " << ctestExec << " -T all" << std::endl << " " << ctestExec << " -T start" << std::endl @@ -2356,7 +2356,7 @@ int cmCTest::Run(std::vector &args, std::string* output) { executeTests = false; cmCTestLog(this, ERROR_MESSAGE, - "CTest -M called with incorrect option: " << str.c_str() + "CTest -M called with incorrect option: " << str << std::endl); cmCTestLog(this, ERROR_MESSAGE, "Available options are:" << std::endl << " " << ctestExec << " -M Continuous" << std::endl @@ -2527,11 +2527,11 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) std::string fname = dir; fname += "/CTestCustom.cmake"; cmCTestLog(this, DEBUG, "* Check for file: " - << fname.c_str() << std::endl); + << fname << std::endl); if ( cmSystemTools::FileExists(fname.c_str()) ) { cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: " - << fname.c_str() << std::endl); + << fname << std::endl); bool erroroc = cmSystemTools::GetErrorOccuredFlag(); cmSystemTools::ResetErrorOccuredFlag(); @@ -2540,7 +2540,7 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) { cmCTestLog(this, ERROR_MESSAGE, "Problem reading custom configuration: " - << fname.c_str() << std::endl); + << fname << std::endl); } found = true; if ( erroroc ) @@ -2552,7 +2552,7 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) std::string rexpr = dir; rexpr += "/CTestCustom.ctest"; cmCTestLog(this, DEBUG, "* Check for file: " - << rexpr.c_str() << std::endl); + << rexpr << std::endl); if ( !found && cmSystemTools::FileExists(rexpr.c_str()) ) { cmsys::Glob gl; @@ -2564,13 +2564,13 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) ++ fileIt ) { cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: " - << fileIt->c_str() << std::endl); + << *fileIt << std::endl); if ( !mf->ReadListFile(0, fileIt->c_str()) || cmSystemTools::GetErrorOccuredFlag() ) { cmCTestLog(this, ERROR_MESSAGE, "Problem reading custom configuration: " - << fileIt->c_str() << std::endl); + << *fileIt << std::endl); } } found = true; @@ -2584,7 +2584,7 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) { cmCTestLog(this, DEBUG, "* Read custom CTest configuration vectors for handler: " - << it->first.c_str() << " (" << it->second << ")" << std::endl); + << it->first << " (" << it->second << ")" << std::endl); it->second->PopulateCustomVectors(mf); } } @@ -2610,7 +2610,7 @@ void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def, for ( it = slist.begin(); it != slist.end(); ++it ) { - cmCTestLog(this, DEBUG, " -- " << it->c_str() << std::endl); + cmCTestLog(this, DEBUG, " -- " << *it << std::endl); vec.push_back(*it); } } @@ -2849,7 +2849,7 @@ void cmCTest::AddCTestConfigurationOverwrite(const std::string& overStr) "CTest configuration overwrite specified in the wrong format." << std::endl << "Valid format is: --overwrite key=value" << std::endl - << "The specified was: --overwrite " << overStr.c_str() << std::endl); + << "The specified was: --overwrite " << overStr << std::endl); return; } std::string key = overStr.substr(0, epos); diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 159f9c3..8f352b1 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -644,7 +644,7 @@ void cmCacheManager::OutputHelpString(std::ostream& fout, fout << "\\n"; } oneLine = helpString.substr(pos, i - pos); - fout << oneLine.c_str() << "\n"; + fout << oneLine << "\n"; pos = i; } } @@ -698,7 +698,7 @@ void cmCacheManager::PrintCache(std::ostream& out) const { if((*i).second.Type != INTERNAL) { - out << (*i).first.c_str() << " = " << (*i).second.Value.c_str() + out << (*i).first << " = " << (*i).second.Value << std::endl; } } diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index c9490ca..a7f6b49 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -293,7 +293,7 @@ int cmCommandArgumentParserHelper::ParseString(const char* str, int verb) if ( Verbose ) { std::cerr << "Expanding [" << str << "] produced: [" - << this->Result.c_str() << "]" << std::endl; + << this->Result << "]" << std::endl; } return 1; } diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 3987283..a3f3277 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -284,7 +284,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) { cmOStringStream e; e << "Failed to open\n" - << " " << outFileName.c_str() << "\n" + << " " << outFileName << "\n" << cmSystemTools::GetLastSystemError(); this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return -1; @@ -519,9 +519,9 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) { cmOStringStream emsg; emsg << "Cannot copy output executable\n" - << " '" << this->OutputFile.c_str() << "'\n" + << " '" << this->OutputFile << "'\n" << "to destination specified by COPY_FILE:\n" - << " '" << copyFile.c_str() << "'\n"; + << " '" << copyFile << "'\n"; if(!this->FindErrorMessage.empty()) { emsg << this->FindErrorMessage.c_str(); diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 56ef6e2..d26d3a9 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -278,7 +278,7 @@ bool cmDependsC::WriteDependencies(const std::set& sources, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE) << std::endl; - internalDepends << " " << i->c_str() << std::endl; + internalDepends << " " << *i << std::endl; } makeDepends << std::endl; diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 1d91b4a..79cb560 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -453,7 +453,7 @@ cmDependsFortran cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE) << std::endl; - internalDepends << " " << i->c_str() << std::endl; + internalDepends << " " << *i << std::endl; } makeDepends << std::endl; @@ -666,7 +666,7 @@ bool cmDependsFortran::CopyModule(const std::vector& args) if(!cmSystemTools::CopyFileAlways(mod_upper.c_str(), stamp.c_str())) { std::cerr << "Error copying Fortran module from \"" - << mod_upper.c_str() << "\" to \"" << stamp.c_str() + << mod_upper << "\" to \"" << stamp << "\".\n"; return false; } @@ -681,7 +681,7 @@ bool cmDependsFortran::CopyModule(const std::vector& args) if(!cmSystemTools::CopyFileAlways(mod_lower.c_str(), stamp.c_str())) { std::cerr << "Error copying Fortran module from \"" - << mod_lower.c_str() << "\" to \"" << stamp.c_str() + << mod_lower << "\" to \"" << stamp << "\".\n"; return false; } @@ -689,9 +689,9 @@ bool cmDependsFortran::CopyModule(const std::vector& args) return true; } - std::cerr << "Error copying Fortran module \"" << args[2].c_str() - << "\". Tried \"" << mod_upper.c_str() - << "\" and \"" << mod_lower.c_str() << "\".\n"; + std::cerr << "Error copying Fortran module \"" << args[2] + << "\". Tried \"" << mod_upper + << "\" and \"" << mod_lower << "\".\n"; return false; } diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx index e23e4b7..02f2d21 100644 --- a/Source/cmDependsJavaParserHelper.cxx +++ b/Source/cmDependsJavaParserHelper.cxx @@ -262,7 +262,7 @@ void cmDependsJavaParserHelper::PrintClasses() sit != files.end(); ++ sit ) { - std::cout << " " << sit->c_str() << ".class" << std::endl; + std::cout << " " << *sit << ".class" << std::endl; } } @@ -308,7 +308,7 @@ int cmDependsJavaParserHelper::ParseString(const char* str, int verb) if ( this->CurrentPackage.size() > 0 ) { std::cout << "Current package is: " << - this->CurrentPackage.c_str() << std::endl; + this->CurrentPackage << std::endl; } std::cout << "Imports packages:"; if ( this->PackagesImport.size() > 0 ) @@ -318,7 +318,7 @@ int cmDependsJavaParserHelper::ParseString(const char* str, int verb) it != this->PackagesImport.end(); ++ it ) { - std::cout << " " << it->c_str(); + std::cout << " " << *it; } } std::cout << std::endl; @@ -330,7 +330,7 @@ int cmDependsJavaParserHelper::ParseString(const char* str, int verb) it != this->ClassesFound.end(); ++ it ) { - std::cout << " " << it->c_str(); + std::cout << " " << *it; } } std::cout << std::endl; diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index a4bc83d..d421889 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -693,7 +693,7 @@ bool cmDocumentation::PrintHelpOneManual(std::ostream& os) return true; } // Argument was not a manual. Complain. - os << "Argument \"" << this->CurrentArgument.c_str() + os << "Argument \"" << this->CurrentArgument << "\" to --help-manual is not an available manual. " << "Use --help-manual-list to see all available manuals.\n"; return false; @@ -715,7 +715,7 @@ bool cmDocumentation::PrintHelpOneCommand(std::ostream& os) return true; } // Argument was not a command. Complain. - os << "Argument \"" << this->CurrentArgument.c_str() + os << "Argument \"" << this->CurrentArgument << "\" to --help-command is not a CMake command. " << "Use --help-command-list to see all commands.\n"; return false; @@ -737,7 +737,7 @@ bool cmDocumentation::PrintHelpOneModule(std::ostream& os) return true; } // Argument was not a module. Complain. - os << "Argument \"" << this->CurrentArgument.c_str() + os << "Argument \"" << this->CurrentArgument << "\" to --help-module is not a CMake module.\n"; return false; } @@ -772,7 +772,7 @@ bool cmDocumentation::PrintHelpOneProperty(std::ostream& os) return true; } // Argument was not a property. Complain. - os << "Argument \"" << this->CurrentArgument.c_str() + os << "Argument \"" << this->CurrentArgument << "\" to --help-property is not a CMake property. " << "Use --help-property-list to see all properties.\n"; return false; @@ -796,7 +796,7 @@ bool cmDocumentation::PrintHelpOnePolicy(std::ostream& os) } // Argument was not a policy. Complain. - os << "Argument \"" << this->CurrentArgument.c_str() + os << "Argument \"" << this->CurrentArgument << "\" to --help-policy is not a CMake policy.\n"; return false; } @@ -817,7 +817,7 @@ bool cmDocumentation::PrintHelpOneVariable(std::ostream& os) return true; } // Argument was not a variable. Complain. - os << "Argument \"" << this->CurrentArgument.c_str() + os << "Argument \"" << this->CurrentArgument << "\" to --help-variable is not a defined variable. " << "Use --help-variable-list to see all defined variables.\n"; return false; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 3dc1f6c..a83a228 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -271,7 +271,7 @@ cmExportInstallFileGenerator::GenerateImportFileConfig( { std::string se = cmSystemTools::GetLastSystemError(); cmOStringStream e; - e << "cannot write to file \"" << fileName.c_str() + e << "cannot write to file \"" << fileName << "\": " << se; cmSystemTools::Error(e.str().c_str()); return false; diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index edb9c38..dba2406 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -499,7 +499,7 @@ void cmExtraCodeBlocksGenerator sit!=otherFiles.end(); ++sit) { - fout<<" c_str() <<"\">\n" + fout<<" \n" " \n"; } @@ -653,7 +653,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, dirIt != uniqIncludeDirs.end(); ++dirIt) { - fout <<" c_str() << "\" />\n"; + fout <<" \n"; } fout<<" \n"; diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index da397b1..1cbd057 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -311,7 +311,7 @@ void cmExtraCodeLiteGenerator { std::string relativePath = cmSystemTools::RelativePath(projectPath.c_str(), sit->first.c_str()); - fout<< " \n"; + fout<< " \n"; } fout<< " \n"; fout<< " \n"; @@ -322,7 +322,7 @@ void cmExtraCodeLiteGenerator { std::string relativePath = cmSystemTools::RelativePath(projectPath.c_str(), sit->c_str()); - fout << " \n"; + fout << " \n"; } fout << " \n"; diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index d02e54d..fcb95a0 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -1292,7 +1292,7 @@ void cmExtraEclipseCDT4Generator::AppendTarget(cmGeneratedFileStream& fout, std::string pathXml = cmExtraEclipseCDT4Generator::EscapeForXML(path); fout << "\n" "" << cmExtraEclipseCDT4Generator::GetEclipsePath(make) diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 1d4e30c..a790e00 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -268,7 +268,7 @@ bool cmFindPackageCommand else { cmOStringStream e; - e << "called with invalid argument \"" << args[i].c_str() << "\""; + e << "called with invalid argument \"" << args[i] << "\""; this->SetError(e.str()); return false; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index b67da5b..b95ff81 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2318,7 +2318,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) it != componentsSet->end(); ++ it ) { - ostr << " \"" << it->c_str() << "\""; + ostr << " \"" << *it << "\""; } } else diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 2e856ba..df3ce10 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -360,7 +360,7 @@ void cmGlobalKdevelopGenerator if (strstr(line, "")) { fout<< " KDevCustomProject\n"; - fout<< " " <" <\n"; //this one is important fout<<" true\n"; //and this one @@ -368,14 +368,14 @@ void cmGlobalKdevelopGenerator // inside kdevcustomproject the must be put if (strstr(line, "")) { - fout<<" "<"<\n"; } // buildtool and builddir go inside if (strstr(line, "")) { fout<<" make\n"; - fout<<" "<\n"; + fout<<" "<\n"; } } } @@ -417,7 +417,7 @@ void cmGlobalKdevelopGenerator " KDevCustomProject\n" " " << primaryLanguage << "\n" " \n" - " " << projectDir.c_str() << + " " << projectDir << "\n"; //this one is important fout<<" true\n"; //and this one @@ -444,12 +444,12 @@ void cmGlobalKdevelopGenerator fout<<" \n" " \n" - " " << outputDir.c_str() << + " " << outputDir << "\n" " \n" - " " << executable.c_str() << "\n" + " " << executable << "\n" " custom\n" - " "<\n" + " "<\n" " \n" " false\n" " true\n" @@ -457,7 +457,7 @@ void cmGlobalKdevelopGenerator " \n" " \n" " make\n"; //this one is important - fout<<" "<\n"; //and this one + fout<<" "<\n"; //and this one fout<<" \n" " \n" " false\n" @@ -480,7 +480,7 @@ void cmGlobalKdevelopGenerator dirIt != this->Blacklist.end(); ++dirIt) { - fout<<" " << dirIt->c_str() << "\n"; + fout<<" " << *dirIt << "\n"; } fout<<" \n"; @@ -558,7 +558,7 @@ void cmGlobalKdevelopGenerator // command fout<<" \n" " \n" - " \n"; if (enableCxx) @@ -601,7 +601,7 @@ void cmGlobalKdevelopGenerator "\n" "\n" " \n" - " \n" " \n" " \n" diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 4a19c0c..f5c56a9 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -357,13 +357,13 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() << "set(CMAKE_MAKEFILE_DEPENDS\n" << " \"" << lg->Convert(cache, - cmLocalGenerator::START_OUTPUT).c_str() << "\"\n"; + cmLocalGenerator::START_OUTPUT) << "\"\n"; for(std::vector::const_iterator i = lfiles.begin(); i != lfiles.end(); ++i) { cmakefileStream << " \"" - << lg->Convert(*i, cmLocalGenerator::START_OUTPUT).c_str() + << lg->Convert(*i, cmLocalGenerator::START_OUTPUT) << "\"\n"; } cmakefileStream @@ -380,10 +380,10 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() << "set(CMAKE_MAKEFILE_OUTPUTS\n" << " \"" << lg->Convert(makefileName, - cmLocalGenerator::START_OUTPUT).c_str() << "\"\n" + cmLocalGenerator::START_OUTPUT) << "\"\n" << " \"" << lg->Convert(check, - cmLocalGenerator::START_OUTPUT).c_str() << "\"\n"; + cmLocalGenerator::START_OUTPUT) << "\"\n"; cmakefileStream << " )\n\n"; // CMake must rerun if a byproduct is missing. @@ -397,7 +397,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() k != outfiles.end(); ++k) { cmakefileStream << " \"" << - lg->Convert(*k,cmLocalGenerator::HOME_OUTPUT).c_str() + lg->Convert(*k,cmLocalGenerator::HOME_OUTPUT) << "\"\n"; } @@ -411,7 +411,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() tmpStr += cmake::GetCMakeFilesDirectory(); tmpStr += "/CMakeDirectoryInformation.cmake"; cmakefileStream << " \"" << - lg->Convert(tmpStr,cmLocalGenerator::HOME_OUTPUT).c_str() + lg->Convert(tmpStr,cmLocalGenerator::HOME_OUTPUT) << "\"\n"; } cmakefileStream << " )\n\n"; @@ -450,7 +450,7 @@ void cmGlobalUnixMakefileGenerator3 std::string tname = lg->GetRelativeTargetDirectory(l->second); tname += "/DependInfo.cmake"; cmSystemTools::ConvertToUnixSlashes(tname); - cmakefileStream << " \"" << tname.c_str() << "\"\n"; + cmakefileStream << " \"" << tname << "\"\n"; } } } diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 824e9e7..601993f 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -349,8 +349,8 @@ void cmGraphVizWriter::WriteConnections(const std::string& targetName, this->WriteNode(libName, this->TargetPtrs.find(libName)->second, insertedNodes, str); - str << " \"" << myNodeName.c_str() << "\" -> \"" - << libNameIt->second.c_str() << "\""; + str << " \"" << myNodeName << "\" -> \"" + << libNameIt->second << "\""; str << " // " << targetName << " -> " << libName << std::endl; this->WriteConnections(libName, insertedNodes, insertedConnections, str); } @@ -455,7 +455,7 @@ void cmGraphVizWriter::WriteNode(const std::string& targetName, std::map::const_iterator nameIt = this->TargetNamesNodes.find(targetName); - str << " \"" << nameIt->second.c_str() << "\" [ label=\"" + str << " \"" << nameIt->second << "\" [ label=\"" << targetName << "\" shape=\"" << getShapeForTarget(target) << "\"];" << std::endl; } diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 0fad9d6..9370e48 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -91,7 +91,7 @@ void cmInstallGenerator << "${CMAKE_ABSOLUTE_DESTINATION_FILES}\")\n"; os << indent << "endif()\n"; } - os << "file(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype.c_str(); + os << "file(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype; if(optional) { os << " OPTIONAL"; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 21957f9..de8dd51 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -503,7 +503,7 @@ void cmLocalGenerator::GenerateInstallRules() { std::string odir = (*ci)->GetMakefile()->GetStartOutputDirectory(); cmSystemTools::ConvertToUnixSlashes(odir); - fout << " include(\"" << odir.c_str() + fout << " include(\"" << odir << "/cmake_install.cmake\")" << std::endl; } } @@ -523,12 +523,12 @@ void cmLocalGenerator::GenerateInstallRules() "endif()\n\n"; fout << "file(WRITE \"" - << homedir.c_str() << "/${CMAKE_INSTALL_MANIFEST}\" " + << homedir << "/${CMAKE_INSTALL_MANIFEST}\" " << "\"\")" << std::endl; fout << "foreach(file ${CMAKE_INSTALL_MANIFEST_FILES})" << std::endl << " file(APPEND \"" - << homedir.c_str() << "/${CMAKE_INSTALL_MANIFEST}\" " + << homedir << "/${CMAKE_INSTALL_MANIFEST}\" " << "\"${file}\\n\")" << std::endl << "endforeach()" << std::endl; } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 5dd2bb1..02d388a 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -625,7 +625,7 @@ cmLocalUnixMakefileGenerator3 i != commands.end(); ++i) { replace = *i; - os << "\t" << replace.c_str() << "\n"; + os << "\t" << replace << "\n"; } if(symbolic && !this->WatcomWMake) { @@ -1933,7 +1933,7 @@ void cmLocalUnixMakefileGenerator3 for(ImplicitDependLanguageMap::const_iterator l = implicitLangs.begin(); l != implicitLangs.end(); ++l) { - cmakefileStream << " \"" << l->first.c_str() << "\"\n"; + cmakefileStream << " \"" << l->first << "\"\n"; } cmakefileStream << " )\n"; @@ -1944,7 +1944,7 @@ void cmLocalUnixMakefileGenerator3 l = implicitLangs.begin(); l != implicitLangs.end(); ++l) { cmakefileStream - << "set(CMAKE_DEPENDS_CHECK_" << l->first.c_str() << "\n"; + << "set(CMAKE_DEPENDS_CHECK_" << l->first << "\n"; ImplicitDependFileMap const& implicitPairs = l->second; // for each file pair @@ -1968,7 +1968,7 @@ void cmLocalUnixMakefileGenerator3 if(cid && *cid) { cmakefileStream - << "set(CMAKE_" << l->first.c_str() << "_COMPILER_ID \"" + << "set(CMAKE_" << l->first << "_COMPILER_ID \"" << cid << "\")\n"; } } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 6fef371..58625fb 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -240,7 +240,7 @@ void cmMakefile::PrintStringVector(const char* s, for(std::vector::const_iterator i = v.begin(); i != v.end(); ++i) { - std::cout << (*i).c_str() << " "; + std::cout << *i << " "; } std::cout << " )\n"; } @@ -253,7 +253,7 @@ void cmMakefile for(std::vector >::const_iterator i = v.begin(); i != v.end(); ++i) { - std::cout << i->first.c_str() << " " << i->second; + std::cout << i->first << " " << i->second; } std::cout << " )\n"; } @@ -273,15 +273,15 @@ void cmMakefile::Print() const } std::cout << " this->StartOutputDirectory; " << - this->StartOutputDirectory.c_str() << std::endl; + this->StartOutputDirectory << std::endl; std::cout << " this->HomeOutputDirectory; " << - this->HomeOutputDirectory.c_str() << std::endl; + this->HomeOutputDirectory << std::endl; std::cout << " this->cmStartDirectory; " << - this->cmStartDirectory.c_str() << std::endl; + this->cmStartDirectory << std::endl; std::cout << " this->cmHomeDirectory; " << - this->cmHomeDirectory.c_str() << std::endl; + this->cmHomeDirectory << std::endl; std::cout << " this->ProjectName; " - << this->ProjectName.c_str() << std::endl; + << this->ProjectName << std::endl; this->PrintStringVector("this->LinkDirectories", this->LinkDirectories); #if defined(CMAKE_BUILD_WITH_CMAKE) for( std::vector::const_iterator i = @@ -2619,7 +2619,7 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source, << " " << filename << ":" << line << "\n"; } error << "when parsing string\n" - << " " << source.c_str() << "\n"; + << " " << source << "\n"; error << emsg; // If the parser failed ("res" is false) then this is a real diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 0730bc3..983fd99 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -353,7 +353,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() std::string compiler = "CMAKE_"; compiler += *l; compiler += "_COMPILER"; - *this->FlagFileStream << "# compile " << l->c_str() << " with " << + *this->FlagFileStream << "# compile " << *l << " with " << this->Makefile->GetSafeDefinition(compiler) << "\n"; } @@ -1353,7 +1353,7 @@ cmMakefileTargetGenerator "_OBJECTS"); *this->BuildFileStream << "# Object files for target " << this->Target->GetName() << "\n" - << variableName.c_str() << " ="; + << variableName << " ="; std::string object; const char* objName = this->Makefile->GetDefinition("CMAKE_NO_QUOTED_OBJECTS"); @@ -1390,7 +1390,7 @@ cmMakefileTargetGenerator << "\n" << "# External object files for target " << this->Target->GetName() << "\n" - << variableNameExternal.c_str() << " ="; + << variableNameExternal << " ="; for(std::vector::const_iterator i = this->ExternalObjects.begin(); i != this->ExternalObjects.end(); ++i) diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index 365665d..edba5ba 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -91,7 +91,7 @@ bool cmSourceGroupCommand else { cmOStringStream err; - err << "Unknown argument \"" << args[i].c_str() << "\". " + err << "Unknown argument \"" << args[i] << "\". " << "Perhaps the FILES keyword is missing.\n"; this->SetError(err.str()); return false; diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx index 60796ec..8d26f86 100644 --- a/Source/cmUseMangledMesaCommand.cxx +++ b/Source/cmUseMangledMesaCommand.cxx @@ -107,12 +107,12 @@ CopyAndFullPathMesaHeader(const char* source, if(glDirLine.find(includeFile.c_str())) { std::string gfile = glDirLine.match(3); - fout << "#include \"" << outdir << "/" << gfile.c_str() << "\"\n"; + fout << "#include \"" << outdir << "/" << gfile << "\"\n"; } else if(glLine.find(includeFile.c_str())) { fout << "#include \"" << outdir << "/" << - includeLine.match(1).c_str() << "\"\n"; + includeLine.match(1) << "\"\n"; } else { diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx index 3c1fe46..debe243 100644 --- a/Source/cmVariableWatchCommand.cxx +++ b/Source/cmVariableWatchCommand.cxx @@ -84,7 +84,7 @@ static void cmVariableWatchCommandVariableAccessed( if ( !processed ) { cmOStringStream msg; - msg << "Variable \"" << variable.c_str() << "\" was accessed using " + msg << "Variable \"" << variable << "\" was accessed using " << accessString << " with value \"" << (newValue?newValue:"") << "\"."; makefile->IssueMessage(cmake::LOG, msg.str()); } @@ -136,7 +136,7 @@ bool cmVariableWatchCommand if ( variable == "CMAKE_CURRENT_LIST_FILE" ) { cmOStringStream ostr; - ostr << "cannot be set on the variable: " << variable.c_str(); + ostr << "cannot be set on the variable: " << variable; this->SetError(ostr.str()); return false; } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index ad8e5e6..4ce1d70 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -433,7 +433,7 @@ bool cmake::SetCacheArgs(const std::vector& args) return false; } } - std::cerr << "loading initial cache file " << path.c_str() << "\n"; + std::cerr << "loading initial cache file " << path << "\n"; this->ReadListFile(args, path.c_str()); } else if(arg.find("-P",0) == 0) @@ -1922,7 +1922,7 @@ int cmake::CheckBuildSystem() { cmOStringStream msg; msg << "Re-run cmake missing file: " - << this->CheckBuildSystemArgument.c_str() << "\n"; + << this->CheckBuildSystemArgument << "\n"; cmSystemTools::Stdout(msg.str().c_str()); } return 1; @@ -1942,7 +1942,7 @@ int cmake::CheckBuildSystem() { cmOStringStream msg; msg << "Re-run cmake error reading : " - << this->CheckBuildSystemArgument.c_str() << "\n"; + << this->CheckBuildSystemArgument << "\n"; cmSystemTools::Stdout(msg.str().c_str()); } // There was an error reading the file. Just rerun. @@ -2076,8 +2076,8 @@ int cmake::CheckBuildSystem() if(verbose) { cmOStringStream msg; - msg << "Re-run cmake file: " << out_oldest.c_str() - << " older than: " << dep_newest.c_str() << "\n"; + msg << "Re-run cmake file: " << out_oldest + << " older than: " << dep_newest << "\n"; cmSystemTools::Stdout(msg.str().c_str()); } return 1; @@ -2351,8 +2351,8 @@ int cmake::GetSystemInformation(std::vector& args) // Copy file if(!cmSystemTools::cmCopyFile(inFile.c_str(), outFile.c_str())) { - std::cerr << "Error copying file \"" << inFile.c_str() - << "\" to \"" << outFile.c_str() << "\".\n"; + std::cerr << "Error copying file \"" << inFile + << "\" to \"" << outFile << "\".\n"; return 1; } diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index ad1f2a5..9aee975 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -102,8 +102,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) { if(!cmSystemTools::cmCopyFile(args[2].c_str(), args[3].c_str())) { - std::cerr << "Error copying file \"" << args[2].c_str() - << "\" to \"" << args[3].c_str() << "\".\n"; + std::cerr << "Error copying file \"" << args[2] + << "\" to \"" << args[3] << "\".\n"; return 1; } return 0; @@ -116,7 +116,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) args[3].c_str())) { std::cerr << "Error copying file (if different) from \"" - << args[2].c_str() << "\" to \"" << args[3].c_str() + << args[2] << "\" to \"" << args[3] << "\".\n"; return 1; } @@ -129,7 +129,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) if(!cmSystemTools::CopyADirectory(args[2].c_str(), args[3].c_str())) { std::cerr << "Error copying directory from \"" - << args[2].c_str() << "\" to \"" << args[3].c_str() + << args[2] << "\" to \"" << args[3] << "\".\n"; return 1; } @@ -143,7 +143,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) { std::string e = cmSystemTools::GetLastSystemError(); std::cerr << "Error renaming from \"" - << args[2].c_str() << "\" to \"" << args[3].c_str() + << args[2] << "\" to \"" << args[3] << "\": " << e << "\n"; return 1; } @@ -156,7 +156,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) if(cmSystemTools::FilesDiffer(args[2].c_str(), args[3].c_str())) { std::cerr << "Files \"" - << args[2].c_str() << "\" to \"" << args[3].c_str() + << args[2] << "\" to \"" << args[3] << "\" are different.\n"; return 1; } @@ -199,7 +199,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) std::vector::iterator it; for ( it = env.begin(); it != env.end(); ++ it ) { - std::cout << it->c_str() << std::endl; + std::cout << *it << std::endl; } return 0; } @@ -209,7 +209,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) { if(!cmSystemTools::MakeDirectory(args[2].c_str())) { - std::cerr << "Error making directory \"" << args[2].c_str() + std::cerr << "Error making directory \"" << args[2] << "\".\n"; return 1; } @@ -221,7 +221,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) if(cmSystemTools::FileIsDirectory(args[2].c_str()) && !cmSystemTools::RemoveADirectory(args[2].c_str())) { - std::cerr << "Error removing directory \"" << args[2].c_str() + std::cerr << "Error removing directory \"" << args[2] << "\".\n"; return 1; } @@ -1181,7 +1181,7 @@ bool cmcmd::RunCommand(const char* comment, for(std::vector::iterator i = command.begin(); i != command.end(); ++i) { - std::cout << i->c_str() << " "; + std::cout << *i << " "; } std::cout << "\n"; } @@ -1257,7 +1257,7 @@ int cmcmd::VisualStudioLinkIncremental(std::vector& args, resourceInputFile += ".resource.txt"; if(verbose) { - std::cout << "Create " << resourceInputFile.c_str() << "\n"; + std::cout << "Create " << resourceInputFile << "\n"; } // Create input file for rc command cmsys::ofstream fout(resourceInputFile.c_str()); @@ -1269,7 +1269,7 @@ int cmcmd::VisualStudioLinkIncremental(std::vector& args, manifestFile += ".embed.manifest"; std::string fullPath= cmSystemTools::CollapseFullPath(manifestFile.c_str()); fout << type << " /* CREATEPROCESS_MANIFEST_RESOURCE_ID " - "*/ 24 /* RT_MANIFEST */ " << "\"" << fullPath.c_str() << "\""; + "*/ 24 /* RT_MANIFEST */ " << "\"" << fullPath << "\""; fout.close(); manifestArg += tempManifest; // add the manifest arg to the linkCommand @@ -1281,7 +1281,7 @@ int cmcmd::VisualStudioLinkIncremental(std::vector& args, { if(verbose) { - std::cout << "Create empty: " << manifestFile.c_str() << "\n"; + std::cout << "Create empty: " << manifestFile << "\n"; } cmsys::ofstream foutTmp(manifestFile.c_str()); } -- cgit v0.12 From c4c6427ed656e181d569d1c7baca29813c12b9fb Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 12 Mar 2014 00:01:12 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 18e328a..aaddd92 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 0) -set(CMake_VERSION_PATCH 20140311) +set(CMake_VERSION_PATCH 20140312) #set(CMake_VERSION_RC 1) -- cgit v0.12 From ae32622bcfe4aee667b749f89e61d9a4fe44c762 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 12 Mar 2014 09:54:20 -0400 Subject: cmake-gui: Fix handling of missing CMAKE_EXTRA_GENERATOR (#14804) Since commit 1a1b737c (stringapi: Use strings for generator names, 2014-02-24) cmExternalMakefileProjectGenerator::CreateFullGeneratorName expects a std::string instead of const char*. When no extra generator name is available, pass an empty string to avoid NULL dereference. --- Source/QtDialog/QCMake.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 12da320..5f9ebaf 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -117,7 +117,7 @@ void QCMake::setBinaryDirectory(const QString& _dir) { const char* extraGen = cachem->GetCacheValue("CMAKE_EXTRA_GENERATOR"); std::string curGen = cmExternalMakefileProjectGenerator:: - CreateFullGeneratorName(itm.GetValue(), extraGen); + CreateFullGeneratorName(itm.GetValue(), extraGen? extraGen : ""); this->setGenerator(QString::fromLocal8Bit(curGen.c_str())); } } -- cgit v0.12 From 3be265b304da0879c79e2fcdfff6f25b1a4e87c1 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 12 Mar 2014 10:39:23 -0400 Subject: Workaround Sun C++ 5.9 compiler crash Adjust whitespace in Source/CPack/cpack.cxx to avoid a strange internal compiler crash. --- Source/CPack/cpack.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 7ebfeda..9eabdca 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -275,8 +275,8 @@ int main (int argc, char const* const* argv) else if ( cpackConfigFileSpecified ) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, - "Cannot find CPack config file: \"" << cpackConfigFile - << "\"" << std::endl); + "Cannot find CPack config file: \"" << + cpackConfigFile << "\"" << std::endl); return 1; } -- cgit v0.12 From d45e7f34611cd678bdda29d7d2b2ff4ce1abbce7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 10 Mar 2014 13:53:57 -0400 Subject: cmCustomCommand: Return std::string from GetWorkingDirectory --- Source/cmCustomCommand.cxx | 10 ---------- Source/cmCustomCommand.h | 7 ++++--- Source/cmGlobalXCodeGenerator.cxx | 5 +++-- Source/cmLocalNinjaGenerator.cxx | 6 +++--- Source/cmLocalUnixMakefileGenerator3.cxx | 13 +++++++------ Source/cmLocalVisualStudio6Generator.cxx | 2 +- Source/cmLocalVisualStudioGenerator.cxx | 8 ++++---- 7 files changed, 22 insertions(+), 29 deletions(-) diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index b672148..ac2eef8 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -101,16 +101,6 @@ const std::vector& cmCustomCommand::GetOutputs() const } //---------------------------------------------------------------------------- -const char* cmCustomCommand::GetWorkingDirectory() const -{ - if(this->WorkingDirectory.size() == 0) - { - return 0; - } - return this->WorkingDirectory.c_str(); -} - -//---------------------------------------------------------------------------- const std::vector& cmCustomCommand::GetDepends() const { return this->Depends; diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index 67c305e..b5d7e62 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -42,12 +42,13 @@ public: /** Get the output file produced by the command. */ const std::vector& GetOutputs() const; - /** Get the working directory. */ - const char* GetWorkingDirectory() const; - /** Get the vector that holds the list of dependencies. */ const std::vector& GetDepends() const; + /** Get the working directory. */ + std::string const& GetWorkingDirectory() const + { return this->WorkingDirectory; } + /** Get the list of command lines. */ const cmCustomCommandLines& GetCommandLines() const; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 30a2a1e..16c74b9 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1646,10 +1646,11 @@ void cmGlobalXCodeGenerator cmSystemTools::ReplaceString(cmd2, "/./", "/"); cmd2 = this->ConvertToRelativeForMake(cmd2.c_str()); std::string cmd; - if(cc.GetWorkingDirectory()) + std::string wd = cc.GetWorkingDirectory(); + if(!wd.empty()) { cmd += "cd "; - cmd += this->ConvertToRelativeForMake(cc.GetWorkingDirectory()); + cmd += this->ConvertToRelativeForMake(wd.c_str()); cmd += " && "; } cmd += cmd2; diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index acaacdd..d68a07b 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -364,8 +364,8 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, { cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile); if (ccg.GetNumberOfCommands() > 0) { - const char* wd = cc->GetWorkingDirectory(); - if (!wd) + std::string wd = cc->GetWorkingDirectory(); + if (wd.empty()) wd = this->GetMakefile()->GetStartOutputDirectory(); cmOStringStream cdCmd; @@ -491,7 +491,7 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher( if(!outputs.empty()) { RelativeRoot relative_root = - cc.GetWorkingDirectory() ? NONE : START_OUTPUT; + cc.GetWorkingDirectory().empty() ? START_OUTPUT : NONE; output = this->Convert(outputs[0], relative_root, SHELL); } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 3681e0e..d3f63f5 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1023,9 +1023,9 @@ cmLocalUnixMakefileGenerator3 } // if the command specified a working directory use it. - const char* dir = this->Makefile->GetStartOutputDirectory(); - const char* workingDir = cc.GetWorkingDirectory(); - if(workingDir) + std::string dir = this->Makefile->GetStartOutputDirectory(); + std::string workingDir = cc.GetWorkingDirectory(); + if(!workingDir.empty()) { dir = workingDir; } @@ -1066,7 +1066,7 @@ cmLocalUnixMakefileGenerator3 // Convert the command to a relative path only if the current // working directory will be the start-output directory. bool had_slash = cmd.find("/") != cmd.npos; - if(!workingDir) + if(workingDir.empty()) { cmd = this->Convert(cmd,START_OUTPUT); } @@ -1079,7 +1079,8 @@ cmLocalUnixMakefileGenerator3 cmd = "./" + cmd; } std::string launcher = - this->MakeLauncher(cc, target, workingDir? NONE : START_OUTPUT); + this->MakeLauncher(cc, target, + workingDir.empty()? START_OUTPUT : NONE); cmd = launcher + this->ConvertShellCommand(cmd, NONE); ccg.AppendArguments(c, cmd); @@ -1125,7 +1126,7 @@ cmLocalUnixMakefileGenerator3 } // Setup the proper working directory for the commands. - this->CreateCDCommand(commands1, dir, relative); + this->CreateCDCommand(commands1, dir.c_str(), relative); // push back the custom commands commands.insert(commands.end(), commands1.begin(), commands1.end()); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index f1fd994..d713024 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -583,7 +583,7 @@ cmLocalVisualStudio6Generator this->Makefile->AddCustomCommandToOutput( output, depends, no_main_dependency, origCommand.GetCommandLines(), comment.c_str(), - origCommand.GetWorkingDirectory())) + origCommand.GetWorkingDirectory().c_str())) { target.AddSourceFile(outsf); } diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 6e93d22..3075c15 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -84,9 +84,9 @@ cmLocalVisualStudioGenerator const std::string& newline_text) { bool useLocal = this->CustomCommandUseLocal(); - const char* workingDirectory = cc.GetWorkingDirectory(); + std::string workingDirectory = cc.GetWorkingDirectory(); cmCustomCommandGenerator ccg(cc, configName, this->Makefile); - RelativeRoot relativeRoot = workingDirectory? NONE : START_OUTPUT; + RelativeRoot relativeRoot = workingDirectory.empty()? START_OUTPUT : NONE; // Avoid leading or trailing newlines. std::string newline = ""; @@ -114,7 +114,7 @@ cmLocalVisualStudioGenerator script += "setlocal"; } - if(workingDirectory) + if(!workingDirectory.empty()) { // Change the working directory. script += newline; @@ -124,7 +124,7 @@ cmLocalVisualStudioGenerator script += check_error; // Change the working drive. - if(workingDirectory[0] && workingDirectory[1] == ':') + if(workingDirectory.size() > 1 && workingDirectory[1] == ':') { script += newline; newline = newline_text; -- cgit v0.12 From 9a5c55441418ef79415b9a1b99c35192d2b8c1b0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 10 Mar 2014 15:04:38 -0400 Subject: cmGlobalXCodeGenerator: Simplify handling of multiple outputs Make the multiple output pair map more local. Generate it where we have the current configuration available. --- Source/cmGlobalXCodeGenerator.cxx | 49 ++++++++++++++------------------------- Source/cmGlobalXCodeGenerator.h | 4 +--- 2 files changed, 19 insertions(+), 34 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 16c74b9..2dd31f3 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1470,32 +1470,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, const & commands, const char* name) { - - // collect multiple outputs of custom commands into a set - // which will be used for every configuration - std::map multipleOutputPairs; - for(std::vector::const_iterator i = commands.begin(); - i != commands.end(); ++i) - { - cmCustomCommand const& cc = *i; - if(!cc.GetCommandLines().empty()) - { - const std::vector& outputs = cc.GetOutputs(); - if(!outputs.empty()) - { - // If there are more than one outputs treat the - // first as the primary output and make the rest depend on it. - std::vector::const_iterator o = outputs.begin(); - std::string primaryOutput = this->ConvertToRelativeForMake(o->c_str()); - for(++o; o != outputs.end(); ++o) - { - std::string currentOutput=this->ConvertToRelativeForMake(o->c_str()); - multipleOutputPairs[currentOutput] = primaryOutput; - } - } - } - } - + bool haveMultipleOutputPairs = false; std::string dir = this->CurrentMakefile->GetCurrentOutputDirectory(); dir += "/CMakeScripts"; cmSystemTools::MakeDirectory(dir.c_str()); @@ -1515,7 +1490,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, target, commands, currentConfig->c_str(), - multipleOutputPairs); + haveMultipleOutputPairs); } std::string cdir = this->CurrentMakefile->GetCurrentOutputDirectory(); @@ -1525,7 +1500,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, makecmd += " -f "; makecmd += this->ConvertToRelativeForMake( (makefile+"$CONFIGURATION").c_str()); - if(!multipleOutputPairs.empty()) + if(haveMultipleOutputPairs) { makecmd += " cmake_check_multiple_outputs"; } @@ -1544,9 +1519,7 @@ void cmGlobalXCodeGenerator std::vector const & commands, const std::string& configName, - const std::map& multipleOutputPairs - ) + bool& haveMultipleOutputPairs) { std::string makefileName=makefileBasename; if(this->XcodeVersion > 20) @@ -1569,6 +1542,7 @@ void cmGlobalXCodeGenerator makefileStream << "all: "; std::map tname; int count = 0; + std::map multipleOutputPairs; for(std::vector::const_iterator i = commands.begin(); i != commands.end(); ++i) { @@ -1584,6 +1558,16 @@ void cmGlobalXCodeGenerator makefileStream << "\\\n\t" << this->ConvertToRelativeForMake(o->c_str()); } + + // If there is more than one output treat the first as the + // primary output and make the rest depend on it. + std::vector::const_iterator o = outputs.begin(); + std::string primaryOutput = this->ConvertToRelativeForMake(o->c_str()); + for(++o; o != outputs.end(); ++o) + { + std::string currentOutput=this->ConvertToRelativeForMake(o->c_str()); + multipleOutputPairs[currentOutput] = primaryOutput; + } } else { @@ -1683,6 +1667,9 @@ void cmGlobalXCodeGenerator << o->second << "; fi\n"; } } + + haveMultipleOutputPairs = + haveMultipleOutputPairs || !multipleOutputPairs.empty(); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 93315ba..be81cdc 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -124,9 +124,7 @@ private: cmTarget& target, std::vector const & commands, const std::string& configName, - const std::map& - multipleOutputPairs - ); + bool& haveMultipleOutputPairs); cmXCodeObject* FindXCodeTarget(cmTarget const*); std::string GetOrCreateId(const std::string& name, const std::string& id); -- cgit v0.12 From bc993f277ebd44fabe8312a85c5682eed011336d Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 10 Mar 2014 15:47:19 -0400 Subject: Generalize cmCustomCommandGenerator to more fields Until now the cmCustomCommandGenerator was used only to compute the command lines of a custom command. Generalize it to get the comment, working directory, dependencies, and outputs of custom commands. Update use in all generators to support this. --- Source/cmCustomCommandGenerator.cxx | 24 ++++++++++++++++++ Source/cmCustomCommandGenerator.h | 5 ++++ Source/cmGlobalXCodeGenerator.cxx | 29 +++++++++++----------- Source/cmLocalGenerator.cxx | 13 +++++----- Source/cmLocalGenerator.h | 3 ++- Source/cmLocalNinjaGenerator.cxx | 33 +++++++++++++------------ Source/cmLocalNinjaGenerator.h | 7 +++--- Source/cmLocalUnixMakefileGenerator3.cxx | 34 ++++++++++++++------------ Source/cmLocalUnixMakefileGenerator3.h | 9 ++++--- Source/cmLocalVisualStudio6Generator.cxx | 39 ++++++++++++++++++------------ Source/cmLocalVisualStudio7Generator.cxx | 24 +++++++++--------- Source/cmLocalVisualStudioGenerator.cxx | 6 ++--- Source/cmLocalVisualStudioGenerator.h | 4 +-- Source/cmMakefileTargetGenerator.cxx | 28 ++++++++++++--------- Source/cmMakefileTargetGenerator.h | 4 +-- Source/cmNinjaNormalTargetGenerator.cxx | 5 +++- Source/cmNinjaTargetGenerator.cxx | 4 ++- Source/cmNinjaUtilityTargetGenerator.cxx | 11 ++++++--- Source/cmVisualStudio10TargetGenerator.cxx | 23 +++++++++--------- 19 files changed, 182 insertions(+), 123 deletions(-) diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index b9cf777..a091cff 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -71,3 +71,27 @@ cmCustomCommandGenerator } } } + +//---------------------------------------------------------------------------- +const char* cmCustomCommandGenerator::GetComment() const +{ + return this->CC.GetComment(); +} + +//---------------------------------------------------------------------------- +std::string cmCustomCommandGenerator::GetWorkingDirectory() const +{ + return this->CC.GetWorkingDirectory(); +} + +//---------------------------------------------------------------------------- +std::vector const& cmCustomCommandGenerator::GetOutputs() const +{ + return this->CC.GetOutputs(); +} + +//---------------------------------------------------------------------------- +std::vector const& cmCustomCommandGenerator::GetDepends() const +{ + return this->CC.GetDepends(); +} diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h index 17d644a..cbcdb41 100644 --- a/Source/cmCustomCommandGenerator.h +++ b/Source/cmCustomCommandGenerator.h @@ -33,9 +33,14 @@ public: const std::string& config, cmMakefile* mf); ~cmCustomCommandGenerator(); + cmCustomCommand const& GetCC() const { return this->CC; } unsigned int GetNumberOfCommands() const; std::string GetCommand(unsigned int c) const; void AppendArguments(unsigned int c, std::string& cmd) const; + const char* GetComment() const; + std::string GetWorkingDirectory() const; + std::vector const& GetOutputs() const; + std::vector const& GetDepends() const; }; #endif diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 2dd31f3..36196a2 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1546,10 +1546,10 @@ void cmGlobalXCodeGenerator for(std::vector::const_iterator i = commands.begin(); i != commands.end(); ++i) { - cmCustomCommand const& cc = *i; - if(!cc.GetCommandLines().empty()) + cmCustomCommandGenerator ccg(*i, configName, this->CurrentMakefile); + if(ccg.GetNumberOfCommands() > 0) { - const std::vector& outputs = cc.GetOutputs(); + const std::vector& outputs = ccg.GetOutputs(); if(!outputs.empty()) { for(std::vector::const_iterator o = outputs.begin(); @@ -1573,8 +1573,8 @@ void cmGlobalXCodeGenerator { cmOStringStream str; str << "_buildpart_" << count++ ; - tname[&cc] = std::string(target.GetName()) + str.str(); - makefileStream << "\\\n\t" << tname[&cc]; + tname[&ccg.GetCC()] = std::string(target.GetName()) + str.str(); + makefileStream << "\\\n\t" << tname[&ccg.GetCC()]; } } } @@ -1582,12 +1582,11 @@ void cmGlobalXCodeGenerator for(std::vector::const_iterator i = commands.begin(); i != commands.end(); ++i) { - cmCustomCommand const& cc = *i; - if(!cc.GetCommandLines().empty()) + cmCustomCommandGenerator ccg(*i, configName, this->CurrentMakefile); + if(ccg.GetNumberOfCommands() > 0) { - cmCustomCommandGenerator ccg(cc, configName, this->CurrentMakefile); makefileStream << "\n"; - const std::vector& outputs = cc.GetOutputs(); + const std::vector& outputs = ccg.GetOutputs(); if(!outputs.empty()) { // There is at least one output, start the rule for it @@ -1598,11 +1597,11 @@ void cmGlobalXCodeGenerator else { // There are no outputs. Use the generated force rule name. - makefileStream << tname[&cc] << ": "; + makefileStream << tname[&ccg.GetCC()] << ": "; } for(std::vector::const_iterator d = - cc.GetDepends().begin(); - d != cc.GetDepends().end(); ++d) + ccg.GetDepends().begin(); + d != ccg.GetDepends().end(); ++d) { std::string dep; if(this->CurrentLocalGenerator @@ -1614,11 +1613,11 @@ void cmGlobalXCodeGenerator } makefileStream << "\n"; - if(const char* comment = cc.GetComment()) + if(const char* comment = ccg.GetComment()) { std::string echo_cmd = "echo "; echo_cmd += (this->CurrentLocalGenerator-> - EscapeForShell(comment, cc.GetEscapeAllowMakeVars())); + EscapeForShell(comment, ccg.GetCC().GetEscapeAllowMakeVars())); makefileStream << "\t" << echo_cmd.c_str() << "\n"; } @@ -1630,7 +1629,7 @@ void cmGlobalXCodeGenerator cmSystemTools::ReplaceString(cmd2, "/./", "/"); cmd2 = this->ConvertToRelativeForMake(cmd2.c_str()); std::string cmd; - std::string wd = cc.GetWorkingDirectory(); + std::string wd = ccg.GetWorkingDirectory(); if(!wd.empty()) { cmd += "cd "; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index de8dd51..ebcfa08 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -22,6 +22,7 @@ #include "cmSourceFile.h" #include "cmTest.h" #include "cmTestGenerator.h" +#include "cmCustomCommandGenerator.h" #include "cmVersion.h" #include "cmake.h" @@ -2482,23 +2483,23 @@ void cmLocalGenerator::AppendFeatureOptions( //---------------------------------------------------------------------------- std::string -cmLocalGenerator::ConstructComment(const cmCustomCommand& cc, +cmLocalGenerator::ConstructComment(cmCustomCommandGenerator const& ccg, const char* default_comment) { // Check for a comment provided with the command. - if(cc.GetComment()) + if(ccg.GetComment()) { - return cc.GetComment(); + return ccg.GetComment(); } // Construct a reasonable default comment if possible. - if(!cc.GetOutputs().empty()) + if(!ccg.GetOutputs().empty()) { std::string comment; comment = "Generating "; const char* sep = ""; - for(std::vector::const_iterator o = cc.GetOutputs().begin(); - o != cc.GetOutputs().end(); ++o) + for(std::vector::const_iterator o = ccg.GetOutputs().begin(); + o != ccg.GetOutputs().end(); ++o) { comment += sep; comment += this->Convert(*o, cmLocalGenerator::START_OUTPUT); diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 4d62833..afcaee9 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -21,6 +21,7 @@ class cmTarget; class cmTargetManifest; class cmSourceFile; class cmCustomCommand; +class cmCustomCommandGenerator; /** \class cmLocalGenerator * \brief Create required build files for a directory. @@ -350,7 +351,7 @@ public: const std::string& targetName, const char* fname); /** Construct a comment for a custom command. */ - std::string ConstructComment(const cmCustomCommand& cc, + std::string ConstructComment(cmCustomCommandGenerator const& ccg, const char* default_comment = ""); // Compute object file names. std::string GetObjectFileNameWithoutTarget(const cmSourceFile& source, diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index d68a07b..7c4aab8 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -303,10 +303,11 @@ cmLocalNinjaGenerator this->GetGlobalNinjaGenerator()->AppendTargetDepends(target, outputs); } -void cmLocalNinjaGenerator::AppendCustomCommandDeps(const cmCustomCommand *cc, - cmNinjaDeps &ninjaDeps) +void cmLocalNinjaGenerator::AppendCustomCommandDeps( + cmCustomCommandGenerator const& ccg, + cmNinjaDeps &ninjaDeps) { - const std::vector &deps = cc->GetDepends(); + const std::vector &deps = ccg.GetDepends(); for (std::vector::const_iterator i = deps.begin(); i != deps.end(); ++i) { std::string dep; @@ -359,12 +360,12 @@ std::string cmLocalNinjaGenerator::BuildCommandLine( return cmd.str(); } -void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, - std::vector &cmdLines) +void cmLocalNinjaGenerator::AppendCustomCommandLines( + cmCustomCommandGenerator const& ccg, + std::vector &cmdLines) { - cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile); if (ccg.GetNumberOfCommands() > 0) { - std::string wd = cc->GetWorkingDirectory(); + std::string wd = ccg.GetWorkingDirectory(); if (wd.empty()) wd = this->GetMakefile()->GetStartOutputDirectory(); @@ -378,7 +379,7 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, cmdLines.push_back(cdCmd.str()); } - std::string launcher = this->MakeCustomLauncher(*cc); + std::string launcher = this->MakeCustomLauncher(ccg); for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) { cmdLines.push_back(launcher + @@ -396,19 +397,21 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc)) return; - const std::vector &outputs = cc->GetOutputs(); + cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile); + + const std::vector &outputs = ccg.GetOutputs(); cmNinjaDeps ninjaOutputs(outputs.size()), ninjaDeps; std::transform(outputs.begin(), outputs.end(), ninjaOutputs.begin(), MapToNinjaPath()); - this->AppendCustomCommandDeps(cc, ninjaDeps); + this->AppendCustomCommandDeps(ccg, ninjaDeps); for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end(); ++i) this->GetGlobalNinjaGenerator()->SeenCustomCommandOutput(*i); std::vector cmdLines; - this->AppendCustomCommandLines(cc, cmdLines); + this->AppendCustomCommandLines(ccg, cmdLines); if (cmdLines.empty()) { this->GetGlobalNinjaGenerator()->WritePhonyBuild( @@ -423,7 +426,7 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( } else { this->GetGlobalNinjaGenerator()->WriteCustomCommandBuild( this->BuildCommandLine(cmdLines), - this->ConstructComment(*cc), + this->ConstructComment(ccg), "Custom command for " + ninjaOutputs[0], ninjaOutputs, ninjaDeps, @@ -472,7 +475,7 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements() } std::string cmLocalNinjaGenerator::MakeCustomLauncher( - const cmCustomCommand& cc) + cmCustomCommandGenerator const& ccg) { const char* property = "RULE_LAUNCH_CUSTOM"; const char* property_value = this->Makefile->GetProperty(property); @@ -487,11 +490,11 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher( RuleVariables vars; vars.RuleLauncher = property; std::string output; - const std::vector& outputs = cc.GetOutputs(); + const std::vector& outputs = ccg.GetOutputs(); if(!outputs.empty()) { RelativeRoot relative_root = - cc.GetWorkingDirectory().empty() ? START_OUTPUT : NONE; + ccg.GetWorkingDirectory().empty() ? START_OUTPUT : NONE; output = this->Convert(outputs[0], relative_root, SHELL); } diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 2d870fb..9d0b7b5 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -16,6 +16,7 @@ # include "cmLocalGenerator.h" # include "cmNinjaTypes.h" +class cmCustomCommandGenerator; class cmGlobalNinjaGenerator; class cmGeneratedFileStream; class cmake; @@ -92,9 +93,9 @@ public: void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs); void AddCustomCommandTarget(cmCustomCommand const* cc, cmTarget* target); - void AppendCustomCommandLines(const cmCustomCommand *cc, + void AppendCustomCommandLines(cmCustomCommandGenerator const& ccg, std::vector &cmdLines); - void AppendCustomCommandDeps(const cmCustomCommand *cc, + void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg, cmNinjaDeps &ninjaDeps); virtual std::string ConvertToLinkReference(std::string const& lib, @@ -124,7 +125,7 @@ private: void WriteCustomCommandBuildStatements(); - std::string MakeCustomLauncher(const cmCustomCommand& cc); + std::string MakeCustomLauncher(cmCustomCommandGenerator const& ccg); std::string ConfigName; std::string HomeRelativeOutputPath; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index d3f63f5..9f12ffe 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -960,7 +960,9 @@ cmLocalUnixMakefileGenerator3 for(std::vector::const_iterator i = ccs.begin(); i != ccs.end(); ++i) { - this->AppendCustomDepend(depends, *i); + cmCustomCommandGenerator ccg(*i, this->ConfigurationName, + this->Makefile); + this->AppendCustomDepend(depends, ccg); } } @@ -968,10 +970,10 @@ cmLocalUnixMakefileGenerator3 void cmLocalUnixMakefileGenerator3 ::AppendCustomDepend(std::vector& depends, - const cmCustomCommand& cc) + cmCustomCommandGenerator const& ccg) { - for(std::vector::const_iterator d = cc.GetDepends().begin(); - d != cc.GetDepends().end(); ++d) + for(std::vector::const_iterator d = ccg.GetDepends().begin(); + d != ccg.GetDepends().end(); ++d) { // Lookup the real name of the dependency in case it is a CMake target. std::string dep; @@ -994,7 +996,9 @@ cmLocalUnixMakefileGenerator3 for(std::vector::const_iterator i = ccs.begin(); i != ccs.end(); ++i) { - this->AppendCustomCommand(commands, *i, target, true, relative); + cmCustomCommandGenerator ccg(*i, this->ConfigurationName, + this->Makefile); + this->AppendCustomCommand(commands, ccg, target, true, relative); } } @@ -1002,7 +1006,7 @@ cmLocalUnixMakefileGenerator3 void cmLocalUnixMakefileGenerator3 ::AppendCustomCommand(std::vector& commands, - const cmCustomCommand& cc, + cmCustomCommandGenerator const& ccg, cmTarget* target, bool echo_comment, cmLocalGenerator::RelativeRoot relative, @@ -1014,8 +1018,8 @@ cmLocalUnixMakefileGenerator3 // their comments generated elsewhere. if(echo_comment) { - const char* comment = cc.GetComment(); - if(comment && *comment) + const char* comment = ccg.GetComment(); + if(comment && !*comment) { this->AppendEcho(commands, comment, cmLocalUnixMakefileGenerator3::EchoGenerate); @@ -1024,7 +1028,7 @@ cmLocalUnixMakefileGenerator3 // if the command specified a working directory use it. std::string dir = this->Makefile->GetStartOutputDirectory(); - std::string workingDir = cc.GetWorkingDirectory(); + std::string workingDir = ccg.GetWorkingDirectory(); if(!workingDir.empty()) { dir = workingDir; @@ -1033,8 +1037,6 @@ cmLocalUnixMakefileGenerator3 { *content << dir; } - cmCustomCommandGenerator ccg(cc, this->ConfigurationName, - this->Makefile); // Add each command line to the set of commands. std::vector commands1; @@ -1079,7 +1081,7 @@ cmLocalUnixMakefileGenerator3 cmd = "./" + cmd; } std::string launcher = - this->MakeLauncher(cc, target, + this->MakeLauncher(ccg, target, workingDir.empty()? START_OUTPUT : NONE); cmd = launcher + this->ConvertShellCommand(cmd, NONE); @@ -1134,9 +1136,9 @@ cmLocalUnixMakefileGenerator3 //---------------------------------------------------------------------------- std::string -cmLocalUnixMakefileGenerator3::MakeLauncher(const cmCustomCommand& cc, - cmTarget* target, - RelativeRoot relative) +cmLocalUnixMakefileGenerator3::MakeLauncher( + cmCustomCommandGenerator const& ccg, + cmTarget* target, RelativeRoot relative) { // Short-circuit if there is no launcher. const char* prop = "RULE_LAUNCH_CUSTOM"; @@ -1152,7 +1154,7 @@ cmLocalUnixMakefileGenerator3::MakeLauncher(const cmCustomCommand& cc, vars.RuleLauncher = prop; vars.CMTarget = target; std::string output; - const std::vector& outputs = cc.GetOutputs(); + const std::vector& outputs = ccg.GetOutputs(); if(!outputs.empty()) { output = this->Convert(outputs[0], relative, SHELL); diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 7987c96..d504247 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -18,6 +18,7 @@ #include "cmDepends.h" class cmCustomCommand; +class cmCustomCommandGenerator; class cmDependInformation; class cmDepends; class cmMakefileTargetGenerator; @@ -289,14 +290,14 @@ protected: void AppendCustomDepends(std::vector& depends, const std::vector& ccs); void AppendCustomDepend(std::vector& depends, - const cmCustomCommand& cc); + cmCustomCommandGenerator const& cc); void AppendCustomCommands(std::vector& commands, const std::vector& ccs, cmTarget* target, cmLocalGenerator::RelativeRoot relative = cmLocalGenerator::HOME_OUTPUT); void AppendCustomCommand(std::vector& commands, - const cmCustomCommand& cc, + cmCustomCommandGenerator const& ccg, cmTarget* target, bool echo_comment=false, cmLocalGenerator::RelativeRoot relative = @@ -313,8 +314,8 @@ protected: private: std::string ConvertShellCommand(std::string const& cmd, RelativeRoot root); - std::string MakeLauncher(const cmCustomCommand& cc, cmTarget* target, - RelativeRoot relative); + std::string MakeLauncher(cmCustomCommandGenerator const& ccg, + cmTarget* target, RelativeRoot relative); friend class cmMakefileTargetGenerator; friend class cmMakefileExecutableTargetGenerator; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index d713024..2ab25cc 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -16,6 +16,7 @@ #include "cmSourceFile.h" #include "cmCacheManager.h" #include "cmGeneratorTarget.h" +#include "cmCustomCommandGenerator.h" #include "cmake.h" #include "cmComputeLinkInformation.h" @@ -59,6 +60,7 @@ public: } void Write(cmCustomCommand const& cc) { + cmCustomCommandGenerator ccg(cc, this->Config, this->LG->GetMakefile()); if(this->First) { this->Code += this->Event + "_Cmds="; @@ -68,7 +70,7 @@ public: { this->Code += "\\\n\t"; } - this->Code += this->LG->ConstructScript(cc, this->Config, "\\\n\t"); + this->Code += this->LG->ConstructScript(ccg, "\\\n\t"); } private: cmLocalVisualStudio6Generator* LG; @@ -575,14 +577,18 @@ cmLocalVisualStudio6Generator target.GetName().size() + 30)]; sprintf(output,"%s/%s_force_%i", this->Makefile->GetStartOutputDirectory(), target.GetName().c_str(), count); - std::string comment = this->ConstructComment(origCommand, ""); + const char* comment = origCommand.GetComment(); + if(!comment && origCommand.GetOutputs().empty()) + { + comment = ""; + } // Add the rule with the given dependencies and commands. std::string no_main_dependency = ""; if(cmSourceFile* outsf = this->Makefile->AddCustomCommandToOutput( output, depends, no_main_dependency, - origCommand.GetCommandLines(), comment.c_str(), + origCommand.GetCommandLines(), comment, origCommand.GetWorkingDirectory().c_str())) { target.AddSourceFile(outsf); @@ -604,20 +610,21 @@ cmLocalVisualStudio6Generator const cmCustomCommand& command, const char* flags) { - std::string comment = - this->ConstructComment(command, "Building Custom Rule $(InputPath)"); - if(comment == "") - { - comment = ""; - } - // Write the rule for each configuration. std::vector::iterator i; for(i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { std::string config = this->GetConfigName(*i); + cmCustomCommandGenerator ccg(command, config, this->Makefile); + std::string comment = + this->ConstructComment(ccg, "Building Custom Rule $(InputPath)"); + if(comment == "") + { + comment = ""; + } + std::string script = - this->ConstructScript(command, config.c_str(), "\\\n\t"); + this->ConstructScript(ccg, "\\\n\t"); if (i == this->Configurations.begin()) { @@ -634,8 +641,8 @@ cmLocalVisualStudio6Generator // Write out the dependencies for the rule. fout << "USERDEP__HACK="; for(std::vector::const_iterator d = - command.GetDepends().begin(); - d != command.GetDepends().end(); + ccg.GetDepends().begin(); + d != ccg.GetDepends().end(); ++d) { // Lookup the real name of the dependency in case it is a CMake target. @@ -655,7 +662,7 @@ cmLocalVisualStudio6Generator fout << " " << comment.c_str(); } fout << "\n\n"; - if(command.GetOutputs().empty()) + if(ccg.GetOutputs().empty()) { fout << source << "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t"; @@ -664,8 +671,8 @@ cmLocalVisualStudio6Generator else { for(std::vector::const_iterator o = - command.GetOutputs().begin(); - o != command.GetOutputs().end(); + ccg.GetOutputs().begin(); + o != ccg.GetOutputs().end(); ++o) { // Write a rule for every output generated by this command. diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 4491140..14ad567 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -18,6 +18,7 @@ #include "cmSourceFile.h" #include "cmCacheManager.h" #include "cmGeneratorTarget.h" +#include "cmCustomCommandGenerator.h" #include "cmake.h" #include "cmComputeLinkInformation.h" @@ -609,9 +610,10 @@ public: } void Write(cmCustomCommand const& cc) { + cmCustomCommandGenerator ccg(cc, this->Config, this->LG->GetMakefile()); if(this->First) { - const char* comment = cc.GetComment(); + const char* comment = ccg.GetComment(); if(comment && *comment) { this->Stream << "\nDescription=\"" @@ -624,7 +626,7 @@ public: { this->Stream << this->LG->EscapeForXML("\n"); } - std::string script = this->LG->ConstructScript(cc, this->Config); + std::string script = this->LG->ConstructScript(ccg); this->Stream << this->LG->EscapeForXML(script.c_str()); } private: @@ -1791,8 +1793,6 @@ WriteCustomRule(std::ostream& fout, const cmCustomCommand& command, FCInfo& fcinfo) { - std::string comment = this->ConstructComment(command); - // Write the rule for each configuration. std::vector::iterator i; std::vector *configs = @@ -1810,6 +1810,7 @@ WriteCustomRule(std::ostream& fout, } for(i = configs->begin(); i != configs->end(); ++i) { + cmCustomCommandGenerator ccg(command, *i, this->Makefile); cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i]; fout << "\t\t\t\tPlatformName << "\">\n"; @@ -1821,7 +1822,8 @@ WriteCustomRule(std::ostream& fout, << this->EscapeForXML(fc.CompileFlags.c_str()) << "\"/>\n"; } - std::string script = this->ConstructScript(command, i->c_str()); + std::string comment = this->ConstructComment(ccg); + std::string script = this->ConstructScript(ccg); if(this->FortranProject) { cmSystemTools::ReplaceString(script, "$(Configuration)", i->c_str()); @@ -1833,7 +1835,7 @@ WriteCustomRule(std::ostream& fout, << "\t\t\t\t\tCommandLine=\"" << this->EscapeForXML(script.c_str()) << "\"\n" << "\t\t\t\t\tAdditionalDependencies=\""; - if(command.GetDepends().empty()) + if(ccg.GetDepends().empty()) { // There are no real dependencies. Produce an artificial one to // make sure the rule runs reliably. @@ -1848,8 +1850,8 @@ WriteCustomRule(std::ostream& fout, { // Write out the dependencies for the rule. for(std::vector::const_iterator d = - command.GetDepends().begin(); - d != command.GetDepends().end(); + ccg.GetDepends().begin(); + d != ccg.GetDepends().end(); ++d) { // Get the real name of the dependency in case it is a CMake target. @@ -1863,7 +1865,7 @@ WriteCustomRule(std::ostream& fout, } fout << "\"\n"; fout << "\t\t\t\t\tOutputs=\""; - if(command.GetOutputs().empty()) + if(ccg.GetOutputs().empty()) { fout << source << "_force"; } @@ -1872,8 +1874,8 @@ WriteCustomRule(std::ostream& fout, // Write a rule for the output generated by this command. const char* sep = ""; for(std::vector::const_iterator o = - command.GetOutputs().begin(); - o != command.GetOutputs().end(); + ccg.GetOutputs().begin(); + o != ccg.GetOutputs().end(); ++o) { fout << sep << this->ConvertToXMLOutputPathSingle(o->c_str()); diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 3075c15..613ee97 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -79,13 +79,11 @@ const char* cmLocalVisualStudioGenerator::GetReportErrorLabel() const //---------------------------------------------------------------------------- std::string cmLocalVisualStudioGenerator -::ConstructScript(cmCustomCommand const& cc, - const std::string& configName, +::ConstructScript(cmCustomCommandGenerator const& ccg, const std::string& newline_text) { bool useLocal = this->CustomCommandUseLocal(); - std::string workingDirectory = cc.GetWorkingDirectory(); - cmCustomCommandGenerator ccg(cc, configName, this->Makefile); + std::string workingDirectory = ccg.GetWorkingDirectory(); RelativeRoot relativeRoot = workingDirectory.empty()? START_OUTPUT : NONE; // Avoid leading or trailing newlines. diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index 94a6293..a89e219 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -19,6 +19,7 @@ class cmSourceFile; class cmSourceGroup; class cmCustomCommand; +class cmCustomCommandGenerator; /** \class cmLocalVisualStudioGenerator * \brief Base class for Visual Studio generators. @@ -46,8 +47,7 @@ public: virtual ~cmLocalVisualStudioGenerator(); /** Construct a script from the given list of command lines. */ - std::string ConstructScript(cmCustomCommand const& cc, - const std::string& configName, + std::string ConstructScript(cmCustomCommandGenerator const& ccg, const std::string& newline = "\n"); /** Label to which to jump in a batch file after a failed step in a diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 983fd99..3161aba 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -21,6 +21,7 @@ #include "cmTarget.h" #include "cmake.h" #include "cmComputeLinkInformation.h" +#include "cmCustomCommandGenerator.h" #include "cmGeneratorExpression.h" #include "cmMakefileExecutableTargetGenerator.h" @@ -158,11 +159,13 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() si = customCommands.begin(); si != customCommands.end(); ++si) { - cmCustomCommand const* cc = (*si)->GetCustomCommand(); - this->GenerateCustomRuleFile(*cc); + cmCustomCommandGenerator ccg(*(*si)->GetCustomCommand(), + this->ConfigName, + this->Makefile); + this->GenerateCustomRuleFile(ccg); if (clean) { - const std::vector& outputs = cc->GetOutputs(); + const std::vector& outputs = ccg.GetOutputs(); for(std::vector::const_iterator o = outputs.begin(); o != outputs.end(); ++o) { @@ -1178,7 +1181,8 @@ cmMakefileTargetGenerator { if(cmCustomCommand* cc = (*source)->GetCustomCommand()) { - const std::vector& outputs = cc->GetOutputs(); + cmCustomCommandGenerator ccg(*cc, this->ConfigName, this->Makefile); + const std::vector& outputs = ccg.GetOutputs(); for(std::vector::const_iterator o = outputs.begin(); o != outputs.end(); ++o) { @@ -1210,11 +1214,11 @@ void cmMakefileTargetGenerator //---------------------------------------------------------------------------- void cmMakefileTargetGenerator -::GenerateCustomRuleFile(const cmCustomCommand& cc) +::GenerateCustomRuleFile(cmCustomCommandGenerator const& ccg) { // Collect the commands. std::vector commands; - std::string comment = this->LocalGenerator->ConstructComment(cc); + std::string comment = this->LocalGenerator->ConstructComment(ccg); if(!comment.empty()) { // add in a progress call if needed @@ -1229,19 +1233,19 @@ void cmMakefileTargetGenerator // Now append the actual user-specified commands. cmOStringStream content; - this->LocalGenerator->AppendCustomCommand(commands, cc, this->Target, false, + this->LocalGenerator->AppendCustomCommand(commands, ccg, this->Target, false, cmLocalGenerator::HOME_OUTPUT, &content); // Collect the dependencies. std::vector depends; - this->LocalGenerator->AppendCustomDepend(depends, cc); + this->LocalGenerator->AppendCustomDepend(depends, ccg); // Check whether we need to bother checking for a symbolic output. bool need_symbolic = this->GlobalGenerator->GetNeedSymbolicMark(); // Write the rule. - const std::vector& outputs = cc.GetOutputs(); + const std::vector& outputs = ccg.GetOutputs(); std::vector::const_iterator o = outputs.begin(); { bool symbolic = false; @@ -1259,7 +1263,7 @@ void cmMakefileTargetGenerator // If the rule has changed make sure the output is rebuilt. if(!symbolic) { - this->GlobalGenerator->AddRuleHash(cc.GetOutputs(), content.str()); + this->GlobalGenerator->AddRuleHash(ccg.GetOutputs(), content.str()); } } @@ -1280,8 +1284,8 @@ void cmMakefileTargetGenerator // Setup implicit dependency scanning. for(cmCustomCommand::ImplicitDependsList::const_iterator - idi = cc.GetImplicitDepends().begin(); - idi != cc.GetImplicitDepends().end(); ++idi) + idi = ccg.GetCC().GetImplicitDepends().begin(); + idi != ccg.GetCC().GetImplicitDepends().end(); ++idi) { std::string objFullPath = this->Convert(outputs[0], cmLocalGenerator::FULL); diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index bed945b..97c58b9 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -15,7 +15,7 @@ #include "cmLocalUnixMakefileGenerator3.h" #include "cmOSXBundleGenerator.h" -class cmCustomCommand; +class cmCustomCommandGenerator; class cmDependInformation; class cmDepends; class cmGeneratorTarget; @@ -102,7 +102,7 @@ protected: std::vector& depends); // write the build rule for a custom command - void GenerateCustomRuleFile(const cmCustomCommand& cc); + void GenerateCustomRuleFile(cmCustomCommandGenerator const& ccg); // write a rule to drive building of more than one output from // another rule diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 34b2e63..2d1bc76 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -18,6 +18,7 @@ #include "cmMakefile.h" #include "cmOSXBundleGenerator.h" #include "cmGeneratorTarget.h" +#include "cmCustomCommandGenerator.h" #include #include @@ -555,7 +556,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() for (std::vector::const_iterator ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) { - this->GetLocalGenerator()->AppendCustomCommandLines(&*ci, + cmCustomCommandGenerator ccg(*ci, this->GetConfigName(), + this->GetMakefile()); + this->GetLocalGenerator()->AppendCustomCommandLines(ccg, *cmdLineLists[i]); } } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index d652018..ed3782c 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -577,7 +577,9 @@ cmNinjaTargetGenerator si != customCommands.end(); ++si) { cmCustomCommand const* cc = (*si)->GetCustomCommand(); - const std::vector& ccoutputs = cc->GetOutputs(); + cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), + this->GetMakefile()); + const std::vector& ccoutputs = ccg.GetOutputs(); std::transform(ccoutputs.begin(), ccoutputs.end(), std::back_inserter(orderOnlyDeps), MapToNinjaPath()); } diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 1a7b445..0fb40c0 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -17,6 +17,7 @@ #include "cmMakefile.h" #include "cmSourceFile.h" #include "cmTarget.h" +#include "cmCustomCommandGenerator.h" cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator( cmGeneratorTarget *target) @@ -37,8 +38,10 @@ void cmNinjaUtilityTargetGenerator::Generate() for (unsigned i = 0; i != 2; ++i) { for (std::vector::const_iterator ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) { - this->GetLocalGenerator()->AppendCustomCommandDeps(&*ci, deps); - this->GetLocalGenerator()->AppendCustomCommandLines(&*ci, commands); + cmCustomCommandGenerator ccg(*ci, this->GetConfigName(), + this->GetMakefile()); + this->GetLocalGenerator()->AppendCustomCommandDeps(ccg, deps); + this->GetLocalGenerator()->AppendCustomCommandLines(ccg, commands); } } @@ -49,10 +52,12 @@ void cmNinjaUtilityTargetGenerator::Generate() { if(cmCustomCommand* cc = (*source)->GetCustomCommand()) { + cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), + this->GetMakefile()); this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget()); // Depend on all custom command outputs. - const std::vector& ccOutputs = cc->GetOutputs(); + const std::vector& ccOutputs = ccg.GetOutputs(); std::transform(ccOutputs.begin(), ccOutputs.end(), std::back_inserter(deps), MapToNinjaPath()); } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 90155b4..7c55f64 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -19,6 +19,7 @@ #include "cmSourceFile.h" #include "cmVisualStudioGeneratorOptions.h" #include "cmLocalVisualStudio7Generator.h" +#include "cmCustomCommandGenerator.h" #include "cmVS10CLFlagTable.h" #include "cmVS10LinkFlagTable.h" #include "cmVS10LibFlagTable.h" @@ -616,8 +617,6 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, } } cmLocalVisualStudio7Generator* lg = this->LocalGenerator; - std::string comment = lg->ConstructComment(command); - comment = cmVS10EscapeComment(comment); std::vector *configs = static_cast (this->GlobalGenerator)->GetConfigurations(); @@ -627,8 +626,11 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, for(std::vector::iterator i = configs->begin(); i != configs->end(); ++i) { + cmCustomCommandGenerator ccg(command, *i, this->Makefile); + std::string comment = lg->ConstructComment(ccg); + comment = cmVS10EscapeComment(comment); std::string script = - cmVS10EscapeXML(lg->ConstructScript(command, i->c_str())); + cmVS10EscapeXML(lg->ConstructScript(ccg)); this->WritePlatformConfigTag("Message",i->c_str(), 3); (*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "\n"; this->WritePlatformConfigTag("Command", i->c_str(), 3); @@ -637,8 +639,8 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, (*this->BuildFileStream ) << source->GetFullPath(); for(std::vector::const_iterator d = - command.GetDepends().begin(); - d != command.GetDepends().end(); + ccg.GetDepends().begin(); + d != ccg.GetDepends().end(); ++d) { std::string dep; @@ -652,8 +654,8 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, this->WritePlatformConfigTag("Outputs", i->c_str(), 3); const char* sep = ""; for(std::vector::const_iterator o = - command.GetOutputs().begin(); - o != command.GetOutputs().end(); + ccg.GetOutputs().begin(); + o != ccg.GetOutputs().end(); ++o) { std::string out = *o; @@ -1835,13 +1837,12 @@ void cmVisualStudio10TargetGenerator::WriteEvent( for(std::vector::const_iterator i = commands.begin(); i != commands.end(); ++i) { - const cmCustomCommand& command = *i; + cmCustomCommandGenerator ccg(*i, configName, this->Makefile); comment += pre; - comment += lg->ConstructComment(command); + comment += lg->ConstructComment(ccg); script += pre; pre = "\n"; - script += - cmVS10EscapeXML(lg->ConstructScript(command, configName.c_str())); + script += cmVS10EscapeXML(lg->ConstructScript(ccg)); } comment = cmVS10EscapeComment(comment); this->WriteString("",3); -- cgit v0.12 From c1dde67e62868529aaea807a3664b2eef9389a5b Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 12 Mar 2014 10:58:16 -0400 Subject: KWSys 2014-03-12 (dd873734) Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ dd873734 | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' 9c653603..dd873734 Brad King (1): 88c5a768 Set policy CMP0025 to NEW within KWSys Stephen Kelly (1): dd873734 SystemTools: Remove some unnecessary c_str() calls Change-Id: I5487fefcb3e44875ed5748fb2c4ab8302fcef984 --- CMakeLists.txt | 3 +++ SystemTools.cxx | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52bcfe1..977d57b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,6 +85,9 @@ # written. CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR) +IF(POLICY CMP0025) + CMAKE_POLICY(SET CMP0025 NEW) +ENDIF() #----------------------------------------------------------------------------- # If a namespace is not specified, use "kwsys" and enable testing. diff --git a/SystemTools.cxx b/SystemTools.cxx index b6a2437..32e79e6 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -4918,8 +4918,8 @@ void SystemTools::ClassInitialize() // Strip off one directory level and see if the logical // mapping still works. - pwd_str = SystemTools::GetFilenamePath(pwd_str.c_str()); - cwd_str = SystemTools::GetFilenamePath(cwd_str.c_str()); + pwd_str = SystemTools::GetFilenamePath(pwd_str); + cwd_str = SystemTools::GetFilenamePath(cwd_str); Realpath(pwd_str.c_str(), pwd_path); } -- cgit v0.12 From c34216cf8a265b617d4422d772187e38e57647ba Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Wed, 12 Mar 2014 20:48:46 -0600 Subject: cmake-gui: Fix compile with Qt5 using UTF-8 internal encoding. Because we already call [to|from]Local8Bit() with C strings where we are supposed to, we do not need to specify UTF-8 encoding when converting C strings to QString. --- Source/QtDialog/CMakeSetup.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 995929e..1b04a00 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -81,9 +81,7 @@ int main(int argc, char** argv) #if defined(KWSYS_CP_UTF8) QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8"); - QTextCodec::setCodecForCStrings(utf8_codec); QTextCodec::setCodecForLocale(utf8_codec); - QTextCodec::setCodecForTr(utf8_codec); #endif // clean out standard Qt paths for plugins, which we don't use anyway -- cgit v0.12 From 4a6a59a120eeb9a60e0da77eb701af80439a34db Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 13 Mar 2014 00:01:10 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index aaddd92..be11dce 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 0) -set(CMake_VERSION_PATCH 20140312) +set(CMake_VERSION_PATCH 20140313) #set(CMake_VERSION_RC 1) -- cgit v0.12 From d5b2e33be2119ad12744ed62920a8f8d9b6d705d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 11 Mar 2014 16:35:58 +0100 Subject: Makefiles: Compute local object files on demand. Don't compute them up front. --- Source/cmGlobalUnixMakefileGenerator3.cxx | 8 +---- Source/cmLocalUnixMakefileGenerator3.cxx | 58 ++++++++++++++++++++++++------- Source/cmLocalUnixMakefileGenerator3.h | 8 ++--- 3 files changed, 50 insertions(+), 24 deletions(-) diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index f5c56a9..0e03e89 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -109,9 +109,6 @@ cmGlobalUnixMakefileGenerator3 ::ComputeTargetObjects(cmGeneratorTarget* gt) const { cmTarget* target = gt->Target; - cmLocalUnixMakefileGenerator3* lg = - static_cast(gt->LocalGenerator); - // Compute full path to object file directory for this target. std::string dir_max; dir_max += gt->Makefile->GetCurrentOutputDirectory(); @@ -128,12 +125,9 @@ cmGlobalUnixMakefileGenerator3 si != objectSources.end(); ++si) { cmSourceFile* sf = *si; - bool hasSourceExtension = true; std::string objectName = gt->LocalGenerator - ->GetObjectFileNameWithoutTarget(*sf, dir_max, - &hasSourceExtension); + ->GetObjectFileNameWithoutTarget(*sf, dir_max); gt->AddObject(sf, objectName); - lg->AddLocalObjectFile(target, sf, objectName, hasSourceExtension); } } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 9f12ffe..a838ce3 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -172,26 +172,57 @@ void cmLocalUnixMakefileGenerator3::Generate() } //---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator3::AddLocalObjectFile( - cmTarget* target, cmSourceFile* sf, std::string objNoTargetDir, - bool hasSourceExtension) +void cmLocalUnixMakefileGenerator3:: +GetLocalObjectFiles(std::map &localObjectFiles) { - if(cmSystemTools::FileIsFullPath(objNoTargetDir.c_str())) + std::set emitted; + cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator ti = targets.begin(); + ti != targets.end(); ++ti) { - objNoTargetDir = cmSystemTools::GetFilenameName(objNoTargetDir); + cmGeneratorTarget* gt = ti->second; + if (gt->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } + std::vector objectSources; + gt->GetObjectSources(objectSources); + // Compute full path to object file directory for this target. + std::string dir_max; + dir_max += gt->Makefile->GetCurrentOutputDirectory(); + dir_max += "/"; + dir_max += this->GetTargetDirectory(*gt->Target); + dir_max += "/"; + // Compute the name of each object file. + for(std::vector::iterator + si = objectSources.begin(); + si != objectSources.end(); ++si) + { + cmSourceFile* sf = *si; + bool hasSourceExtension = true; + std::string objectName = this->GetObjectFileNameWithoutTarget(*sf, + dir_max, + &hasSourceExtension); + if(cmSystemTools::FileIsFullPath(objectName.c_str())) + { + objectName = cmSystemTools::GetFilenameName(objectName); + } + LocalObjectInfo& info = localObjectFiles[objectName]; + info.HasSourceExtension = hasSourceExtension; + info.push_back(LocalObjectEntry(gt->Target, sf->GetLanguage())); + } } - LocalObjectInfo& info = this->LocalObjectFiles[objNoTargetDir]; - info.HasSourceExtension = hasSourceExtension; - info.push_back(LocalObjectEntry(target, sf->GetLanguage())); } //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3::GetIndividualFileTargets (std::vector& targets) { + std::map localObjectFiles; + this->GetLocalObjectFiles(localObjectFiles); for (std::map::iterator lo = - this->LocalObjectFiles.begin(); - lo != this->LocalObjectFiles.end(); ++lo) + localObjectFiles.begin(); + lo != localObjectFiles.end(); ++lo) { targets.push_back(lo->first); @@ -253,11 +284,14 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() bool do_assembly_rules = this->GetCreateAssemblySourceRules(); + std::map localObjectFiles; + this->GetLocalObjectFiles(localObjectFiles); + // now write out the object rules // for each object file name for (std::map::iterator lo = - this->LocalObjectFiles.begin(); - lo != this->LocalObjectFiles.end(); ++lo) + localObjectFiles.begin(); + lo != localObjectFiles.end(); ++lo) { // Add a convenience rule for building the object file. this->WriteObjectConvenienceRule(ruleFileStream, diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index d504247..27070e2 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -224,10 +224,6 @@ public: // write the target rules for the local Makefile into the stream void WriteLocalAllRules(std::ostream& ruleFileStream); - void AddLocalObjectFile(cmTarget* target, cmSourceFile* sf, - std::string objNoTargetDir, - bool hasSourceExtension); - std::vector const& GetLocalHelp() { return this->LocalHelp; } /** Get whether to create rules to generate preprocessed and @@ -366,7 +362,9 @@ private: LocalObjectInfo():HasSourceExtension(false), HasPreprocessRule(false), HasAssembleRule(false) {} }; - std::map LocalObjectFiles; + void GetLocalObjectFiles( + std::map &localObjectFiles); + void WriteObjectConvenienceRule(std::ostream& ruleFileStream, const char* comment, const char* output, LocalObjectInfo const& info); -- cgit v0.12 From cd43433de56ab31269a076fb2b2ace8babaa107d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 12 Mar 2014 21:09:20 +0100 Subject: cmGlobalGenerator: Extract a ComputeTargetObjectDirectory interface. Make it public for future external calls. --- Source/cmGlobalGenerator.cxx | 6 ++++++ Source/cmGlobalGenerator.h | 2 ++ Source/cmGlobalNinjaGenerator.cxx | 27 ++++++++++++++++----------- Source/cmGlobalNinjaGenerator.h | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 27 +++++++++++++++++---------- Source/cmGlobalUnixMakefileGenerator3.h | 1 + Source/cmGlobalVisualStudioGenerator.cxx | 7 ++++++- Source/cmGlobalVisualStudioGenerator.h | 1 + Source/cmGlobalXCodeGenerator.cxx | 5 +++++ Source/cmGlobalXCodeGenerator.h | 1 + 10 files changed, 56 insertions(+), 23 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index b95ff81..c9ae799 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1449,6 +1449,7 @@ void cmGlobalGenerator::ComputeGeneratorTargetObjects() continue; } cmGeneratorTarget* gt = ti->second; + this->ComputeTargetObjectDirectory(gt); gt->LookupObjectLibraries(); this->ComputeTargetObjects(gt); } @@ -1520,6 +1521,11 @@ void cmGlobalGenerator::ComputeTargetObjects(cmGeneratorTarget*) const // Implemented in generator subclasses that need this. } +//---------------------------------------------------------------------------- +void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const +{ +} + void cmGlobalGenerator::CheckLocalGenerators() { std::map notFoundMap; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 91e71a8..ed07b10 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -323,6 +323,8 @@ public: GetExportedTargetsFile(const std::string &filename) const; void AddCMP0042WarnTarget(const std::string& target); + virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; + protected: typedef std::vector GeneratorVector; // for a project collect all its targets by following depend diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 0a05f5a..686414d 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -634,16 +634,6 @@ std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const // TODO: Refactor to combine with cmGlobalUnixMakefileGenerator3 impl. void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const { - cmTarget* target = gt->Target; - - // Compute full path to object file directory for this target. - std::string dir_max; - dir_max += gt->Makefile->GetCurrentOutputDirectory(); - dir_max += "/"; - dir_max += gt->LocalGenerator->GetTargetDirectory(*target); - dir_max += "/"; - gt->ObjectDirectory = dir_max; - std::vector objectSources; gt->GetObjectSources(objectSources); // Compute the name of each object file. @@ -653,12 +643,27 @@ void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const { cmSourceFile* sf = *si; std::string objectName = gt->LocalGenerator - ->GetObjectFileNameWithoutTarget(*sf, dir_max); + ->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory); gt->AddObject(sf, objectName); } } //---------------------------------------------------------------------------- +void cmGlobalNinjaGenerator +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const +{ + cmTarget* target = gt->Target; + + // Compute full path to object file directory for this target. + std::string dir_max; + dir_max += gt->Makefile->GetCurrentOutputDirectory(); + dir_max += "/"; + dir_max += gt->LocalGenerator->GetTargetDirectory(*target); + dir_max += "/"; + gt->ObjectDirectory = dir_max; +} + +//---------------------------------------------------------------------------- // Private methods void cmGlobalNinjaGenerator::OpenBuildFileStream() diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 7725cf3..e3a22e5 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -299,7 +299,7 @@ public: void AddTargetAlias(const std::string& alias, cmTarget* target); - + virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: /// Overloaded methods. diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 0e03e89..f9ec0a9 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -108,15 +108,6 @@ void cmGlobalUnixMakefileGenerator3 ::ComputeTargetObjects(cmGeneratorTarget* gt) const { - cmTarget* target = gt->Target; - // Compute full path to object file directory for this target. - std::string dir_max; - dir_max += gt->Makefile->GetCurrentOutputDirectory(); - dir_max += "/"; - dir_max += gt->LocalGenerator->GetTargetDirectory(*target); - dir_max += "/"; - gt->ObjectDirectory = dir_max; - std::vector objectSources; gt->GetObjectSources(objectSources); // Compute the name of each object file. @@ -126,11 +117,27 @@ cmGlobalUnixMakefileGenerator3 { cmSourceFile* sf = *si; std::string objectName = gt->LocalGenerator - ->GetObjectFileNameWithoutTarget(*sf, dir_max); + ->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory); gt->AddObject(sf, objectName); } } +//---------------------------------------------------------------------------- +void +cmGlobalUnixMakefileGenerator3 +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const +{ + cmTarget* target = gt->Target; + + // Compute full path to object file directory for this target. + std::string dir_max; + dir_max += gt->Makefile->GetCurrentOutputDirectory(); + dir_max += "/"; + dir_max += gt->LocalGenerator->GetTargetDirectory(*target); + dir_max += "/"; + gt->ObjectDirectory = dir_max; +} + void cmGlobalUnixMakefileGenerator3::Configure() { // Initialize CMAKE_EDIT_COMMAND cache entry. diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 8115176..42453f2 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -128,6 +128,7 @@ public: /** Does the make tool tolerate .NOTPARALLEL? */ virtual bool AllowNotParallel() const { return true; } + virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: void WriteMainMakefile2(); void WriteMainCMakefile(); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 69c893c..f3cba5a 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -159,10 +159,15 @@ cmGlobalVisualStudioGenerator } gt->AddObject(sf, objectName); } +} +//---------------------------------------------------------------------------- +void cmGlobalVisualStudioGenerator +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const +{ std::string dir = gt->Makefile->GetCurrentOutputDirectory(); dir += "/"; - std::string tgtDir = lg->GetTargetDirectory(*gt->Target); + std::string tgtDir = gt->LocalGenerator->GetTargetDirectory(*gt->Target); if(!tgtDir.empty()) { dir += tgtDir; diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 7e8dcf8..f957056 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -88,6 +88,7 @@ public: virtual std::string ExpandCFGIntDir(const std::string& str, const std::string& config) const; + void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: // Does this VS version link targets to each other if there are // dependencies in the SLN file? This was done for VS versions diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 36196a2..6c12040 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3964,7 +3964,12 @@ cmGlobalXCodeGenerator gt->AddObject(sf, objectName); } +} +//---------------------------------------------------------------------------- +void cmGlobalXCodeGenerator +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const +{ const char* configName = this->GetCMakeCFGIntDir(); std::string dir = this->GetObjectsNormalDirectory( "$(PROJECT_NAME)", configName, gt->Target); diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index be81cdc..f9dd58f 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -204,6 +204,7 @@ private: std::vector const& defines, bool dflag = false); + void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: virtual const char* GetInstallTargetName() const { return "install"; } virtual const char* GetPackageTargetName() const { return "package"; } -- cgit v0.12 From bc51221164330a24e90cf896300ded637b86d740 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 12 Mar 2014 23:43:43 +0100 Subject: cmGeneratorTarget: Constify the AddObject API. The storage is already const. --- Source/cmGeneratorTarget.cxx | 3 ++- Source/cmGeneratorTarget.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index db88749..1d8d2dd 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -321,7 +321,8 @@ const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file) return this->Objects[file]; } -void cmGeneratorTarget::AddObject(cmSourceFile *sf, std::string const&name) +void cmGeneratorTarget::AddObject(cmSourceFile const* sf, + std::string const&name) { this->Objects[sf] = name; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 81a447f..e5ed271 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -35,7 +35,7 @@ public: void GetObjectSources(std::vector &) const; const std::string& GetObjectName(cmSourceFile const* file); - void AddObject(cmSourceFile *sf, std::string const&name); + void AddObject(cmSourceFile const* sf, std::string const&name); bool HasExplicitObjectName(cmSourceFile const* file) const; void AddExplicitObjectName(cmSourceFile* sf); -- cgit v0.12 From 6132d979d9d7877f5b116a2a110245adbb89e1b7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 13 Mar 2014 12:28:32 +0100 Subject: cmGeneratorTarget: Constify the AddExplicitObjectName API. The storage is already const. --- Source/cmGeneratorTarget.cxx | 2 +- Source/cmGeneratorTarget.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 1d8d2dd..4d335cd 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -328,7 +328,7 @@ void cmGeneratorTarget::AddObject(cmSourceFile const* sf, } //---------------------------------------------------------------------------- -void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile* sf) +void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile const* sf) { this->ExplicitObjectName.insert(sf); } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e5ed271..d1a0e06 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -37,7 +37,7 @@ public: void AddObject(cmSourceFile const* sf, std::string const&name); bool HasExplicitObjectName(cmSourceFile const* file) const; - void AddExplicitObjectName(cmSourceFile* sf); + void AddExplicitObjectName(cmSourceFile const* sf); void GetResxSources(std::vector&) const; void GetIDLSources(std::vector&) const; -- cgit v0.12 From 04cf50ff62a022296832cef6b48fb532508eb853 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 12 Mar 2014 23:45:43 +0100 Subject: cmOSXBundleGenerator: Make MacOSXContentGeneratorType arg const. --- Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmMakefileTargetGenerator.h | 2 +- Source/cmNinjaTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.h | 2 +- Source/cmOSXBundleGenerator.h | 3 ++- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 3161aba..fdca7f7 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -373,7 +373,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() //---------------------------------------------------------------------------- void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() - (cmSourceFile& source, const char* pkgloc) + (cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. if(!this->Generator->GetTarget()->IsBundleOnApple()) diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 97c58b9..f59bd9b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -81,7 +81,7 @@ protected: MacOSXContentGeneratorType(cmMakefileTargetGenerator* gen) : Generator(gen) {} - void operator()(cmSourceFile& source, const char* pkgloc); + void operator()(cmSourceFile const& source, const char* pkgloc); private: cmMakefileTargetGenerator* Generator; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index ed3782c..149b129 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -733,7 +733,7 @@ cmNinjaTargetGenerator //---------------------------------------------------------------------------- void cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( - cmSourceFile& source, const char* pkgloc) + cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. if(!this->Generator->GetTarget()->IsBundleOnApple()) diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index e66e55f..900e2bd 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -129,7 +129,7 @@ protected: MacOSXContentGeneratorType(cmNinjaTargetGenerator* g) : Generator(g) {} - void operator()(cmSourceFile& source, const char* pkgloc); + void operator()(cmSourceFile const& source, const char* pkgloc); private: cmNinjaTargetGenerator* Generator; diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h index 95b4aef..5acdd9f 100644 --- a/Source/cmOSXBundleGenerator.h +++ b/Source/cmOSXBundleGenerator.h @@ -44,7 +44,8 @@ public: struct MacOSXContentGeneratorType { virtual ~MacOSXContentGeneratorType() {} - virtual void operator()(cmSourceFile& source, const char* pkgloc) = 0; + virtual void operator()(cmSourceFile const& source, + const char* pkgloc) = 0; }; void GenerateMacOSXContentStatements( -- cgit v0.12 From dcfcd23ed53d3bfe8ef299b8a3a38c47c27fa6b6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 13 Mar 2014 00:19:50 +0100 Subject: cmGeneratorTarget: Make GetSourceDepends const. --- Source/cmGeneratorTarget.cxx | 2 +- Source/cmGeneratorTarget.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4d335cd..bde60b8 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -241,7 +241,7 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const //---------------------------------------------------------------------------- std::vector const* -cmGeneratorTarget::GetSourceDepends(cmSourceFile* sf) const +cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const { SourceEntriesType::const_iterator i = this->SourceEntries.find(sf); if(i != this->SourceEntries.end()) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d1a0e06..1c4276c 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -87,7 +87,8 @@ public: void LookupObjectLibraries(); /** Get sources that must be built before the given source. */ - std::vector const* GetSourceDepends(cmSourceFile* sf) const; + std::vector const* + GetSourceDepends(cmSourceFile const* sf) const; /** * Flags for a given source file as used in this target. Typically assigned @@ -121,7 +122,7 @@ public: private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; - typedef std::map SourceEntriesType; + typedef std::map SourceEntriesType; SourceEntriesType SourceEntries; std::map Objects; -- cgit v0.12 From c725bb3cbd51edd4043f81d01b7a01bbd42adb2f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 12 Mar 2014 23:50:42 +0100 Subject: Constify some APIs in generators. --- Source/cmGlobalVisualStudio10Generator.cxx | 2 +- Source/cmGlobalVisualStudio10Generator.h | 4 ++-- Source/cmMakefileTargetGenerator.cxx | 9 +++++---- Source/cmMakefileTargetGenerator.h | 9 +++++---- Source/cmNinjaTargetGenerator.cxx | 10 +++++----- Source/cmNinjaTargetGenerator.h | 10 +++++----- Source/cmVisualStudio10TargetGenerator.cxx | 11 ++++++----- Source/cmVisualStudio10TargetGenerator.h | 13 +++++++------ 8 files changed, 36 insertions(+), 32 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 840e888..37a416b 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -470,7 +470,7 @@ cmGlobalVisualStudio10Generator //---------------------------------------------------------------------------- void cmGlobalVisualStudio10Generator::PathTooLong( - cmTarget* target, cmSourceFile* sf, std::string const& sfRel) + cmTarget* target, cmSourceFile const* sf, std::string const& sfRel) { size_t len = (strlen(target->GetMakefile()->GetCurrentOutputDirectory()) + 1 + sfRel.length()); diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 999a9d5..ede6b1b 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -87,7 +87,7 @@ public: /** Generate an .rule file path for a given command output. */ virtual std::string GenerateRuleFile(std::string const& output) const; - void PathTooLong(cmTarget* target, cmSourceFile* sf, + void PathTooLong(cmTarget* target, cmSourceFile const* sf, std::string const& sfRel); virtual const char* GetToolsVersion() { return "4.0"; } @@ -112,7 +112,7 @@ private: LongestSourcePath(): Length(0), Target(0), SourceFile(0) {} size_t Length; cmTarget* Target; - cmSourceFile* SourceFile; + cmSourceFile const* SourceFile; std::string SourceRel; }; LongestSourcePath LongestSource; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index fdca7f7..32e1c1a 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -423,7 +423,8 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() } //---------------------------------------------------------------------------- -void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) +void cmMakefileTargetGenerator +::WriteObjectRuleFiles(cmSourceFile const& source) { // Identify the language of the source file. const std::string& lang = @@ -498,7 +499,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) //---------------------------------------------------------------------------- void cmMakefileTargetGenerator -::AppendFortranFormatFlags(std::string& flags, cmSourceFile& source) +::AppendFortranFormatFlags(std::string& flags, cmSourceFile const& source) { const char* srcfmt = source.GetProperty("Fortran_FORMAT"); cmLocalGenerator::FortranFormat format = @@ -529,7 +530,7 @@ void cmMakefileTargetGenerator ::WriteObjectBuildFile(std::string &obj, const std::string& lang, - cmSourceFile& source, + cmSourceFile const& source, std::vector& depends) { this->LocalGenerator->AppendRuleDepend(depends, @@ -1194,7 +1195,7 @@ cmMakefileTargetGenerator //---------------------------------------------------------------------------- void cmMakefileTargetGenerator -::WriteObjectDependRules(cmSourceFile& source, +::WriteObjectDependRules(cmSourceFile const& source, std::vector& depends) { // Create the list of dependencies known at cmake time. These are diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index f59bd9b..7ff6da9 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -89,16 +89,16 @@ protected: friend struct MacOSXContentGeneratorType; // write the rules for an object - void WriteObjectRuleFiles(cmSourceFile& source); + void WriteObjectRuleFiles(cmSourceFile const& source); // write the build rule for an object void WriteObjectBuildFile(std::string &obj, const std::string& lang, - cmSourceFile& source, + cmSourceFile const& source, std::vector& depends); // write the depend.make file for an object - void WriteObjectDependRules(cmSourceFile& source, + void WriteObjectDependRules(cmSourceFile const& source, std::vector& depends); // write the build rule for a custom command @@ -126,7 +126,8 @@ protected: // Return the a string with -F flags on apple std::string GetFrameworkFlags(std::string const& l); - void AppendFortranFormatFlags(std::string& flags, cmSourceFile& source); + void AppendFortranFormatFlags(std::string& flags, + cmSourceFile const& source); // append intertarget dependencies void AppendTargetDepends(std::vector& depends); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 149b129..3738ca7 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -126,7 +126,7 @@ void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags, // void cmMakefileTargetGenerator::WriteTargetLanguageFlags() // Refactor it. std::string -cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, +cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source, const std::string& language) { // TODO: Fortran support. @@ -211,7 +211,7 @@ bool cmNinjaTargetGenerator::needsDepFile(const std::string& lang) // void cmMakefileTargetGenerator::WriteTargetLanguageFlags(). std::string cmNinjaTargetGenerator:: -ComputeDefines(cmSourceFile *source, const std::string& language) +ComputeDefines(cmSourceFile const* source, const std::string& language) { std::set defines; @@ -269,14 +269,14 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const std::string cmNinjaTargetGenerator -::GetSourceFilePath(cmSourceFile* source) const +::GetSourceFilePath(cmSourceFile const* source) const { return ConvertToNinjaPath(source->GetFullPath().c_str()); } std::string cmNinjaTargetGenerator -::GetObjectFilePath(cmSourceFile* source) const +::GetObjectFilePath(cmSourceFile const* source) const { std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); if(!path.empty()) @@ -536,7 +536,7 @@ cmNinjaTargetGenerator void cmNinjaTargetGenerator -::WriteObjectBuildStatement(cmSourceFile* source) +::WriteObjectBuildStatement(cmSourceFile const* source) { std::string comment; const std::string language = source->GetLanguage(); diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 900e2bd..8669e6e 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -79,10 +79,10 @@ protected: * @note Generally it is the value of the variable whose name is computed * by LanguageFlagsVarName(). */ - std::string ComputeFlagsForObject(cmSourceFile *source, + std::string ComputeFlagsForObject(cmSourceFile const* source, const std::string& language); - std::string ComputeDefines(cmSourceFile *source, + std::string ComputeDefines(cmSourceFile const* source, const std::string& language); std::string ConvertToNinjaPath(const char *path) const { @@ -96,10 +96,10 @@ protected: cmNinjaDeps ComputeLinkDeps() const; /// @return the source file path for the given @a source. - std::string GetSourceFilePath(cmSourceFile* source) const; + std::string GetSourceFilePath(cmSourceFile const* source) const; /// @return the object file path for the given @a source. - std::string GetObjectFilePath(cmSourceFile* source) const; + std::string GetObjectFilePath(cmSourceFile const* source) const; /// @return the file path where the target named @a name is generated. std::string GetTargetFilePath(const std::string& name) const; @@ -110,7 +110,7 @@ protected: void WriteLanguageRules(const std::string& language); void WriteCompileRule(const std::string& language); void WriteObjectBuildStatements(); - void WriteObjectBuildStatement(cmSourceFile* source); + void WriteObjectBuildStatement(cmSourceFile const* source); void WriteCustomCommandBuildStatement(cmCustomCommand *cc); cmNinjaDeps GetObjects() const diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 7c55f64..cc1fdbc 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -562,7 +562,8 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommands() } //---------------------------------------------------------------------------- -void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf) +void cmVisualStudio10TargetGenerator +::WriteCustomCommand(cmSourceFile const* sf) { if(this->SourcesVisited.insert(sf).second) { @@ -585,7 +586,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf) } void -cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, +cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source, cmCustomCommand const & command) { @@ -928,7 +929,7 @@ WriteGroupSources(const char* name, } void cmVisualStudio10TargetGenerator::WriteSource( - const char* tool, cmSourceFile* sf, const char* end) + const char* tool, cmSourceFile const* sf, const char* end) { // Visual Studio tools append relative paths to the current dir, as in: // @@ -1091,9 +1092,9 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( - cmSourceFile* source) + cmSourceFile const* source) { - cmSourceFile& sf = *source; + cmSourceFile const& sf = *source; std::string objectName; if(this->GeneratorTarget->HasExplicitObjectName(&sf)) diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 02b951c..8faeb8e 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -45,7 +45,7 @@ public: private: struct ToolSource { - cmSourceFile* SourceFile; + cmSourceFile const* SourceFile; bool RelativePath; }; struct ToolSources: public std::vector {}; @@ -55,7 +55,8 @@ private: void WriteString(const char* line, int indentLevel); void WriteProjectConfigurations(); void WriteProjectConfigurationValues(); - void WriteSource(const char* tool, cmSourceFile* sf, const char* end = 0); + void WriteSource(const char* tool, cmSourceFile const* sf, + const char* end = 0); void WriteSources(const char* tool, std::vector const&); void WriteAllSources(); void WriteDotNetReferences(); @@ -77,13 +78,13 @@ private: std::vector const & includes); void OutputIncludes(std::vector const & includes); void OutputLinkIncremental(std::string const& configName); - void WriteCustomRule(cmSourceFile* source, + void WriteCustomRule(cmSourceFile const* source, cmCustomCommand const & command); void WriteCustomCommands(); - void WriteCustomCommand(cmSourceFile* sf); + void WriteCustomCommand(cmSourceFile const* sf); void WriteGroups(); void WriteProjectReferences(); - bool OutputSourceSpecificFlags(cmSourceFile* source); + bool OutputSourceSpecificFlags(cmSourceFile const* source); void AddLibraries(cmComputeLinkInformation& cli, std::string& libstring); void WriteLibOptions(std::string const& config); void WriteEvents(std::string const& configName); @@ -111,7 +112,7 @@ private: cmGlobalVisualStudio10Generator* GlobalGenerator; cmGeneratedFileStream* BuildFileStream; cmLocalVisualStudio7Generator* LocalGenerator; - std::set SourcesVisited; + std::set SourcesVisited; typedef std::map ToolSourceMap; ToolSourceMap Tools; -- cgit v0.12 From 9ad804ac7be18efb92040434808f89174586b13d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 12 Mar 2014 23:06:05 +0100 Subject: cmGeneratorTarget: Constify cmSourceFile* in containers. Some of them will be used with other APIs which require value_type to be cmSourceFile const*. --- Source/cmGeneratorTarget.cxx | 27 +++++++++++++++---------- Source/cmGeneratorTarget.h | 18 ++++++++--------- Source/cmGlobalNinjaGenerator.cxx | 6 +++--- Source/cmGlobalUnixMakefileGenerator3.cxx | 6 +++--- Source/cmGlobalVisualStudioGenerator.cxx | 10 +++++----- Source/cmGlobalXCodeGenerator.cxx | 6 +++--- Source/cmLocalUnixMakefileGenerator3.cxx | 6 +++--- Source/cmMakefileTargetGenerator.cxx | 16 +++++++-------- Source/cmNinjaTargetGenerator.cxx | 20 +++++++++---------- Source/cmOSXBundleGenerator.cxx | 7 ++++--- Source/cmOSXBundleGenerator.h | 2 +- Source/cmVisualStudio10TargetGenerator.cxx | 32 +++++++++++++++--------------- Source/cmVisualStudio10TargetGenerator.h | 3 ++- 13 files changed, 84 insertions(+), 75 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index bde60b8..8efd7bb 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -97,7 +97,7 @@ struct DoAccept template<> struct DoAccept { - static void Do(std::vector& files, cmSourceFile* f) + static void Do(std::vector& files, cmSourceFile* f) { files.push_back(f); } @@ -120,7 +120,7 @@ struct DoAccept }; //---------------------------------------------------------------------------- -template > +template > struct TagVisitor { DataType& Data; @@ -306,7 +306,8 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt, //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetObjectSources(std::vector &data) const +cmGeneratorTarget +::GetObjectSources(std::vector &data) const { IMPLEMENT_VISIT(ObjectSources); if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY) @@ -342,34 +343,39 @@ bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetIDLSources(std::vector& data) const +void cmGeneratorTarget +::GetIDLSources(std::vector& data) const { IMPLEMENT_VISIT(IDLSources); } //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetHeaderSources(std::vector& data) const +cmGeneratorTarget +::GetHeaderSources(std::vector& data) const { IMPLEMENT_VISIT(HeaderSources); } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetExtraSources(std::vector& data) const +void cmGeneratorTarget +::GetExtraSources(std::vector& data) const { IMPLEMENT_VISIT(ExtraSources); } //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetCustomCommands(std::vector& data) const +cmGeneratorTarget +::GetCustomCommands(std::vector& data) const { IMPLEMENT_VISIT(CustomCommands); } //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetExternalObjects(std::vector& data) const +cmGeneratorTarget +::GetExternalObjects(std::vector& data) const { IMPLEMENT_VISIT(ExternalObjects); } @@ -384,7 +390,8 @@ cmGeneratorTarget::GetExpectedResxHeaders(std::set& srcs) const } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetResxSources(std::vector& srcs) const +void cmGeneratorTarget +::GetResxSources(std::vector& srcs) const { ResxData data; IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData) @@ -570,7 +577,7 @@ cmGeneratorTarget::UseObjectLibraries(std::vector& objs) const cmTarget* objLib = *ti; cmGeneratorTarget* ogt = this->GlobalGenerator->GetGeneratorTarget(objLib); - for(std::vector::const_iterator + for(std::vector::const_iterator si = ogt->ObjectSources.begin(); si != ogt->ObjectSources.end(); ++si) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1c4276c..139e736 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -32,19 +32,19 @@ public: bool GetPropertyAsBool(const std::string& prop) const; void GetSourceFiles(std::vector& files) const; - void GetObjectSources(std::vector &) const; + void GetObjectSources(std::vector &) const; const std::string& GetObjectName(cmSourceFile const* file); void AddObject(cmSourceFile const* sf, std::string const&name); bool HasExplicitObjectName(cmSourceFile const* file) const; void AddExplicitObjectName(cmSourceFile const* sf); - void GetResxSources(std::vector&) const; - void GetIDLSources(std::vector&) const; - void GetExternalObjects(std::vector&) const; - void GetHeaderSources(std::vector&) const; - void GetExtraSources(std::vector&) const; - void GetCustomCommands(std::vector&) const; + void GetResxSources(std::vector&) const; + void GetIDLSources(std::vector&) const; + void GetExternalObjects(std::vector&) const; + void GetHeaderSources(std::vector&) const; + void GetExtraSources(std::vector&) const; + void GetCustomCommands(std::vector&) const; void GetExpectedResxHeaders(std::set&) const; cmTarget* Target; @@ -117,7 +117,7 @@ public: struct ResxData { mutable std::set ExpectedResxHeaders; - mutable std::vector ResxSources; + mutable std::vector ResxSources; }; private: friend class cmTargetTraceDependencies; @@ -127,7 +127,7 @@ private: std::map Objects; std::set ExplicitObjectName; - mutable std::vector ObjectSources; + mutable std::vector ObjectSources; std::vector ObjectLibraries; mutable std::map > SystemIncludesCache; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 686414d..e9c31e9 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -634,14 +634,14 @@ std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const // TODO: Refactor to combine with cmGlobalUnixMakefileGenerator3 impl. void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const { - std::vector objectSources; + std::vector objectSources; gt->GetObjectSources(objectSources); // Compute the name of each object file. - for(std::vector::iterator + for(std::vector::iterator si = objectSources.begin(); si != objectSources.end(); ++si) { - cmSourceFile* sf = *si; + cmSourceFile const* sf = *si; std::string objectName = gt->LocalGenerator ->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory); gt->AddObject(sf, objectName); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index f9ec0a9..6ce8678 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -108,14 +108,14 @@ void cmGlobalUnixMakefileGenerator3 ::ComputeTargetObjects(cmGeneratorTarget* gt) const { - std::vector objectSources; + std::vector objectSources; gt->GetObjectSources(objectSources); // Compute the name of each object file. - for(std::vector::iterator + for(std::vector::iterator si = objectSources.begin(); si != objectSources.end(); ++si) { - cmSourceFile* sf = *si; + cmSourceFile const* sf = *si; std::string objectName = gt->LocalGenerator ->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory); gt->AddObject(sf, objectName); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index f3cba5a..bd57d0c 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -129,13 +129,13 @@ cmGlobalVisualStudioGenerator // Count the number of object files with each name. Note that // windows file names are not case sensitive. std::map counts; - std::vector objectSources; + std::vector objectSources; gt->GetObjectSources(objectSources); - for(std::vector::const_iterator + for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { - cmSourceFile* sf = *si; + cmSourceFile const* sf = *si; std::string objectNameLower = cmSystemTools::LowerCase( cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath())); objectNameLower += ".obj"; @@ -144,11 +144,11 @@ cmGlobalVisualStudioGenerator // For all source files producing duplicate names we need unique // object name computation. - for(std::vector::const_iterator + for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { - cmSourceFile* sf = *si; + cmSourceFile const* sf = *si; std::string objectName = cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); objectName += ".obj"; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 6c12040..4904d51 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3944,13 +3944,13 @@ cmGlobalXCodeGenerator // to avoid exact duplicate file names. Note that Mac file names are not // typically case sensitive, hence the LowerCase. std::map counts; - std::vector objectSources; + std::vector objectSources; gt->GetObjectSources(objectSources); - for(std::vector::const_iterator + for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { - cmSourceFile* sf = *si; + cmSourceFile const* sf = *si; std::string objectName = cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); objectName += ".o"; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index a838ce3..79240e1 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -185,7 +185,7 @@ GetLocalObjectFiles(std::map &localObjectFiles) { continue; } - std::vector objectSources; + std::vector objectSources; gt->GetObjectSources(objectSources); // Compute full path to object file directory for this target. std::string dir_max; @@ -194,11 +194,11 @@ GetLocalObjectFiles(std::map &localObjectFiles) dir_max += this->GetTargetDirectory(*gt->Target); dir_max += "/"; // Compute the name of each object file. - for(std::vector::iterator + for(std::vector::iterator si = objectSources.begin(); si != objectSources.end(); ++si) { - cmSourceFile* sf = *si; + cmSourceFile const* sf = *si; bool hasSourceExtension = true; std::string objectName = this->GetObjectFileNameWithoutTarget(*sf, dir_max, diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 32e1c1a..6759d05 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -153,9 +153,9 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() // First generate the object rule files. Save a list of all object // files for this target. - std::vector customCommands; + std::vector customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector::const_iterator + for(std::vector::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { @@ -176,27 +176,27 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() } } } - std::vector headerSources; + std::vector headerSources; this->GeneratorTarget->GetHeaderSources(headerSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( headerSources, this->MacOSXContentGenerator); - std::vector extraSources; + std::vector extraSources; this->GeneratorTarget->GetExtraSources(extraSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( extraSources, this->MacOSXContentGenerator); - std::vector externalObjects; + std::vector externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects); - for(std::vector::const_iterator + for(std::vector::const_iterator si = externalObjects.begin(); si != externalObjects.end(); ++si) { this->ExternalObjects.push_back((*si)->GetFullPath()); } - std::vector objectSources; + std::vector objectSources; this->GeneratorTarget->GetObjectSources(objectSources); - for(std::vector::const_iterator + for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { // Generate this object file's rule file. diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 3738ca7..4319f3c 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -480,36 +480,36 @@ cmNinjaTargetGenerator << this->GetTargetName() << "\n\n"; - std::vector customCommands; + std::vector customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector::const_iterator + for(std::vector::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { cmCustomCommand const* cc = (*si)->GetCustomCommand(); this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget()); } - std::vector headerSources; + std::vector headerSources; this->GeneratorTarget->GetHeaderSources(headerSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( headerSources, this->MacOSXContentGenerator); - std::vector extraSources; + std::vector extraSources; this->GeneratorTarget->GetExtraSources(extraSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( extraSources, this->MacOSXContentGenerator); - std::vector externalObjects; + std::vector externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects); - for(std::vector::const_iterator + for(std::vector::const_iterator si = externalObjects.begin(); si != externalObjects.end(); ++si) { this->Objects.push_back(this->GetSourceFilePath(*si)); } - std::vector objectSources; + std::vector objectSources; this->GeneratorTarget->GetObjectSources(objectSources); - for(std::vector::const_iterator + for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { this->WriteObjectBuildStatement(*si); @@ -570,9 +570,9 @@ cmNinjaTargetGenerator } // Add order-only dependencies on custom command outputs. - std::vector customCommands; + std::vector customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector::const_iterator + for(std::vector::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 835f892..6f16913 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -190,13 +190,14 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, //---------------------------------------------------------------------------- void cmOSXBundleGenerator:: -GenerateMacOSXContentStatements(std::vector const& sources, - MacOSXContentGeneratorType* generator) +GenerateMacOSXContentStatements( + std::vector const& sources, + MacOSXContentGeneratorType* generator) { if (this->MustSkip()) return; - for(std::vector::const_iterator + for(std::vector::const_iterator si = sources.begin(); si != sources.end(); ++si) { cmGeneratorTarget::SourceFileFlags tsFlags = diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h index 5acdd9f..f945c15 100644 --- a/Source/cmOSXBundleGenerator.h +++ b/Source/cmOSXBundleGenerator.h @@ -49,7 +49,7 @@ public: }; void GenerateMacOSXContentStatements( - std::vector const& sources, + std::vector const& sources, MacOSXContentGeneratorType* generator); std::string InitMacOSXContentDirectory(const char* pkgloc); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index cc1fdbc..b8631ca 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -377,12 +377,12 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences() void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() { - std::vector resxObjs; + std::vector resxObjs; this->GeneratorTarget->GetResxSources(resxObjs); if(!resxObjs.empty()) { this->WriteString("\n", 1); - for(std::vector::const_iterator oi = resxObjs.begin(); + for(std::vector::const_iterator oi = resxObjs.begin(); oi != resxObjs.end(); ++oi) { std::string obj = (*oi)->GetFullPath(); @@ -551,9 +551,9 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() void cmVisualStudio10TargetGenerator::WriteCustomCommands() { this->SourcesVisited.clear(); - std::vector customCommands; + std::vector customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector::const_iterator + for(std::vector::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { @@ -746,12 +746,12 @@ void cmVisualStudio10TargetGenerator::WriteGroups() this->WriteGroupSources(ti->first.c_str(), ti->second, sourceGroups); } - std::vector resxObjs; + std::vector resxObjs; this->GeneratorTarget->GetResxSources(resxObjs); if(!resxObjs.empty()) { this->WriteString("\n", 1); - for(std::vector::const_iterator oi = resxObjs.begin(); + for(std::vector::const_iterator oi = resxObjs.begin(); oi != resxObjs.end(); ++oi) { std::string obj = (*oi)->GetFullPath(); @@ -902,7 +902,7 @@ WriteGroupSources(const char* name, for(ToolSources::const_iterator s = sources.begin(); s != sources.end(); ++s) { - cmSourceFile* sf = s->SourceFile; + cmSourceFile const* sf = s->SourceFile; std::string const& source = sf->GetFullPath(); cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); @@ -985,9 +985,9 @@ void cmVisualStudio10TargetGenerator::WriteSource( } void cmVisualStudio10TargetGenerator::WriteSources( - const char* tool, std::vector const& sources) + const char* tool, std::vector const& sources) { - for(std::vector::const_iterator + for(std::vector::const_iterator si = sources.begin(); si != sources.end(); ++si) { this->WriteSource(tool, *si); @@ -1002,16 +1002,16 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } this->WriteString("\n", 1); - std::vector headerSources; + std::vector headerSources; this->GeneratorTarget->GetHeaderSources(headerSources); this->WriteSources("ClInclude", headerSources); - std::vector idlSources; + std::vector idlSources; this->GeneratorTarget->GetIDLSources(idlSources); this->WriteSources("Midl", idlSources); - std::vector objectSources; + std::vector objectSources; this->GeneratorTarget->GetObjectSources(objectSources); - for(std::vector::const_iterator + for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { @@ -1050,7 +1050,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } } - std::vector externalObjects; + std::vector externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects); if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10) { @@ -1062,7 +1062,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() { // If an object file is generated in this target, then vs10 will use // it in the build, and we have to list it as None instead of Object. - for(std::vector::const_iterator + for(std::vector::const_iterator si = externalObjects.begin(); si != externalObjects.end(); ++si) { @@ -1072,7 +1072,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } } - std::vector extraSources; + std::vector extraSources; this->GeneratorTarget->GetExtraSources(extraSources); this->WriteSources("None", extraSources); diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 8faeb8e..d72c6fd 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -57,7 +57,8 @@ private: void WriteProjectConfigurationValues(); void WriteSource(const char* tool, cmSourceFile const* sf, const char* end = 0); - void WriteSources(const char* tool, std::vector const&); + void WriteSources(const char* tool, + std::vector const&); void WriteAllSources(); void WriteDotNetReferences(); void WriteEmbeddedResourceGroup(); -- cgit v0.12 From f6da044080d854b9ad87cef5c2a6f5195722a6da Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 11 Mar 2014 17:37:26 +0100 Subject: cmLocalGenerator: Add ComputeObjectFilenames interface. Implement it in the local generators and use it in the global generators. --- Source/cmGlobalNinjaGenerator.cxx | 23 +++++++++------ Source/cmGlobalUnixMakefileGenerator3.cxx | 21 ++++++++------ Source/cmGlobalVisualStudioGenerator.cxx | 48 +++++++++---------------------- Source/cmGlobalXCodeGenerator.cxx | 30 +++++++------------ Source/cmLocalGenerator.cxx | 8 ++++++ Source/cmLocalGenerator.h | 4 +++ Source/cmLocalNinjaGenerator.cxx | 14 +++++++++ Source/cmLocalNinjaGenerator.h | 4 +++ Source/cmLocalUnixMakefileGenerator3.cxx | 14 +++++++++ Source/cmLocalUnixMakefileGenerator3.h | 4 +++ Source/cmLocalVisualStudioGenerator.cxx | 40 ++++++++++++++++++++++++++ Source/cmLocalVisualStudioGenerator.h | 4 +++ Source/cmLocalXCodeGenerator.cxx | 28 ++++++++++++++++++ Source/cmLocalXCodeGenerator.h | 3 ++ 14 files changed, 176 insertions(+), 69 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index e9c31e9..08507eb 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -19,6 +19,7 @@ #include "cmVersion.h" #include +#include const char* cmGlobalNinjaGenerator::NINJA_BUILD_FILE = "build.ninja"; const char* cmGlobalNinjaGenerator::NINJA_RULES_FILE = "rules.ninja"; @@ -636,15 +637,21 @@ void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const { std::vector objectSources; gt->GetObjectSources(objectSources); - // Compute the name of each object file. - for(std::vector::iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) + + std::map mapping; + for(std::vector::const_iterator it + = objectSources.begin(); it != objectSources.end(); ++it) + { + mapping[*it]; + } + + gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); + + for(std::map::const_iterator it + = mapping.begin(); it != mapping.end(); ++it) { - cmSourceFile const* sf = *si; - std::string objectName = gt->LocalGenerator - ->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory); - gt->AddObject(sf, objectName); + assert(!it->second.empty()); + gt->AddObject(it->first, it->second); } } diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 6ce8678..91258ed 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -110,15 +110,20 @@ cmGlobalUnixMakefileGenerator3 { std::vector objectSources; gt->GetObjectSources(objectSources); - // Compute the name of each object file. - for(std::vector::iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) + + std::map mapping; + for(std::vector::const_iterator it + = objectSources.begin(); it != objectSources.end(); ++it) + { + mapping[*it]; + } + + gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); + + for(std::map::const_iterator it + = mapping.begin(); it != mapping.end(); ++it) { - cmSourceFile const* sf = *si; - std::string objectName = gt->LocalGenerator - ->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory); - gt->AddObject(sf, objectName); + gt->AddObject(it->first, it->second); } } diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index bd57d0c..9740fbfb 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -122,42 +122,22 @@ void cmGlobalVisualStudioGenerator ::ComputeTargetObjects(cmGeneratorTarget* gt) const { - cmLocalVisualStudioGenerator* lg = - static_cast(gt->LocalGenerator); - std::string dir_max = lg->ComputeLongestObjectDirectory(*gt->Target); - - // Count the number of object files with each name. Note that - // windows file names are not case sensitive. - std::map counts; std::vector objectSources; gt->GetObjectSources(objectSources); - for(std::vector::const_iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) - { - cmSourceFile const* sf = *si; - std::string objectNameLower = cmSystemTools::LowerCase( - cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath())); - objectNameLower += ".obj"; - counts[objectNameLower] += 1; - } - - // For all source files producing duplicate names we need unique - // object name computation. - for(std::vector::const_iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) - { - cmSourceFile const* sf = *si; - std::string objectName = - cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); - objectName += ".obj"; - if(counts[cmSystemTools::LowerCase(objectName)] > 1) - { - gt->AddExplicitObjectName(sf); - objectName = lg->GetObjectFileNameWithoutTarget(*sf, dir_max); - } - gt->AddObject(sf, objectName); + + std::map mapping; + for(std::vector::const_iterator it + = objectSources.begin(); it != objectSources.end(); ++it) + { + mapping[*it]; + } + + gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); + + for(std::map::const_iterator it + = mapping.begin(); it != mapping.end(); ++it) + { + gt->AddObject(it->first, it->second); } } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4904d51..0a4b51c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3939,30 +3939,22 @@ void cmGlobalXCodeGenerator ::ComputeTargetObjects(cmGeneratorTarget* gt) const { - // Count the number of object files with each name. Warn about duplicate - // names since Xcode names them uniquely automatically with a numeric suffix - // to avoid exact duplicate file names. Note that Mac file names are not - // typically case sensitive, hence the LowerCase. - std::map counts; std::vector objectSources; gt->GetObjectSources(objectSources); - for(std::vector::const_iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) + + std::map mapping; + for(std::vector::const_iterator it + = objectSources.begin(); it != objectSources.end(); ++it) { - cmSourceFile const* sf = *si; - std::string objectName = - cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); - objectName += ".o"; + mapping[*it]; + } - std::string objectNameLower = cmSystemTools::LowerCase(objectName); - counts[objectNameLower] += 1; - if (2 == counts[objectNameLower]) - { - // TODO: emit warning about duplicate name? - } + gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); - gt->AddObject(sf, objectName); + for(std::map::const_iterator it + = mapping.begin(); it != mapping.end(); ++it) + { + gt->AddObject(it->first, it->second); } } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index ebcfa08..c63de79 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3081,6 +3081,14 @@ cmLocalGenerator } //---------------------------------------------------------------------------- +void cmLocalGenerator::ComputeObjectFilenames( + std::map&, + cmGeneratorTarget const*) +{ + +} + +//---------------------------------------------------------------------------- std::string cmLocalGenerator ::GetObjectFileNameWithoutTarget(const cmSourceFile& source, diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index afcaee9..61488fe 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -372,6 +372,10 @@ public: std::string& linkPath, cmGeneratorTarget* target); + virtual void ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const* gt = 0); + protected: ///! put all the libraries for a target on into the given stream virtual void OutputLinkLibraries(std::string& linkLibraries, diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 7c4aab8..2f763ce 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -267,6 +267,20 @@ void cmLocalNinjaGenerator::SetConfigName() } } +//---------------------------------------------------------------------------- +void cmLocalNinjaGenerator::ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const* gt) +{ + for(std::map::iterator + si = mapping.begin(); si != mapping.end(); ++si) + { + cmSourceFile const* sf = si->first; + si->second = this->GetObjectFileNameWithoutTarget(*sf, + gt->ObjectDirectory); + } +} + void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os) { cmGlobalNinjaGenerator::WriteDivider(os); diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 9d0b7b5..e91e60b 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -101,6 +101,10 @@ public: virtual std::string ConvertToLinkReference(std::string const& lib, OutputFormat format = SHELL); + virtual void ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const* gt = 0); + protected: virtual std::string ConvertToIncludeReference(std::string const& path, diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 79240e1..2d36089 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -172,6 +172,20 @@ void cmLocalUnixMakefileGenerator3::Generate() } //---------------------------------------------------------------------------- +void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const* gt) +{ + for(std::map::iterator + si = mapping.begin(); si != mapping.end(); ++si) + { + cmSourceFile const* sf = si->first; + si->second = this->GetObjectFileNameWithoutTarget(*sf, + gt->ObjectDirectory); + } +} + +//---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3:: GetLocalObjectFiles(std::map &localObjectFiles) { diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 27070e2..14543fb 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -313,6 +313,10 @@ private: std::string MakeLauncher(cmCustomCommandGenerator const& ccg, cmTarget* target, RelativeRoot relative); + virtual void ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const* gt = 0); + friend class cmMakefileTargetGenerator; friend class cmMakefileExecutableTargetGenerator; friend class cmMakefileLibraryTargetGenerator; diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 613ee97..9680d43 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -31,6 +31,46 @@ cmLocalVisualStudioGenerator::~cmLocalVisualStudioGenerator() } //---------------------------------------------------------------------------- +void cmLocalVisualStudioGenerator::ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const* gt) +{ + std::string dir_max = this->ComputeLongestObjectDirectory(*gt->Target); + + // Count the number of object files with each name. Note that + // windows file names are not case sensitive. + std::map counts; + + for(std::map::iterator + si = mapping.begin(); si != mapping.end(); ++si) + { + cmSourceFile const* sf = si->first; + std::string objectNameLower = cmSystemTools::LowerCase( + cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath())); + objectNameLower += ".obj"; + counts[objectNameLower] += 1; + } + + // For all source files producing duplicate names we need unique + // object name computation. + + for(std::map::iterator + si = mapping.begin(); si != mapping.end(); ++si) + { + cmSourceFile const* sf = si->first; + std::string objectName = + cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); + objectName += ".obj"; + if(counts[cmSystemTools::LowerCase(objectName)] > 1) + { + const_cast(gt)->AddExplicitObjectName(sf); + objectName = this->GetObjectFileNameWithoutTarget(*sf, dir_max); + } + si->second = objectName; + } +} + +//---------------------------------------------------------------------------- cmsys::auto_ptr cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target, const std::string& config, diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index a89e219..3bf4f43 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -61,6 +61,10 @@ public: virtual void AddCMakeListsRules() = 0; + virtual void ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const* = 0); + protected: virtual const char* ReportErrorLabel() const; virtual bool CustomCommandUseLocal() const { return false; } diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index 5857aef..8ff6c87 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -71,3 +71,31 @@ void cmLocalXCodeGenerator::GenerateInstallRules() t->HasMacOSXRpathInstallNameDir(""); } } + +//---------------------------------------------------------------------------- +void cmLocalXCodeGenerator::ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const*) +{ + // Count the number of object files with each name. Warn about duplicate + // names since Xcode names them uniquely automatically with a numeric suffix + // to avoid exact duplicate file names. Note that Mac file names are not + // typically case sensitive, hence the LowerCase. + std::map counts; + for(std::map::iterator + si = mapping.begin(); si != mapping.end(); ++si) + { + cmSourceFile const* sf = si->first; + std::string objectName = + cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); + objectName += ".o"; + + std::string objectNameLower = cmSystemTools::LowerCase(objectName); + counts[objectNameLower] += 1; + if (2 == counts[objectNameLower]) + { + // TODO: emit warning about duplicate name? + } + si->second = objectName; + } +} diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index 3bfe3a3..f553a17 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -32,6 +32,9 @@ public: const std::string& rawFlag); virtual void Generate(); virtual void GenerateInstallRules(); + virtual void ComputeObjectFilenames( + std::map& mapping, + cmGeneratorTarget const* gt = 0); private: }; -- cgit v0.12 From 328c217960ac3ee92270739a2dc4fc9d566789c3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 13 Mar 2014 15:11:08 -0400 Subject: Help: Drop cmStdString from cmake-developer(7) examples The type no longer exists within CMake. --- Help/manual/cmake-developer.7.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst index 376b56c..d025d63 100644 --- a/Help/manual/cmake-developer.7.rst +++ b/Help/manual/cmake-developer.7.rst @@ -55,7 +55,7 @@ used in a comparison with the iterator returned by ``end()``: .. code-block:: c++ - const std::set& someSet = getSet(); + const std::set& someSet = getSet(); if (someSet.find("needle") == someSet.end()) // Wrong { // ... @@ -66,8 +66,8 @@ The return value of ``find()`` must be assigned to an intermediate .. code-block:: c++ - const std::set& someSet; - const std::set::const_iterator i = someSet.find("needle"); + const std::set& someSet; + const std::set::const_iterator i = someSet.find("needle"); if (i != propSet.end()) // Ok { // ... @@ -110,7 +110,7 @@ conversion is not allowed: .. code-block:: c++ - std::set theSet; + std::set theSet; std::vector theVector; theVector.insert(theVector.end(), theSet.begin(), theSet.end()); // Wrong @@ -118,9 +118,9 @@ A loop must be used instead: .. code-block:: c++ - std::set theSet; + std::set theSet; std::vector theVector; - for(std::set::iterator li = theSet.begin(); + for(std::set::iterator li = theSet.begin(); li != theSet.end(); ++li) { theVector.push_back(*li); -- cgit v0.12 From d363cbf3156c5e8ef160ffbb45cfa269addebb50 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 13 Mar 2014 15:46:30 -0400 Subject: Tests: Make RunCMake.find_dependency tolerate line number changes --- Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt | 2 +- Tests/RunCMake/find_dependency/extra-args-stderr.txt | 2 +- Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt b/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt index 6f4fc04..348f8bb 100644 --- a/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt +++ b/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:35 \(message\): +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): Invalid arguments to find_dependency. EXACT may only be specified if a VERSION is specified Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/find_dependency/extra-args-stderr.txt b/Tests/RunCMake/find_dependency/extra-args-stderr.txt index 1b52380..83a7f02 100644 --- a/Tests/RunCMake/find_dependency/extra-args-stderr.txt +++ b/Tests/RunCMake/find_dependency/extra-args-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:47 \(message\): +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): Invalid arguments to find_dependency Call Stack \(most recent call first\): extra-args.cmake:4 \(find_dependency\) diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt b/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt index c36148f..fee8d5d 100644 --- a/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt +++ b/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:42 \(message\): +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): Invalid arguments to find_dependency Call Stack \(most recent call first\): invalid-arg-3.cmake:4 \(find_dependency\) -- cgit v0.12 From a25b809f2075828e5ae488f74d85f5a31940460a Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 13 Mar 2014 15:49:08 -0400 Subject: Tests: Check find_dependency empty extra arguments Add cases for empty arg 2 and arg 3. --- Tests/RunCMake/find_dependency/RunCMakeTest.cmake | 2 ++ Tests/RunCMake/find_dependency/empty-arg-3-result.txt | 1 + Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt | 5 +++++ Tests/RunCMake/find_dependency/empty-arg-3.cmake | 4 ++++ Tests/RunCMake/find_dependency/empty-version-result.txt | 1 + Tests/RunCMake/find_dependency/empty-version-stderr.txt | 5 +++++ Tests/RunCMake/find_dependency/empty-version.cmake | 4 ++++ 7 files changed, 22 insertions(+) create mode 100644 Tests/RunCMake/find_dependency/empty-arg-3-result.txt create mode 100644 Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt create mode 100644 Tests/RunCMake/find_dependency/empty-arg-3.cmake create mode 100644 Tests/RunCMake/find_dependency/empty-version-result.txt create mode 100644 Tests/RunCMake/find_dependency/empty-version-stderr.txt create mode 100644 Tests/RunCMake/find_dependency/empty-version.cmake diff --git a/Tests/RunCMake/find_dependency/RunCMakeTest.cmake b/Tests/RunCMake/find_dependency/RunCMakeTest.cmake index b85104a..9403136 100644 --- a/Tests/RunCMake/find_dependency/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_dependency/RunCMakeTest.cmake @@ -1,5 +1,7 @@ include(RunCMake) run_cmake(EXACT-no-version) +run_cmake(empty-version) +run_cmake(empty-arg-3) run_cmake(invalid-arg-3) run_cmake(extra-args) diff --git a/Tests/RunCMake/find_dependency/empty-arg-3-result.txt b/Tests/RunCMake/find_dependency/empty-arg-3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-arg-3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt b/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt new file mode 100644 index 0000000..bf9b02b --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): + Invalid arguments to find_dependency +Call Stack \(most recent call first\): + empty-arg-3.cmake:4 \(find_dependency\) + CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/empty-arg-3.cmake b/Tests/RunCMake/find_dependency/empty-arg-3.cmake new file mode 100644 index 0000000..b08200a --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-arg-3.cmake @@ -0,0 +1,4 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 1.2 "") diff --git a/Tests/RunCMake/find_dependency/empty-version-result.txt b/Tests/RunCMake/find_dependency/empty-version-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-version-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/empty-version-stderr.txt b/Tests/RunCMake/find_dependency/empty-version-stderr.txt new file mode 100644 index 0000000..b5e9f46 --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-version-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at .*/Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): + Invalid arguments to find_dependency. VERSION is empty +Call Stack \(most recent call first\): + empty-version.cmake:4 \(find_dependency\) + CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/empty-version.cmake b/Tests/RunCMake/find_dependency/empty-version.cmake new file mode 100644 index 0000000..e6f17cd --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-version.cmake @@ -0,0 +1,4 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 "") -- cgit v0.12 From 9840320dff7d6bc0fc64d06271a639303ea53ce7 Mon Sep 17 00:00:00 2001 From: Volkan Gezer Date: Thu, 27 Feb 2014 14:37:52 +0100 Subject: CTest: Add support for Intel coverage files By default, Intel compiler coverage tools generate HTML files as reports, but the option -txtlcov can be given to codecov to output a coverage file with LCov format. To use Intel coverage: * build the project with coverage flags * run the application * run profmerge * run codecov The output file will be "build_dir/CodeCoverage/SRCFILEDIR.LCOV". Ask users to compile with -prof-dir${BUILD_DIR} instead of searching the entire build tree recursively to find coverage files. --- Source/CTest/cmCTestCoverageHandler.cxx | 305 ++++++++++++++++++++++++++++++++ Source/CTest/cmCTestCoverageHandler.h | 4 + 2 files changed, 309 insertions(+) diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index f0b1124..cb6e56e 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -383,6 +383,12 @@ int cmCTestCoverageHandler::ProcessHandler() { return error; } + file_count += this->HandleLCovCoverage(&cont); + error = cont.Error; + if ( file_count < 0 ) + { + return error; + } file_count += this->HandleTracePyCoverage(&cont); error = cont.Error; if ( file_count < 0 ) @@ -880,6 +886,13 @@ int cmCTestCoverageHandler::HandleGCovCoverage( std::string gcovExtraFlags = this->CTest->GetCTestConfiguration("CoverageExtraFlags"); + // Immediately skip to next coverage option since codecov is only for Intel + // compiler + if ( gcovCommand == "codecov" ) + { + return 0; + } + // Style 1 std::string st1gcovOutputRex1 = "[0-9]+\\.[0-9]+% of [0-9]+ (source |)lines executed in file (.*)$"; @@ -1296,6 +1309,270 @@ int cmCTestCoverageHandler::HandleGCovCoverage( return file_count; } +//---------------------------------------------------------------------- +int cmCTestCoverageHandler::HandleLCovCoverage( + cmCTestCoverageHandlerContainer* cont) +{ + std::string lcovCommand + = this->CTest->GetCTestConfiguration("CoverageCommand"); + std::string lcovExtraFlags + = this->CTest->GetCTestConfiguration("CoverageExtraFlags"); + if ( lcovCommand != "codecov" ) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " Not a valid Intel Coverage command." + << std::endl); + return 0; + } + // There is only percentage completed output from LCOV + std::string st2lcovOutputRex3 = "[0-9]+%"; + cmsys::RegularExpression st2re3(st2lcovOutputRex3.c_str()); + + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " This is coverage command: " << lcovCommand + << std::endl); + + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " These are coverage command flags: " << lcovExtraFlags + << std::endl); + + std::vector files; + this->FindLCovFiles(files); + std::vector::iterator it; + + if ( files.size() == 0 ) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " Cannot find any LCov coverage files." + << std::endl); + // No coverage files is a valid thing, so the exit code is 0 + return 0; + } + std::string testingDir = this->CTest->GetBinaryDir(); + std::string tempDir = testingDir; + std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory(); + + std::set missingFiles; + + std::string actualSourceFile = ""; + cmCTestLog(this->CTest, HANDLER_OUTPUT, + " Processing coverage (each . represents one file):" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); + int file_count = 0; + + // make sure output from lcov is in English! + cmCTestCoverageHandlerLocale locale_C; + static_cast(locale_C); + + // In intel compiler we have to call codecov only once in each executable + // directory. It collects all *.dyn files to generate .dpi file. + for ( it = files.begin(); it != files.end(); ++ it ) + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush); + std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str()); + cmSystemTools::ChangeDirectory(fileDir.c_str()); + std::string command = "\"" + lcovCommand + "\" " + + lcovExtraFlags + " "; + + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Current coverage dir: " + << fileDir.c_str() << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, command.c_str() + << std::endl); + + std::string output = ""; + std::string errors = ""; + int retVal = 0; + *cont->OFS << "* Run coverage for: " << fileDir.c_str() << std::endl; + *cont->OFS << " Command: " << command.c_str() << std::endl; + int res = this->CTest->RunCommand(command.c_str(), &output, &errors, + &retVal, fileDir.c_str(), 0 /*this->TimeOut*/); + + *cont->OFS << " Output: " << output.c_str() << std::endl; + *cont->OFS << " Errors: " << errors.c_str() << std::endl; + if ( ! res ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Problem running coverage on file: " << it->c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Command produced error: " << errors << std::endl); + cont->Error ++; + continue; + } + if ( retVal != 0 ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: " + << retVal << " while processing: " << it->c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Command produced error: " << cont->Error << std::endl); + } + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "--------------------------------------------------------------" + << std::endl + << output << std::endl + << "--------------------------------------------------------------" + << std::endl); + + std::vector lines; + std::vector::iterator line; + + cmSystemTools::Split(output.c_str(), lines); + + for ( line = lines.begin(); line != lines.end(); ++line) + { + std::string sourceFile; + std::string lcovFile; + + if ( line->size() == 0 ) + { + // Ignore empty line + } + // Look for LCOV files in binary directory + // Intel Compiler creates a CodeCoverage dir for each subfolder and + // each subfolder has LCOV files + cmsys::Glob gl; + gl.RecurseOn(); + gl.RecurseThroughSymlinksOff(); + std::string dir; + std::vector lcovFiles; + dir = this->CTest->GetBinaryDir(); + std::string daGlob; + daGlob = dir; + daGlob += "/*.LCOV"; + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " looking for LCOV files in: " << daGlob << std::endl); + gl.FindFiles(daGlob); + // Keep a list of all LCOV files + lcovFiles.insert(lcovFiles.end(), gl.GetFiles().begin(), + gl.GetFiles().end()); + + for(std::vector::iterator a = lcovFiles.begin(); + a != lcovFiles.end(); ++a) + { + lcovFile = *a; + cmsys::ifstream srcead(lcovFile.c_str()); + if ( ! srcead ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: " + << lcovFile << std::endl); + } + std::string srcname; + + int success = cmSystemTools::GetLineFromStream(srcead, srcname); + if ( !success ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error while parsing lcov file '" << lcovFile << "':" + << " No source file name found!" << std::endl); + return 0; + } + srcname = srcname.substr(18); + // We can directly read found LCOV files to determine the source + // files + sourceFile = srcname; + actualSourceFile = srcname; + + for(std::vector::iterator t = lcovFiles.begin(); + t != lcovFiles.end(); ++t) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found LCOV File: " + << *t << std::endl); + } + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SourceFile: " + << sourceFile << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "lCovFile: " + << lcovFile << std::endl); + + // If we have some LCOV files to process + if ( !lcovFile.empty() && !actualSourceFile.empty() ) + { + cmCTestCoverageHandlerContainer::SingleFileCoverageVector& vec + = cont->TotalCoverage[actualSourceFile]; + + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " in lcovFile: " + << lcovFile << std::endl); + + cmsys::ifstream ifile(lcovFile.c_str()); + if ( ! ifile ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: " + << lcovFile << std::endl); + } + else + { + long cnt = -1; + std::string nl; + + // Skip the first line + cmSystemTools::GetLineFromStream(ifile, nl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "File is ready, start reading." << std::endl); + while ( cmSystemTools::GetLineFromStream(ifile, nl) ) + { + cnt ++; + + // Skip empty lines + if ( !nl.size() ) + { + continue; + } + + // Skip unused lines + if ( nl.size() < 12 ) + { + continue; + } + + // Read the coverage count from the beginning of the lcov + // output line + std::string prefix = nl.substr(0, 17); + int cov = atoi(prefix.c_str()); + + // Read the line number starting at the 17th character of the + // lcov output line + std::string lineNumber = nl.substr(17, 7); + + int lineIdx = atoi(lineNumber.c_str())-1; + if ( lineIdx >= 0 ) + { + while ( vec.size() <= static_cast(lineIdx) ) + { + vec.push_back(-1); + } + + // Initially all entries are -1 (not used). If we get coverage + // information, increment it to 0 first. + if ( vec[lineIdx] < 0 ) + { + if ( cov > 0 || prefix.find("#") != prefix.npos ) + { + vec[lineIdx] = 0; + } + } + + vec[lineIdx] += cov; + } + } + } + + actualSourceFile = ""; + } + } + } + + file_count++; + + if ( file_count % 50 == 0 ) + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, " processed: " << file_count + << " out of " << files.size() << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); + } + } + + cmSystemTools::ChangeDirectory(currentDirectory.c_str()); + return file_count; +} + //---------------------------------------------------------------------------- void cmCTestCoverageHandler::FindGCovFiles(std::vector& files) { @@ -1327,6 +1604,34 @@ void cmCTestCoverageHandler::FindGCovFiles(std::vector& files) } } +//---------------------------------------------------------------------------- +void cmCTestCoverageHandler::FindLCovFiles(std::vector& files) +{ + cmsys::Glob gl; + gl.RecurseOff(); // No need of recurse if -prof_dir${BUILD_DIR} flag is + // used while compiling. + gl.RecurseThroughSymlinksOff(); + std::string prevBinaryDir; + cmSystemTools::ChangeDirectory( + this->CTest->GetCTestConfiguration("BuildDirectory").c_str()); + + // Run profmerge to merge all *.dyn files into dpi files + cmSystemTools::RunSingleCommand("profmerge"); + + prevBinaryDir = cmSystemTools::GetCurrentWorkingDirectory().c_str(); + + // DPI file should appear in build directory + std::string daGlob; + daGlob = prevBinaryDir; + daGlob += "/*.dpi"; + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " looking for dpi files in: " << daGlob << std::endl); + gl.FindFiles(daGlob); + files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end()); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Now searching in: " << daGlob << std::endl); +} + //---------------------------------------------------------------------- int cmCTestCoverageHandler::HandleTracePyCoverage( cmCTestCoverageHandlerContainer* cont) diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h index 6a8f55d..0a0fe81 100644 --- a/Source/CTest/cmCTestCoverageHandler.h +++ b/Source/CTest/cmCTestCoverageHandler.h @@ -68,6 +68,10 @@ private: int HandleGCovCoverage(cmCTestCoverageHandlerContainer* cont); void FindGCovFiles(std::vector& files); + //! Handle coverage using Intel's LCov + int HandleLCovCoverage(cmCTestCoverageHandlerContainer* cont); + void FindLCovFiles(std::vector& files); + //! Handle coverage using xdebug php coverage int HandlePHPCoverage(cmCTestCoverageHandlerContainer* cont); -- cgit v0.12 From 9a026b902b7c7c263e6c3a70f755f974e8953132 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 14 Mar 2014 00:01:14 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index be11dce..040cd27 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 0) -set(CMake_VERSION_PATCH 20140313) +set(CMake_VERSION_PATCH 20140314) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 1af77f3f1dcd2fe160a9ea1d7936742c968f25d1 Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Fri, 14 Mar 2014 11:51:45 +0100 Subject: FeatureSummary: Add missing titles for PACKAGES_FOUND and PACKAGES_NOT_FOUND Since now these can be used with the WHAT argument a title is required. --- Modules/FeatureSummary.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake index 6696515..a72954c 100644 --- a/Modules/FeatureSummary.cmake +++ b/Modules/FeatureSummary.cmake @@ -492,6 +492,8 @@ function(FEATURE_SUMMARY) set(title_ENABLED_FEATURES "The following features have been enabled:") set(title_DISABLED_FEATURES "The following features have been disabled:") + set(title_PACKAGES_FOUND "The following packages have been found:") + set(title_PACKAGES_NOT_FOUND "The following packages have not been found:") set(title_OPTIONAL_PACKAGES_FOUND "The following OPTIONAL packages have been found:") set(title_OPTIONAL_PACKAGES_NOT_FOUND "The following OPTIONAL packages have not been found:") set(title_RECOMMENDED_PACKAGES_FOUND "The following RECOMMENDED packages have been found:") -- cgit v0.12 From a9e6de2acc1ac2e51b4d737b3abbeee3bf43832c Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 5 Mar 2014 17:01:26 -0500 Subject: FindPythonInterp: Use consistent version with PythonLibs (#13794) If find_package(PythonLibs) find_package(PythonInterp) is called, help PythonInterp to get a version of PYTHON_EXECUTABLE consistent with the library versions found by PythonLibs. --- Modules/FindPythonInterp.cmake | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 8da848c..780cda8 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -71,18 +71,23 @@ if(PythonInterp_FIND_VERSION) else() set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS}) endif() - -list(APPEND _Python_NAMES python) - -# Search for the current active python version first find_program(PYTHON_EXECUTABLE NAMES ${_Python_NAMES}) # Set up the versions we know about, in the order we will search. Always add # the user supplied additional versions to the front. -set(_Python_VERSIONS - ${Python_ADDITIONAL_VERSIONS} - ${_PYTHON_FIND_OTHER_VERSIONS} - ) +set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS}) +# If FindPythonInterp has already found the major and minor version, +# insert that version next to get consistent versions of the interpreter and +# library. +if(DEFINED PYTHONLIBS_VERSION_STRING) + string(REPLACE "." ";" _PYTHONLIBS_VERSION "${PYTHONLIBS_VERSION_STRING}") + list(GET _PYTHONLIBS_VERSION 0 _PYTHONLIBS_VERSION_MAJOR) + list(GET _PYTHONLIBS_VERSION 1 _PYTHONLIBS_VERSION_MINOR) + list(APPEND _Python_VERSIONS ${_PYTHONLIBS_VERSION_MAJOR}.${_PYTHONLIBS_VERSION_MINOR}) +endif() +# Search for the current active python version first +list(APPEND _Python_VERSIONS ";") +list(APPEND _Python_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS}) unset(_PYTHON_FIND_OTHER_VERSIONS) unset(_PYTHON1_VERSIONS) @@ -91,7 +96,7 @@ unset(_PYTHON3_VERSIONS) # Search for newest python version if python executable isn't found if(NOT PYTHON_EXECUTABLE) - foreach(_CURRENT_VERSION ${_Python_VERSIONS}) + foreach(_CURRENT_VERSION IN LISTS _Python_VERSIONS) set(_Python_NAMES python${_CURRENT_VERSION}) if(WIN32) list(APPEND _Python_NAMES python) -- cgit v0.12 From 59220198022d2e081ddba164c1ec62a6e9d438eb Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Thu, 13 Mar 2014 11:19:11 -0400 Subject: FindPython*: Document suggested find_package order (#13794) Document in both FindPythonInterp.cmake and FindPythonLibs.cmake that find_package(PythonInterp) should be called before find_package(PythonLibs). --- Modules/FindPythonInterp.cmake | 4 ++++ Modules/FindPythonLibs.cmake | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 780cda8..f8ff5d8 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -27,6 +27,10 @@ # of version numbers that should be taken into account when searching # for Python. You need to set this variable before calling # find_package(PythonInterp). +# +# If also calling find_package(PythonLibs), call find_package(PythonInterp) +# first to get the currently active Python version by default with a consistent +# version of PYTHON_LIBRARIES. #============================================================================= # Copyright 2005-2010 Kitware, Inc. diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 656ed7b..1f90f5b 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -31,6 +31,10 @@ # # PYTHON_LIBRARY - path to the python library # PYTHON_INCLUDE_DIR - path to where Python.h is found +# +# If also calling find_package(PythonInterp), call find_package(PythonInterp) +# first to get the currently active Python version by default with a consistent +# version of PYTHON_LIBRARIES. #============================================================================= # Copyright 2001-2009 Kitware, Inc. -- cgit v0.12 From 13778cd3be03de966c006b7acc6c1ec07019ab07 Mon Sep 17 00:00:00 2001 From: Sean D'Epagnier Date: Mon, 10 Mar 2014 13:37:26 +0800 Subject: CPackDeb: Add option to set compression type Add a CPACK_DEBIAN_COMPRESSION_TYPE option to set the compression type. Default to 'gzip' to preserve existing behavior. Use "cmake -E tar" for 'gzip', 'bzip2', and 'none'. Use system "tar" for 'lzma' and 'xz'. --- Modules/CPackDeb.cmake | 13 +++++++++- Source/CPack/cmCPackDebGenerator.cxx | 46 +++++++++++++++++++++++++++++------- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index c79ef06..b210bbb 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -67,7 +67,12 @@ # * Mandatory : YES # * Default : 'devel' # -# The debian package section +# .. variable:: CPACK_DEBIAN_COMPRESSION_TYPE +# +# * Mandatory : YES +# * Default : 'gzip' +# +# Possible values are: lzma, xz, bzip2 and gzip. # # .. variable:: CPACK_DEBIAN_PACKAGE_PRIORITY # @@ -390,6 +395,12 @@ if(NOT CPACK_DEBIAN_PACKAGE_PRIORITY) set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") endif() +# Compression: (recommended) +if(NOT CPACK_DEBIAN_COMPRESSION_TYPE) + set(CPACK_DEBIAN_COMPRESSION_TYPE "gzip") +endif() + + # Recommends: # You should set: CPACK_DEBIAN_PACKAGE_RECOMMENDS diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 27e9d9f..936942b 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -403,9 +403,39 @@ int cmCPackDebGenerator::createDeb() if (NULL != this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE")) { cmd += this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE"); } - cmd += " \""; - cmd += cmakeExecutable; - cmd += "\" -E tar cfz data.tar.gz "; + + const char* debian_compression_type = + this->GetOption("CPACK_DEBIAN_COMPRESSION_TYPE"); + if(!debian_compression_type) + { + debian_compression_type = "gzip"; + } + + std::string cmake_tar = " ", compression_modifier = "a", compression_suffix; + if(!strcmp(debian_compression_type, "lzma")) { + compression_suffix = ".lzma"; + } else if(!strcmp(debian_compression_type, "xz")) { + compression_suffix = ".xz"; + } else if(!strcmp(debian_compression_type, "bzip2")) { + compression_suffix = ".bz2"; + compression_modifier = "j"; + cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E "; + } else if(!strcmp(debian_compression_type, "gzip")) { + compression_suffix = ".gz"; + compression_modifier = "z"; + cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E "; + } else if(!strcmp(debian_compression_type, "none")) { + compression_suffix = ""; + compression_modifier = ""; + cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E "; + } else { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error unrecognized compression type: " + << debian_compression_type << std::endl); + } + + cmd += cmake_tar + "tar c" + compression_modifier + "f data.tar" + + compression_suffix; // now add all directories which have to be compressed // collect all top level install dirs for that @@ -493,9 +523,7 @@ int cmCPackDebGenerator::createDeb() { cmd = this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE"); } - cmd += " \""; - cmd += cmakeExecutable; - cmd += "\" -E tar cfz control.tar.gz ./control ./md5sums"; + cmd += cmake_tar + "tar czf control.tar.gz ./control ./md5sums"; const char* controlExtra = this->GetOption("CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA"); if( controlExtra ) @@ -514,7 +542,7 @@ int cmCPackDebGenerator::createDeb() if( cmsys::SystemTools::CopyFileIfDifferent( i->c_str(), localcopy.c_str()) ) { - // debian is picky and need relative to ./ path in the tar.gz + // debian is picky and need relative to ./ path in the tar.* cmd += " ./"; cmd += filenamename; } @@ -538,7 +566,7 @@ int cmCPackDebGenerator::createDeb() return 0; } - // ar -r your-package-name.deb debian-binary control.tar.gz data.tar.gz + // ar -r your-package-name.deb debian-binary control.tar.* data.tar.* // since debian packages require BSD ar (most Linux distros and even // FreeBSD and NetBSD ship GNU ar) we use a copy of OpenBSD ar here. std::vector arFiles; @@ -546,7 +574,7 @@ int cmCPackDebGenerator::createDeb() topLevelString += "/"; arFiles.push_back(topLevelString + "debian-binary"); arFiles.push_back(topLevelString + "control.tar.gz"); - arFiles.push_back(topLevelString + "data.tar.gz"); + arFiles.push_back(topLevelString + "data.tar" + compression_suffix); std::string outputFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); outputFileName += "/"; outputFileName += this->GetOption("CPACK_OUTPUT_FILE_NAME"); -- cgit v0.12 From 16caa6ecba698e08cb1b2608aa479b7484cad73a Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 14 Mar 2014 09:34:14 -0400 Subject: Help: Add release notes for topic 'cpack-deb-compression-types' --- Help/release/dev/cpack-deb-compression-types.rst | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Help/release/dev/cpack-deb-compression-types.rst diff --git a/Help/release/dev/cpack-deb-compression-types.rst b/Help/release/dev/cpack-deb-compression-types.rst new file mode 100644 index 0000000..a33e333 --- /dev/null +++ b/Help/release/dev/cpack-deb-compression-types.rst @@ -0,0 +1,6 @@ +cpack-deb-compression-types +--------------------------- + +* The :module:`CPackDeb` module learned a new + :variable:`CPACK_DEBIAN_COMPRESSION_TYPE` variable to set the + tarball compression type. -- cgit v0.12 From 3a7501d9eb7e1a22a8c4161c88008c7929451554 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 14 Mar 2014 10:31:30 -0400 Subject: Help: Add release notes for topic 'ctest-intel-coverage' --- Help/release/dev/ctest-intel-coverage.rst | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Help/release/dev/ctest-intel-coverage.rst diff --git a/Help/release/dev/ctest-intel-coverage.rst b/Help/release/dev/ctest-intel-coverage.rst new file mode 100644 index 0000000..11455a5 --- /dev/null +++ b/Help/release/dev/ctest-intel-coverage.rst @@ -0,0 +1,5 @@ +ctest-intel-coverage +-------------------- + +* The :command:`ctest_coverage` command learned to support + Intel coverage files with the ``codecov`` tool. -- cgit v0.12 From 91fd99b86532dbf35d8c7396654b9beac058c8f3 Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Fri, 14 Mar 2014 08:47:37 -0600 Subject: Encoding: Provide option to configure CMake to use UTF-8 encoding. --- CMakeLists.txt | 7 +++++++ Source/CMakeLists.txt | 5 +++++ Source/QtDialog/CMakeLists.txt | 5 ----- Source/QtDialog/CMakeSetup.cxx | 2 +- Source/cmConfigure.cmake.h.in | 1 + 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f83015..b0793d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,13 @@ if("${CMake_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") endmacro() endif() +# option to set the internal encoding of CMake to UTF-8 +option(CMAKE_ENCODING_UTF8 "Use UTF-8 encoding internally (experimental)." OFF) +mark_as_advanced(CMAKE_ENCODING_UTF8) +if(CMAKE_ENCODING_UTF8) + set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8) +endif() + #----------------------------------------------------------------------- # a macro to deal with system libraries, implemented as a macro # simply to improve readability of the main script diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 966e0f6..9fb8d9a 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -24,6 +24,11 @@ endif() set(EXECUTABLE_OUTPUT_PATH ${CMake_BIN_DIR}) +# ensure Unicode friendly APIs are used on Windows +if(WIN32) + add_definitions(-DUNICODE -D_UNICODE) +endif() + # configure the .h file configure_file( "${CMake_SOURCE_DIR}/Source/cmConfigure.cmake.h.in" diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 0dd01d8..4308a4d 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -55,11 +55,6 @@ else() endif() endif() - -if(WIN32 AND KWSYS_ENCODING_DEFAULT_CODEPAGE MATCHES CP_UTF8) - add_definitions(-DKWSYS_CP_UTF8) -endif() - set(SRCS AddCacheEntry.cxx AddCacheEntry.h diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 995929e..e37bd9d 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -79,7 +79,7 @@ int main(int argc, char** argv) QApplication app(argc, argv); -#if defined(KWSYS_CP_UTF8) +#if defined(CMAKE_ENCODING_UTF8) QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8"); QTextCodec::setCodecForCStrings(utf8_codec); QTextCodec::setCodecForLocale(utf8_codec); diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index c5e95d0..2b0280d 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -16,4 +16,5 @@ #cmakedefine HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE #cmakedefine HAVE_UNSETENV #cmakedefine CMAKE_USE_ELF_PARSER +#cmakedefine CMAKE_ENCODING_UTF8 #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" -- cgit v0.12 From ee8cef8725486519a7ab47eb16208d4d64e0ab99 Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Fri, 14 Mar 2014 08:48:42 -0600 Subject: Encoding: If configured, write Visual Studio project files as UTF-8. --- Source/cmGlobalVisualStudio7Generator.cxx | 14 +++++++++++++- Source/cmGlobalVisualStudio7Generator.h | 3 +++ Source/cmGlobalVisualStudioGenerator.cxx | 3 ++- Source/cmLocalVisualStudio7Generator.cxx | 12 ++++++++---- Source/cmVisualStudio10TargetGenerator.cxx | 6 ++++-- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 320b440..42033c5 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -873,7 +873,8 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target) std::string guid = this->GetGUID(pname.c_str()); fout << - "\n" + "Encoding() << "\"?>\n" "GetIDEVersion() << "0\"\n" @@ -1038,3 +1039,14 @@ cmIDEFlagTable const* cmGlobalVisualStudio7Generator::GetExtraFlagTableVS7() { return cmVS7ExtraFlagTable; } + +std::string cmGlobalVisualStudio7Generator::Encoding() +{ + std::ostringstream encoding; +#ifdef CMAKE_ENCODING_UTF8 + encoding << "UTF-8"; +#else + encoding << "Windows-1252"; +#endif + return encoding.str(); +} diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 0d2e410..1dc709d 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -109,6 +109,9 @@ public: virtual void FindMakeProgram(cmMakefile*); + // Encoding for Visual Studio files + virtual std::string Encoding(); + protected: virtual const char* GetIDEVersion() { return "7.0"; } diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 69c893c..2b2a471 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -1,3 +1,4 @@ + /*============================================================================ CMake - Cross Platform Makefile Generator Copyright 2000-2009 Kitware, Inc., Insight Software Consortium @@ -918,4 +919,4 @@ std::string cmGlobalVisualStudioGenerator::ExpandCFGIntDir( i += config.size(); } return tmp; -} +} \ No newline at end of file diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 14ad567..52524aa 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1975,7 +1975,8 @@ cmLocalVisualStudio7Generator cmGlobalVisualStudio7Generator* gg = static_cast(this->GlobalGenerator); - fout << "\n" + fout << "Encoding() << "\"?>\n" << "GetIntelProjectVersion() << "\"\n"; @@ -2038,7 +2039,12 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, this->WriteProjectStartFortran(fout, libName, target); return; } - fout << "\n" + + cmGlobalVisualStudio7Generator* gg = + static_cast(this->GlobalGenerator); + + fout << "Encoding() << "\"?>\n" << "Version == VS71) @@ -2059,8 +2065,6 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, { keyword = "Win32Proj"; } - cmGlobalVisualStudio7Generator* gg = - static_cast(this->GlobalGenerator); fout << "\tName=\"" << projLabel << "\"\n"; if(this->Version >= VS8) { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 7c55f64..8e8968d 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -222,7 +222,8 @@ void cmVisualStudio10TargetGenerator::Generate() //get the tools version to use const std::string toolsVer(this->GlobalGenerator->GetToolsVersion()); std::string project_defaults= - "\n"; + "GlobalGenerator->Encoding() + "\"?>\n"; project_defaults.append("GlobalGenerator->GetToolsVersion()); std::string project_defaults= - "\n"; + "GlobalGenerator->Encoding() + "\"?>\n"; project_defaults.append(" Date: Sat, 15 Mar 2014 00:01:11 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 040cd27..6a8a823 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 0) -set(CMake_VERSION_PATCH 20140314) +set(CMake_VERSION_PATCH 20140315) #set(CMake_VERSION_RC 1) -- cgit v0.12 From c481fadc07e72193f16a4f1fb9d477db133f1120 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 14 Mar 2014 11:02:47 +0100 Subject: cmGeneratorTarget: Don't store ObjectSources for object libraries. Compute them on demand instead. --- Source/cmGeneratorTarget.cxx | 10 ++++------ Source/cmGeneratorTarget.h | 1 - 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 8efd7bb..2a144c6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -310,10 +310,6 @@ cmGeneratorTarget ::GetObjectSources(std::vector &data) const { IMPLEMENT_VISIT(ObjectSources); - if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY) - { - this->ObjectSources = data; - } } //---------------------------------------------------------------------------- @@ -577,9 +573,11 @@ cmGeneratorTarget::UseObjectLibraries(std::vector& objs) const cmTarget* objLib = *ti; cmGeneratorTarget* ogt = this->GlobalGenerator->GetGeneratorTarget(objLib); + std::vector objectSources; + ogt->GetObjectSources(objectSources); for(std::vector::const_iterator - si = ogt->ObjectSources.begin(); - si != ogt->ObjectSources.end(); ++si) + si = objectSources.begin(); + si != objectSources.end(); ++si) { std::string obj = ogt->ObjectDirectory; obj += ogt->Objects[*si]; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 139e736..53e27c5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -127,7 +127,6 @@ private: std::map Objects; std::set ExplicitObjectName; - mutable std::vector ObjectSources; std::vector ObjectLibraries; mutable std::map > SystemIncludesCache; -- cgit v0.12 From 6c9dd0ec7b1e000b0bedd567fa52074671d639c9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 11 Mar 2014 20:39:01 +0100 Subject: cmGlobalGenerator: Make ComputeTargetObjects non-virtual Implement it in terms of the ComputeObjectFilenames virtual method on the local generators. Remove the reimplementation from the global generators which are now all functionally identical. --- Source/cmGlobalGenerator.cxx | 21 +++++++++++++++++++-- Source/cmGlobalGenerator.h | 2 +- Source/cmGlobalNinjaGenerator.cxx | 23 ----------------------- Source/cmGlobalNinjaGenerator.h | 2 -- Source/cmGlobalUnixMakefileGenerator3.cxx | 24 ------------------------ Source/cmGlobalUnixMakefileGenerator3.h | 1 - Source/cmGlobalVisualStudioGenerator.cxx | 24 ------------------------ Source/cmGlobalVisualStudioGenerator.h | 1 - Source/cmGlobalXCodeGenerator.cxx | 24 ------------------------ Source/cmGlobalXCodeGenerator.h | 1 - 10 files changed, 20 insertions(+), 103 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index c9ae799..5b6d729 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1516,9 +1516,26 @@ cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const } //---------------------------------------------------------------------------- -void cmGlobalGenerator::ComputeTargetObjects(cmGeneratorTarget*) const +void cmGlobalGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const { - // Implemented in generator subclasses that need this. + std::vector objectSources; + gt->GetObjectSources(objectSources); + + std::map mapping; + for(std::vector::const_iterator it + = objectSources.begin(); it != objectSources.end(); ++it) + { + mapping[*it]; + } + + gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); + + for(std::map::const_iterator it + = mapping.begin(); it != mapping.end(); ++it) + { + assert(!it->second.empty()); + gt->AddObject(it->first, it->second); + } } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index ed07b10..49a418d 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -443,7 +443,7 @@ private: void CreateGeneratorTargets(cmMakefile* mf); void CreateGeneratorTargets(); void ComputeGeneratorTargetObjects(); - virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; + void ComputeTargetObjects(cmGeneratorTarget* gt) const; void ClearGeneratorMembers(); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 08507eb..49ce1b5 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -632,29 +632,6 @@ std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const return cmSystemTools::GetCMakeGUICommand(); } -// TODO: Refactor to combine with cmGlobalUnixMakefileGenerator3 impl. -void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const -{ - std::vector objectSources; - gt->GetObjectSources(objectSources); - - std::map mapping; - for(std::vector::const_iterator it - = objectSources.begin(); it != objectSources.end(); ++it) - { - mapping[*it]; - } - - gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); - - for(std::map::const_iterator it - = mapping.begin(); it != mapping.end(); ++it) - { - assert(!it->second.empty()); - gt->AddObject(it->first, it->second); - } -} - //---------------------------------------------------------------------------- void cmGlobalNinjaGenerator ::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index e3a22e5..f2643af 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -310,8 +310,6 @@ protected: private: virtual std::string GetEditCacheCommand() const; - /// @see cmGlobalGenerator::ComputeTargetObjects - virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; void OpenBuildFileStream(); void CloseBuildFileStream(); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 91258ed..4632071 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -106,30 +106,6 @@ std::string cmGlobalUnixMakefileGenerator3::GetEditCacheCommand() const //---------------------------------------------------------------------------- void cmGlobalUnixMakefileGenerator3 -::ComputeTargetObjects(cmGeneratorTarget* gt) const -{ - std::vector objectSources; - gt->GetObjectSources(objectSources); - - std::map mapping; - for(std::vector::const_iterator it - = objectSources.begin(); it != objectSources.end(); ++it) - { - mapping[*it]; - } - - gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); - - for(std::map::const_iterator it - = mapping.begin(); it != mapping.end(); ++it) - { - gt->AddObject(it->first, it->second); - } -} - -//---------------------------------------------------------------------------- -void -cmGlobalUnixMakefileGenerator3 ::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const { cmTarget* target = gt->Target; diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 42453f2..d003789 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -199,7 +199,6 @@ protected: private: virtual const char* GetBuildIgnoreErrorsFlag() const { return "-i"; } virtual std::string GetEditCacheCommand() const; - virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; }; #endif diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 9740fbfb..749517c 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -118,30 +118,6 @@ void cmGlobalVisualStudioGenerator::Generate() } //---------------------------------------------------------------------------- -void -cmGlobalVisualStudioGenerator -::ComputeTargetObjects(cmGeneratorTarget* gt) const -{ - std::vector objectSources; - gt->GetObjectSources(objectSources); - - std::map mapping; - for(std::vector::const_iterator it - = objectSources.begin(); it != objectSources.end(); ++it) - { - mapping[*it]; - } - - gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); - - for(std::map::const_iterator it - = mapping.begin(); it != mapping.end(); ++it) - { - gt->AddObject(it->first, it->second); - } -} - -//---------------------------------------------------------------------------- void cmGlobalVisualStudioGenerator ::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const { diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index f957056..1ab8990 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -117,7 +117,6 @@ private: virtual std::string GetVSMakeProgram() = 0; void PrintCompilerAdvice(std::ostream&, std::string const&, const char*) const {} - void ComputeTargetObjects(cmGeneratorTarget* gt) const; void FollowLinkDepends(cmTarget const* target, std::set& linked); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 0a4b51c..d4eb85b 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3934,30 +3934,6 @@ bool cmGlobalXCodeGenerator::IsMultiConfig() return true; } - //---------------------------------------------------------------------------- -void -cmGlobalXCodeGenerator -::ComputeTargetObjects(cmGeneratorTarget* gt) const -{ - std::vector objectSources; - gt->GetObjectSources(objectSources); - - std::map mapping; - for(std::vector::const_iterator it - = objectSources.begin(); it != objectSources.end(); ++it) - { - mapping[*it]; - } - - gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); - - for(std::map::const_iterator it - = mapping.begin(); it != mapping.end(); ++it) - { - gt->AddObject(it->first, it->second); - } -} - //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator ::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index f9dd58f..23616b4 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -217,7 +217,6 @@ protected: private: void PrintCompilerAdvice(std::ostream&, std::string const&, const char*) const {} - void ComputeTargetObjects(cmGeneratorTarget* gt) const; std::string GetObjectsNormalDirectory( const std::string &projName, -- cgit v0.12 From 7d6d45f23c25355f1da0ad9fcd9e45cdb05194f8 Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Sat, 15 Mar 2014 22:56:47 +0100 Subject: CheckTypeSize: Support for CXX when C language is not enabled This example now works without need to enable C language: cmake_minimum_required(VERSION x.x.x) project(foo CXX) include(CheckTypeSize) check_type_size("short" SIZEOF_SHORT LANGUAGE CXX) Fixes #14056 --- Modules/CheckTypeSize.cmake | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index ec28d8b..333b325 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -75,6 +75,7 @@ # License text for the above reference.) include(CheckIncludeFile) +include(CheckIncludeFileCXX) cmake_policy(PUSH) cmake_minimum_required(VERSION 2.6 FATAL_ERROR) @@ -218,9 +219,15 @@ macro(CHECK_TYPE_SIZE TYPE VARIABLE) set(_builtin 0) else() set(_builtin 1) - check_include_file(sys/types.h HAVE_SYS_TYPES_H) - check_include_file(stdint.h HAVE_STDINT_H) - check_include_file(stddef.h HAVE_STDDEF_H) + if("${_language}" STREQUAL "C") + check_include_file(sys/types.h HAVE_SYS_TYPES_H) + check_include_file(stdint.h HAVE_STDINT_H) + check_include_file(stddef.h HAVE_STDDEF_H) + elseif("${_language}" STREQUAL "CXX") + check_include_file_cxx(sys/types.h HAVE_SYS_TYPES_H) + check_include_file_cxx(stdint.h HAVE_STDINT_H) + check_include_file_cxx(stddef.h HAVE_STDDEF_H) + endif() endif() unset(_CHECK_TYPE_SIZE_BUILTIN_TYPES_ONLY) unset(_CHECK_TYPE_SIZE_LANGUAGE) -- cgit v0.12 From 2eb158caf0bee12d5d74e0b50b9ea2bad9a0c7fc Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 16 Mar 2014 00:01:05 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 6a8a823..5ed534b 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 0) -set(CMake_VERSION_PATCH 20140315) +set(CMake_VERSION_PATCH 20140316) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 6313be44aa465ea883e3578b3a0424ae0c217d5c Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 17 Mar 2014 00:01:05 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 5ed534b..562040a 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 0) -set(CMake_VERSION_PATCH 20140316) +set(CMake_VERSION_PATCH 20140317) #set(CMake_VERSION_RC 1) -- cgit v0.12 From ea17a03be5794a934991b1f958cab12b7011da74 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 15 Mar 2014 11:07:57 +0100 Subject: cmTarget: Port _LOCATION support to updated string APIs --- Source/cmTarget.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c07fd0f..17c8a4d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2673,7 +2673,7 @@ const char *cmTarget::GetProperty(const std::string& prop, // Support "_LOCATION". if(cmHasLiteralSuffix(prop, "_LOCATION")) { - std::string configName(prop, strlen(prop) - 9); + std::string configName(prop.c_str(), prop.size() - 9); if(configName != "IMPORTED") { if (!this->HandleLocationPropertyPolicy()) @@ -2681,7 +2681,7 @@ const char *cmTarget::GetProperty(const std::string& prop, return 0; } this->Properties.SetProperty(prop, - this->GetLocation(configName.c_str()), + this->GetLocation(configName), cmProperty::TARGET); } } -- cgit v0.12 From 3df5147043d83aa09acd5c9ce31d5c602efb99db Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Thu, 6 Mar 2014 18:55:04 +0100 Subject: FindPkgConfig: Extend PKG_CONFIG_PATH using CMake variables (#12926) Use CMAKE_PREFIX_PATH, CMAKE_FRAMEWORK_PATH, and CMAKE_APPBUNDLE_PATH cache and environment variables to extend PKG_CONFIG_PATH before calling pkg-config. In each of the path in these variables it searches for lib/pkgconfig. Then, depending on the system, it searches for lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig (debian) or for lib64/pkgconfig (other 64 bit unixes). If any of these path is found, it is appended to the PKG_CONFIG_PATH enviromnent variable. Add two new arguments to the pkg_check_module and pkg_search_module macro, NO_CMAKE_PATH and NO_CMAKE_ENVIRONMENT_PATH. The new signature are therefore: pkg_check_modules( [REQUIRED] [QUIET] [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH] []*) pkg_search_module( [REQUIRED] [QUIET] [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH] []*) By default, if CMAKE_MINIMUM_REQUIRED_VERSION is 3.1 or later (in order to keep compatibility with the previous behavior), or if PKG_CONFIG_USE_CMAKE_PREFIX_PATH is set, the CMAKE_PREFIX_PATH, CMAKE_FRAMEWORK_PATH, and CMAKE_APPBUNDLE_PATH cache and environment variables will be added to pkgconfig search path. The NO_CMAKE_PATH and NO_CMAKE_ENVIRONMENT_PATH arguments disable this behavior for the cache variables and the environment variables, respectively, similarly to the find_package() command. --- Modules/FindPkgConfig.cmake | 158 +++++++++++++++++++-- Tests/RunCMake/CMakeLists.txt | 5 + Tests/RunCMake/FindPkgConfig/CMakeLists.txt | 3 + .../FindPkgConfig_PKGCONFIG_PATH.cmake | 51 +++++++ Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake | 3 + Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat | 16 +++ Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh | 20 +++ .../lib/i386-linux-gnu/pkgconfig/.placeholder | 0 .../pc-bar/lib/pkgconfig/.placeholder | 0 .../lib/x86_64-linux-gnu/pkgconfig/.placeholder | 0 .../pc-bar/lib64/pkgconfig/.placeholder | 0 .../lib/i386-linux-gnu/pkgconfig/.placeholder | 0 .../pc-foo/lib/pkgconfig/.placeholder | 0 .../lib/x86_64-linux-gnu/pkgconfig/.placeholder | 0 .../pc-foo/lib64/pkgconfig/.placeholder | 0 15 files changed, 248 insertions(+), 8 deletions(-) create mode 100644 Tests/RunCMake/FindPkgConfig/CMakeLists.txt create mode 100644 Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake create mode 100644 Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake create mode 100755 Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat create mode 100755 Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh create mode 100644 Tests/RunCMake/FindPkgConfig/pc-bar/lib/i386-linux-gnu/pkgconfig/.placeholder create mode 100644 Tests/RunCMake/FindPkgConfig/pc-bar/lib/pkgconfig/.placeholder create mode 100644 Tests/RunCMake/FindPkgConfig/pc-bar/lib/x86_64-linux-gnu/pkgconfig/.placeholder create mode 100644 Tests/RunCMake/FindPkgConfig/pc-bar/lib64/pkgconfig/.placeholder create mode 100644 Tests/RunCMake/FindPkgConfig/pc-foo/lib/i386-linux-gnu/pkgconfig/.placeholder create mode 100644 Tests/RunCMake/FindPkgConfig/pc-foo/lib/pkgconfig/.placeholder create mode 100644 Tests/RunCMake/FindPkgConfig/pc-foo/lib/x86_64-linux-gnu/pkgconfig/.placeholder create mode 100644 Tests/RunCMake/FindPkgConfig/pc-foo/lib64/pkgconfig/.placeholder diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index b0ceb2b..812bb92 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -99,9 +99,20 @@ macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp) endmacro() # Splits given arguments into options and a package list -macro(_pkgconfig_parse_options _result _is_req _is_silent) +macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cmake_environment_path) set(${_is_req} 0) set(${_is_silent} 0) + set(${_no_cmake_path} 0) + set(${_no_cmake_environment_path} 0) + if(DEFINED PKG_CONFIG_USE_CMAKE_PREFIX_PATH) + if(NOT PKG_CONFIG_USE_CMAKE_PREFIX_PATH) + set(${_no_cmake_path} 1) + set(${_no_cmake_environment_path} 1) + endif() + elseif(${CMAKE_MINIMUM_REQUIRED_VERSION} VERSION_LESS 3.1) + set(${_no_cmake_path} 1) + set(${_no_cmake_environment_path} 1) + endif() foreach(_pkg ${ARGN}) if (_pkg STREQUAL "REQUIRED") @@ -110,15 +121,23 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent) if (_pkg STREQUAL "QUIET") set(${_is_silent} 1) endif () + if (_pkg STREQUAL "NO_CMAKE_PATH") + set(${_no_cmake_path} 1) + endif() + if (_pkg STREQUAL "NO_CMAKE_ENVIRONMENT_PATH") + set(${_no_cmake_environment_path} 1) + endif() endforeach() set(${_result} ${ARGN}) list(REMOVE_ITEM ${_result} "REQUIRED") list(REMOVE_ITEM ${_result} "QUIET") + list(REMOVE_ITEM ${_result} "NO_CMAKE_PATH") + list(REMOVE_ITEM ${_result} "NO_CMAKE_ENVIRONMENT_PATH") endmacro() ### -macro(_pkg_check_modules_internal _is_required _is_silent _prefix) +macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _prefix) _pkgconfig_unset(${_prefix}_FOUND) _pkgconfig_unset(${_prefix}_VERSION) _pkgconfig_unset(${_prefix}_PREFIX) @@ -157,6 +176,95 @@ macro(_pkg_check_modules_internal _is_required _is_silent _prefix) set(_pkg_check_modules_packages) set(_pkg_check_modules_failed) + set(_extra_paths) + + if(NOT _no_cmake_path) + if(NOT "${CMAKE_PREFIX_PATH}" STREQUAL "") + list(APPEND _extra_paths ${CMAKE_PREFIX_PATH}) + endif() + if(NOT "${CMAKE_FRAMEWORK_PATH}" STREQUAL "") + list(APPEND _extra_paths ${CMAKE_FRAMEWORK_PATH}) + endif() + if(NOT "${CMAKE_APPBUNDLE_PATH}" STREQUAL "") + list(APPEND _extra_paths ${CMAKE_FRAMEWORK_PATH}) + endif() + endif() + + if(NOT _no_cmake_environment_path) + if(NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "") + file(TO_CMAKE_PATH "$ENV{CMAKE_PREFIX_PATH}" _path) + list(APPEND _extra_paths ${_path}) + unset(_path) + endif() + if(NOT "$ENV{CMAKE_FRAMEWORK_PATH}" STREQUAL "") + file(TO_CMAKE_PATH "$ENV{CMAKE_FRAMEWORK_PATH}" _path) + list(APPEND _extra_paths ${_path}) + unset(_path) + endif() + if(NOT "$ENV{CMAKE_APPBUNDLE_PATH}" STREQUAL "") + file(TO_CMAKE_PATH "$ENV{CMAKE_APPBUNDLE_PATH}" _path) + list(APPEND _extra_paths ${_path}) + unset(_path) + endif() + endif() + + if(NOT "${_extra_paths}" STREQUAL "") + # Save the PKG_CONFIG_PATH environment variable, and add paths + # from the CMAKE_PREFIX_PATH variables + set(_pkgconfig_path_old $ENV{PKG_CONFIG_PATH}) + set(_pkgconfig_path ${_pkgconfig_path_old}) + if(NOT "${_pkgconfig_path}" STREQUAL "") + file(TO_CMAKE_PATH "${_pkgconfig_path}" _pkgconfig_path) + endif() + + # Create a list of the possible pkgconfig subfolder (depending on + # the system + set(_lib_dirs) + if(NOT DEFINED CMAKE_SYSTEM_NAME + OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" + AND NOT CMAKE_CROSSCOMPILING)) + if(EXISTS "/etc/debian_version") # is this a debian system ? + if(CMAKE_LIBRARY_ARCHITECTURE) + list(APPEND _lib_dirs "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig") + endif() + else() + # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property + get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) + if(uselib64) + list(APPEND _lib_dirs "lib64/pkgconfig") + endif() + endif() + endif() + list(APPEND _lib_dirs "lib/pkgconfig") + + # Check if directories exist and eventually append them to the + # pkgconfig path list + foreach(_prefix_dir ${_extra_paths}) + foreach(_lib_dir ${_lib_dirs}) + if(EXISTS "${_prefix_dir}/${_lib_dir}") + list(APPEND _pkgconfig_path "${_prefix_dir}/${_lib_dir}") + list(REMOVE_DUPLICATES _pkgconfig_path) + endif() + endforeach() + endforeach() + + # Prepare and set the environment variable + if(NOT "${_pkgconfig_path}" STREQUAL "") + # remove empty values from the list + list(REMOVE_ITEM _pkgconfig_path "") + file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path) + if(UNIX) + string(REPLACE ";" ":" _pkgconfig_path "${_pkgconfig_path}") + string(REPLACE "\\ " " " _pkgconfig_path "${_pkgconfig_path}") + endif() + set(ENV{PKG_CONFIG_PATH} ${_pkgconfig_path}) + endif() + + # Unset variables + unset(_lib_dirs) + unset(_pkgconfig_path) + endif() + # iterate through module list and check whether they exist and match the required version foreach (_pkg_check_modules_pkg ${_pkg_check_modules_list}) set(_pkg_check_modules_exist_query) @@ -260,6 +368,14 @@ macro(_pkg_check_modules_internal _is_required _is_silent _prefix) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS "" --cflags ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER "" --cflags-only-other ) endif() + + if(NOT "${_extra_paths}" STREQUAL "") + # Restore the environment variable + set(ENV{PKG_CONFIG_PATH} ${_pkgconfig_path}) + endif() + + unset(_extra_paths) + unset(_pkgconfig_path_old) else() if (${_is_required}) message(SEND_ERROR "pkg-config tool not found") @@ -276,13 +392,25 @@ endmacro() Checks for all the given modules. :: - pkg_check_modules( [REQUIRED] [QUIET] []*) + pkg_check_modules( [REQUIRED] [QUIET] + [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH] + []*) + When the ``REQUIRED`` argument was set, macros will fail with an error when module(s) could not be found. When the ``QUIET`` argument is set, no status messages will be printed. + By default, if :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` is 3.1 or + later, or if :variable:`PKG_CONFIG_USE_CMAKE_PREFIX_PATH` is set, the + :variable:`CMAKE_PREFIX_PATH`, :variable:`CMAKE_FRAMEWORK_PATH`, and + :variable:`CMAKE_APPBUNDLE_PATH` cache and environment variables will + be added to ``pkg-config`` search path. + The ``NO_CMAKE_PATH`` and ``NO_CMAKE_ENVIRONMENT_PATH`` arguments + disable this behavior for the cache variables and the environment + variables, respectively. + It sets the following variables: :: PKG_CONFIG_FOUND ... if pkg-config executable was found @@ -362,8 +490,8 @@ endmacro() macro(pkg_check_modules _prefix _module0) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) - _pkgconfig_parse_options (_pkg_modules _pkg_is_required _pkg_is_silent "${_module0}" ${ARGN}) - _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" "${_prefix}" ${_pkg_modules}) + _pkgconfig_parse_options (_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN}) + _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} "${_prefix}" ${_pkg_modules}) _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) endif() @@ -376,7 +504,9 @@ endmacro() Same as :command:`pkg_check_modules`, but instead it checks for given modules and uses the first working one. :: - pkg_search_module( [REQUIRED] [QUIET] []*) + pkg_search_module( [REQUIRED] [QUIET] + [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH] + []*) Examples @@ -388,7 +518,7 @@ macro(pkg_search_module _prefix _module0) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) set(_pkg_modules_found 0) - _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent "${_module0}" ${ARGN}) + _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN}) if (NOT ${_pkg_is_silent}) message(STATUS "checking for one of the modules '${_pkg_modules_alt}'") @@ -397,7 +527,7 @@ macro(pkg_search_module _prefix _module0) # iterate through all modules and stop at the first working one. foreach(_pkg_alt ${_pkg_modules_alt}) if(NOT _pkg_modules_found) - _pkg_check_modules_internal(0 1 "${_prefix}" "${_pkg_alt}") + _pkg_check_modules_internal(0 1 ${_no_cmake_path} ${_no_cmake_environment_path} "${_prefix}" "${_pkg_alt}") endif() if (${_prefix}_FOUND) @@ -420,6 +550,18 @@ endmacro() .. variable:: PKG_CONFIG_EXECUTABLE Path to the pkg-config executable. + + +.. variable:: PKG_CONFIG_USE_CMAKE_PREFIX_PATH + + Whether :command:`pkg_check_modules` and :command:`pkg_search_module` + should add the paths in :variable:`CMAKE_PREFIX_PATH`, + :variable:`CMAKE_FRAMEWORK_PATH`, and :variable:`CMAKE_APPBUNDLE_PATH` + cache and environment variables to ``pkg-config`` search path. + + If this variable is not set, this behavior is enabled by default if + :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` is 3.1 or later, disabled + otherwise. #]========================================] diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index d401a93..c7091d6 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -106,6 +106,11 @@ if (QT4_FOUND) add_RunCMake_test(ObsoleteQtMacros) endif() +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + add_RunCMake_test(FindPkgConfig) +endif() + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio [^6]") add_RunCMake_test(include_external_msproject) add_RunCMake_test(SolutionGlobalSections) diff --git a/Tests/RunCMake/FindPkgConfig/CMakeLists.txt b/Tests/RunCMake/FindPkgConfig/CMakeLists.txt new file mode 100644 index 0000000..72abfc8 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.11) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake new file mode 100644 index 0000000..5f9913f --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake @@ -0,0 +1,51 @@ +# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS +enable_language(C) + +# Prepare environment and variables +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE) +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo") +if(WIN32) + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem") + set(ENV{PKG_CONFIG_PATH} "C:\\baz") +else() + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem") + set(ENV{PKG_CONFIG_PATH} "/baz") +endif() + + +find_package(PkgConfig) + + +if(NOT DEFINED CMAKE_SYSTEM_NAME + OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" + AND NOT CMAKE_CROSSCOMPILING)) + if(EXISTS "/etc/debian_version") # is this a debian system ? + if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(i386-linux-gnu|x86_64-linux-gnu)$") + # Cannot create directories for all the existing architectures... + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() + else() + # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property + get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) + if(uselib64) + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() + endif() +else() + if(WIN32) + set(expected_path "C:\\baz;${CMAKE_CURRENT_SOURCE_DIR}\\pc-foo\\lib\\pkgconfig;${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar\\lib\\pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() +endif() + + +pkg_check_modules (FOO "${expected_path}") + +if(NOT "FOO_FOUND") + message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".") +endif() diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake new file mode 100644 index 0000000..ad77ad0 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(FindPkgConfig_PKGCONFIG_PATH) diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat new file mode 100755 index 0000000..b2096ed --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat @@ -0,0 +1,16 @@ +@ECHO OFF +IF "%1"=="" ( + EXIT /B 255 +) +IF "%1"=="--version" ( + ECHO 0.0-cmake-dummy + EXIT /B 0 +) + +IF "%1"=="--exists" ( + SHIFT + IF NOT "%*"=="%PKG_CONFIG_PATH%" ( + EXIT /B 1 + ) +) +EXIT /B 0 diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh new file mode 100755 index 0000000..e62bb74 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# This is a replacement for pkg-config that compares the string passed +# to the --exists argument with the PKG_CONFIG_PATH environment variable +# and returns 1 if they are different. + +case $1 in + --version) + echo "0.0-cmake-dummy" + ;; + --exists) + shift + echo "$@" + echo "${PKG_CONFIG_PATH}" + [ "$@" = "${PKG_CONFIG_PATH}" ] || exit 1 + ;; + *) + exit 255 + ;; +esac diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib/i386-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/i386-linux-gnu/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib/x86_64-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/x86_64-linux-gnu/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib64/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib64/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib/i386-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/i386-linux-gnu/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib/x86_64-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/x86_64-linux-gnu/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib64/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib64/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 -- cgit v0.12 From fbc883c94237a488084e863a79e5301c12171aa6 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Sun, 16 Mar 2014 12:35:18 +0100 Subject: Watcom: Add one blank line to Makefile for better readability --- Source/cmLocalUnixMakefileGenerator3.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 2d36089..d3836df 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -829,6 +829,7 @@ cmLocalUnixMakefileGenerator3 "!ifndef VERBOSE\n" ".SILENT\n" "!endif\n" + "\n" ; } else -- cgit v0.12 From d83ef53a1293899c0ab58aca184b7d5866051876 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 17 Mar 2014 15:27:01 +0100 Subject: Rename local 'dir_max' variables to 'dir' The code is not computing the maximum length directory, as is the case in cmLocalVisualStudioGenerator::ComputeLongestObjectDirectory. --- Source/cmGlobalNinjaGenerator.cxx | 12 ++++++------ Source/cmGlobalUnixMakefileGenerator3.cxx | 12 ++++++------ Source/cmLocalUnixMakefileGenerator3.cxx | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 49ce1b5..88f1b08 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -639,12 +639,12 @@ void cmGlobalNinjaGenerator cmTarget* target = gt->Target; // Compute full path to object file directory for this target. - std::string dir_max; - dir_max += gt->Makefile->GetCurrentOutputDirectory(); - dir_max += "/"; - dir_max += gt->LocalGenerator->GetTargetDirectory(*target); - dir_max += "/"; - gt->ObjectDirectory = dir_max; + std::string dir; + dir += gt->Makefile->GetCurrentOutputDirectory(); + dir += "/"; + dir += gt->LocalGenerator->GetTargetDirectory(*target); + dir += "/"; + gt->ObjectDirectory = dir; } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 4632071..e37ee10 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -111,12 +111,12 @@ cmGlobalUnixMakefileGenerator3 cmTarget* target = gt->Target; // Compute full path to object file directory for this target. - std::string dir_max; - dir_max += gt->Makefile->GetCurrentOutputDirectory(); - dir_max += "/"; - dir_max += gt->LocalGenerator->GetTargetDirectory(*target); - dir_max += "/"; - gt->ObjectDirectory = dir_max; + std::string dir; + dir += gt->Makefile->GetCurrentOutputDirectory(); + dir += "/"; + dir += gt->LocalGenerator->GetTargetDirectory(*target); + dir += "/"; + gt->ObjectDirectory = dir; } void cmGlobalUnixMakefileGenerator3::Configure() diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 2d36089..6e2e6a8 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -202,11 +202,11 @@ GetLocalObjectFiles(std::map &localObjectFiles) std::vector objectSources; gt->GetObjectSources(objectSources); // Compute full path to object file directory for this target. - std::string dir_max; - dir_max += gt->Makefile->GetCurrentOutputDirectory(); - dir_max += "/"; - dir_max += this->GetTargetDirectory(*gt->Target); - dir_max += "/"; + std::string dir; + dir += gt->Makefile->GetCurrentOutputDirectory(); + dir += "/"; + dir += this->GetTargetDirectory(*gt->Target); + dir += "/"; // Compute the name of each object file. for(std::vector::iterator si = objectSources.begin(); @@ -215,7 +215,7 @@ GetLocalObjectFiles(std::map &localObjectFiles) cmSourceFile const* sf = *si; bool hasSourceExtension = true; std::string objectName = this->GetObjectFileNameWithoutTarget(*sf, - dir_max, + dir, &hasSourceExtension); if(cmSystemTools::FileIsFullPath(objectName.c_str())) { -- cgit v0.12 From 2e0611f981f17889cb701db2ffd9436c771bb7e1 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 17 Mar 2014 15:29:49 +0100 Subject: cmGeneratorExpression: Remove unused include. --- Source/cmGeneratorExpression.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 5b97e8b..d0a6aef 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -16,8 +16,6 @@ #include "cmStandardIncludes.h" #include "cmListFileCache.h" -#include - #include #include -- cgit v0.12 From c3a2f78b5a322bd14123cb301dc62dc3b58073b5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 17 Mar 2014 15:32:19 +0100 Subject: Makefiles: Remove duplicate code. The cmGlobalUnixMakefileGenerator3::ProgressMapCompare struct is logically equivalent to cmStrictTargetComparison. --- Source/cmGlobalUnixMakefileGenerator3.cxx | 15 --------------- Source/cmGlobalUnixMakefileGenerator3.h | 4 +--- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index e37ee10..3aa293e 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -958,21 +958,6 @@ cmGlobalUnixMakefileGenerator3::RecordTargetProgress( } //---------------------------------------------------------------------------- -bool -cmGlobalUnixMakefileGenerator3::ProgressMapCompare -::operator()(cmTarget const* l, cmTarget const* r) const -{ - // Order by target name. - if(int c = strcmp(l->GetName().c_str(), r->GetName().c_str())) - { - return c < 0; - } - // Order duplicate targets by binary directory. - return strcmp(l->GetMakefile()->GetCurrentOutputDirectory(), - r->GetMakefile()->GetCurrentOutputDirectory()) < 0; -} - -//---------------------------------------------------------------------------- void cmGlobalUnixMakefileGenerator3::TargetProgress ::WriteProgressVariables(unsigned long total, unsigned long ¤t) diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index d003789..f44dd12 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -185,10 +185,8 @@ protected: std::vector Marks; void WriteProgressVariables(unsigned long total, unsigned long& current); }; - struct ProgressMapCompare { bool operator()(cmTarget const*, - cmTarget const*) const; }; typedef std::map ProgressMapType; + cmStrictTargetComparison> ProgressMapType; ProgressMapType ProgressMap; size_t CountProgressMarksInTarget(cmTarget const* target, -- cgit v0.12 From 10e6f1e716758c5ad5dcb63a5c69551ff3b9f6ff Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 17 Mar 2014 15:33:54 +0100 Subject: cmMakefile: Fix typo in comment. --- Source/cmMakefile.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 58625fb..f312399 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2071,7 +2071,7 @@ cmMakefile::LinearGetSourceFileWithOutput(const std::string& name) const // does this source file have a custom command? if ((*i)->GetCustomCommand()) { - // is the output of the custom command match the source files name + // Does the output of the custom command match the source file name? const std::vector& outputs = (*i)->GetCustomCommand()->GetOutputs(); for(std::vector::const_iterator o = outputs.begin(); -- cgit v0.12 From 19012b4652953ea8d8a470d1790419b1d8682850 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 17 Mar 2014 15:34:53 +0100 Subject: cmMakefile: Fix style. Use this-> for member access. --- Source/cmMakefile.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f312399..f390237 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2101,7 +2101,7 @@ cmSourceFile *cmMakefile::GetSourceFileWithOutput( // linear-time search for an output with a matching suffix. if(!cmSystemTools::FileIsFullPath(name.c_str())) { - return LinearGetSourceFileWithOutput(name); + return this->LinearGetSourceFileWithOutput(name); } // Otherwise we use an efficient lookup map. OutputToSourceMap::const_iterator o = this->OutputToSource.find(name); -- cgit v0.12 From 413282c0cfb0bafc6ab325c6d4798e4765e021fa Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 17 Mar 2014 11:05:34 -0400 Subject: file: Avoid runaway DOWNLOAD/UPLOAD progress reports (#14807) Curl makes progress callbacks frequently but we round to the nearest percent and report only when that changes so that we make at most 101 progress reports. However, when unexpected data beyond the total are transferred the progress can get beyond 100% and lead to unlimited reports. Avoid this case by capping the reported progress to 100%. --- Source/cmFileCommand.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 9fabdc7..5bfb664 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2539,6 +2539,11 @@ namespace { if (total > 0.0) { this->CurrentPercentage = static_cast(value/total*100.0 + 0.5); + if(this->CurrentPercentage > 100) + { + // Avoid extra progress reports for unexpected data beyond total. + this->CurrentPercentage = 100; + } } bool updated = (OldPercentage != this->CurrentPercentage); -- cgit v0.12 From 7d35b550605596b441af65e96be320ab7d33acc1 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 17 Mar 2014 11:24:20 -0400 Subject: ExternalProject: Add option to disable download progress (#14807) Add a DOWNLOAD_NO_PROGRESS option to disable progress reports while downloading source tarballs. --- Modules/ExternalProject.cmake | 14 +++++++++++--- Tests/ExternalProject/CMakeLists.txt | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 1e83163..8235dda 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -20,6 +20,7 @@ # [DOWNLOAD_NAME fname] # File name to store (if not end of URL) # [DOWNLOAD_DIR dir] # Directory to store downloaded files # [DOWNLOAD_COMMAND cmd...] # Command to download source tree +# [DOWNLOAD_NO_PROGRESS 1] # Disable download progress reports # [CVS_REPOSITORY cvsroot] # CVSROOT of CVS repository # [CVS_MODULE mod] # Module to checkout from CVS repo # [CVS_TAG tag] # Tag to checkout from CVS repo @@ -515,7 +516,7 @@ endif() endfunction(_ep_write_gitupdate_script) -function(_ep_write_downloadfile_script script_filename remote local timeout hash tls_verify tls_cainfo) +function(_ep_write_downloadfile_script script_filename remote local timeout no_progress hash tls_verify tls_cainfo) if(timeout) set(timeout_args TIMEOUT ${timeout}) set(timeout_msg "${timeout} seconds") @@ -524,6 +525,12 @@ function(_ep_write_downloadfile_script script_filename remote local timeout hash set(timeout_msg "none") endif() + if(no_progress) + set(show_progress "") + else() + set(show_progress "SHOW_PROGRESS") + endif() + if("${hash}" MATCHES "${_ep_hash_regex}") set(hash_args EXPECTED_HASH ${CMAKE_MATCH_1}=${CMAKE_MATCH_2}) else() @@ -563,7 +570,7 @@ ${tls_cainfo} file(DOWNLOAD \"${remote}\" \"${local}\" - SHOW_PROGRESS + ${show_progress} ${hash_args} ${timeout_args} STATUS status @@ -1443,10 +1450,11 @@ function(_ep_add_download_command name) string(REPLACE ";" "-" fname "${fname}") set(file ${download_dir}/${fname}) get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT) + get_property(no_progress TARGET ${name} PROPERTY _EP_DOWNLOAD_NO_PROGRESS) get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO) set(download_script "${stamp_dir}/download-${name}.cmake") - _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${hash}" "${tls_verify}" "${tls_cainfo}") + _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}") set(cmd ${CMAKE_COMMAND} -P "${download_script}" COMMAND) set(retries 3) diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index d9344ec..0ed5561 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -98,6 +98,7 @@ ExternalProject_Add(${proj} CVS_TAG "" DEPENDS "MinimalNoOpProject" NonExternalProjectTarget DOWNLOAD_COMMAND "" + DOWNLOAD_NO_PROGRESS 1 INSTALL_COMMAND "" PATCH_COMMAND "" STEP_TARGETS install update -- cgit v0.12 From 7f857775e212436dbca623a4bfe37a20c6c98e0a Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Mon, 17 Mar 2014 17:36:14 +0100 Subject: CheckTypeSize: Add unit test to cover the no-C case --- Tests/RunCMake/CheckModules/CheckTypeSizeOkNoC.cmake | 4 ++++ Tests/RunCMake/CheckModules/RunCMakeTest.cmake | 2 ++ 2 files changed, 6 insertions(+) create mode 100644 Tests/RunCMake/CheckModules/CheckTypeSizeOkNoC.cmake diff --git a/Tests/RunCMake/CheckModules/CheckTypeSizeOkNoC.cmake b/Tests/RunCMake/CheckModules/CheckTypeSizeOkNoC.cmake new file mode 100644 index 0000000..b2dcd7f --- /dev/null +++ b/Tests/RunCMake/CheckModules/CheckTypeSizeOkNoC.cmake @@ -0,0 +1,4 @@ +enable_language(CXX) +include(CheckTypeSize) +check_type_size(int SIZEOF_INT LANGUAGE CXX) +check_type_size(int SIZEOF_INT BUILTIN_TYPES_ONLY LANGUAGE CXX) diff --git a/Tests/RunCMake/CheckModules/RunCMakeTest.cmake b/Tests/RunCMake/CheckModules/RunCMakeTest.cmake index fda7ebf..5b4e57e 100644 --- a/Tests/RunCMake/CheckModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CheckModules/RunCMakeTest.cmake @@ -12,3 +12,5 @@ run_cmake(CheckTypeSizeUnknownLanguage) run_cmake(CheckTypeSizeMissingLanguage) run_cmake(CheckTypeSizeUnknownArgument) run_cmake(CheckTypeSizeMixedArgs) + +run_cmake(CheckTypeSizeOkNoC) -- cgit v0.12 From 453d2b2438a1c9e8a21e89addf446f5bec3a4000 Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Mon, 17 Mar 2014 17:50:29 +0100 Subject: FindPkgConfig: small refactoring --- Modules/FindPkgConfig.cmake | 55 +++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 812bb92..286cc23 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -136,6 +136,31 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cma list(REMOVE_ITEM ${_result} "NO_CMAKE_ENVIRONMENT_PATH") endmacro() +# Add the content of a variable or an environment variable to a list of +# paths +# Usage: +# - _pkgconfig_add_extra_path(_extra_paths VAR) +# - _pkgconfig_add_extra_path(_extra_paths ENV VAR) +function(_pkgconfig_add_extra_path _extra_paths_var _var) + set(_is_env 0) + if(_var STREQUAL "ENV") + set(_var ${ARGV2}) + set(_is_env 1) + endif() + if(NOT _is_env) + if(NOT "${${_var}}" STREQUAL "") + list(APPEND ${_extra_paths_var} ${CMAKE_PREFIX_PATH}) + endif() + else() + if(NOT "$ENV{${_var}}" STREQUAL "") + file(TO_CMAKE_PATH "$ENV{${_var}}" _path) + list(APPEND ${_extra_paths_var} ${_path}) + unset(_path) + endif() + endif() + set(${_extra_paths_var} ${${_extra_paths_var}} PARENT_SCOPE) +endfunction() + ### macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _prefix) _pkgconfig_unset(${_prefix}_FOUND) @@ -179,33 +204,15 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma set(_extra_paths) if(NOT _no_cmake_path) - if(NOT "${CMAKE_PREFIX_PATH}" STREQUAL "") - list(APPEND _extra_paths ${CMAKE_PREFIX_PATH}) - endif() - if(NOT "${CMAKE_FRAMEWORK_PATH}" STREQUAL "") - list(APPEND _extra_paths ${CMAKE_FRAMEWORK_PATH}) - endif() - if(NOT "${CMAKE_APPBUNDLE_PATH}" STREQUAL "") - list(APPEND _extra_paths ${CMAKE_FRAMEWORK_PATH}) - endif() + _pkgconfig_add_extra_path(_extra_paths CMAKE_PREFIX_PATH) + _pkgconfig_add_extra_path(_extra_paths CMAKE_FRAMEWORK_PATH) + _pkgconfig_add_extra_path(_extra_paths CMAKE_APPBUNDLE_PATH) endif() if(NOT _no_cmake_environment_path) - if(NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "") - file(TO_CMAKE_PATH "$ENV{CMAKE_PREFIX_PATH}" _path) - list(APPEND _extra_paths ${_path}) - unset(_path) - endif() - if(NOT "$ENV{CMAKE_FRAMEWORK_PATH}" STREQUAL "") - file(TO_CMAKE_PATH "$ENV{CMAKE_FRAMEWORK_PATH}" _path) - list(APPEND _extra_paths ${_path}) - unset(_path) - endif() - if(NOT "$ENV{CMAKE_APPBUNDLE_PATH}" STREQUAL "") - file(TO_CMAKE_PATH "$ENV{CMAKE_APPBUNDLE_PATH}" _path) - list(APPEND _extra_paths ${_path}) - unset(_path) - endif() + _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_PREFIX_PATH) + _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_FRAMEWORK_PATH) + _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_APPBUNDLE_PATH) endif() if(NOT "${_extra_paths}" STREQUAL "") -- cgit v0.12 From cc5a0d8f42f9ad8bc5ac50be343db05128a0c6ea Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Mon, 17 Mar 2014 18:09:54 +0100 Subject: FindPkgConfig: More unit tests --- .../FindPkgConfig_NO_PKGCONFIG_PATH.cmake | 41 +++++++++++++++++ .../FindPkgConfig_PKGCONFIG_PATH.cmake | 2 +- ..._PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH.cmake | 51 ++++++++++++++++++++++ ...indPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH.cmake | 51 ++++++++++++++++++++++ Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake | 3 ++ Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat | 2 + Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh | 4 +- 7 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 Tests/RunCMake/FindPkgConfig/FindPkgConfig_NO_PKGCONFIG_PATH.cmake create mode 100644 Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH.cmake create mode 100644 Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH.cmake diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_NO_PKGCONFIG_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_NO_PKGCONFIG_PATH.cmake new file mode 100644 index 0000000..924976e --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_NO_PKGCONFIG_PATH.cmake @@ -0,0 +1,41 @@ +# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS +enable_language(C) + +# Prepare environment and variables +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH FALSE) +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo") +if(WIN32) + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem") + set(ENV{PKG_CONFIG_PATH} "C:\\baz") +else() + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem") + set(ENV{PKG_CONFIG_PATH} "/baz") +endif() + + +find_package(PkgConfig) + +if(WIN32) + set(expected_path "C:\\baz") +else() + set(expected_path "/baz") +endif() + + +pkg_check_modules(FOO "${expected_path}") + +if(NOT "FOO_FOUND") + message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".") +endif() + + + +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE) + +pkg_check_modules(BAR "${expected_path}" NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH) + +if(NOT "BAR_FOUND") + message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".") +endif() diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake index 5f9913f..4a66e85 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake @@ -44,7 +44,7 @@ else() endif() -pkg_check_modules (FOO "${expected_path}") +pkg_check_modules(FOO "${expected_path}") if(NOT "FOO_FOUND") message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".") diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH.cmake new file mode 100644 index 0000000..0b057b8 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH.cmake @@ -0,0 +1,51 @@ +# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS +enable_language(C) + +# Prepare environment and variables +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE) +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo") +if(WIN32) + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem") + set(ENV{PKG_CONFIG_PATH} "C:\\baz") +else() + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem") + set(ENV{PKG_CONFIG_PATH} "/baz") +endif() + + +find_package(PkgConfig) + + +if(NOT DEFINED CMAKE_SYSTEM_NAME + OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" + AND NOT CMAKE_CROSSCOMPILING)) + if(EXISTS "/etc/debian_version") # is this a debian system ? + if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(i386-linux-gnu|x86_64-linux-gnu)$") + # Cannot create directories for all the existing architectures... + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig") + endif() + else() + # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property + get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) + if(uselib64) + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig") + endif() + endif() +else() + if(WIN32) + set(expected_path "C:\\baz;${CMAKE_CURRENT_SOURCE_DIR}\\pc-foo\\lib\\pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig") + endif() +endif() + + +pkg_check_modules(FOO "${expected_path}" NO_CMAKE_ENVIRONMENT_PATH) + +if(NOT "FOO_FOUND") + message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".") +endif() diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH.cmake new file mode 100644 index 0000000..a3154f1 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH.cmake @@ -0,0 +1,51 @@ +# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS +enable_language(C) + +# Prepare environment and variables +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE) +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo") +if(WIN32) + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem") + set(ENV{PKG_CONFIG_PATH} "C:\\baz") +else() + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem") + set(ENV{PKG_CONFIG_PATH} "/baz") +endif() + + +find_package(PkgConfig) + + +if(NOT DEFINED CMAKE_SYSTEM_NAME + OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" + AND NOT CMAKE_CROSSCOMPILING)) + if(EXISTS "/etc/debian_version") # is this a debian system ? + if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(i386-linux-gnu|x86_64-linux-gnu)$") + # Cannot create directories for all the existing architectures... + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() + else() + # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property + get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) + if(uselib64) + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() + endif() +else() + if(WIN32) + set(expected_path "C:\\baz;${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar\\lib\\pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() +endif() + + +pkg_check_modules(FOO "${expected_path}" NO_CMAKE_PATH) + +if(NOT "FOO_FOUND") + message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".") +endif() diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake index ad77ad0..bca93bb 100644 --- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake @@ -1,3 +1,6 @@ include(RunCMake) +run_cmake(FindPkgConfig_NO_PKGCONFIG_PATH) run_cmake(FindPkgConfig_PKGCONFIG_PATH) +run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH) +run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH) diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat index b2096ed..f2f86b0 100755 --- a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat +++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat @@ -9,6 +9,8 @@ IF "%1"=="--version" ( IF "%1"=="--exists" ( SHIFT + ECHO Expected: %* + ECHO Found: %PKG_CONFIG_PATH% IF NOT "%*"=="%PKG_CONFIG_PATH%" ( EXIT /B 1 ) diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh index e62bb74..852e841 100755 --- a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh +++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh @@ -10,8 +10,8 @@ case $1 in ;; --exists) shift - echo "$@" - echo "${PKG_CONFIG_PATH}" + echo "Expected: $@" + echo "Found: ${PKG_CONFIG_PATH}" [ "$@" = "${PKG_CONFIG_PATH}" ] || exit 1 ;; *) -- cgit v0.12 From f1b953ec9b71375b1ecb2bcb2eac5af0f2a895d3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 17 Mar 2014 13:12:10 -0400 Subject: Help: Add notes for topic 'ExternalProject-no-download-progress' --- Help/release/dev/ExternalProject-no-download-progress.rst | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Help/release/dev/ExternalProject-no-download-progress.rst diff --git a/Help/release/dev/ExternalProject-no-download-progress.rst b/Help/release/dev/ExternalProject-no-download-progress.rst new file mode 100644 index 0000000..41db55d --- /dev/null +++ b/Help/release/dev/ExternalProject-no-download-progress.rst @@ -0,0 +1,6 @@ +ExternalProject-no-download-progress +------------------------------------ + +* The :module:`ExternalProject` module ``ExternalProject_Add`` command + learned a new ``DOWNLOAD_NO_PROGRESS`` option to disable progress + output while downloading the source tarball. -- cgit v0.12 From 9292d3b8a016fb48f5b5b1518895b6d63e51bc2e Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 17 Mar 2014 19:38:57 +0100 Subject: Watcom: Detect compiler target architecture and platform In CMakePlatformId.h.in, fill ARCHITECTURE_ID and PLATFORM_ID for Open Watcom. --- Modules/CMakePlatformId.h.in | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index 1e41fec..bc26c07 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -74,6 +74,23 @@ #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) # define PLATFORM_ID "Xenix" +#elif defined(__WATCOMC__) +# if defined(__LINUX__) +# define PLATFORM_ID "Linux" + +# elif defined(__DOS__) +# define PLATFORM_ID "DOS" + +# elif defined(__OS2__) +# define PLATFORM_ID "OS2" + +# elif defined(__WINDOWS__) +# define PLATFORM_ID "Windows3x" + +# else /* unknown platform */ +# define PLATFORM_ID "" +# endif + #else /* unknown platform */ # define PLATFORM_ID "" @@ -107,6 +124,17 @@ # define ARCHITECTURE_ID "" # endif +#elif defined(__WATCOMC__) +# if defined(_M_I86) +# define ARCHITECTURE_ID "I86" + +# elif defined(_M_IX86) +# define ARCHITECTURE_ID "X86" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + #else # define ARCHITECTURE_ID "" #endif -- cgit v0.12 From 5d9aa66c91909b8d7eab16edb020c9a14205ba69 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 17 Mar 2014 19:41:02 +0100 Subject: Watcom: Introduce OpenWatcom compiler id and fix compiler version Distinguish "Open Watcom" from old "Watcom" by introducing a new "OpenWatcom" compiler id. The __WATCOMC__ format is "VVRP" for Watcom and "VVRP + 1100" for Open Watcom. --- Modules/CMakeCCompilerId.c.in | 17 +++++++++++++---- Modules/CMakeCXXCompilerId.cpp.in | 17 +++++++++++++---- Modules/InstallRequiredSystemLibraries.cmake | 4 ---- Modules/Platform/Windows-wcl386.cmake | 24 +++++++++++++----------- Source/cmExtraCodeBlocksGenerator.cxx | 2 +- 5 files changed, 40 insertions(+), 24 deletions(-) diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index 561ccf2..16e19cd 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -68,10 +68,19 @@ # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) #elif defined(__WATCOMC__) -# define COMPILER_ID "Watcom" - /* __WATCOMC__ = VVRR */ -# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) -# define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100) +# if __WATCOMC__ < 1200 +# define COMPILER_ID "Watcom" + /* __WATCOMC__ = VVRP */ +# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) +# else +# define COMPILER_ID "OpenWatcom" + /* __WATCOMC__ = VVRP + 1100 */ +# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) +# endif +# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) +# if (__WATCOMC__ % 10) > 0 +# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) +# endif #elif defined(__SUNPRO_C) # define COMPILER_ID "SunPro" diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 6c602d4..d81df77 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -73,10 +73,19 @@ # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) #elif defined(__WATCOMC__) -# define COMPILER_ID "Watcom" - /* __WATCOMC__ = VVRR */ -# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) -# define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100) +# if __WATCOMC__ < 1200 +# define COMPILER_ID "Watcom" + /* __WATCOMC__ = VVRP */ +# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) +# else +# define COMPILER_ID "OpenWatcom" + /* __WATCOMC__ = VVRP + 1100 */ +# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) +# endif +# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) +# if (__WATCOMC__ % 10) > 0 +# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) +# endif #elif defined(__SUNPRO_CC) # define COMPILER_ID "SunPro" diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 7e68e8f..4b551e6 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -374,10 +374,6 @@ if(WATCOM) string(REGEX MATCHALL "[0-9]+" _watcom_version_list "${_compiler_version}") list(GET _watcom_version_list 0 _watcom_major) list(GET _watcom_version_list 1 _watcom_minor) - if(${_watcom_major} GREATER 11) - math(EXPR _watcom_major "${_watcom_major} - 11") - endif() - math(EXPR _watcom_minor "${_watcom_minor} / 10") set( __install__libs ${CompilerPath}/clbr${_watcom_major}${_watcom_minor}.dll ${CompilerPath}/mt7r${_watcom_major}${_watcom_minor}.dll diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake index d40d718..6b1cfd1 100644 --- a/Modules/Platform/Windows-wcl386.cmake +++ b/Modules/Platform/Windows-wcl386.cmake @@ -93,16 +93,18 @@ if(NOT _CMAKE_WATCOM_VERSION) set(WATCOM17) set(WATCOM18) set(WATCOM19) - if("${_compiler_version}" LESS 12.70) - set(WATCOM16 1) - endif() - if("${_compiler_version}" EQUAL 12.70) - set(WATCOM17 1) - endif() - if("${_compiler_version}" EQUAL 12.80) - set(WATCOM18 1) - endif() - if("${_compiler_version}" EQUAL 12.90) - set(WATCOM19 1) + if("${_compiler_id}" STREQUAL "OpenWatcom") + if("${_compiler_version}" VERSION_LESS 1.7) + set(WATCOM16 1) + endif() + if("${_compiler_version}" VERSION_EQUAL 1.7) + set(WATCOM17 1) + endif() + if("${_compiler_version}" VERSION_EQUAL 1.8) + set(WATCOM18 1) + endif() + if("${_compiler_version}" VERSION_EQUAL 1.9) + set(WATCOM19 1) + endif() endif() endif() diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index dba2406..e99bf04 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -715,7 +715,7 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf) { compiler = "icc"; } - else if (compilerId == "Watcom") + else if (compilerId == "Watcom" || compilerId == "OpenWatcom") { compiler = "ow"; } -- cgit v0.12 From 64c2342a8d0f3e655349d3897d2dee46a89aaedc Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 17 Mar 2014 19:30:38 +0100 Subject: Watcom: Enable 'WMake Makefiles' generator on Linux --- Source/CMakeLists.txt | 10 +++++++++- Source/cmGlobalWatcomWMakeGenerator.cxx | 4 ++++ Source/cmake.cxx | 10 +++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 9fb8d9a..762470f 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -404,7 +404,6 @@ if (WIN32) cmGlobalVisualStudio12Generator.cxx cmGlobalVisualStudioGenerator.cxx cmGlobalVisualStudioGenerator.h - cmGlobalWatcomWMakeGenerator.cxx cmIDEFlagTable.h cmIDEOptions.cxx cmIDEOptions.h @@ -424,6 +423,15 @@ if (WIN32) endif() endif () +# Watcom support +if(WIN32 OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + set_property(SOURCE cmake.cxx APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_USE_WMAKE) + list(APPEND SRCS + cmGlobalWatcomWMakeGenerator.cxx + cmGlobalWatcomWMakeGenerator.h + ) +endif() + # Ninja support set(SRCS ${SRCS} cmGlobalNinjaGenerator.cxx diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx index 671166e..0ae1b34 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.cxx +++ b/Source/cmGlobalWatcomWMakeGenerator.cxx @@ -16,7 +16,9 @@ cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator() { this->FindMakeProgramFile = "CMakeFindWMake.cmake"; +#ifdef _WIN32 this->ForceUnixPaths = false; +#endif this->ToolSupportsColor = true; this->NeedSymbolicMark = true; this->EmptyRuleHackCommand = "@cd ."; @@ -44,7 +46,9 @@ cmLocalGenerator *cmGlobalWatcomWMakeGenerator::CreateLocalGenerator() { cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3; lg->SetDefineWindowsNULL(true); +#ifdef _WIN32 lg->SetWindowsShell(true); +#endif lg->SetWatcomWMake(true); lg->SetMakeSilentFlag("-h"); lg->SetGlobalGenerator(this); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 4ce1d70..ede6842 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -60,13 +60,15 @@ # include "cmGlobalBorlandMakefileGenerator.h" # include "cmGlobalNMakeMakefileGenerator.h" # include "cmGlobalJOMMakefileGenerator.h" -# include "cmGlobalWatcomWMakeGenerator.h" # define CMAKE_HAVE_VS_GENERATORS # endif # include "cmGlobalMSYSMakefileGenerator.h" # include "cmGlobalMinGWMakefileGenerator.h" #else #endif +#if defined(CMAKE_USE_WMAKE) +# include "cmGlobalWatcomWMakeGenerator.h" +#endif #include "cmGlobalUnixMakefileGenerator3.h" #include "cmGlobalNinjaGenerator.h" #include "cmExtraCodeLiteGenerator.h" @@ -1781,8 +1783,6 @@ void cmake::AddDefaultGenerators() cmGlobalNMakeMakefileGenerator::NewFactory()); this->Generators.push_back( cmGlobalJOMMakefileGenerator::NewFactory()); - this->Generators.push_back( - cmGlobalWatcomWMakeGenerator::NewFactory()); # endif this->Generators.push_back( cmGlobalMSYSMakefileGenerator::NewFactory()); @@ -1793,6 +1793,10 @@ void cmake::AddDefaultGenerators() cmGlobalUnixMakefileGenerator3::NewFactory()); this->Generators.push_back( cmGlobalNinjaGenerator::NewFactory()); +#if defined(CMAKE_USE_WMAKE) + this->Generators.push_back( + cmGlobalWatcomWMakeGenerator::NewFactory()); +#endif #ifdef CMAKE_USE_XCODE this->Generators.push_back( cmGlobalXCodeGenerator::NewFactory()); -- cgit v0.12 From 98383f802aadcd2d469c4d7543e0a2abe8c3cdb9 Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Thu, 6 Mar 2014 22:55:07 -0700 Subject: Unicode: check encoding of files given to configure_file. UTF-16 and UTF-32 files are rejected. --- Source/cmMakefile.cxx | 14 ++++++++++++++ Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/configure_file/CMakeLists.txt | 3 +++ Tests/RunCMake/configure_file/NO-BOM.cmake | 2 ++ Tests/RunCMake/configure_file/NO-BOM.txt.in | 1 + Tests/RunCMake/configure_file/RunCMakeTest.cmake | 8 ++++++++ Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt | 1 + Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt | 6 ++++++ Tests/RunCMake/configure_file/UTF16BE-BOM.cmake | 2 ++ Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in | Bin 0 -> 26 bytes Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt | 1 + Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt | 6 ++++++ Tests/RunCMake/configure_file/UTF16LE-BOM.cmake | 2 ++ Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in | Bin 0 -> 26 bytes Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt | 1 + Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt | 6 ++++++ Tests/RunCMake/configure_file/UTF32BE-BOM.cmake | 2 ++ Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in | Bin 0 -> 52 bytes Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt | 1 + Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt | 6 ++++++ Tests/RunCMake/configure_file/UTF32LE-BOM.cmake | 2 ++ Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in | Bin 0 -> 52 bytes Tests/RunCMake/configure_file/UTF8-BOM.cmake | 2 ++ Tests/RunCMake/configure_file/UTF8-BOM.txt.in | 1 + bootstrap | 1 + 25 files changed, 69 insertions(+) create mode 100644 Tests/RunCMake/configure_file/CMakeLists.txt create mode 100644 Tests/RunCMake/configure_file/NO-BOM.cmake create mode 100644 Tests/RunCMake/configure_file/NO-BOM.txt.in create mode 100644 Tests/RunCMake/configure_file/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt create mode 100644 Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt create mode 100644 Tests/RunCMake/configure_file/UTF16BE-BOM.cmake create mode 100644 Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in create mode 100644 Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt create mode 100644 Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt create mode 100644 Tests/RunCMake/configure_file/UTF16LE-BOM.cmake create mode 100644 Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in create mode 100644 Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt create mode 100644 Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt create mode 100644 Tests/RunCMake/configure_file/UTF32BE-BOM.cmake create mode 100644 Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in create mode 100644 Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt create mode 100644 Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt create mode 100644 Tests/RunCMake/configure_file/UTF32LE-BOM.cmake create mode 100644 Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in create mode 100644 Tests/RunCMake/configure_file/UTF8-BOM.cmake create mode 100644 Tests/RunCMake/configure_file/UTF8-BOM.txt.in diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 92177c8..d0e6c30 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3518,6 +3518,20 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, return 0; } + cmsys::FStream::BOM bom = cmsys::FStream::ReadBOM(fin); + if(bom != cmsys::FStream::BOM_None && + bom != cmsys::FStream::BOM_UTF8) + { + cmOStringStream e; + e << "File starts with a Byte-Order-Mark that is not UTF-8:\n " + << sinfile; + this->IssueMessage(cmake::FATAL_ERROR, e.str()); + return 0; + } + // rewind to copy BOM to output file + fin.seekg(0); + + // now copy input to output and expand variables in the // input file at the same time std::string inLine; diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index d401a93..a8726f4 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -95,6 +95,7 @@ add_RunCMake_test(TargetPolicies) add_RunCMake_test(alias_targets) add_RunCMake_test(interface_library) add_RunCMake_test(no_install_prefix) +add_RunCMake_test(configure_file) find_package(Qt4 QUIET) find_package(Qt5Core QUIET) diff --git a/Tests/RunCMake/configure_file/CMakeLists.txt b/Tests/RunCMake/configure_file/CMakeLists.txt new file mode 100644 index 0000000..2897109 --- /dev/null +++ b/Tests/RunCMake/configure_file/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.0) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/configure_file/NO-BOM.cmake b/Tests/RunCMake/configure_file/NO-BOM.cmake new file mode 100644 index 0000000..003d526 --- /dev/null +++ b/Tests/RunCMake/configure_file/NO-BOM.cmake @@ -0,0 +1,2 @@ + +configure_file(NO-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/NO-BOM.txt) diff --git a/Tests/RunCMake/configure_file/NO-BOM.txt.in b/Tests/RunCMake/configure_file/NO-BOM.txt.in new file mode 100644 index 0000000..557db03 --- /dev/null +++ b/Tests/RunCMake/configure_file/NO-BOM.txt.in @@ -0,0 +1 @@ +Hello World diff --git a/Tests/RunCMake/configure_file/RunCMakeTest.cmake b/Tests/RunCMake/configure_file/RunCMakeTest.cmake new file mode 100644 index 0000000..c8bfa57 --- /dev/null +++ b/Tests/RunCMake/configure_file/RunCMakeTest.cmake @@ -0,0 +1,8 @@ +include(RunCMake) + +run_cmake(NO-BOM) +run_cmake(UTF8-BOM) +run_cmake(UTF16LE-BOM) +run_cmake(UTF16BE-BOM) +run_cmake(UTF32LE-BOM) +run_cmake(UTF32BE-BOM) diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt b/Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt new file mode 100644 index 0000000..5132c4d --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at UTF16BE-BOM.cmake:2 \(configure_file\): + File starts with a Byte-Order-Mark that is not UTF-8: + + .*/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM.cmake b/Tests/RunCMake/configure_file/UTF16BE-BOM.cmake new file mode 100644 index 0000000..c570742 --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF16BE-BOM.cmake @@ -0,0 +1,2 @@ + +configure_file(UTF16BE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF16BE-BOM.txt) diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in new file mode 100644 index 0000000..70fd9cb Binary files /dev/null and b/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in differ diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt b/Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt new file mode 100644 index 0000000..8f997bc --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at UTF16LE-BOM.cmake:2 \(configure_file\): + File starts with a Byte-Order-Mark that is not UTF-8: + + .*/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM.cmake b/Tests/RunCMake/configure_file/UTF16LE-BOM.cmake new file mode 100644 index 0000000..05c9cd7 --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF16LE-BOM.cmake @@ -0,0 +1,2 @@ + +configure_file(UTF16LE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF16LE-BOM.txt) diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in new file mode 100644 index 0000000..036f8c5 Binary files /dev/null and b/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in differ diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt b/Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt new file mode 100644 index 0000000..12811aa --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at UTF32BE-BOM.cmake:2 \(configure_file\): + File starts with a Byte-Order-Mark that is not UTF-8: + + .*/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM.cmake b/Tests/RunCMake/configure_file/UTF32BE-BOM.cmake new file mode 100644 index 0000000..0c6ea87 --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF32BE-BOM.cmake @@ -0,0 +1,2 @@ + +configure_file(UTF32BE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF32BE-BOM.txt) diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in new file mode 100644 index 0000000..c87cfd5 Binary files /dev/null and b/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in differ diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt b/Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt new file mode 100644 index 0000000..fa9e01a --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at UTF32LE-BOM.cmake:2 \(configure_file\): + File starts with a Byte-Order-Mark that is not UTF-8: + + .*/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM.cmake b/Tests/RunCMake/configure_file/UTF32LE-BOM.cmake new file mode 100644 index 0000000..b6351b0 --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF32LE-BOM.cmake @@ -0,0 +1,2 @@ + +configure_file(UTF32LE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF32LE-BOM.txt) diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in new file mode 100644 index 0000000..27c8183 Binary files /dev/null and b/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in differ diff --git a/Tests/RunCMake/configure_file/UTF8-BOM.cmake b/Tests/RunCMake/configure_file/UTF8-BOM.cmake new file mode 100644 index 0000000..af2adae --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF8-BOM.cmake @@ -0,0 +1,2 @@ + +configure_file(UTF8-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF8-BOM.txt) diff --git a/Tests/RunCMake/configure_file/UTF8-BOM.txt.in b/Tests/RunCMake/configure_file/UTF8-BOM.txt.in new file mode 100644 index 0000000..abc0aca --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF8-BOM.txt.in @@ -0,0 +1 @@ +Hello World diff --git a/bootstrap b/bootstrap index 69dcbce..4e61f3e 100755 --- a/bootstrap +++ b/bootstrap @@ -329,6 +329,7 @@ fi KWSYS_CXX_SOURCES="\ Directory \ EncodingCXX \ + FStream \ Glob \ RegularExpression \ SystemTools" -- cgit v0.12 From 2c5e78fa5d54e5e10c586725ca9e068ac26f352e Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 18 Mar 2014 00:01:09 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 562040a..cac80a2 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 0) -set(CMake_VERSION_PATCH 20140317) +set(CMake_VERSION_PATCH 20140318) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 8b8691adcad725e365407118d6d282994efad152 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 19 Mar 2014 00:01:09 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index cac80a2..9dffee3 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 0) -set(CMake_VERSION_PATCH 20140318) +set(CMake_VERSION_PATCH 20140319) #set(CMake_VERSION_RC 1) -- cgit v0.12 From cf3e87e195448af50a9b2f0ca02732756e82ff2f Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 19 Mar 2014 13:33:00 -0400 Subject: Tests: Teach CMakeOnly.AllFindModules to tolerate a system KDE4 The FindKDE4 module (incorrectly) modifies CMAKE_MODULE_PATH on the caller's behalf. This causes KDE4-installed find modules to be used by the test instead of those in CMake. Teach the test to restore the CMAKE_MODULE_PATH to its original value after each find_package call. This ensures that the next find_package actually tests our module. --- Tests/CMakeOnly/AllFindModules/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt index 691728a..15493be 100644 --- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt +++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt @@ -8,11 +8,14 @@ endif () # Avoid ctest truncation of output message(STATUS "CTEST_FULL_OUTPUT") +set(ORIGINAL_MODULE_PATH "${CMAKE_MODULE_PATH}") + file(GLOB FIND_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../Modules/Find*.cmake" ) macro(do_find MODULE_NAME) message(STATUS " Checking Find${MODULE_NAME}") find_package(${MODULE_NAME}) + set(CMAKE_MODULE_PATH "${ORIGINAL_MODULE_PATH}") endmacro() # It is only possible to use either Qt3 or Qt4 in one project. -- cgit v0.12 From f039a3a78e58f5ab2724704294513d7c25f0510c Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 20 Mar 2014 00:01:05 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 9dffee3..0744061 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 0) -set(CMake_VERSION_PATCH 20140319) +set(CMake_VERSION_PATCH 20140320) #set(CMake_VERSION_RC 1) -- cgit v0.12 From d97606477118ba186f49753b5630e4ddb24a6cd2 Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Thu, 20 Mar 2014 10:03:56 +0100 Subject: Revert "UseSWIG: Name extra generated files after module name (#10080)" This reverts commit f0111deb1ea21f667b2fbf57f55d5ee2a80f5ccc. --- Modules/UseSWIG.cmake | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 4ae6f81..11ca205 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -85,6 +85,9 @@ macro(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile) set(${outfiles} "") get_source_file_property(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename ${infile} SWIG_MODULE_NAME) + if(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND") + get_filename_component(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${infile}" NAME_WE) + endif() foreach(it ${SWIG_${language}_EXTRA_FILE_EXTENSION}) set(${outfiles} ${${outfiles}} "${generatedpath}/${SWIG_GET_EXTRA_OUTPUT_FILES_module_basename}.${it}") @@ -100,10 +103,6 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) get_source_file_property(swig_source_file_generated ${infile} GENERATED) get_source_file_property(swig_source_file_cplusplus ${infile} CPLUSPLUS) get_source_file_property(swig_source_file_flags ${infile} SWIG_FLAGS) - get_source_file_property(_SWIG_MODULE_NAME ${infile} SWIG_MODULE_NAME) - if ( NOT _SWIG_MODULE_NAME ) - set_source_files_properties(${infile} PROPERTIES SWIG_MODULE_NAME ${name}) - endif () if("${swig_source_file_flags}" STREQUAL "NOTFOUND") set(swig_source_file_flags "") endif() -- cgit v0.12 From 84a423040686fb5855cbe65d4aa4e209dc4ca870 Mon Sep 17 00:00:00 2001 From: David Cole Date: Mon, 17 Mar 2014 07:32:35 -0400 Subject: Tests: Prevent unnecessary rebuilds in CTestTestMemcheck Repeated "cmake . && ninja" calls were resulting in rebuilds every time. Change the test so that it uses "file(WRITE" to generate a ".in" file and then configure_file to "copy if different" that ".in" file to the final generated source file. Now, rebuilds will only occur if there are changes to the generated source file on "cmake ." runs after the first one. --- Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt b/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt index c5aa2cd..47d6a24 100644 --- a/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt @@ -1,7 +1,12 @@ # A dummy checker implementation that does not write the requested output file # so it triggers an error for every checker. -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ret0.c" "int main(){return 0;}\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ret0.c.in" "int main(){return 0;}\n") + +configure_file( + "${CMAKE_CURRENT_BINARY_DIR}/ret0.c.in" + "${CMAKE_CURRENT_BINARY_DIR}/ret0.c" + ) foreach(_pseudo IN ITEMS valgrind purify BC) add_executable(pseudonl_${_pseudo} "${CMAKE_CURRENT_BINARY_DIR}/ret0.c") -- cgit v0.12 From 77f06b145d57c4665ff5d71b89a70c54a009ad14 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 5 Mar 2014 09:52:45 +0100 Subject: Modules: Add an Andriod platform file It is much like Linux but has no SONAME or RPATH. --- Modules/Platform/Android.cmake | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Modules/Platform/Android.cmake diff --git a/Modules/Platform/Android.cmake b/Modules/Platform/Android.cmake new file mode 100644 index 0000000..a4c122d --- /dev/null +++ b/Modules/Platform/Android.cmake @@ -0,0 +1,5 @@ +include(Platform/Linux) +set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "") +# RPath is useless on Android, because we can't determine the installation +# location ahead of time. +set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") -- cgit v0.12 From bbffccca42d4f209220e833e1a86e735a5c83339 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 7 Mar 2014 17:20:10 +0100 Subject: add_custom_command: Evaluate generator expressions in DEPENDS Rely on evaluation in cmCustomCommandGenerator for the generators. When tracing target dependencies, depend on the union of dependencies for all configurations. --- Help/command/add_custom_command.rst | 4 +++ .../dev/add_custom_command-DEPENDS-genex.rst | 5 +++ Source/cmCustomCommandGenerator.cxx | 18 ++++++++-- Source/cmCustomCommandGenerator.h | 2 ++ Source/cmGeneratorTarget.cxx | 39 +++++++++++++++++++--- Tests/CustomCommand/CMakeLists.txt | 7 ++-- 6 files changed, 66 insertions(+), 9 deletions(-) create mode 100644 Help/release/dev/add_custom_command-DEPENDS-genex.rst diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst index b0c5446..028ca5a 100644 --- a/Help/command/add_custom_command.rst +++ b/Help/command/add_custom_command.rst @@ -156,3 +156,7 @@ target is built before any target using this custom command. Additionally, if the target is an executable or library a file-level dependency is created to cause the custom command to re-run whenever the target is recompiled. + +Arguments to ``DEPENDS`` may use "generator expressions" with the syntax +``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for +available expressions. diff --git a/Help/release/dev/add_custom_command-DEPENDS-genex.rst b/Help/release/dev/add_custom_command-DEPENDS-genex.rst new file mode 100644 index 0000000..1e528e6 --- /dev/null +++ b/Help/release/dev/add_custom_command-DEPENDS-genex.rst @@ -0,0 +1,5 @@ +add_custom_command-DEPENDS-genex +-------------------------------- + +* The :command:`add_custom_command` command learned to interpret + :manual:`cmake-generator-expressions(7)` in arguments to ``DEPENDS``. diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index a091cff..cebd9f5 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -21,7 +21,7 @@ cmCustomCommandGenerator::cmCustomCommandGenerator( cmCustomCommand const& cc, const std::string& config, cmMakefile* mf): CC(cc), Config(config), Makefile(mf), LG(mf->GetLocalGenerator()), OldStyle(cc.GetEscapeOldStyle()), MakeVars(cc.GetEscapeAllowMakeVars()), - GE(new cmGeneratorExpression(cc.GetBacktrace())) + GE(new cmGeneratorExpression(cc.GetBacktrace())), DependsDone(false) { } @@ -93,5 +93,19 @@ std::vector const& cmCustomCommandGenerator::GetOutputs() const //---------------------------------------------------------------------------- std::vector const& cmCustomCommandGenerator::GetDepends() const { - return this->CC.GetDepends(); + if (!this->DependsDone) + { + this->DependsDone = true; + std::vector depends = this->CC.GetDepends(); + for(std::vector::const_iterator + i = depends.begin(); + i != depends.end(); ++i) + { + cmsys::auto_ptr cge + = this->GE->Parse(*i); + cmSystemTools::ExpandListArgument( + cge->Evaluate(this->Makefile, this->Config), this->Depends); + } + } + return this->Depends; } diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h index cbcdb41..0d8a0a4 100644 --- a/Source/cmCustomCommandGenerator.h +++ b/Source/cmCustomCommandGenerator.h @@ -28,6 +28,8 @@ class cmCustomCommandGenerator bool OldStyle; bool MakeVars; cmGeneratorExpression* GE; + mutable bool DependsDone; + mutable std::vector Depends; public: cmCustomCommandGenerator(cmCustomCommand const& cc, const std::string& config, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2a144c6..b35e859 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -19,6 +19,7 @@ #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionDAGChecker.h" #include "cmComputeLinkInformation.h" +#include "cmCustomCommandGenerator.h" #include @@ -610,6 +611,9 @@ private: bool IsUtility(std::string const& dep); void CheckCustomCommand(cmCustomCommand const& cc); void CheckCustomCommands(const std::vector& commands); + void FollowCommandDepends(cmCustomCommand const& cc, + const std::string& config, + std::set& emitted); }; //---------------------------------------------------------------------------- @@ -826,16 +830,41 @@ cmTargetTraceDependencies } // Queue the custom command dependencies. - std::vector const& depends = cc.GetDepends(); + std::vector configs; + std::set emitted; + this->Makefile->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } + for(std::vector::const_iterator ci = configs.begin(); + ci != configs.end(); ++ci) + { + this->FollowCommandDepends(cc, *ci, emitted); + } +} + +//---------------------------------------------------------------------------- +void cmTargetTraceDependencies::FollowCommandDepends(cmCustomCommand const& cc, + const std::string& config, + std::set& emitted) +{ + cmCustomCommandGenerator ccg(cc, config, this->Makefile); + + const std::vector& depends = ccg.GetDepends(); + for(std::vector::const_iterator di = depends.begin(); di != depends.end(); ++di) { std::string const& dep = *di; - if(!this->IsUtility(dep)) + if(emitted.insert(dep).second) { - // The dependency does not name a target and may be a file we - // know how to generate. Queue it. - this->FollowName(dep); + if(!this->IsUtility(dep)) + { + // The dependency does not name a target and may be a file we + // know how to generate. Queue it. + this->FollowName(dep); + } } } } diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index bbae387..a194a5f 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -185,7 +185,7 @@ add_executable(CustomCommand # here to test adding the generation rule after referencing the # generated source in a target. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/generated.c - DEPENDS generator + DEPENDS $<1:generator> $<0:does_not_exist> COMMAND generator ARGS ${PROJECT_BINARY_DIR}/generated.c ) @@ -221,8 +221,11 @@ add_subdirectory(GeneratorInExtraDir) add_executable(tcat tcat.cxx) +# Test that list expansion from a generator expression works. +set_property(TARGET tcat PROPERTY DEPSLIST tcat gen_redirect_in.c) + add_custom_command(OUTPUT gen_redirect.c - DEPENDS tcat gen_redirect_in.c + DEPENDS $ COMMAND tcat < ${CMAKE_CURRENT_SOURCE_DIR}/gen_redirect_in.c > gen_redirect.c COMMAND ${CMAKE_COMMAND} -E echo "#endif" >> gen_redirect.c VERBATIM -- cgit v0.12 From 95cdf132489c79e88a10fdf7a7566fa002c7680b Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Wed, 19 Mar 2014 17:31:01 +0100 Subject: Treat .m files consistently as C across all generators Objective C sources should be compiled with the C compiler, not C++. The Xcode generator correctly classifies ".m" sources already. The cmSystemTools::GetFileFormat method was fixed by commit v2.8.0~1782 (fix for 7045, use gcc for .m, 2008-08-19) but it is not used by any of the generator since commit v2.4.0~2819 (major changes to support addition of languages, 2004-09-22). Fix the CMAKE__SOURCE_FILE_EXTENSIONS table entries so that cmGlobalGenerator::GetLanguageFromExtension tells the Makefile, Ninja, and VS IDE generators to compile ".m" sources as C. This makes behavior consistent on all generators. Signed-off-by: Tim Blechmann --- Modules/CMakeCCompiler.cmake.in | 2 +- Modules/CMakeCXXCompiler.cmake.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index 804cce2..694f8b8 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -26,7 +26,7 @@ if(CMAKE_COMPILER_IS_MINGW) set(MINGW 1) endif() set(CMAKE_C_COMPILER_ID_RUN 1) -set(CMAKE_C_SOURCE_FILE_EXTENSIONS c) +set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m) set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) set(CMAKE_C_LINKER_PREFERENCE 10) diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index 35aa6c4..c75611a 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -27,7 +27,7 @@ if(CMAKE_COMPILER_IS_MINGW) endif() set(CMAKE_CXX_COMPILER_ID_RUN 1) set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC) -set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;CPP) +set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;mm;CPP) set(CMAKE_CXX_LINKER_PREFERENCE 30) set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1) -- cgit v0.12 From 12faf00d71e9a9d9f48ee13ef9dd0011fa95c385 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 19 Mar 2014 15:21:09 -0400 Subject: KWSys 2014-03-19 (a8aa1014) Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ a8aa1014 | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' dd873734..a8aa1014 Gerhard Grimm (1): fa86f1ba SystemInformation: Fix HP-UX PA-RISC processor detection Rolf Eike Beer (1): a8aa1014 SystemInformation: Fix HP-UX Intel processor detection Change-Id: I5891a6898cc73caf1b2be98859d5d4b11a24c5df --- SystemInformation.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/SystemInformation.cxx b/SystemInformation.cxx index 9c26380..720a7c3 100644 --- a/SystemInformation.cxx +++ b/SystemInformation.cxx @@ -5023,21 +5023,26 @@ bool SystemInformationImplementation::QueryHPUXProcessor() case CPU_PA_RISC1_0: this->ChipID.Vendor = "Hewlett-Packard"; this->ChipID.Family = 0x100; + break; case CPU_PA_RISC1_1: this->ChipID.Vendor = "Hewlett-Packard"; this->ChipID.Family = 0x110; + break; case CPU_PA_RISC2_0: this->ChipID.Vendor = "Hewlett-Packard"; this->ChipID.Family = 0x200; -# ifdef CPU_HP_INTEL_EM_1_0 + break; +# if defined(CPU_HP_INTEL_EM_1_0) || defined(CPU_IA64_ARCHREV_0) +# ifdef CPU_HP_INTEL_EM_1_0 case CPU_HP_INTEL_EM_1_0: -# endif -# ifdef CPU_IA64_ARCHREV_0 +# endif +# ifdef CPU_IA64_ARCHREV_0 case CPU_IA64_ARCHREV_0: -# endif +# endif this->ChipID.Vendor = "GenuineIntel"; this->Features.HasIA64 = true; break; +# endif default: return false; } -- cgit v0.12 From 2abd8efecbc6be237190f8fa2f10d6e0b53e08b9 Mon Sep 17 00:00:00 2001 From: Bruno Nova Date: Wed, 19 Mar 2014 19:44:46 +0000 Subject: UseJava: Copy resource files before compiling the jar (#13360) Co-Author: Mary Ellen Foster --- Modules/UseJava.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 654b4d0..127012f 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -426,6 +426,7 @@ function(add_jar _TARGET_NAME) set(_JAVA_DEPENDS) set(_JAVA_COMPILE_DEPENDS) set(_JAVA_RESOURCE_FILES) + set(_JAVA_RESOURCE_FILES_RELATIVE) foreach(_JAVA_SOURCE_FILE ${_JAVA_SOURCE_FILES}) get_filename_component(_JAVA_EXT ${_JAVA_SOURCE_FILE} EXT) get_filename_component(_JAVA_FILE ${_JAVA_SOURCE_FILE} NAME_WE) @@ -462,7 +463,8 @@ function(add_jar _TARGET_NAME) __java_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/${_JAVA_SOURCE_FILE} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_SOURCE_FILE} "Copying ${_JAVA_SOURCE_FILE} to the build directory") - list(APPEND _JAVA_RESOURCE_FILES ${_JAVA_SOURCE_FILE}) + list(APPEND _JAVA_RESOURCE_FILES ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_SOURCE_FILE}) + list(APPEND _JAVA_RESOURCE_FILES_RELATIVE ${_JAVA_SOURCE_FILE}) endif () endforeach() @@ -529,7 +531,7 @@ function(add_jar _TARGET_NAME) OUTPUT ${_JAVA_JAR_OUTPUT_PATH} COMMAND ${Java_JAR_EXECUTABLE} -cf${_ENTRY_POINT_OPTION}${_MANIFEST_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE} ${_MANIFEST_VALUE} - ${_JAVA_RESOURCE_FILES} @java_class_filelist + ${_JAVA_RESOURCE_FILES_RELATIVE} @java_class_filelist COMMAND ${CMAKE_COMMAND} -D_JAVA_TARGET_DIR=${_add_jar_OUTPUT_DIR} -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME} @@ -549,7 +551,7 @@ function(add_jar _TARGET_NAME) OUTPUT ${_JAVA_JAR_OUTPUT_PATH} COMMAND ${Java_JAR_EXECUTABLE} -cf${_ENTRY_POINT_OPTION}${_MANIFEST_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE} ${_MANIFEST_VALUE} - ${_JAVA_RESOURCE_FILES} @java_class_filelist + ${_JAVA_RESOURCE_FILES_RELATIVE} @java_class_filelist COMMAND ${CMAKE_COMMAND} -D_JAVA_TARGET_DIR=${_add_jar_OUTPUT_DIR} -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME} -- cgit v0.12 From f1fd3714a40327c461633b64d82f6815ed3e7817 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 18 Mar 2014 00:09:40 +0100 Subject: cmMakefile: Report type of INTERFACE library in conflict. --- Source/cmMakefile.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f82acc8..dce71de 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4200,6 +4200,9 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, case cmTarget::UTILITY: e << "a custom target "; break; + case cmTarget::INTERFACE_LIBRARY: + e << "an interface library "; + break; default: break; } e << "created in source directory \"" -- cgit v0.12 From 6373e08d439195557f77e8de7081252a5326f463 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 21 Mar 2014 00:01:16 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 0744061..62932b4 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 0) -set(CMake_VERSION_PATCH 20140320) +set(CMake_VERSION_PATCH 20140321) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 734df96f5ad3d47b3c7825715f0b524292aa6ede Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Mar 2014 11:03:37 +0100 Subject: Qt4: Fix moc command dependencies for incremental build. Since commit v2.8.12~327^2 (Qt4Macros: Allow specifying a TARGET in invokations of macros., 2013-02-26), a parameters file is populated with moc arguments at generate-time. When the compile definitions or include directories change, the parameters file is updated but moc is not re-run in response. Fix that by making the moc invocation depend on the parameters file. Reported-At: https://bugreports.qt-project.org/browse/QTBUG-36970 --- Modules/Qt4Macros.cmake | 2 +- Tests/Qt4Targets/CMakeLists.txt | 27 ++++++++++++++++++++++++++ Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt | 13 +++++++++++++ Tests/Qt4Targets/IncrementalMoc/foo.cpp | 8 ++++++++ Tests/Qt4Targets/IncrementalMoc/foo.h | 9 +++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt create mode 100644 Tests/Qt4Targets/IncrementalMoc/foo.cpp create mode 100644 Tests/Qt4Targets/IncrementalMoc/foo.h diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index 8baf896..aca8996 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -141,7 +141,7 @@ macro (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target) set(_moc_extra_parameters_file @${_moc_parameters_file}) add_custom_command(OUTPUT ${outfile} COMMAND Qt4::moc ${_moc_extra_parameters_file} - DEPENDS ${infile} + DEPENDS ${infile} ${_moc_parameters_file} ${_moc_working_dir} VERBATIM) endmacro () diff --git a/Tests/Qt4Targets/CMakeLists.txt b/Tests/Qt4Targets/CMakeLists.txt index af9fc3f..7430084 100644 --- a/Tests/Qt4Targets/CMakeLists.txt +++ b/Tests/Qt4Targets/CMakeLists.txt @@ -36,3 +36,30 @@ add_executable(Qt4WrapMacroTest WIN32 main_wrap_test.cpp ${moc_file}) set_property(TARGET Qt4WrapMacroTest PROPERTY AUTOMOC OFF) target_include_directories(Qt4WrapMacroTest PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface") target_link_libraries(Qt4WrapMacroTest Qt4::QtGui) + +set(timeformat "%Y%j%H%M%S") +try_compile(RESULT + "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild" + "${CMAKE_CURRENT_SOURCE_DIR}/IncrementalMoc" + IncrementalMoc + CMAKE_FLAGS -DADD_DEF=0 "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}") +file(TIMESTAMP "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild/moc_foo.cpp" tsvar_before "${timeformat}") +if (NOT tsvar_before) + message(SEND_ERROR "Unable to read timestamp from moc file from first build!") +endif() + +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 2) # Ensure that the timestamp will change. + +try_compile(RESULT + "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild" + "${CMAKE_CURRENT_SOURCE_DIR}/IncrementalMoc" + IncrementalMoc + CMAKE_FLAGS -DADD_DEF=1 "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}") +file(TIMESTAMP "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild/moc_foo.cpp" tsvar_after "${timeformat}") +if (NOT tsvar_after) + message(SEND_ERROR "Unable to read timestamp from moc file from second build!") +endif() + +if (NOT tsvar_after GREATER tsvar_before) + message(SEND_ERROR "Rebuild did not re-create moc file. Before: ${tsvar_before}. After: ${tsvar_after}") +endif() diff --git a/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt b/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt new file mode 100644 index 0000000..4ba0ced --- /dev/null +++ b/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt @@ -0,0 +1,13 @@ + +cmake_minimum_required(VERSION 2.8.12) +project(IncrementalMoc) + +find_package(Qt4 REQUIRED) + +qt4_generate_moc(foo.h moc_foo.cpp) + +add_library(testlib foo.cpp moc_foo.cpp) +target_link_libraries(testlib Qt4::QtCore) +if (ADD_DEF) + target_compile_definitions(testlib PRIVATE NEW_DEF) +endif() diff --git a/Tests/Qt4Targets/IncrementalMoc/foo.cpp b/Tests/Qt4Targets/IncrementalMoc/foo.cpp new file mode 100644 index 0000000..e924f7e --- /dev/null +++ b/Tests/Qt4Targets/IncrementalMoc/foo.cpp @@ -0,0 +1,8 @@ + +#include "foo.h" + +Foo::Foo() + : QObject(0) +{ + +} diff --git a/Tests/Qt4Targets/IncrementalMoc/foo.h b/Tests/Qt4Targets/IncrementalMoc/foo.h new file mode 100644 index 0000000..38d899f --- /dev/null +++ b/Tests/Qt4Targets/IncrementalMoc/foo.h @@ -0,0 +1,9 @@ + +#include + +class Foo : QObject +{ + Q_OBJECT +public: + Foo(); +}; -- cgit v0.12 From 84603d804c285c75f4bf81f9d79f0ebd0ca68fea Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 3 Mar 2014 15:47:08 +0100 Subject: Haiku: Enable CMake builtin ELF editor Co-Author: Brad King --- Source/CMakeLists.txt | 18 ++++++++++++++++++ Source/cmELF.cxx | 20 ++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 762470f..27d099d 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -18,6 +18,23 @@ else() endif() if(HAVE_ELF_H) set(CMAKE_USE_ELF_PARSER 1) +elseif(HAIKU) + # On Haiku, we need to include elf32.h from the private headers + set(CMake_HAIKU_INCLUDE_DIRS + /boot/system/develop/headers/private/system + /boot/system/develop/headers/private/system/arch/x86 + ) + + set(CMAKE_REQUIRED_INCLUDES ${CMake_HAIKU_INCLUDE_DIRS}) + CHECK_INCLUDE_FILE("elf32.h" HAVE_ELF32_H) + unset(CMAKE_REQUIRED_INCLUDES) + + if(HAVE_ELF32_H) + set(CMAKE_USE_ELF_PARSER 1) + else() + unset(CMake_HAIKU_INCLUDE_DIRS) + set(CMAKE_USE_ELF_PARSER) + endif() else() set(CMAKE_USE_ELF_PARSER) endif() @@ -57,6 +74,7 @@ include_directories( ${CMAKE_EXPAT_INCLUDES} ${CMAKE_TAR_INCLUDES} ${CMAKE_COMPRESS_INCLUDES} + ${CMake_HAIKU_INCLUDE_DIRS} ) # let cmake know it is supposed to use it diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index bc1c25b..dc6772c 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -23,6 +23,26 @@ #if defined(__OpenBSD__) # include # include +#elif defined(__HAIKU__) +# include +# include + typedef struct Elf32_Ehdr Elf32_Ehdr; + typedef struct Elf32_Shdr Elf32_Shdr; + typedef struct Elf32_Sym Elf32_Sym; + typedef struct Elf32_Rel Elf32_Rel; + typedef struct Elf32_Rela Elf32_Rela; +# define ELFMAG0 0x7F +# define ELFMAG1 'E' +# define ELFMAG2 'L' +# define ELFMAG3 'F' +# define ET_NONE 0 +# define ET_REL 1 +# define ET_EXEC 2 +# define ET_DYN 3 +# define ET_CORE 4 +# define EM_386 3 +# define EM_SPARC 2 +# define EM_PPC 20 #else # include #endif -- cgit v0.12 From 0cc42b871ab9c9153d839ab8fc55a6a887d55092 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 3 Mar 2014 15:57:05 +0100 Subject: Haiku: Fix compiler detection when using distcc Also remove outdated include directories. --- Modules/Platform/Haiku.cmake | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Modules/Platform/Haiku.cmake b/Modules/Platform/Haiku.cmake index 825f851..dfc2664 100644 --- a/Modules/Platform/Haiku.cmake +++ b/Modules/Platform/Haiku.cmake @@ -21,18 +21,26 @@ set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") # "/boot/system/develop/lib//", which we assume to be the secondary # architecture specific subdirectory and extract the name of the architecture # accordingly. -set(__HAIKU_COMPILER ${CMAKE_C_COMPILER}) -if(NOT __HAIKU_COMPILER) +# First of all, find a C or C++ compiler we can run. The "arg1" is necessary +# here for compilers such as "distcc gcc-x86" or "ccache gcc-x86" +# TODO See CMakeDetermineCompilerId.cmake for some more things we may want to do. +if(CMAKE_C_COMPILER) + set(__HAIKU_COMPILER ${CMAKE_C_COMPILER}) + string (STRIP "${CMAKE_C_COMPILER_ARG1}" __HAIKU_COMPILER_FLAGS) +else() set(__HAIKU_COMPILER ${CMAKE_CXX_COMPILER}) + string (STRIP "${CMAKE_CXX_COMPILER_ARG1}" __HAIKU_COMPILER_FLAGS) endif() + execute_process( - COMMAND ${__HAIKU_COMPILER} -print-search-dirs + COMMAND ${__HAIKU_COMPILER} ${__HAIKU_COMPILER_FLAGS} -print-search-dirs OUTPUT_VARIABLE _HAIKU_SEARCH_DIRS + RESULT_VARIABLE _HAIKU_SEARCH_DIRS_FOUND OUTPUT_STRIP_TRAILING_WHITESPACE) -string(REGEX MATCH ".*\nlibraries: =?([^\n]*:)?/boot/system/develop/lib/([^/]*)/(:[^\n]*)?\n.*" _dummy "\n${_HAIKU_SEARCH_DIRS}\n") +string(REGEX MATCH "libraries: =?([^\n]*:)?/boot/system/develop/lib/([^/]*)/?(:?\n+)" _dummy "${_HAIKU_SEARCH_DIRS}\n") set(CMAKE_HAIKU_SECONDARY_ARCH "${CMAKE_MATCH_2}") if(NOT CMAKE_HAIKU_SECONDARY_ARCH) @@ -53,14 +61,12 @@ else() endif() list(APPEND CMAKE_SYSTEM_PREFIX_PATH - /boot/common/non-packaged - /boot/common + /boot/system/non-packaged /boot/system ) LIST(APPEND CMAKE_HAIKU_COMMON_INCLUDE_DIRECTORIES - /boot/common/non-packaged/develop/headers${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR} - /boot/common/develop/headers${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR} + /boot/system/non-packaged/develop/headers${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR} /boot/system/develop/headers/os /boot/system/develop/headers/os/app /boot/system/develop/headers/os/device @@ -108,8 +114,7 @@ LIST(APPEND CMAKE_HAIKU_CXX_INCLUDE_DIRECTORIES LIST(APPEND CMAKE_SYSTEM_INCLUDE_PATH ${CMAKE_HAIKU_C_INCLUDE_DIRECTORIES}) LIST(APPEND CMAKE_HAIKU_DEVELOP_LIB_DIRECTORIES - /boot/common/non-packaged/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR} - /boot/common/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR} + /boot/system/non-packaged/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR} /boot/system/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR} ) @@ -120,6 +125,6 @@ LIST(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES LIST(APPEND CMAKE_SYSTEM_LIBRARY_PATH ${CMAKE_HAIKU_DEVELOP_LIB_DIRECTORIES}) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX "/boot/common" CACHE PATH + set(CMAKE_INSTALL_PREFIX "/boot/system" CACHE PATH "Install path prefix, prepended onto install directories." FORCE) endif() -- cgit v0.12 From bccc056ba86ede84b9f0acb066de97103a74268a Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 21 Mar 2014 08:28:37 -0400 Subject: cmake: Advise user to remove CMakeFiles with CMakeCache.txt (#14820) --- Source/cmake.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index ede6842..2cf636c 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1413,8 +1413,8 @@ int cmake::ActualConfigure() message += "\nDoes not match the generator used previously: "; message += genName; message += - "\nEither remove the CMakeCache.txt file or choose a different" - " binary directory."; + "\nEither remove the CMakeCache.txt file and CMakeFiles " + "directory or choose a different binary directory."; cmSystemTools::Error(message.c_str()); return -2; } @@ -1445,8 +1445,8 @@ int cmake::ActualConfigure() message += "\nDoes not match the toolset used previously: "; message += tsName; message += - "\nEither remove the CMakeCache.txt file or choose a different" - " binary directory."; + "\nEither remove the CMakeCache.txt file and CMakeFiles " + "directory or choose a different binary directory."; cmSystemTools::Error(message.c_str()); return -2; } -- cgit v0.12 From d514e41118c8404171cbc6a9520407499af6064a Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 22 Mar 2014 00:01:05 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 62932b4..b107969 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 0) -set(CMake_VERSION_PATCH 20140321) +set(CMake_VERSION_PATCH 20140322) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 6f39a6ff321ca1682af684713c8ff93a21fe32ae Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 23 Mar 2014 00:01:06 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index b107969..87a4165 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 0) -set(CMake_VERSION_PATCH 20140322) +set(CMake_VERSION_PATCH 20140323) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 9523d2a55c99fb0910531ae7160b099faeab6638 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 23 Mar 2014 23:47:56 -0400 Subject: ninja: Add support for custom depfile formats Not everything that isn't MSVC is GCC. I have support for LDC's depfile format on its way upstream[1], but its future is uncertain. CMake should at least support this for future depfile formats. [1]https://github.com/martine/ninja/pull/721 --- Help/release/dev/custom-ninja-deptypes.rst | 5 +++++ Source/cmNinjaTargetGenerator.cxx | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 Help/release/dev/custom-ninja-deptypes.rst diff --git a/Help/release/dev/custom-ninja-deptypes.rst b/Help/release/dev/custom-ninja-deptypes.rst new file mode 100644 index 0000000..7750da8 --- /dev/null +++ b/Help/release/dev/custom-ninja-deptypes.rst @@ -0,0 +1,5 @@ +custom-ninja-deptypes +--------------------- + +* Add a `CMAKE_NINJA_DEPTYPE_` variable so that compilers may set the + deptype for use in Ninja other than those CMake itself knows about. diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4319f3c..8865b3d 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -418,6 +418,11 @@ cmNinjaTargetGenerator else { deptype = "gcc"; + const char* langdeptype = mf->GetDefinition("CMAKE_NINJA_DEPTYPE_" + lang); + if (langdeptype) + { + deptype = langdeptype; + } depfile = "$DEP_FILE"; const std::string flagsName = "CMAKE_DEPFILE_FLAGS_" + lang; std::string depfileFlags = mf->GetSafeDefinition(flagsName); -- cgit v0.12 From 8a306d68e02595a8fc119cf7e2fa267a6ea64498 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 24 Mar 2014 00:01:06 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 87a4165..32ea2fa 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 0) -set(CMake_VERSION_PATCH 20140323) +set(CMake_VERSION_PATCH 20140324) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 63a4c0af31fd067a189aaa44cd4b8d17e9efd5c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= Date: Sat, 22 Mar 2014 08:54:34 +0100 Subject: FindPkgConfig: Stop processing when REQUIRED package not found (#14381) Make the behavior similar to find_package. --- Modules/FindPkgConfig.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 286cc23..8327143 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -337,7 +337,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma if(_pkg_check_modules_failed) # fail when requested if (${_is_required}) - message(SEND_ERROR "A required package was not found") + message(FATAL_ERROR "A required package was not found") endif () else() # when we are here, we checked whether requested modules -- cgit v0.12 From 1b18f442f48ebd8f88c1f64ef016784613cc2f2d Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 24 Mar 2014 12:33:11 +0100 Subject: Avoid trailing space in CMAKE_*_LINKER_FLAGS when LDFLAGS is empty --- Modules/CMakeCommonLanguageInclude.cmake | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Modules/CMakeCommonLanguageInclude.cmake b/Modules/CMakeCommonLanguageInclude.cmake index 38a6d35..fa025a8 100644 --- a/Modules/CMakeCommonLanguageInclude.cmake +++ b/Modules/CMakeCommonLanguageInclude.cmake @@ -16,9 +16,11 @@ # cache values that can be initialized in the platform-compiler.cmake file # it may be included by more than one language. -set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}" - CACHE STRING "Flags used by the linker.") - +if(NOT "x$ENV{LDFLAGS}" STREQUAL "x") + set (CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}") + set (CMAKE_SHARED_LINKER_FLAGS_INIT "${CMAKE_SHARED_LINKER_FLAGS_INIT} $ENV{LDFLAGS}") + set (CMAKE_MODULE_LINKER_FLAGS_INIT "${CMAKE_MODULE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}") +endif() if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) # default build type is none @@ -82,12 +84,17 @@ if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING "Flags used by the linker during Release with Debug Info builds.") endif() + +# executable linker flags +set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_INIT}" + CACHE STRING "Flags used by the linker.") + # shared linker flags -set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} $ENV{LDFLAGS}" +set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT}" CACHE STRING "Flags used by the linker during the creation of dll's.") # module linker flags -set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}" +set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS_INIT}" CACHE STRING "Flags used by the linker during the creation of modules.") # static linker flags @@ -124,4 +131,3 @@ CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL CMAKE_STATIC_LINKER_FLAGS_RELEASE CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO ) - -- cgit v0.12 From 261acd91093ba5f2bf79f38a9632887ab2dd5f1c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 25 Mar 2014 01:16:49 +0100 Subject: QtAutogen: Use the basename for resource files. The rcc tool generates a cpp file with a symbol called qInitResources or called qInitResources_${name}, if the name is passed. The qInitResources symbol clashes if multiple qrc files are used in one target. Always pass the name to ensure that the symbol is unique. This is also the behavior of the qtx_add_resource macros. --- Source/cmQtAutoGenerators.cxx | 2 ++ Tests/QtAutogen/CMakeLists.txt | 2 +- Tests/QtAutogen/resourcetester.cpp | 2 ++ Tests/QtAutogen/second_resource.qrc | 5 +++++ 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 Tests/QtAutogen/second_resource.qrc diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 2c5dd45..fcc898a 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -2074,6 +2074,8 @@ bool cmQtAutoGenerators::GenerateQrc() } } + command.push_back("-name"); + command.push_back(basename); command.push_back("-o"); command.push_back(rcc_output_file); command.push_back(*si); diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index 0821b45..cf80f41 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -66,7 +66,7 @@ add_custom_command( add_executable(QtAutogen main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp xyz.cpp yaf.cpp gadget.cpp $ - test.qrc resourcetester.cpp generated.cpp + test.qrc second_resource.qrc resourcetester.cpp generated.cpp ) set_property(TARGET QtAutogen APPEND PROPERTY AUTOGEN_TARGET_DEPENDS generate_moc_input "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h") diff --git a/Tests/QtAutogen/resourcetester.cpp b/Tests/QtAutogen/resourcetester.cpp index 43314e1..0c64d80 100644 --- a/Tests/QtAutogen/resourcetester.cpp +++ b/Tests/QtAutogen/resourcetester.cpp @@ -16,6 +16,8 @@ void ResourceTester::doTest() { if (!QFile::exists(":/CMakeLists.txt")) qApp->exit(EXIT_FAILURE); + if (!QFile::exists(":/main.cpp")) + qApp->exit(EXIT_FAILURE); QTimer::singleShot(0, qApp, SLOT(quit())); } diff --git a/Tests/QtAutogen/second_resource.qrc b/Tests/QtAutogen/second_resource.qrc new file mode 100644 index 0000000..27bfb14 --- /dev/null +++ b/Tests/QtAutogen/second_resource.qrc @@ -0,0 +1,5 @@ + + + main.cpp + + -- cgit v0.12 From 71a11252e95797113ecb1a969386f496b7d4861b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 25 Mar 2014 01:26:27 +0100 Subject: QtAutogen: Fix use of multiple ui files in a single target. Don't store a mapping of the directory to the ui file. The directory will be a unique key, allowing only one ui file to be specified. Use the source file name instead as the mapping key. --- Source/cmQtAutoGenerators.cxx | 11 +++++++---- Source/cmQtAutoGenerators.h | 2 +- Tests/QtAutogen/CMakeLists.txt | 2 +- Tests/QtAutogen/second_widget.cpp | 14 ++++++++++++++ Tests/QtAutogen/second_widget.h | 19 +++++++++++++++++++ Tests/QtAutogen/second_widget.ui | 32 ++++++++++++++++++++++++++++++++ 6 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 Tests/QtAutogen/second_widget.cpp create mode 100644 Tests/QtAutogen/second_widget.h create mode 100644 Tests/QtAutogen/second_widget.ui diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index fcc898a..a8bb317 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1786,8 +1786,8 @@ void cmQtAutoGenerators::ParseForUic(const std::string& absFilename, std::string::size_type matchOffset = 0; - const std::string absPath = cmsys::SystemTools::GetFilenamePath( - cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; + const std::string realName = + cmsys::SystemTools::GetRealPath(absFilename.c_str()); matchOffset = 0; if ((strstr(contentsString.c_str(), "ui_") != NULL) @@ -1804,7 +1804,7 @@ void cmQtAutoGenerators::ParseForUic(const std::string& absFilename, // finding the correct header, so we need to remove the ui_ part basename = basename.substr(3); - includedUis[absPath] = basename; + includedUis[realName] = basename; matchOffset += uiIncludeRegExp.end(); } while(uiIncludeRegExp.find(contentsString.c_str() + matchOffset)); @@ -1960,7 +1960,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, return false; } -bool cmQtAutoGenerators::GenerateUi(const std::string& path, +bool cmQtAutoGenerators::GenerateUi(const std::string& realName, const std::string& uiFileName) { if (!cmsys::SystemTools::FileExists(this->Builddir.c_str(), false)) @@ -1968,6 +1968,9 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& path, cmsys::SystemTools::MakeDirectory(this->Builddir.c_str()); } + const std::string path = cmsys::SystemTools::GetFilenamePath( + realName.c_str()) + '/'; + std::string ui_output_file = "ui_" + uiFileName + ".h"; std::string ui_input_file = path + uiFileName + ".ui"; diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index 2840fbf..9ddf64f 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -48,7 +48,7 @@ private: bool RunAutogen(cmMakefile* makefile); bool GenerateMoc(const std::string& sourceFile, const std::string& mocFileName); - bool GenerateUi(const std::string& path, const std::string& uiFileName); + bool GenerateUi(const std::string& realName, const std::string& uiFileName); bool GenerateQrc(); void ParseCppFile(const std::string& absFilename, const std::vector& headerExtensions, diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index cf80f41..d2116aa 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -64,7 +64,7 @@ add_custom_command( DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in" ) -add_executable(QtAutogen main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp +add_executable(QtAutogen main.cpp calwidget.cpp second_widget.cpp foo.cpp blub.cpp bar.cpp abc.cpp xyz.cpp yaf.cpp gadget.cpp $ test.qrc second_resource.qrc resourcetester.cpp generated.cpp ) diff --git a/Tests/QtAutogen/second_widget.cpp b/Tests/QtAutogen/second_widget.cpp new file mode 100644 index 0000000..65ba962 --- /dev/null +++ b/Tests/QtAutogen/second_widget.cpp @@ -0,0 +1,14 @@ + +#include "second_widget.h" +#include "ui_second_widget.h" + +SecondWidget::SecondWidget(QWidget *parent) + : QWidget(parent), ui(new Ui::SecondWidget) +{ + ui->setupUi(this); +} + +SecondWidget::~SecondWidget() +{ + delete ui; +} diff --git a/Tests/QtAutogen/second_widget.h b/Tests/QtAutogen/second_widget.h new file mode 100644 index 0000000..fe4d175 --- /dev/null +++ b/Tests/QtAutogen/second_widget.h @@ -0,0 +1,19 @@ + +#include + +namespace Ui +{ +class SecondWidget; +} + +class SecondWidget : public QWidget +{ + Q_OBJECT +public: + explicit SecondWidget(QWidget *parent = 0); + + ~SecondWidget(); + +private: + Ui::SecondWidget* ui; +}; diff --git a/Tests/QtAutogen/second_widget.ui b/Tests/QtAutogen/second_widget.ui new file mode 100644 index 0000000..4effa58 --- /dev/null +++ b/Tests/QtAutogen/second_widget.ui @@ -0,0 +1,32 @@ + + + SecondWidget + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + 80 + 20 + 94 + 24 + + + + PushButton + + + + + + -- cgit v0.12 From a56a8f95364e6ec1fc50cb6a792325d914c16235 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 25 Mar 2014 00:01:06 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 32ea2fa..66ba566 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 0) -set(CMake_VERSION_PATCH 20140324) +set(CMake_VERSION_PATCH 20140325) #set(CMake_VERSION_RC 1) -- cgit v0.12 From f284b003d7eee7345f3daa2893a21ff605ba09a7 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 25 Mar 2014 16:22:44 -0400 Subject: FindBoost: Search next to MPI libs for graph_parallel (#14832) In addition to the MPI libraries, graph_parallel lives in the MPI libdir as well. --- Modules/FindBoost.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index a57e12c..d4026af 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -954,7 +954,8 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS}) # Compute component-specific hints. set(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT "") - if(${COMPONENT} STREQUAL "mpi" OR ${COMPONENT} STREQUAL "mpi_python") + if(${COMPONENT} STREQUAL "mpi" OR ${COMPONENT} STREQUAL "mpi_python" OR + ${COMPONENT} STREQUAL "graph_parallel") foreach(lib ${MPI_CXX_LIBRARIES} ${MPI_C_LIBRARIES}) if(IS_ABSOLUTE "${lib}") get_filename_component(libdir "${lib}" PATH) -- cgit v0.12 From fdf7bd27a30fa53ae6f4239088444baba1d7f84e Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Tue, 25 Mar 2014 22:46:11 +0100 Subject: FindThreads: replace MATCHES with STREQUAL --- Modules/FindThreads.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index ec671bf..d7473a7 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -96,7 +96,7 @@ else() if(NOT CMAKE_HAVE_THREADS_LIBRARY) # If we did not found -lpthread, -lpthread, or -lthread, look for -pthread - if("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG") + if("x${THREADS_HAVE_PTHREAD_ARG}" STREQUAL "x") message(STATUS "Check if compiler accepts -pthread") try_run(THREADS_PTHREAD_ARG THREADS_HAVE_PTHREAD_ARG ${CMAKE_BINARY_DIR} -- cgit v0.12 From 858ce31f4cd8d247a6dd7b8ae70ab9a38f71e7a2 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Tue, 25 Mar 2014 23:47:49 +0100 Subject: FindThreads: avoid useless checks if a thread library is already found --- Modules/FindThreads.cmake | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index d7473a7..ff8aa29 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -63,32 +63,31 @@ else() set(CMAKE_THREAD_LIBS_INIT "") set(CMAKE_HAVE_THREADS_LIBRARY 1) set(Threads_FOUND TRUE) - endif() + else() - if(NOT CMAKE_HAVE_THREADS_LIBRARY) # Do we have -lpthreads CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE) if(CMAKE_HAVE_PTHREADS_CREATE) set(CMAKE_THREAD_LIBS_INIT "-lpthreads") set(CMAKE_HAVE_THREADS_LIBRARY 1) set(Threads_FOUND TRUE) - endif() - - # Ok, how about -lpthread - CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE) - if(CMAKE_HAVE_PTHREAD_CREATE) - set(CMAKE_THREAD_LIBS_INIT "-lpthread") - set(CMAKE_HAVE_THREADS_LIBRARY 1) - set(Threads_FOUND TRUE) - endif() + else() - if(CMAKE_SYSTEM MATCHES "SunOS.*") - # On sun also check for -lthread - CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE) - if(CMAKE_HAVE_THR_CREATE) - set(CMAKE_THREAD_LIBS_INIT "-lthread") + # Ok, how about -lpthread + CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE) + if(CMAKE_HAVE_PTHREAD_CREATE) + set(CMAKE_THREAD_LIBS_INIT "-lpthread") set(CMAKE_HAVE_THREADS_LIBRARY 1) set(Threads_FOUND TRUE) + + elseif(CMAKE_SYSTEM MATCHES "SunOS.*") + # On sun also check for -lthread + CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE) + if(CMAKE_HAVE_THR_CREATE) + set(CMAKE_THREAD_LIBS_INIT "-lthread") + set(CMAKE_HAVE_THREADS_LIBRARY 1) + set(Threads_FOUND TRUE) + endif() endif() endif() endif() -- cgit v0.12 From 693f8bf34df5aaf22ed30039eff181352ed6574a Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Tue, 25 Mar 2014 23:49:54 +0100 Subject: FindThreads: simplify checking for SunOS --- Modules/FindThreads.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index ff8aa29..7f84522 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -80,7 +80,7 @@ else() set(CMAKE_HAVE_THREADS_LIBRARY 1) set(Threads_FOUND TRUE) - elseif(CMAKE_SYSTEM MATCHES "SunOS.*") + elseif(CMAKE_SYSTEM_NAME MATCHES "SunOS") # On sun also check for -lthread CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE) if(CMAKE_HAVE_THR_CREATE) -- cgit v0.12 From a29ea834de49cfcbf9b28e4403fd45f0c559bb06 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 26 Mar 2014 00:01:05 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 66ba566..9e471b3 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 0) -set(CMake_VERSION_PATCH 20140325) +set(CMake_VERSION_PATCH 20140326) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 90e22f8f713cb90f2020942cc168badedd6176e1 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Tue, 25 Mar 2014 16:16:51 +0100 Subject: OS X: Fix Info.plist placement in a CFBundle Fix cmOSXBundleGenerator::CreateCFBundle to place Info.plist under the same root directory as the rest of the bundle. Without this, Info.plist was placed into CMAKE_BINARY_DIR, not CMAKE_CURRENT_BINARY_DIR because the target path was not generated correctly. --- Source/cmOSXBundleGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 6f16913..786e6e2 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -178,7 +178,7 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, // Configure the Info.plist file. Note that it needs the executable name // to be set. - std::string plist = + std::string plist = root + "/" + this->GT->Target->GetCFBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, -- cgit v0.12 From 536747552fa62a0faf2b529991dae8109703890f Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 26 Mar 2014 14:00:16 -0400 Subject: CTestCustom: Suppress "note: in expansion of macro" diagnostic context Such notes only appear with other diagnostics and should not be considered a warning on their own. --- CTestCustom.cmake.in | 1 + 1 file changed, 1 insertion(+) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index b0f86ec..6010b64 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -54,6 +54,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION "ld: warning: directory not found for option .-(F|L)" "warning.*This version of Mac OS X is unsupported" "clang.*: warning: argument unused during compilation: .-g" + "note: in expansion of macro" # diagnostic context note # Ignore clang's summary warning, assuming prior text has matched some # other warning expression: -- cgit v0.12 From 27b812132c4c47c810b96bd2a1a28e7fb502a62e Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 26 Mar 2014 15:07:32 -0400 Subject: Tests/CTestTestMemcheck: Help Xcode 2.x create output dirs Add the PRE_BUILD step to all targets that need it so the output directories get created no matter which target is built first. --- Tests/CTestTestMemcheck/CMakeLists.txt | 23 ++++++++++++++-------- .../NoLogDummyChecker/CMakeLists.txt | 12 +++++------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index 9bd7249..8984463 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -19,14 +19,6 @@ add_executable(pseudo_valgrind "${CMAKE_CURRENT_BINARY_DIR}/ret0.cxx") set_target_properties(pseudo_valgrind PROPERTIES OUTPUT_NAME valgrind) target_link_libraries(pseudo_valgrind CMakeLib) -# Xcode 2.x forgets to create the output directory before linking -# the individual architectures. -if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]") - add_custom_command(TARGET pseudo_valgrind - PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}" - ) -endif() - add_executable(pseudo_purify "${CMAKE_CURRENT_BINARY_DIR}/ret0.cxx") set_target_properties(pseudo_purify PROPERTIES OUTPUT_NAME purify) target_link_libraries(pseudo_purify CMakeLib) @@ -196,3 +188,18 @@ set_tests_properties(CTestTestMemcheckDummyValgrindCustomOptions PROPERTIES set_tests_properties(CTestTestMemcheckDummyValgrindTwoTargets PROPERTIES PASS_REGULAR_EXPRESSION "\nMemory check project ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets\n.*\n *Start 1: RunCMake\n(.*\n)?Memory check command: .* \"--log-file=${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets/Testing/Temporary/MemoryChecker.1.log\" \"-q\".*\n *Start 2: RunCMakeAgain\n(.*\n)?Memory check command: .* \"--log-file=${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets/Testing/Temporary/MemoryChecker.2.log\" \"-q\".*\n") + +# Xcode 2.x forgets to create the output directory before linking +# the individual architectures. +if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]") + foreach(t + memcheck_fail + pseudo_BC + pseudo_purify + pseudo_valgrind + ) + add_custom_command(TARGET ${t} + PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}" + ) + endforeach() +endif() diff --git a/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt b/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt index 47d6a24..3a45bfe 100644 --- a/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt @@ -11,12 +11,12 @@ configure_file( foreach(_pseudo IN ITEMS valgrind purify BC) add_executable(pseudonl_${_pseudo} "${CMAKE_CURRENT_BINARY_DIR}/ret0.c") set_target_properties(pseudonl_${_pseudo} PROPERTIES OUTPUT_NAME ${_pseudo}) -endforeach() -# Xcode 2.x forgets to create the output directory before linking -# the individual architectures. -if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]") - add_custom_command(TARGET pseudonl_valgrind + # Xcode 2.x forgets to create the output directory before linking + # the individual architectures. + if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]") + add_custom_command(TARGET pseudonl_${_pseudo} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}" ) -endif() + endif() +endforeach() -- cgit v0.12 From e03ac807cf177b351b4b1720e16480a792bc1833 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 27 Mar 2014 00:01:18 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 9e471b3..03391c0 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 0) -set(CMake_VERSION_PATCH 20140326) +set(CMake_VERSION_PATCH 20140327) #set(CMake_VERSION_RC 1) -- cgit v0.12 From a863a8fecd368f3b17930dd7832fb2e0ba042616 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 25 Mar 2014 07:17:45 +0100 Subject: cmLocalUnixMakefileGenerator3: Re-organize ConvertToQuotedOutputPath Use one code path whether the components list is empty or not. Fix indentation accordingly. --- Source/cmLocalUnixMakefileGenerator3.cxx | 65 ++++++++++++++++---------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index cc872d5..8fa14d2 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -2183,52 +2183,51 @@ cmLocalUnixMakefileGenerator3 std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p) { - // Split the path into its components. std::vector components; cmSystemTools::SplitPath(p, components); + // Open the quoted result. + std::string result = "\""; + // Return an empty path if there are no components. - if(components.empty()) + if(!components.empty()) { - return "\"\""; - } - - // Choose a slash direction and fix root component. - const char* slash = "/"; + // Choose a slash direction and fix root component. + const char* slash = "/"; #if defined(_WIN32) && !defined(__CYGWIN__) - if(!cmSystemTools::GetForceUnixPaths()) - { - slash = "\\"; - for(std::string::iterator i = components[0].begin(); - i != components[0].end(); ++i) - { - if(*i == '/') - { - *i = '\\'; - } - } - } + if(!cmSystemTools::GetForceUnixPaths()) + { + slash = "\\"; + for(std::string::iterator i = components[0].begin(); + i != components[0].end(); ++i) + { + if(*i == '/') + { + *i = '\\'; + } + } + } #endif - // Begin the quoted result with the root component. - std::string result = "\""; - result += components[0]; + // Begin the quoted result with the root component. + result += components[0]; - // Now add the rest of the components separated by the proper slash - // direction for this platform. - bool first = true; - for(unsigned int i=1; i < components.size(); ++i) - { - // Only the last component can be empty to avoid double slashes. - if(components[i].length() > 0 || (i == (components.size()-1))) + // Now add the rest of the components separated by the proper slash + // direction for this platform. + bool first = true; + for(unsigned int i=1; i < components.size(); ++i) { - if(!first) + // Only the last component can be empty to avoid double slashes. + if(components[i].length() > 0 || (i == (components.size()-1))) { - result += slash; + if(!first) + { + result += slash; + } + result += components[i]; + first = false; } - result += components[i]; - first = false; } } -- cgit v0.12 From 423009c17f50f837bca178a2cc5edfd62963f1ea Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 25 Mar 2014 07:17:45 +0100 Subject: Makefile: Generate single-quoted object lists for Watcom Drop the CMAKE_NO_QUOTED_OBJECTS internal variable from the Makefile generators. The underlying problem is with the Watcom linker, not with WMake. The Watcom linker wants object files to be single-quoted. Add _USE_WATCOM_QUOTE platform information variables to tell the generators to use Watcom-style single quotes for object files on link lines. On Windows, Watcom uses the GetCommandLine API to get the original command-line string and do custom parsing that expects single quotes. On POSIX systems, Watcom approximates the original command line by joining all argv[] entries separated by a single space. Therefore we need to double-quote the single-quoted arguments so that the shell does not consume them and they are available for the parser to see. --- Modules/Platform/Windows-wcl386.cmake | 5 ++++ Source/cmGlobalWatcomWMakeGenerator.cxx | 1 - Source/cmLocalUnixMakefileGenerator3.cxx | 30 ++++++++++++++++++-- Source/cmLocalUnixMakefileGenerator3.h | 3 +- Source/cmMakefileExecutableTargetGenerator.cxx | 4 ++- Source/cmMakefileLibraryTargetGenerator.cxx | 5 +++- Source/cmMakefileTargetGenerator.cxx | 39 ++++++++------------------ Source/cmMakefileTargetGenerator.h | 6 ++-- 8 files changed, 57 insertions(+), 36 deletions(-) diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake index 6b1cfd1..617761b 100644 --- a/Modules/Platform/Windows-wcl386.cmake +++ b/Modules/Platform/Windows-wcl386.cmake @@ -39,6 +39,11 @@ set (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-br -bm -d2 -ot -dNDEBUG") set (CMAKE_C_STANDARD_LIBRARIES_INIT "library clbrdll.lib library plbrdll.lib library kernel32.lib library user32.lib library gdi32.lib library winspool.lib library comdlg32.lib library advapi32.lib library shell32.lib library ole32.lib library oleaut32.lib library uuid.lib library odbc32.lib library odbccp32.lib") set (CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") +foreach(type CREATE_SHARED_LIBRARY CREATE_SHARED_MODULE LINK_EXECUTABLE) + set(CMAKE_C_${type}_USE_WATCOM_QUOTE 1) + set(CMAKE_CXX_${type}_USE_WATCOM_QUOTE 1) +endforeach() + set(CMAKE_C_CREATE_IMPORT_LIBRARY "wlib -c -q -n -b +") set(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY}) diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx index 0ae1b34..e44ed79 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.cxx +++ b/Source/cmGlobalWatcomWMakeGenerator.cxx @@ -35,7 +35,6 @@ void cmGlobalWatcomWMakeGenerator mf->AddDefinition("CMAKE_MANGLE_OBJECT_FILE_NAMES", "1"); mf->AddDefinition("CMAKE_MAKE_LINE_CONTINUE", "&"); mf->AddDefinition("CMAKE_MAKE_SYMBOLIC_RULE", ".SYMBOLIC"); - mf->AddDefinition("CMAKE_NO_QUOTED_OBJECTS", "1"); mf->AddDefinition("CMAKE_GENERATOR_CC", "wcl386"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "wcl386"); this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 8fa14d2..ff173f5 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -2181,14 +2181,27 @@ cmLocalUnixMakefileGenerator3 //---------------------------------------------------------------------------- std::string -cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p) +cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p, + bool useWatcomQuote) { // Split the path into its components. std::vector components; cmSystemTools::SplitPath(p, components); // Open the quoted result. - std::string result = "\""; + std::string result; + if(useWatcomQuote) + { +#if defined(_WIN32) && !defined(__CYGWIN__) + result = "'"; +#else + result = "\"'"; +#endif + } + else + { + result = "\""; + } // Return an empty path if there are no components. if(!components.empty()) @@ -2232,7 +2245,18 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p) } // Close the quoted result. - result += "\""; + if(useWatcomQuote) + { +#if defined(_WIN32) && !defined(__CYGWIN__) + result += "'"; +#else + result += "'\""; +#endif + } + else + { + result += "\""; + } return result; } diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 14543fb..99974ee 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -186,7 +186,8 @@ public: const char *targetDir, cmLocalGenerator::RelativeRoot returnDir); - static std::string ConvertToQuotedOutputPath(const char* p); + static std::string ConvertToQuotedOutputPath(const char* p, + bool useWatcomQuote); std::string CreateMakeVariable(const std::string& sin, const std::string& s2in); diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index a61005b..701d5a0 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -290,6 +290,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) linkRuleVar += linkLanguage; linkRuleVar += "_LINK_EXECUTABLE"; std::string linkRule = this->GetLinkRule(linkRuleVar); + bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE"); std::vector commands1; cmSystemTools::ExpandListArgument(linkRule, real_link_commands); if(this->Target->IsExecutableWithExports()) @@ -343,7 +344,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // rule. std::string buildObjs; this->CreateObjectLists(useLinkScript, false, - useResponseFileForObjects, buildObjs, depends); + useResponseFileForObjects, buildObjs, depends, + useWatcomQuote); cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_LINK"; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 02469d1..754f62f 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -458,6 +458,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules this->Target); } + bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE"); + // Determine whether a link script will be used. bool useLinkScript = this->GlobalGenerator->GetUseLinkScript(); @@ -553,7 +555,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // rule. std::string buildObjs; this->CreateObjectLists(useLinkScript, useArchiveRules, - useResponseFileForObjects, buildObjs, depends); + useResponseFileForObjects, buildObjs, depends, + useWatcomQuote); cmLocalGenerator::RuleVariables vars; vars.TargetPDB = targetOutPathPDB.c_str(); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 6759d05..b3d3f71 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1349,7 +1349,8 @@ cmMakefileTargetGenerator::AppendProgress(std::vector& commands) void cmMakefileTargetGenerator ::WriteObjectsVariable(std::string& variableName, - std::string& variableNameExternal) + std::string& variableNameExternal, + bool useWatcomQuote) { // Write a make variable assignment that lists all objects for the // target. @@ -1360,8 +1361,6 @@ cmMakefileTargetGenerator << "# Object files for target " << this->Target->GetName() << "\n" << variableName << " ="; std::string object; - const char* objName = - this->Makefile->GetDefinition("CMAKE_NO_QUOTED_OBJECTS"); const char* lineContinue = this->Makefile->GetDefinition("CMAKE_MAKE_LINE_CONTINUE"); if(!lineContinue) @@ -1372,17 +1371,9 @@ cmMakefileTargetGenerator i != this->Objects.end(); ++i) { *this->BuildFileStream << " " << lineContinue << "\n"; - if(objName) - { - *this->BuildFileStream << - this->Convert(*i, cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::MAKEFILE); - } - else - { - *this->BuildFileStream << - this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str()); - } + *this->BuildFileStream << + this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str(), + useWatcomQuote); } *this->BuildFileStream << "\n"; @@ -1404,17 +1395,9 @@ cmMakefileTargetGenerator *this->BuildFileStream << " " << lineContinue << "\n" << this->Makefile->GetSafeDefinition("CMAKE_OBJECT_NAME"); - if(objName) - { - *this->BuildFileStream << - this->Convert(*i, cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::MAKEFILE); - } - else - { - *this->BuildFileStream << - this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str()); - } + *this->BuildFileStream << + this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str(), + useWatcomQuote); } *this->BuildFileStream << "\n" << "\n"; } @@ -1882,11 +1865,13 @@ void cmMakefileTargetGenerator ::CreateObjectLists(bool useLinkScript, bool useArchiveRules, bool useResponseFile, std::string& buildObjs, - std::vector& makefile_depends) + std::vector& makefile_depends, + bool useWatcomQuote) { std::string variableName; std::string variableNameExternal; - this->WriteObjectsVariable(variableName, variableNameExternal); + this->WriteObjectsVariable(variableName, variableNameExternal, + useWatcomQuote); if(useResponseFile) { // MSVC response files cannot exceed 128K. diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 7ff6da9..ff94660 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -113,7 +113,8 @@ protected: // write out the variable that lists the objects for this target void WriteObjectsVariable(std::string& variableName, - std::string& variableNameExternal); + std::string& variableNameExternal, + bool useWatcomQuote); void WriteObjectsString(std::string& buildObjs); void WriteObjectsStrings(std::vector& objStrings, std::string::size_type limit = std::string::npos); @@ -172,7 +173,8 @@ protected: /** Create lists of object files for linking and cleaning. */ void CreateObjectLists(bool useLinkScript, bool useArchiveRules, bool useResponseFile, std::string& buildObjs, - std::vector& makefile_depends); + std::vector& makefile_depends, + bool useWatcomQuote); void AddIncludeFlags(std::string& flags, const std::string& lang); -- cgit v0.12 From cab2e31443a38b1023ec46eb99759a4be941fea0 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 28 Mar 2014 00:01:05 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 03391c0..00ab3fe 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 0) -set(CMake_VERSION_PATCH 20140327) +set(CMake_VERSION_PATCH 20140328) #set(CMake_VERSION_RC 1) -- cgit v0.12 From c3e238dd538322268a4475ac4454b35fe39a134e Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 28 Mar 2014 17:59:31 +0100 Subject: ProcessorCount: use mpsched on HPUX if machinfo is not present Co-Author: Gerhard Grimm --- Modules/ProcessorCount.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake index 0fe0b32..e034a28 100644 --- a/Modules/ProcessorCount.cmake +++ b/Modules/ProcessorCount.cmake @@ -104,6 +104,18 @@ function(ProcessorCount var) string(REGEX MATCHALL "Number of CPUs = ([0-9]+)" procs "${machinfo_output}") set(count "${CMAKE_MATCH_1}") #message("ProcessorCount: trying machinfo '${ProcessorCount_cmd_machinfo}'") + else() + find_program(ProcessorCount_cmd_mpsched mpsched) + mark_as_advanced(ProcessorCount_cmd_mpsched) + if(ProcessorCount_cmd_mpsched) + execute_process(COMMAND ${ProcessorCount_cmd_mpsched} -s + OUTPUT_QUIET + ERROR_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE mpsched_output) + string(REGEX MATCHALL "Processor Count *: *([0-9]+)" procs "${mpsched_output}") + set(count "${CMAKE_MATCH_1}") + #message("ProcessorCount: trying mpsched -s '${ProcessorCount_cmd_mpsched}'") + endif() endif() endif() -- cgit v0.12 From 5bad8ae342a7f1134fe3bb1ad3f2cc9852679124 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 29 Mar 2014 00:01:05 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 00ab3fe..62b1bae 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 0) -set(CMake_VERSION_PATCH 20140328) +set(CMake_VERSION_PATCH 20140329) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 4c0cc9ab9195d348ea5f1b004789ec334531bbb1 Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Sat, 29 Mar 2014 20:12:27 -0600 Subject: Check*.cmake : Add CMAKE_REQUIRED_QUIET flag. Setting this flag can silence messages from the Check*.cmake modules. This can be used by Find*.cmake modules when they are in silent mode. --- Modules/CMakePushCheckState.cmake | 3 +++ Modules/CheckCSourceCompiles.cmake | 13 ++++++++++--- Modules/CheckCSourceRuns.cmake | 13 ++++++++++--- Modules/CheckCXXSourceCompiles.cmake | 13 ++++++++++--- Modules/CheckCXXSourceRuns.cmake | 13 ++++++++++--- Modules/CheckCXXSymbolExists.cmake | 1 + Modules/CheckFunctionExists.cmake | 13 ++++++++++--- Modules/CheckIncludeFile.cmake | 13 ++++++++++--- Modules/CheckIncludeFileCXX.cmake | 13 ++++++++++--- Modules/CheckIncludeFiles.cmake | 13 ++++++++++--- Modules/CheckLibraryExists.cmake | 13 ++++++++++--- Modules/CheckPrototypeDefinition.cmake | 9 +++++++-- Modules/CheckStructHasMember.cmake | 1 + Modules/CheckSymbolExists.cmake | 13 ++++++++++--- Modules/CheckTypeSize.cmake | 13 ++++++++++--- Modules/CheckVariableExists.cmake | 13 ++++++++++--- 16 files changed, 132 insertions(+), 38 deletions(-) diff --git a/Modules/CMakePushCheckState.cmake b/Modules/CMakePushCheckState.cmake index 39f0023..bf4ec0e 100644 --- a/Modules/CMakePushCheckState.cmake +++ b/Modules/CMakePushCheckState.cmake @@ -53,6 +53,7 @@ macro(CMAKE_RESET_CHECK_STATE) set(CMAKE_REQUIRED_DEFINITIONS) set(CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_QUIET) endmacro() @@ -68,6 +69,7 @@ macro(CMAKE_PUSH_CHECK_STATE) set(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS}) set(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES}) set(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS}) + set(_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_QUIET}) if (ARGC GREATER 0 AND ARGV0 STREQUAL "RESET") cmake_reset_check_state() @@ -84,6 +86,7 @@ macro(CMAKE_POP_CHECK_STATE) set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) set(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_QUIET ${_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1") endif() diff --git a/Modules/CheckCSourceCompiles.cmake b/Modules/CheckCSourceCompiles.cmake index c2f6915..8721d55 100644 --- a/Modules/CheckCSourceCompiles.cmake +++ b/Modules/CheckCSourceCompiles.cmake @@ -21,6 +21,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2005-2009 Kitware, Inc. @@ -67,7 +68,9 @@ macro(CHECK_C_SOURCE_COMPILES SOURCE VAR) file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c" "${SOURCE}\n") - message(STATUS "Performing Test ${VAR}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR}") + endif() try_compile(${VAR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c @@ -85,13 +88,17 @@ macro(CHECK_C_SOURCE_COMPILES SOURCE VAR) if(${VAR}) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") - message(STATUS "Performing Test ${VAR} - Success") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Success") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n" "${OUTPUT}\n" "Source file was:\n${SOURCE}\n") else() - message(STATUS "Performing Test ${VAR} - Failed") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Failed") + endif() set(${VAR} "" CACHE INTERNAL "Test ${VAR}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing C SOURCE FILE Test ${VAR} failed with the following output:\n" diff --git a/Modules/CheckCSourceRuns.cmake b/Modules/CheckCSourceRuns.cmake index 2e68454..a4fa57e 100644 --- a/Modules/CheckCSourceRuns.cmake +++ b/Modules/CheckCSourceRuns.cmake @@ -21,6 +21,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2006-2009 Kitware, Inc. @@ -56,7 +57,9 @@ macro(CHECK_C_SOURCE_RUNS SOURCE VAR) file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c" "${SOURCE}\n") - message(STATUS "Performing Test ${VAR}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR}") + endif() try_run(${VAR}_EXITCODE ${VAR}_COMPILED ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c @@ -73,7 +76,9 @@ macro(CHECK_C_SOURCE_RUNS SOURCE VAR) # if the return value was 0 then it worked if("${${VAR}_EXITCODE}" EQUAL 0) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") - message(STATUS "Performing Test ${VAR} - Success") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Success") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n" "${OUTPUT}\n" @@ -86,7 +91,9 @@ macro(CHECK_C_SOURCE_RUNS SOURCE VAR) set(${VAR} "" CACHE INTERNAL "Test ${VAR}") endif() - message(STATUS "Performing Test ${VAR} - Failed") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Failed") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing C SOURCE FILE Test ${VAR} failed with the following output:\n" "${OUTPUT}\n" diff --git a/Modules/CheckCXXSourceCompiles.cmake b/Modules/CheckCXXSourceCompiles.cmake index c7ef5ec..6ce64a1 100644 --- a/Modules/CheckCXXSourceCompiles.cmake +++ b/Modules/CheckCXXSourceCompiles.cmake @@ -21,6 +21,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2005-2009 Kitware, Inc. @@ -68,7 +69,9 @@ macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR) file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx" "${SOURCE}\n") - message(STATUS "Performing Test ${VAR}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR}") + endif() try_compile(${VAR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx @@ -86,13 +89,17 @@ macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR) if(${VAR}) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") - message(STATUS "Performing Test ${VAR} - Success") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Success") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing C++ SOURCE FILE Test ${VAR} succeded with the following output:\n" "${OUTPUT}\n" "Source file was:\n${SOURCE}\n") else() - message(STATUS "Performing Test ${VAR} - Failed") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Failed") + endif() set(${VAR} "" CACHE INTERNAL "Test ${VAR}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing C++ SOURCE FILE Test ${VAR} failed with the following output:\n" diff --git a/Modules/CheckCXXSourceRuns.cmake b/Modules/CheckCXXSourceRuns.cmake index 4e3ff6c..c655863 100644 --- a/Modules/CheckCXXSourceRuns.cmake +++ b/Modules/CheckCXXSourceRuns.cmake @@ -21,6 +21,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2006-2009 Kitware, Inc. @@ -56,7 +57,9 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR) file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx" "${SOURCE}\n") - message(STATUS "Performing Test ${VAR}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR}") + endif() try_run(${VAR}_EXITCODE ${VAR}_COMPILED ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx @@ -74,7 +77,9 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR) # if the return value was 0 then it worked if("${${VAR}_EXITCODE}" EQUAL 0) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") - message(STATUS "Performing Test ${VAR} - Success") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Success") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing C++ SOURCE FILE Test ${VAR} succeded with the following output:\n" "${OUTPUT}\n" @@ -87,7 +92,9 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR) set(${VAR} "" CACHE INTERNAL "Test ${VAR}") endif() - message(STATUS "Performing Test ${VAR} - Failed") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Failed") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing C++ SOURCE FILE Test ${VAR} failed with the following output:\n" "${OUTPUT}\n" diff --git a/Modules/CheckCXXSymbolExists.cmake b/Modules/CheckCXXSymbolExists.cmake index aa62fbf..084fbb4 100644 --- a/Modules/CheckCXXSymbolExists.cmake +++ b/Modules/CheckCXXSymbolExists.cmake @@ -27,6 +27,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2003-2011 Kitware, Inc. diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake index e232bd7..bfd1836 100644 --- a/Modules/CheckFunctionExists.cmake +++ b/Modules/CheckFunctionExists.cmake @@ -20,6 +20,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2002-2011 Kitware, Inc. @@ -40,7 +41,9 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) if("${VARIABLE}" MATCHES "^${VARIABLE}$") set(MACRO_CHECK_FUNCTION_DEFINITIONS "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}") - message(STATUS "Looking for ${FUNCTION}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${FUNCTION}") + endif() if(CMAKE_REQUIRED_LIBRARIES) set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) @@ -63,12 +66,16 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) OUTPUT_VARIABLE OUTPUT) if(${VARIABLE}) set(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}") - message(STATUS "Looking for ${FUNCTION} - found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${FUNCTION} - found") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the function ${FUNCTION} exists passed with the following output:\n" "${OUTPUT}\n\n") else() - message(STATUS "Looking for ${FUNCTION} - not found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${FUNCTION} - not found") + endif() set(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the function ${FUNCTION} exists failed with the following output:\n" diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake index 9dc1648..ea73267 100644 --- a/Modules/CheckIncludeFile.cmake +++ b/Modules/CheckIncludeFile.cmake @@ -24,6 +24,7 @@ # CMAKE_REQUIRED_FLAGS = string of compile command line flags # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2002-2009 Kitware, Inc. @@ -49,7 +50,9 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE) set(CHECK_INCLUDE_FILE_VAR ${INCLUDE}) configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.c.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.c) - message(STATUS "Looking for ${INCLUDE}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${INCLUDE}") + endif() if(${ARGC} EQUAL 3) set(CMAKE_C_FLAGS_SAVE ${CMAKE_C_FLAGS}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARGV2}") @@ -69,14 +72,18 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE) endif() if(${VARIABLE}) - message(STATUS "Looking for ${INCLUDE} - found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${INCLUDE} - found") + endif() set(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the include file ${INCLUDE} " "exists passed with the following output:\n" "${OUTPUT}\n\n") else() - message(STATUS "Looking for ${INCLUDE} - not found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${INCLUDE} - not found") + endif() set(${VARIABLE} "" CACHE INTERNAL "Have include ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the include file ${INCLUDE} " diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake index fa36a3f..39abeff 100644 --- a/Modules/CheckIncludeFileCXX.cmake +++ b/Modules/CheckIncludeFileCXX.cmake @@ -28,6 +28,7 @@ # CMAKE_REQUIRED_FLAGS = string of compile command line flags # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2002-2009 Kitware, Inc. @@ -53,7 +54,9 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) set(CHECK_INCLUDE_FILE_VAR ${INCLUDE}) configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx) - message(STATUS "Looking for C++ include ${INCLUDE}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for C++ include ${INCLUDE}") + endif() if(${ARGC} EQUAL 3) set(CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGV2}") @@ -73,14 +76,18 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) endif() if(${VARIABLE}) - message(STATUS "Looking for C++ include ${INCLUDE} - found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for C++ include ${INCLUDE} - found") + endif() set(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the include file ${INCLUDE} " "exists passed with the following output:\n" "${OUTPUT}\n\n") else() - message(STATUS "Looking for C++ include ${INCLUDE} - not found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for C++ include ${INCLUDE} - not found") + endif() set(${VARIABLE} "" CACHE INTERNAL "Have include ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the include file ${INCLUDE} " diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake index 182067f..6aa0f2b 100644 --- a/Modules/CheckIncludeFiles.cmake +++ b/Modules/CheckIncludeFiles.cmake @@ -23,6 +23,7 @@ # CMAKE_REQUIRED_FLAGS = string of compile command line flags # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2003-2012 Kitware, Inc. @@ -66,7 +67,9 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) set(_description "include file ${_INCLUDE}") endif() - message(STATUS "Looking for ${_description}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${_description}") + endif() try_compile(${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFiles.c @@ -76,14 +79,18 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) "${CHECK_INCLUDE_FILES_INCLUDE_DIRS}" OUTPUT_VARIABLE OUTPUT) if(${VARIABLE}) - message(STATUS "Looking for ${_description} - found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${_description} - found") + endif() set(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if files ${INCLUDE} " "exist passed with the following output:\n" "${OUTPUT}\n\n") else() - message(STATUS "Looking for ${_description} - not found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${_description} - not found") + endif() set(${VARIABLE} "" CACHE INTERNAL "Have includes ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if files ${INCLUDE} " diff --git a/Modules/CheckLibraryExists.cmake b/Modules/CheckLibraryExists.cmake index f5c563c..2b41379 100644 --- a/Modules/CheckLibraryExists.cmake +++ b/Modules/CheckLibraryExists.cmake @@ -23,6 +23,7 @@ # CMAKE_REQUIRED_FLAGS = string of compile command line flags # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2002-2009 Kitware, Inc. @@ -43,7 +44,9 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE) if("${VARIABLE}" MATCHES "^${VARIABLE}$") set(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}") - message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}") + endif() set(CHECK_LIBRARY_EXISTS_LIBRARIES ${LIBRARY}) if(CMAKE_REQUIRED_LIBRARIES) set(CHECK_LIBRARY_EXISTS_LIBRARIES @@ -60,14 +63,18 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE) OUTPUT_VARIABLE OUTPUT) if(${VARIABLE}) - message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - found") + endif() set(${VARIABLE} 1 CACHE INTERNAL "Have library ${LIBRARY}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the function ${FUNCTION} exists in the ${LIBRARY} " "passed with the following output:\n" "${OUTPUT}\n\n") else() - message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - not found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - not found") + endif() set(${VARIABLE} "" CACHE INTERNAL "Have library ${LIBRARY}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the function ${FUNCTION} exists in the ${LIBRARY} " diff --git a/Modules/CheckPrototypeDefinition.cmake b/Modules/CheckPrototypeDefinition.cmake index 25ea7f4..fe00074 100644 --- a/Modules/CheckPrototypeDefinition.cmake +++ b/Modules/CheckPrototypeDefinition.cmake @@ -33,6 +33,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2005-2009 Kitware, Inc. @@ -97,12 +98,16 @@ function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIAB if (${_VARIABLE}) set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}") - message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n" "${OUTPUT}\n\n") else () - message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False") + endif() set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} failed with the following output:\n" diff --git a/Modules/CheckStructHasMember.cmake b/Modules/CheckStructHasMember.cmake index a864e82..880a688 100644 --- a/Modules/CheckStructHasMember.cmake +++ b/Modules/CheckStructHasMember.cmake @@ -28,6 +28,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages # # # diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake index e1ca412..bf2e797 100644 --- a/Modules/CheckSymbolExists.cmake +++ b/Modules/CheckSymbolExists.cmake @@ -28,6 +28,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2003-2011 Kitware, Inc. @@ -74,7 +75,9 @@ macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE) configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" "${SOURCEFILE}" @ONLY) - message(STATUS "Looking for ${SYMBOL}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${SYMBOL}") + endif() try_compile(${VARIABLE} ${CMAKE_BINARY_DIR} "${SOURCEFILE}" @@ -85,7 +88,9 @@ macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE) "${CMAKE_SYMBOL_EXISTS_INCLUDES}" OUTPUT_VARIABLE OUTPUT) if(${VARIABLE}) - message(STATUS "Looking for ${SYMBOL} - found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${SYMBOL} - found") + endif() set(${VARIABLE} 1 CACHE INTERNAL "Have symbol ${SYMBOL}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the ${SYMBOL} " @@ -93,7 +98,9 @@ macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE) "${OUTPUT}\nFile ${SOURCEFILE}:\n" "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") else() - message(STATUS "Looking for ${SYMBOL} - not found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${SYMBOL} - not found") + endif() set(${VARIABLE} "" CACHE INTERNAL "Have symbol ${SYMBOL}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the ${SYMBOL} " diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index 333b325..d4651b9 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -59,6 +59,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages # CMAKE_EXTRA_INCLUDE_FILES = list of extra headers to include #============================================================================= @@ -85,7 +86,9 @@ get_filename_component(__check_type_size_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) #----------------------------------------------------------------------------- # Helper function. DO NOT CALL DIRECTLY. function(__check_type_size_impl type var map builtin language) - message(STATUS "Check size of ${type}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Check size of ${type}") + endif() # Include header files. set(headers) @@ -169,13 +172,17 @@ function(__check_type_size_impl type var map builtin language) message(SEND_ERROR "CHECK_TYPE_SIZE found different results, consider setting CMAKE_OSX_ARCHITECTURES or CMAKE_TRY_COMPILE_OSX_ARCHITECTURES to one or no architecture !") endif() - message(STATUS "Check size of ${type} - done") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Check size of ${type} - done") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining size of ${type} passed with the following output:\n${output}\n\n") set(${var} "${${var}}" CACHE INTERNAL "CHECK_TYPE_SIZE: sizeof(${type})") else() # The check failed to compile. - message(STATUS "Check size of ${type} - failed") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Check size of ${type} - failed") + endif() file(READ ${src} content) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining size of ${type} failed with the following output:\n${output}\n${src}:\n${content}\n\n") diff --git a/Modules/CheckVariableExists.cmake b/Modules/CheckVariableExists.cmake index 4861ff0..3a7ef13 100644 --- a/Modules/CheckVariableExists.cmake +++ b/Modules/CheckVariableExists.cmake @@ -27,6 +27,7 @@ # CMAKE_REQUIRED_FLAGS = string of compile command line flags # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2002-2009 Kitware, Inc. @@ -47,7 +48,9 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE) if("${VARIABLE}" MATCHES "^${VARIABLE}$") set(MACRO_CHECK_VARIABLE_DEFINITIONS "-DCHECK_VARIABLE_EXISTS=${VAR} ${CMAKE_REQUIRED_FLAGS}") - message(STATUS "Looking for ${VAR}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${VAR}") + endif() if(CMAKE_REQUIRED_LIBRARIES) set(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) @@ -63,13 +66,17 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE) OUTPUT_VARIABLE OUTPUT) if(${VARIABLE}) set(${VARIABLE} 1 CACHE INTERNAL "Have variable ${VAR}") - message(STATUS "Looking for ${VAR} - found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${VAR} - found") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the variable ${VAR} exists passed with the following output:\n" "${OUTPUT}\n\n") else() set(${VARIABLE} "" CACHE INTERNAL "Have variable ${VAR}") - message(STATUS "Looking for ${VAR} - not found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${VAR} - not found") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the variable ${VAR} exists failed with the following output:\n" "${OUTPUT}\n\n") -- cgit v0.12 From 83934757c942672d8bea79f11e51a184b168a212 Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Sat, 29 Mar 2014 20:22:54 -0600 Subject: Find*: Make find_package(.. QUIET) affect Check* modules. Fixes issues #14812 and #14813 where find_package(OpenMP QUIET) and find_package(Qt4 QUIET) would still print out messages when calling check*() functions. Also a partial fix for #14445 where building CMake (without cmake-gui) when Qt5 is installed and Qt4 is not installed and warnings come out of FindQt4.cmake. --- Modules/FindBLAS.cmake | 4 ++++ Modules/FindBZip2.cmake | 4 ++++ Modules/FindBacktrace.cmake | 1 + Modules/FindCups.cmake | 4 ++++ Modules/FindCurses.cmake | 4 ++++ Modules/FindGIF.cmake | 1 + Modules/FindLAPACK.cmake | 5 +++++ Modules/FindLibLZMA.cmake | 3 +++ Modules/FindOpenCL.cmake | 1 + Modules/FindOpenMP.cmake | 12 ++++++++++-- Modules/FindQt4.cmake | 20 +++++++++++--------- Modules/FindThreads.cmake | 3 +++ Modules/FindX11.cmake | 3 +++ 13 files changed, 54 insertions(+), 11 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 3b658ef..1cf9124 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -52,6 +52,9 @@ include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) +cmake_push_check_state() +set(CMAKE_REQUIRED_QUIET ${BLAS_FIND_QUIETLY}) set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) @@ -687,4 +690,5 @@ else() endif() endif() +cmake_pop_check_state() set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake index 3883877..b479332 100644 --- a/Modules/FindBZip2.cmake +++ b/Modules/FindBZip2.cmake @@ -57,7 +57,11 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(BZip2 if (BZIP2_FOUND) include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) + cmake_push_check_state() + set(CMAKE_REQUIRED_QUIET ${BZip2_FIND_QUIETLY}) CHECK_LIBRARY_EXISTS("${BZIP2_LIBRARIES}" BZ2_bzCompressInit "" BZIP2_NEED_PREFIX) + cmake_pop_check_state() endif () mark_as_advanced(BZIP2_INCLUDE_DIR) diff --git a/Modules/FindBacktrace.cmake b/Modules/FindBacktrace.cmake index 83789cc..5620661 100644 --- a/Modules/FindBacktrace.cmake +++ b/Modules/FindBacktrace.cmake @@ -62,6 +62,7 @@ if (NOT DEFINED Backtrace_LIBRARY) # First, check if we already have backtrace(), e.g., in libc cmake_push_check_state(RESET) set(CMAKE_REQUIRED_INCLUDES ${Backtrace_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_QUIET ${Backtrace_FIND_QUIETLY}) check_symbol_exists("backtrace" "${_Backtrace_HEADER_TRY}" _Backtrace_SYM_FOUND) cmake_pop_check_state() endif() diff --git a/Modules/FindCups.cmake b/Modules/FindCups.cmake index 4b55d6a..61353ca 100644 --- a/Modules/FindCups.cmake +++ b/Modules/FindCups.cmake @@ -36,9 +36,13 @@ find_library(CUPS_LIBRARIES NAMES cups ) if (CUPS_INCLUDE_DIR AND CUPS_LIBRARIES AND CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE) include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) + cmake_push_check_state() + set(CMAKE_REQUIRED_QUIET ${Cups_FIND_QUIETLY}) # ippDeleteAttribute is new in cups-1.1.19 (and used by kdeprint) CHECK_LIBRARY_EXISTS(cups ippDeleteAttribute "" CUPS_HAS_IPP_DELETE_ATTRIBUTE) + cmake_pop_check_state() endif () if (CUPS_INCLUDE_DIR AND EXISTS "${CUPS_INCLUDE_DIR}/cups/cups.h") diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake index 971edb7..fa420c1 100644 --- a/Modules/FindCurses.cmake +++ b/Modules/FindCurses.cmake @@ -67,6 +67,9 @@ endif() # default search paths. if(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES) include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) + cmake_push_check_state() + set(CMAKE_REQUIRED_QUIET ${Curses_FIND_QUIETLY}) CHECK_LIBRARY_EXISTS("${CURSES_CURSES_LIBRARY}" wsyncup "" CURSES_CURSES_HAS_WSYNCUP) @@ -77,6 +80,7 @@ if(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES) set(CURSES_USE_NCURSES TRUE) endif() endif() + cmake_pop_check_state() endif() diff --git a/Modules/FindGIF.cmake b/Modules/FindGIF.cmake index 117ded7..7bbb8cf 100644 --- a/Modules/FindGIF.cmake +++ b/Modules/FindGIF.cmake @@ -66,6 +66,7 @@ if(GIF_INCLUDE_DIR) include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) include(${CMAKE_CURRENT_LIST_DIR}/CheckStructHasMember.cmake) CMAKE_PUSH_CHECK_STATE() + set(CMAKE_REQUIRED_QUIET ${GIF_FIND_QUIETLY}) set(GIF_VERSION 3) set(CMAKE_REQUIRED_INCLUDES "${GIF_INCLUDE_DIR}") CHECK_STRUCT_HAS_MEMBER(GifFileType UserData gif_lib.h GIF_GifFileType_UserData ) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 69da4cd..33f4f0c 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -54,6 +54,10 @@ include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) else () include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake) endif () +include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) + +cmake_push_check_state() +set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY}) set(LAPACK_FOUND FALSE) set(LAPACK95_FOUND FALSE) @@ -347,4 +351,5 @@ else() endif() endif() +cmake_pop_check_state() set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) diff --git a/Modules/FindLibLZMA.cmake b/Modules/FindLibLZMA.cmake index be01594..742b851 100644 --- a/Modules/FindLibLZMA.cmake +++ b/Modules/FindLibLZMA.cmake @@ -55,9 +55,12 @@ endif() # Avoid using old codebase if (LIBLZMA_LIBRARY) include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) + set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) + set(CMAKE_REQUIRED_QUIET ${LibLZMA_FIND_QUIETLY}) CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_auto_decoder "" LIBLZMA_HAS_AUTO_DECODER) CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_easy_encoder "" LIBLZMA_HAS_EASY_ENCODER) CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_lzma_preset "" LIBLZMA_HAS_LZMA_PRESET) + set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) endif () include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) diff --git a/Modules/FindOpenCL.cmake b/Modules/FindOpenCL.cmake index eee06bf..b5eed9a 100644 --- a/Modules/FindOpenCL.cmake +++ b/Modules/FindOpenCL.cmake @@ -35,6 +35,7 @@ function(_FIND_OPENCL_VERSION) include(CheckSymbolExists) include(CMakePushCheckState) + set(CMAKE_REQUIRED_QUIET ${OpenCL_FIND_QUIETLY}) CMAKE_PUSH_CHECK_STATE() foreach(VERSION "2_0" "1_2" "1_1" "1_0") diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index fead4a6..30972ae 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -39,6 +39,8 @@ # License text for the above reference.) set(_OPENMP_REQUIRED_VARS) +set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) +set(CMAKE_REQUIRED_QUIET ${OpenMP_FIND_QUIETLY}) function(_OPENMP_FLAG_CANDIDATES LANG) set(OpenMP_FLAG_CANDIDATES @@ -116,7 +118,9 @@ if(CMAKE_C_COMPILER_LOADED) set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") set(CMAKE_REQUIRED_FLAGS "${FLAG}") unset(OpenMP_FLAG_DETECTED CACHE) - message(STATUS "Try OpenMP C flag = [${FLAG}]") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Try OpenMP C flag = [${FLAG}]") + endif() check_c_source_compiles("${OpenMP_C_TEST_SOURCE}" OpenMP_FLAG_DETECTED) set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}") if(OpenMP_FLAG_DETECTED) @@ -150,7 +154,9 @@ if(CMAKE_CXX_COMPILER_LOADED) set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") set(CMAKE_REQUIRED_FLAGS "${FLAG}") unset(OpenMP_FLAG_DETECTED CACHE) - message(STATUS "Try OpenMP CXX flag = [${FLAG}]") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Try OpenMP CXX flag = [${FLAG}]") + endif() check_cxx_source_compiles("${OpenMP_CXX_TEST_SOURCE}" OpenMP_FLAG_DETECTED) set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}") if(OpenMP_FLAG_DETECTED) @@ -167,6 +173,8 @@ if(CMAKE_CXX_COMPILER_LOADED) unset(OpenMP_CXX_TEST_SOURCE) endif() +set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) + if(_OPENMP_REQUIRED_VARS) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index d0515c6..e44d1d9 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -335,6 +335,7 @@ endif() include(${CMAKE_CURRENT_LIST_DIR}/CheckCXXSymbolExists.cmake) include(${CMAKE_CURRENT_LIST_DIR}/MacroAddFileDependencies.cmake) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) set(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake) @@ -613,9 +614,13 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) set(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE INTERNAL "Qt library dir" FORCE) set(QT_QTCORE_FOUND 1) else() - message(WARNING "${QT_QMAKE_EXECUTABLE} reported QT_INSTALL_LIBS as \"${QT_LIBRARY_DIR_TMP}\" " - "but QtCore could not be found there. " - "Qt is NOT installed correctly for the target build environment.") + if(NOT Qt4_FIND_QUIETLY) + message(WARNING + "${QT_QMAKE_EXECUTABLE} reported QT_INSTALL_LIBS as " + "\"${QT_LIBRARY_DIR_TMP}\" " + "but QtCore could not be found there. " + "Qt is NOT installed correctly for the target build environment.") + endif() set(Qt4_FOUND FALSE) if(Qt4_FIND_REQUIRED) message( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.") @@ -747,11 +752,10 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) # Find out what window system we're using # ############################################# - # Save required variable - set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) - set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) + cmake_push_check_state() # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}") + set(CMAKE_REQUIRED_QUIET ${Qt4_FIND_QUIETLY}) # Check for Window system symbols (note: only one should end up being set) CHECK_CXX_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11) CHECK_CXX_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN) @@ -771,9 +775,7 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) endif () endif () - # Restore CMAKE_REQUIRED_INCLUDES and CMAKE_REQUIRED_FLAGS variables - set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) - set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) + cmake_pop_check_state() # ############################################# diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index 7f84522..6d1c65d 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -37,6 +37,8 @@ include (CheckIncludeFiles) include (CheckLibraryExists) include (CheckSymbolExists) set(Threads_FOUND FALSE) +set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) +set(CMAKE_REQUIRED_QUIET ${Threads_FIND_QUIETLY}) # Do we have sproc? if(CMAKE_SYSTEM MATCHES IRIX AND NOT CMAKE_THREAD_PREFER_PTHREAD) @@ -173,5 +175,6 @@ if(CMAKE_USE_PTHREADS_INIT) endif() endif() +set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Threads DEFAULT_MSG Threads_FOUND) diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index 67cecc2..3a31cf0 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -73,6 +73,8 @@ if (UNIX) # found in tcl on the mac set(CMAKE_FIND_FRAMEWORK_SAVE ${CMAKE_FIND_FRAMEWORK}) set(CMAKE_FIND_FRAMEWORK NEVER) + set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) + set(CMAKE_REQUIRED_QUIET ${X11_FIND_QUIETLY}) set(X11_INC_SEARCH_PATH /usr/pkg/xorg/include /usr/X11R6/include @@ -507,6 +509,7 @@ if (UNIX) X11_XSync_INCLUDE_PATH ) set(CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_SAVE}) + set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) endif () # X11_FIND_REQUIRED_ could be checked too -- cgit v0.12 From 9298987a826dd8c71b02779145d5b9e3ebc30f4f Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 30 Mar 2014 00:01:06 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 62b1bae..94b8baf 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 0) -set(CMake_VERSION_PATCH 20140329) +set(CMake_VERSION_PATCH 20140330) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 480be00bfac0af72d373b5ef190ebc770a1bc7c1 Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Sat, 29 Mar 2014 22:39:43 -0600 Subject: cmake-gui: Don't resolve symlinks with using file dialog. This fixes bug #14274 where a clang++ symlink was resolved to a clang executable. --- Source/QtDialog/CMakeSetupDialog.cxx | 6 ++++-- Source/QtDialog/QCMakeWidgets.cxx | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index f62afd6..1a98cea 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -578,7 +578,8 @@ void CMakeSetupDialog::doInterrupt() void CMakeSetupDialog::doSourceBrowse() { QString dir = QFileDialog::getExistingDirectory(this, - tr("Enter Path to Source"), this->SourceDirectory->text()); + tr("Enter Path to Source"), this->SourceDirectory->text(), + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); if(!dir.isEmpty()) { this->setSourceDirectory(dir); @@ -608,7 +609,8 @@ void CMakeSetupDialog::updateBinaryDirectory(const QString& dir) void CMakeSetupDialog::doBinaryBrowse() { QString dir = QFileDialog::getExistingDirectory(this, - tr("Enter Path to Build"), this->BinaryDirectory->currentText()); + tr("Enter Path to Build"), this->BinaryDirectory->currentText(), + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); if(!dir.isEmpty() && dir != this->BinaryDirectory->currentText()) { this->setBinaryDirectory(dir); diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx index a0c5e17..41f98b5 100644 --- a/Source/QtDialog/QCMakeWidgets.cxx +++ b/Source/QtDialog/QCMakeWidgets.cxx @@ -67,7 +67,8 @@ void QCMakeFilePathEditor::chooseFile() title = title.arg(this->Variable); } this->fileDialogExists(true); - path = QFileDialog::getOpenFileName(this, title, info.absolutePath()); + path = QFileDialog::getOpenFileName(this, title, info.absolutePath(), + QString(), NULL, QFileDialog::DontResolveSymlinks); this->fileDialogExists(false); if(!path.isEmpty()) @@ -91,7 +92,8 @@ void QCMakePathEditor::chooseFile() title = title.arg(this->Variable); } this->fileDialogExists(true); - path = QFileDialog::getExistingDirectory(this, title, this->text()); + path = QFileDialog::getExistingDirectory(this, title, this->text(), + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); this->fileDialogExists(false); if(!path.isEmpty()) { -- cgit v0.12 From 521b930bf4e211735842e71f1eb0018c2184a05f Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 31 Mar 2014 00:01:05 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 94b8baf..4b27c72 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 0) -set(CMake_VERSION_PATCH 20140330) +set(CMake_VERSION_PATCH 20140331) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 8c9c4fe1a6d0c660c7e4e4c1af2cdf2e889fbfbd Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Fri, 28 Mar 2014 11:42:09 -0400 Subject: Remove 'return' statements that can never be reached Clang -Wunreachable-code-return warns otherwise. --- Source/CursesDialog/cmCursesOptionsWidget.cxx | 1 - Source/cmSystemTools.cxx | 1 - 2 files changed, 2 deletions(-) diff --git a/Source/CursesDialog/cmCursesOptionsWidget.cxx b/Source/CursesDialog/cmCursesOptionsWidget.cxx index 652b2df..d97c737 100644 --- a/Source/CursesDialog/cmCursesOptionsWidget.cxx +++ b/Source/CursesDialog/cmCursesOptionsWidget.cxx @@ -59,7 +59,6 @@ bool cmCursesOptionsWidget::HandleInput(int& key, cmCursesMainForm*, WINDOW* w) { return false; } - return false; } void cmCursesOptionsWidget::AddOption(std::string const & option ) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index ff05975..2f5f493 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1662,7 +1662,6 @@ long copy_data(struct archive *ar, struct archive *aw) return (r); } } - return r; } bool extract_tar(const char* outFileName, bool verbose, -- cgit v0.12 From beaa7e037761c734d7587b847d8af1ce3dce37d9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 18 Mar 2014 17:46:37 +0100 Subject: cmGeneratorTarget: Compute the object directory early. Ensure it is populated before tracing dependencies. --- Source/cmGlobalGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 5b6d729..07637b3 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1407,6 +1407,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(cmMakefile *mf) { cmTarget* t = &ti->second; cmGeneratorTarget* gt = new cmGeneratorTarget(t); + this->ComputeTargetObjectDirectory(gt); this->GeneratorTargets[t] = gt; generatorTargets[t] = gt; } @@ -1449,7 +1450,6 @@ void cmGlobalGenerator::ComputeGeneratorTargetObjects() continue; } cmGeneratorTarget* gt = ti->second; - this->ComputeTargetObjectDirectory(gt); gt->LookupObjectLibraries(); this->ComputeTargetObjects(gt); } -- cgit v0.12 From 99a9c51f1a65b58f366506929b3b82297809c1ca Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 12 Mar 2014 12:29:58 +0100 Subject: cmTarget: Use GetSourceFiles for languages. --- Source/cmTarget.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 17c8a4d..a7c4488 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4844,8 +4844,10 @@ bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, //---------------------------------------------------------------------------- void cmTarget::GetLanguages(std::set& languages) const { + std::vector sourceFiles; + this->GetSourceFiles(sourceFiles); for(std::vector::const_iterator - i = this->SourceFiles.begin(); i != this->SourceFiles.end(); ++i) + i = sourceFiles.begin(); i != sourceFiles.end(); ++i) { const std::string& lang = (*i)->GetLanguage(); if(!lang.empty()) -- cgit v0.12 From 0ed5ce4cd8cdd7613a5fa43c9a9fc48f210c90f6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 17 Mar 2014 16:54:11 +0100 Subject: cmTarget: Rename AddSource method for backward compatibility. Add a new AddSource method for future use. --- Source/cmGlobalXCodeGenerator.cxx | 4 ++-- Source/cmMakefile.cxx | 2 +- Source/cmTarget.cxx | 9 +++++++-- Source/cmTarget.h | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d4eb85b..f93fc12 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -412,7 +412,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, std::string listfile = mf->GetStartDirectory(); listfile += "/"; listfile += "CMakeLists.txt"; - allbuild->AddSource(listfile.c_str()); + allbuild->AddSourceCMP0049(listfile.c_str()); // Add XCODE depend helper std::string dir = mf->GetCurrentOutputDirectory(); @@ -495,7 +495,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, listfile = lg->GetMakefile()->GetStartDirectory(); listfile += "/"; listfile += "CMakeLists.txt"; - target.AddSource(listfile.c_str()); + target.AddSourceCMP0049(listfile.c_str()); } } } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index dce71de..1fcbcd7 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1266,7 +1266,7 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName, commandLines, comment, workingDirectory, no_replace, escapeOldStyle); - cmSourceFile* sf = target->AddSource(force); + cmSourceFile* sf = target->AddSourceCMP0049(force); // The output is not actually created so mark it symbolic. if(sf) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a7c4488..835aaad 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -587,13 +587,13 @@ void cmTarget::AddSources(std::vector const& srcs) } else { - this->AddSource(src); + this->AddSourceCMP0049(src); } } } //---------------------------------------------------------------------------- -cmSourceFile* cmTarget::AddSource(const std::string& s) +cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s) { std::string src = s; @@ -632,7 +632,12 @@ cmSourceFile* cmTarget::AddSource(const std::string& s) } } } + return this->AddSource(src); +} +//---------------------------------------------------------------------------- +cmSourceFile* cmTarget::AddSource(const std::string& src) +{ cmSourceFile* sf = this->Makefile->GetOrCreateSource(src); this->AddSourceFile(sf); return sf; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 3ef853b..e385443 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -146,6 +146,7 @@ public: * Add sources to the target. */ void AddSources(std::vector const& srcs); + cmSourceFile* AddSourceCMP0049(const std::string& src); cmSourceFile* AddSource(const std::string& src); enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED}; -- cgit v0.12 From b1cbba68ce44bf8d78a6e41ff465461f0abf83a9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 26 Feb 2014 13:26:05 +0100 Subject: cmSourceFileLocation: Make copyable and assignable. This allows using it in containers and algorithms. --- Source/cmSourceFileLocation.cxx | 41 +++++++++++++++++++++++++++++++++++++++++ Source/cmSourceFileLocation.h | 3 +++ 2 files changed, 44 insertions(+) diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index 30a53cb..3e78b29 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -16,6 +16,42 @@ #include "cmGlobalGenerator.h" #include "cmSystemTools.h" +#include "assert.h" + +//---------------------------------------------------------------------------- +cmSourceFileLocation::cmSourceFileLocation() + : Makefile(0), AmbiguousDirectory(true), AmbiguousExtension(true) +{ + +} + +//---------------------------------------------------------------------------- +cmSourceFileLocation::cmSourceFileLocation(const cmSourceFileLocation& loc) + : Makefile(loc.Makefile) +{ + this->AmbiguousDirectory = loc.AmbiguousDirectory; + this->AmbiguousExtension = loc.AmbiguousExtension; + this->Directory = loc.Directory; + this->Name = loc.Name; +} + +//---------------------------------------------------------------------------- +cmSourceFileLocation& +cmSourceFileLocation::operator=(const cmSourceFileLocation& loc) +{ + if(this == &loc) + { + return *this; + } + this->Makefile = loc.Makefile; + this->AmbiguousDirectory = loc.AmbiguousDirectory; + this->AmbiguousExtension = loc.AmbiguousExtension; + this->Directory = loc.Directory; + this->Name = loc.Name; + this->UpdateExtension(this->Name); + return *this; +} + //---------------------------------------------------------------------------- cmSourceFileLocation ::cmSourceFileLocation(cmMakefile const* mf, const std::string& name) @@ -59,6 +95,7 @@ void cmSourceFileLocation::Update(cmSourceFileLocation const& loc) //---------------------------------------------------------------------------- void cmSourceFileLocation::DirectoryUseSource() { + assert(this->Makefile); if(this->AmbiguousDirectory) { this->Directory = @@ -71,6 +108,7 @@ void cmSourceFileLocation::DirectoryUseSource() //---------------------------------------------------------------------------- void cmSourceFileLocation::DirectoryUseBinary() { + assert(this->Makefile); if(this->AmbiguousDirectory) { this->Directory = @@ -83,6 +121,7 @@ void cmSourceFileLocation::DirectoryUseBinary() //---------------------------------------------------------------------------- void cmSourceFileLocation::UpdateExtension(const std::string& name) { + assert(this->Makefile); // Check the extension. std::string ext = cmSystemTools::GetFilenameLastExtension(name); if(!ext.empty()) { ext = ext.substr(1); } @@ -152,6 +191,7 @@ bool cmSourceFileLocation ::MatchesAmbiguousExtension(cmSourceFileLocation const& loc) const { + assert(this->Makefile); // This location's extension is not ambiguous but loc's extension // is. See if the names match as-is. if(this->Name == loc.Name) @@ -188,6 +228,7 @@ cmSourceFileLocation //---------------------------------------------------------------------------- bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc) { + assert(this->Makefile); if(this->AmbiguousExtension && loc.AmbiguousExtension) { // Both extensions are ambiguous. Since only the old fixed set of diff --git a/Source/cmSourceFileLocation.h b/Source/cmSourceFileLocation.h index c83e8c0..82a62ab 100644 --- a/Source/cmSourceFileLocation.h +++ b/Source/cmSourceFileLocation.h @@ -34,6 +34,9 @@ public: * instance with an initial name. */ cmSourceFileLocation(cmMakefile const* mf, const std::string& name); + cmSourceFileLocation(); + cmSourceFileLocation(const cmSourceFileLocation& loc); + cmSourceFileLocation& operator=(const cmSourceFileLocation& loc); /** * Return whether the givne source file location could refers to the -- cgit v0.12 From d38423ecc4105d8339b7461130b964f3c69e8847 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 17 Mar 2014 17:49:38 +0100 Subject: cmTarget: Add a method to obtain list of filenames for sources. --- Source/cmGeneratorTarget.cxx | 24 ++++++++++++------------ Source/cmTarget.cxx | 14 ++++++++++++++ Source/cmTarget.h | 1 + 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b35e859..834f9fd 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -600,12 +600,12 @@ private: cmGlobalGenerator const* GlobalGenerator; typedef cmGeneratorTarget::SourceEntry SourceEntry; SourceEntry* CurrentEntry; - std::queue SourceQueue; - std::set SourcesQueued; + std::queue SourceQueue; + std::set SourcesQueued; typedef std::map NameMapType; NameMapType NameMap; - void QueueSource(cmSourceFile* sf); + void QueueSource(std::string const& name); void FollowName(std::string const& name); void FollowNames(std::vector const& names); bool IsUtility(std::string const& dep); @@ -628,11 +628,11 @@ cmTargetTraceDependencies this->CurrentEntry = 0; // Queue all the source files already specified for the target. - std::vector sources; if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) { + std::vector sources; this->Target->GetSourceFiles(sources); - for(std::vector::const_iterator si = sources.begin(); + for(std::vector::const_iterator si = sources.begin(); si != sources.end(); ++si) { this->QueueSource(*si); @@ -652,7 +652,8 @@ void cmTargetTraceDependencies::Trace() while(!this->SourceQueue.empty()) { // Get the next source from the queue. - cmSourceFile* sf = this->SourceQueue.front(); + std::string src = this->SourceQueue.front(); + cmSourceFile* sf = this->Makefile->GetSource(src); this->SourceQueue.pop(); this->CurrentEntry = &this->GeneratorTarget->SourceEntries[sf]; @@ -680,14 +681,14 @@ void cmTargetTraceDependencies::Trace() } //---------------------------------------------------------------------------- -void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf) +void cmTargetTraceDependencies::QueueSource(std::string const& name) { - if(this->SourcesQueued.insert(sf).second) + if(this->SourcesQueued.insert(name).second) { - this->SourceQueue.push(sf); + this->SourceQueue.push(name); // Make sure this file is in the target. - this->Target->AddSourceFile(sf); + this->Target->AddSource(name); } } @@ -709,8 +710,7 @@ void cmTargetTraceDependencies::FollowName(std::string const& name) { this->CurrentEntry->Depends.push_back(sf); } - - this->QueueSource(sf); + this->QueueSource(sf->GetFullPath()); } } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 835aaad..0866d10 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -542,6 +542,20 @@ bool cmTarget::IsBundleOnApple() const } //---------------------------------------------------------------------------- +void cmTarget::GetSourceFiles(std::vector &files) const +{ + assert(this->GetType() != INTERFACE_LIBRARY); + std::vector sourceFiles; + this->GetSourceFiles(sourceFiles); + for(std::vector::const_iterator + si = sourceFiles.begin(); + si != sourceFiles.end(); ++si) + { + files.push_back((*si)->GetFullPath()); + } +} + +//---------------------------------------------------------------------------- void cmTarget::GetSourceFiles(std::vector &files) const { assert(this->GetType() != INTERFACE_LIBRARY); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e385443..8df9bd8 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -135,6 +135,7 @@ public: /** * Get the list of the source files used by this target */ + void GetSourceFiles(std::vector &files) const; void GetSourceFiles(std::vector &files) const; void AddSourceFile(cmSourceFile* sf); std::vector const& GetObjectLibraries() const -- cgit v0.12 From 26d494ba01809553e335cca4f925d14dab2c50f7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 12 Mar 2014 12:45:14 +0100 Subject: cmTarget: Use string API to add sources to cmTarget objects. Continue to call GetOrCreateSource where necessary to create cmSourceFile objects which have the GENERATED attribute set. --- Source/cmFLTKWrapUICommand.cxx | 2 +- Source/cmGlobalVisualStudio8Generator.cxx | 3 ++- Source/cmGlobalXCodeGenerator.cxx | 6 +++--- Source/cmLocalGenerator.cxx | 4 ++-- Source/cmLocalVisualStudio6Generator.cxx | 6 +++--- Source/cmLocalVisualStudio7Generator.cxx | 4 ++-- Source/cmMakefile.cxx | 2 +- Source/cmQtAutoGenerators.cxx | 17 +++++++---------- 8 files changed, 21 insertions(+), 23 deletions(-) diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index 0a36b82..e2b114a 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -168,7 +168,7 @@ void cmFLTKWrapUICommand::FinalPass() for(size_t classNum = 0; classNum < lastHeadersClass; classNum++) { this->Makefile->GetTargets()[this->Target] - .AddSourceFile(this->GeneratedSourcesClasses[classNum]); + .AddSource(this->GeneratedSourcesClasses[classNum]->GetFullPath()); } } } diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index ab4380c..e80df84 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -16,6 +16,7 @@ #include "cmVisualStudioWCEPlatformParser.h" #include "cmake.h" #include "cmGeneratedFileStream.h" +#include "cmSourceFile.h" static const char vs8generatorName[] = "Visual Studio 8 2005"; @@ -323,7 +324,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() no_main_dependency, commandLines, "Checking Build System", no_working_directory, true)) { - tgt->AddSourceFile(file); + tgt->AddSource(file->GetFullPath()); } else { diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index f93fc12..96b23d2 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1260,7 +1260,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) if(cmSourceFile* sf = mf->GetOrCreateSource(fname.c_str())) { sf->SetProperty("LANGUAGE", llang.c_str()); - cmtarget.AddSourceFile(sf); + cmtarget.AddSource(fname); } } @@ -2934,8 +2934,8 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, if(cmtarget.GetPropertyAsBool("MACOSX_BUNDLE")) { std::string plist = this->ComputeInfoPListLocation(cmtarget); - cmSourceFile* sf = mf->GetOrCreateSource(plist.c_str(), true); - cmtarget.AddSourceFile(sf); + mf->GetOrCreateSource(plist, true); + cmtarget.AddSource(plist); } std::vector classes; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c47147c..61d2a80 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -754,8 +754,8 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, comment.c_str(), this->Makefile->GetStartOutputDirectory() ); - target.Target->AddSourceFile - (this->Makefile->GetSource(targetFullPath)); + this->Makefile->GetSource(targetFullPath); + target.Target->AddSource(targetFullPath); } diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 2ab25cc..e99f3a4 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -253,9 +253,9 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt) makefileIn.c_str(), commandLines, comment.c_str(), no_working_directory, true); - if(cmSourceFile* file = this->Makefile->GetSource(makefileIn.c_str())) + if(this->Makefile->GetSource(makefileIn.c_str())) { - tgt.AddSourceFile(file); + tgt.AddSource(makefileIn); } else { @@ -591,7 +591,7 @@ cmLocalVisualStudio6Generator origCommand.GetCommandLines(), comment, origCommand.GetWorkingDirectory().c_str())) { - target.AddSourceFile(outsf); + target.AddSource(outsf->GetFullPath()); } // Replace the dependencies with the output of this rule so that the diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 52524aa..e8562ca 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -117,7 +117,7 @@ void cmLocalVisualStudio7Generator::AddCMakeListsRules() { if(l->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET) { - l->second.AddSourceFile(sf); + l->second.AddSource(sf->GetFullPath()); } } } @@ -153,7 +153,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() force.c_str(), no_depends, no_main_dependency, force_commands, " ", 0, true)) { - tgt.AddSourceFile(file); + tgt.AddSource(file->GetFullPath()); } } } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 1fcbcd7..06dc0c5 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1182,7 +1182,7 @@ cmMakefile::AddCustomCommandOldStyle(const std::string& target, { if (this->Targets.find(target) != this->Targets.end()) { - this->Targets[target].AddSourceFile(sf); + this->Targets[target].AddSource(sf->GetFullPath()); } else { diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index a6e6af7..71c4630 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -187,13 +187,11 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) mocCppFile += "/"; mocCppFile += automocTargetName; mocCppFile += ".cpp"; - cmSourceFile* mocCppSource = makefile->GetOrCreateSource( - mocCppFile, - true); + makefile->GetOrCreateSource(mocCppFile, true); makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", mocCppFile.c_str(), false); - target->AddSourceFile(mocCppSource); + target->AddSource(mocCppFile); } // create a custom target for running generators at buildtime: std::string autogenTargetName = getAutogenTargetName(target); @@ -479,7 +477,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) const char *skipMocSep = ""; const char *skipUicSep = ""; - std::vector newRccFiles; + std::vector newRccFiles; for(std::vector::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); @@ -512,9 +510,8 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) rcc_output_file += "/qrc_" + basename + ".cpp"; makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", rcc_output_file.c_str(), false); - cmSourceFile* rccCppSource - = makefile->GetOrCreateSource(rcc_output_file, true); - newRccFiles.push_back(rccCppSource); + makefile->GetOrCreateSource(rcc_output_file, true); + newRccFiles.push_back(rcc_output_file); } } @@ -546,11 +543,11 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) } } - for(std::vector::const_iterator fileIt = newRccFiles.begin(); + for(std::vector::const_iterator fileIt = newRccFiles.begin(); fileIt != newRccFiles.end(); ++fileIt) { - const_cast(target)->AddSourceFile(*fileIt); + const_cast(target)->AddSource(*fileIt); } } -- cgit v0.12 From 59e8740acaf0b749e8a7028f168a6a6d6d69194f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 17 Mar 2014 18:45:37 +0100 Subject: cmTarget: Remove AddSourceFile method It is no longer used. --- Source/cmTarget.cxx | 16 +++++----------- Source/cmTarget.h | 1 - 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0866d10..9d17320 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -579,16 +579,6 @@ void cmTarget::GetSourceFiles(std::vector &files) const } //---------------------------------------------------------------------------- -void cmTarget::AddSourceFile(cmSourceFile* sf) -{ - if (std::find(this->SourceFiles.begin(), this->SourceFiles.end(), sf) - == this->SourceFiles.end()) - { - this->SourceFiles.push_back(sf); - } -} - -//---------------------------------------------------------------------------- void cmTarget::AddSources(std::vector const& srcs) { for(std::vector::const_iterator i = srcs.begin(); @@ -653,7 +643,11 @@ cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s) cmSourceFile* cmTarget::AddSource(const std::string& src) { cmSourceFile* sf = this->Makefile->GetOrCreateSource(src); - this->AddSourceFile(sf); + if (std::find(this->SourceFiles.begin(), this->SourceFiles.end(), sf) + == this->SourceFiles.end()) + { + this->SourceFiles.push_back(sf); + } return sf; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8df9bd8..e9e3622 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -137,7 +137,6 @@ public: */ void GetSourceFiles(std::vector &files) const; void GetSourceFiles(std::vector &files) const; - void AddSourceFile(cmSourceFile* sf); std::vector const& GetObjectLibraries() const { return this->ObjectLibraries; -- cgit v0.12 From fcc9287897dd9b378c2f87329346c2f23becd54f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 27 Mar 2014 23:09:39 +0100 Subject: cmSourceFileLocation: Remove unused Update method. The string overload is never called. This allows the removal of the unused UpdateDirectory method. --- Source/cmSourceFileLocation.cxx | 24 ------------------------ Source/cmSourceFileLocation.h | 2 -- 2 files changed, 26 deletions(-) diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index 3e78b29..24e646f 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -65,19 +65,6 @@ cmSourceFileLocation } //---------------------------------------------------------------------------- -void cmSourceFileLocation::Update(const std::string& name) -{ - if(this->AmbiguousDirectory) - { - this->UpdateDirectory(name); - } - if(this->AmbiguousExtension) - { - this->UpdateExtension(name); - } -} - -//---------------------------------------------------------------------------- void cmSourceFileLocation::Update(cmSourceFileLocation const& loc) { if(this->AmbiguousDirectory && !loc.AmbiguousDirectory) @@ -176,17 +163,6 @@ void cmSourceFileLocation::UpdateExtension(const std::string& name) } //---------------------------------------------------------------------------- -void cmSourceFileLocation::UpdateDirectory(const std::string& name) -{ - // If a full path was given we know the directory. - if(cmSystemTools::FileIsFullPath(name.c_str())) - { - this->Directory = cmSystemTools::GetFilenamePath(name); - this->AmbiguousDirectory = false; - } -} - -//---------------------------------------------------------------------------- bool cmSourceFileLocation ::MatchesAmbiguousExtension(cmSourceFileLocation const& loc) const diff --git a/Source/cmSourceFileLocation.h b/Source/cmSourceFileLocation.h index 82a62ab..c37fb1d 100644 --- a/Source/cmSourceFileLocation.h +++ b/Source/cmSourceFileLocation.h @@ -96,9 +96,7 @@ private: // Update the location with additional knowledge. void Update(cmSourceFileLocation const& loc); - void Update(const std::string& name); void UpdateExtension(const std::string& name); - void UpdateDirectory(const std::string& name); }; #endif -- cgit v0.12 From 4959f3413c83f38dd222dced11d7a3933e145ae4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 27 Mar 2014 22:56:36 +0100 Subject: cmSourceFileLocation: Collapse full path for directory comparisons. Otherwise Matches() ends up doing a comparison of the directories /path/to/dir/subdir/.. and /path/to/dir as strings and not matching where it should. --- Source/cmSourceFileLocation.cxx | 5 +++++ Tests/Properties/CMakeLists.txt | 2 ++ Tests/Properties/SubDir2/CMakeLists.txt | 5 +++++ Tests/Properties/subdirtest.cxx | 9 +++++++++ 4 files changed, 21 insertions(+) create mode 100644 Tests/Properties/SubDir2/CMakeLists.txt create mode 100644 Tests/Properties/subdirtest.cxx diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index 24e646f..c050202 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -60,6 +60,11 @@ cmSourceFileLocation this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name.c_str()); this->AmbiguousExtension = true; this->Directory = cmSystemTools::GetFilenamePath(name); + if (cmSystemTools::FileIsFullPath(this->Directory.c_str())) + { + this->Directory + = cmSystemTools::CollapseFullPath(this->Directory.c_str()); + } this->Name = cmSystemTools::GetFilenameName(name); this->UpdateExtension(name); } diff --git a/Tests/Properties/CMakeLists.txt b/Tests/Properties/CMakeLists.txt index 285d596..11fca45 100644 --- a/Tests/Properties/CMakeLists.txt +++ b/Tests/Properties/CMakeLists.txt @@ -143,3 +143,5 @@ set_property(CACHE SOME_ENTRY PROPERTY VALUE "${expect_VALUE}") set_property(CACHE SOME_ENTRY PROPERTY ADVANCED "${expect_ADVANCED}") set_property(CACHE SOME_ENTRY PROPERTY STRINGS "${expect_STRINGS}") check_cache_props() + +add_subdirectory(SubDir2) diff --git a/Tests/Properties/SubDir2/CMakeLists.txt b/Tests/Properties/SubDir2/CMakeLists.txt new file mode 100644 index 0000000..377dc83 --- /dev/null +++ b/Tests/Properties/SubDir2/CMakeLists.txt @@ -0,0 +1,5 @@ + +set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/../subdirtest.cxx" + PROPERTIES COMPILE_DEFINITIONS SUBDIR_TEST) + +add_executable(subdirtest "${CMAKE_CURRENT_SOURCE_DIR}/../subdirtest.cxx") diff --git a/Tests/Properties/subdirtest.cxx b/Tests/Properties/subdirtest.cxx new file mode 100644 index 0000000..02d8f3d --- /dev/null +++ b/Tests/Properties/subdirtest.cxx @@ -0,0 +1,9 @@ + +#ifndef SUBDIR_TEST +#error Expected SUBDIR_TEST +#endif + +int main(int, char**) +{ + return 0; +} -- cgit v0.12 From 8cd113ad1d715cc9ce865956870cd462d3659089 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 17 Mar 2014 18:36:04 +0100 Subject: cmTarget: Store strings instead of cmSourceFile* to represent SOURCES. This will allow the strings to contain generator expressions. At this point, generator expressions are still not part of the SOURCES property when it is read. --- Source/cmTarget.cxx | 176 ++++++++++++++++++++++++++++++++++++++++------------ Source/cmTarget.h | 1 - 2 files changed, 135 insertions(+), 42 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9d17320..8bfc428 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -150,6 +150,7 @@ public: std::vector IncludeDirectoriesEntries; std::vector CompileOptionsEntries; std::vector CompileDefinitionsEntries; + std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; mutable std::map > @@ -545,37 +546,51 @@ bool cmTarget::IsBundleOnApple() const void cmTarget::GetSourceFiles(std::vector &files) const { assert(this->GetType() != INTERFACE_LIBRARY); - std::vector sourceFiles; - this->GetSourceFiles(sourceFiles); - for(std::vector::const_iterator - si = sourceFiles.begin(); - si != sourceFiles.end(); ++si) - { - files.push_back((*si)->GetFullPath()); + for(std::vector::const_iterator + si = this->Internal->SourceEntries.begin(); + si != this->Internal->SourceEntries.end(); ++si) + { + std::vector srcs; + cmSystemTools::ExpandListArgument((*si)->ge->GetInput(), srcs); + for(std::vector::const_iterator i = srcs.begin(); + i != srcs.end(); ++i) + { + std::string src = *i; + cmSourceFile* sf = this->Makefile->GetOrCreateSource(src); + std::string e; + src = sf->GetFullPath(&e); + if(src.empty()) + { + if(!e.empty()) + { + cmake* cm = this->Makefile->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e, + this->GetBacktrace()); + } + return; + } + files.push_back(src); + } } } //---------------------------------------------------------------------------- void cmTarget::GetSourceFiles(std::vector &files) const { - assert(this->GetType() != INTERFACE_LIBRARY); - for(std::vector::const_iterator - si = this->SourceFiles.begin(); - si != this->SourceFiles.end(); ++si) + std::vector srcs; + this->GetSourceFiles(srcs); + + std::set emitted; + + for(std::vector::const_iterator i = srcs.begin(); + i != srcs.end(); ++i) { - std::string e; - if((*si)->GetFullPath(&e).empty()) + cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i); + if (emitted.insert(sf).second) { - if(!e.empty()) - { - cmake* cm = this->Makefile->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e, - this->GetBacktrace()); - } - return; + files.push_back(sf); } } - files = this->SourceFiles; } //---------------------------------------------------------------------------- @@ -640,17 +655,86 @@ cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s) } //---------------------------------------------------------------------------- +struct CreateLocation +{ + cmMakefile const* Makefile; + + CreateLocation(cmMakefile const* mf) + : Makefile(mf) + { + + } + + cmSourceFileLocation operator()(const std::string& filename) + { + return cmSourceFileLocation(this->Makefile, filename); + } +}; + +//---------------------------------------------------------------------------- +struct LocationMatcher +{ + const cmSourceFileLocation& Needle; + + LocationMatcher(const cmSourceFileLocation& needle) + : Needle(needle) + { + + } + + bool operator()(cmSourceFileLocation &loc) + { + return loc.Matches(this->Needle); + } +}; + + +//---------------------------------------------------------------------------- +struct TargetPropertyEntryFinder +{ +private: + const cmSourceFileLocation& Needle; +public: + TargetPropertyEntryFinder(const cmSourceFileLocation& needle) + : Needle(needle) + { + + } + + bool operator()(cmTargetInternals::TargetPropertyEntry* entry) + { + std::vector files; + cmSystemTools::ExpandListArgument(entry->ge->GetInput(), files); + std::vector locations(files.size()); + std::transform(files.begin(), files.end(), locations.begin(), + CreateLocation(this->Needle.GetMakefile())); + + return std::find_if(locations.begin(), locations.end(), + LocationMatcher(this->Needle)) != locations.end(); + } +}; + +//---------------------------------------------------------------------------- cmSourceFile* cmTarget::AddSource(const std::string& src) { - cmSourceFile* sf = this->Makefile->GetOrCreateSource(src); - if (std::find(this->SourceFiles.begin(), this->SourceFiles.end(), sf) - == this->SourceFiles.end()) + cmSourceFileLocation sfl(this->Makefile, src); + if (std::find_if(this->Internal->SourceEntries.begin(), + this->Internal->SourceEntries.end(), + TargetPropertyEntryFinder(sfl)) + == this->Internal->SourceEntries.end()) { - this->SourceFiles.push_back(sf); + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr cge = ge.Parse(src); + this->Internal->SourceEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); } - return sf; + return this->Makefile->GetOrCreateSource(src); } + + //---------------------------------------------------------------------------- void cmTarget::ProcessSourceExpression(std::string const& expr) { @@ -2779,25 +2863,34 @@ const char *cmTarget::GetProperty(const std::string& prop, { cmOStringStream ss; const char* sep = ""; - for(std::vector::const_iterator - i = this->SourceFiles.begin(); - i != this->SourceFiles.end(); ++i) + typedef cmTargetInternals::TargetPropertyEntry + TargetPropertyEntry; + for(std::vector::const_iterator + i = this->Internal->SourceEntries.begin(); + i != this->Internal->SourceEntries.end(); ++i) { - // Separate from the previous list entries. - ss << sep; - sep = ";"; + std::string entry = (*i)->ge->GetInput(); - // Construct what is known about this source file location. - cmSourceFileLocation const& location = (*i)->GetLocation(); - std::string sname = location.GetDirectory(); - if(!sname.empty()) + std::vector files; + cmSystemTools::ExpandListArgument(entry, files); + for (std::vector::const_iterator + li = files.begin(); li != files.end(); ++li) { - sname += "/"; - } - sname += location.GetName(); + cmSourceFile *sf = this->Makefile->GetOrCreateSource(*li); + // Construct what is known about this source file location. + cmSourceFileLocation const& location = sf->GetLocation(); + std::string sname = location.GetDirectory(); + if(!sname.empty()) + { + sname += "/"; + } + sname += location.GetName(); - // Append this list entry. - ss << sname; + ss << sep; + sep = ";"; + // Append this list entry. + ss << sname; + } } this->Properties.SetProperty("SOURCES", ss.str().c_str(), cmProperty::TARGET); @@ -6410,6 +6503,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() deleteAndClear(this->Pointer->IncludeDirectoriesEntries); deleteAndClear(this->Pointer->CompileOptionsEntries); deleteAndClear(this->Pointer->CompileDefinitionsEntries); + deleteAndClear(this->Pointer->SourceEntries); delete this->Pointer; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e9e3622..45fca53 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -686,7 +686,6 @@ private: std::vector PreLinkCommands; std::vector PostBuildCommands; TargetType TargetTypeValue; - std::vector SourceFiles; std::vector ObjectLibraries; LinkLibraryVectorType LinkLibraries; LinkLibraryVectorType PrevLinkedLibraries; -- cgit v0.12 From bf98cc252f18e761ed9a57d2f7a9304bfbb621de Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 26 Feb 2014 15:59:18 +0100 Subject: Genex: Evaluate TARGET_OBJECTS as a normal expression. --- Help/manual/cmake-generator-expressions.7.rst | 3 + Help/release/dev/file-GENERATE-TARGET_OBJECTS.rst | 6 ++ Source/cmGeneratorExpressionEvaluator.cxx | 64 ++++++++++++++++++++++ Source/cmSourceFile.cxx | 12 ++++ Source/cmSourceFile.h | 4 ++ Tests/GeneratorExpression/CMakeLists.txt | 14 +++++ Tests/GeneratorExpression/check_object_files.cmake | 48 ++++++++++++++++ Tests/GeneratorExpression/objlib1.c | 5 ++ Tests/GeneratorExpression/objlib2.c | 5 ++ Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/TargetObjects/CMakeLists.txt | 3 + Tests/RunCMake/TargetObjects/NoTarget-result.txt | 1 + Tests/RunCMake/TargetObjects/NoTarget-stderr.txt | 8 +++ Tests/RunCMake/TargetObjects/NoTarget.cmake | 2 + .../TargetObjects/NotObjlibTarget-result.txt | 1 + .../TargetObjects/NotObjlibTarget-stderr.txt | 8 +++ Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake | 4 ++ Tests/RunCMake/TargetObjects/RunCMakeTest.cmake | 4 ++ Tests/RunCMake/TargetObjects/empty.cpp | 7 +++ 19 files changed, 200 insertions(+) create mode 100644 Help/release/dev/file-GENERATE-TARGET_OBJECTS.rst create mode 100644 Tests/GeneratorExpression/check_object_files.cmake create mode 100644 Tests/GeneratorExpression/objlib1.c create mode 100644 Tests/GeneratorExpression/objlib2.c create mode 100644 Tests/RunCMake/TargetObjects/CMakeLists.txt create mode 100644 Tests/RunCMake/TargetObjects/NoTarget-result.txt create mode 100644 Tests/RunCMake/TargetObjects/NoTarget-stderr.txt create mode 100644 Tests/RunCMake/TargetObjects/NoTarget.cmake create mode 100644 Tests/RunCMake/TargetObjects/NotObjlibTarget-result.txt create mode 100644 Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt create mode 100644 Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake create mode 100644 Tests/RunCMake/TargetObjects/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/TargetObjects/empty.cpp diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index ac8c3f8..17263d4 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -188,3 +188,6 @@ property is non-empty:: Content of ``...`` converted to upper case. ``$`` Content of ``...`` converted to a C identifier. +``$`` + List of objects resulting from build of ``objLib``. ``objLib`` must be an + object of type ``OBJECT_LIBRARY``. diff --git a/Help/release/dev/file-GENERATE-TARGET_OBJECTS.rst b/Help/release/dev/file-GENERATE-TARGET_OBJECTS.rst new file mode 100644 index 0000000..853a803 --- /dev/null +++ b/Help/release/dev/file-GENERATE-TARGET_OBJECTS.rst @@ -0,0 +1,6 @@ +file-GENERATE-TARGET_OBJECTS +---------------------------- + +* The :command:`file(GENERATE)` subcommand learned to evaluate the + ``TARGET_OBJECTS`` + :manual:`generator expression `. diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 14b2a1a..669694c 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -15,6 +15,8 @@ #include "cmGeneratorExpressionParser.h" #include "cmGeneratorExpressionDAGChecker.h" #include "cmGeneratorExpression.h" +#include "cmLocalGenerator.h" +#include "cmSourceFile.h" #include @@ -1240,6 +1242,67 @@ static const struct TargetNameNode : public cmGeneratorExpressionNode } targetNameNode; //---------------------------------------------------------------------------- +static const struct TargetObjectsNode : public cmGeneratorExpressionNode +{ + TargetObjectsNode() {} + + std::string Evaluate(const std::vector ¶meters, + cmGeneratorExpressionContext *context, + const GeneratorExpressionContent *content, + cmGeneratorExpressionDAGChecker *) const + { + std::string tgtName = parameters.front(); + cmGeneratorTarget* gt = + context->Makefile->FindGeneratorTargetToUse(tgtName.c_str()); + if (!gt) + { + cmOStringStream e; + e << "Objects of target \"" << tgtName + << "\" referenced but no such target exists."; + reportError(context, content->GetOriginalExpression(), e.str()); + return std::string(); + } + if (gt->GetType() != cmTarget::OBJECT_LIBRARY) + { + cmOStringStream e; + e << "Objects of target \"" << tgtName + << "\" referenced but is not an OBJECT library."; + reportError(context, content->GetOriginalExpression(), e.str()); + return std::string(); + } + + std::vector objectSources; + gt->GetObjectSources(objectSources); + std::map mapping; + + for(std::vector::const_iterator it + = objectSources.begin(); it != objectSources.end(); ++it) + { + mapping[*it]; + } + + gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); + + std::string obj_dir = gt->ObjectDirectory; + std::string result; + const char* sep = ""; + for(std::map::const_iterator it + = mapping.begin(); it != mapping.end(); ++it) + { + assert(!it->second.empty()); + result += sep; + std::string objFile = obj_dir + it->second; + cmSourceFile* sf = context->Makefile->GetOrCreateSource(objFile, true); + sf->SetObjectLibrary(tgtName); + sf->SetProperty("EXTERNAL_OBJECT", "1"); + result += objFile; + sep = ";"; + } + return result; + } +} targetObjectsNode; + +//---------------------------------------------------------------------------- static const char* targetPolicyWhitelist[] = { 0 #define TARGET_POLICY_STRING(POLICY) \ @@ -1593,6 +1656,7 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier) nodeMap["SEMICOLON"] = &semicolonNode; nodeMap["TARGET_PROPERTY"] = &targetPropertyNode; nodeMap["TARGET_NAME"] = &targetNameNode; + nodeMap["TARGET_OBJECTS"] = &targetObjectsNode; nodeMap["TARGET_POLICY"] = &targetPolicyNode; nodeMap["BUILD_INTERFACE"] = &buildInterfaceNode; nodeMap["INSTALL_INTERFACE"] = &installInterfaceNode; diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index b9b6251..0ab30a2 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -39,6 +39,18 @@ std::string const& cmSourceFile::GetExtension() const } //---------------------------------------------------------------------------- +void cmSourceFile::SetObjectLibrary(std::string const& objlib) +{ + this->ObjectLibrary = objlib; +} + +//---------------------------------------------------------------------------- +std::string cmSourceFile::GetObjectLibrary() const +{ + return this->ObjectLibrary; +} + +//---------------------------------------------------------------------------- std::string cmSourceFile::GetLanguage() { // If the language was set explicitly by the user then use it. diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 17c96ac..755a2cf 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -97,6 +97,9 @@ public: */ bool Matches(cmSourceFileLocation const&); + void SetObjectLibrary(std::string const& objlib); + std::string GetObjectLibrary() const; + private: cmSourceFileLocation Location; cmPropertyMap Properties; @@ -105,6 +108,7 @@ private: std::string Language; std::string FullPath; bool FindFullPathFailed; + std::string ObjectLibrary; bool FindFullPath(std::string* error); bool TryFullPath(const std::string& path, const std::string& ext); diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index a0e34ef..66b175a 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -258,3 +258,17 @@ set(CMP0044_TYPE NEW) add_subdirectory(CMP0044 ${CMAKE_BINARY_DIR}/CMP0044-NEW) set(CMP0044_TYPE OLD) add_subdirectory(CMP0044 ${CMAKE_BINARY_DIR}/CMP0044-OLD) + +add_library(objlib OBJECT objlib1.c objlib2.c) +file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/objlib_files" + CONTENT "$,\n>\n" +) +add_custom_target(check_object_files ALL + COMMAND ${CMAKE_COMMAND} + "-DOBJLIB_LISTFILE=${CMAKE_CURRENT_BINARY_DIR}/objlib_files" + -DTEST_CONFIGURATION=${CMAKE_BUILD_TYPE} + -DEXPECTED_NUM_OBJECTFILES=2 + -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake" + DEPENDS objlib +) diff --git a/Tests/GeneratorExpression/check_object_files.cmake b/Tests/GeneratorExpression/check_object_files.cmake new file mode 100644 index 0000000..889fe80 --- /dev/null +++ b/Tests/GeneratorExpression/check_object_files.cmake @@ -0,0 +1,48 @@ + +if (NOT EXISTS ${OBJLIB_LISTFILE}) + message(SEND_ERROR "Object listing file \"${OBJLIB_LISTFILE}\" not found!") +endif() + +file(STRINGS ${OBJLIB_LISTFILE} objlib_files) + +list(LENGTH objlib_files num_objectfiles) +if (NOT EXPECTED_NUM_OBJECTFILES EQUAL num_objectfiles) + message(SEND_ERROR "Unexpected number of entries in object list file (${num_objectfiles} instead of ${EXPECTED_NUM_OBJECTFILES})") +endif() + +foreach(objlib_file ${objlib_files}) + set(file_exists False) + if (EXISTS ${objlib_file}) + set(file_exists True) + endif() + + if (NOT file_exists) + if (objlib_file MATCHES ".(CURRENT_ARCH)") + string(REPLACE "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)" "*" config_file "${objlib_file}") + string(REPLACE "$(PROJECT_NAME)" "GeneratorExpression" config_file "${config_file}") + string(REPLACE "$(CURRENT_ARCH)" "*" config_file "${config_file}") + file(GLOB_RECURSE files "${config_file}") + list(LENGTH files num_files) + if (NOT files) + message(SEND_ERROR "Got no files for expression ${config_file}") + endif() + set(file_exists True) + else() + foreach(config_macro "$(Configuration)" "$(OutDir)" "$(IntDir)") + string(REPLACE "${config_macro}" "${TEST_CONFIGURATION}" config_file "${objlib_file}") + list(APPEND attempts ${config_file}) + if (EXISTS ${config_file}) + set(file_exists True) + endif() + endforeach() + endif() + endif() + + if (NOT file_exists) + if(attempts) + list(REMOVE_DUPLICATES attempts) + set(tried " Tried ${attempts}") + endif() + message(SEND_ERROR "File \"${objlib_file}\" does not exist!${tried}") + endif() +endforeach() diff --git a/Tests/GeneratorExpression/objlib1.c b/Tests/GeneratorExpression/objlib1.c new file mode 100644 index 0000000..aa8de0a --- /dev/null +++ b/Tests/GeneratorExpression/objlib1.c @@ -0,0 +1,5 @@ + +void objlib1() +{ + +} diff --git a/Tests/GeneratorExpression/objlib2.c b/Tests/GeneratorExpression/objlib2.c new file mode 100644 index 0000000..3c7307a --- /dev/null +++ b/Tests/GeneratorExpression/objlib2.c @@ -0,0 +1,5 @@ + +void objlib2() +{ + +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 7691f32..31e7805 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -49,6 +49,7 @@ add_RunCMake_test(GeneratorToolset) add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) add_RunCMake_test(ObjectLibrary) +add_RunCMake_test(TargetObjects) add_RunCMake_test(find_dependency) if(NOT WIN32) add_RunCMake_test(PositionIndependentCode) diff --git a/Tests/RunCMake/TargetObjects/CMakeLists.txt b/Tests/RunCMake/TargetObjects/CMakeLists.txt new file mode 100644 index 0000000..be9d403 --- /dev/null +++ b/Tests/RunCMake/TargetObjects/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.4) +project(${RunCMake_TEST}) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/TargetObjects/NoTarget-result.txt b/Tests/RunCMake/TargetObjects/NoTarget-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/TargetObjects/NoTarget-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/TargetObjects/NoTarget-stderr.txt b/Tests/RunCMake/TargetObjects/NoTarget-stderr.txt new file mode 100644 index 0000000..2c4f877 --- /dev/null +++ b/Tests/RunCMake/TargetObjects/NoTarget-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at NoTarget.cmake:2 \(file\): + Error evaluating generator expression: + + \$ + + Objects of target "NoTarget" referenced but no such target exists. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/TargetObjects/NoTarget.cmake b/Tests/RunCMake/TargetObjects/NoTarget.cmake new file mode 100644 index 0000000..f203c23 --- /dev/null +++ b/Tests/RunCMake/TargetObjects/NoTarget.cmake @@ -0,0 +1,2 @@ + +file(GENERATE OUTPUT test_output CONTENT $) diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget-result.txt b/Tests/RunCMake/TargetObjects/NotObjlibTarget-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/TargetObjects/NotObjlibTarget-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt b/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt new file mode 100644 index 0000000..bb83934 --- /dev/null +++ b/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at NotObjlibTarget.cmake:4 \(file\): + Error evaluating generator expression: + + \$ + + Objects of target "StaticLib" referenced but is not an OBJECT library. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake b/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake new file mode 100644 index 0000000..c7f8a71 --- /dev/null +++ b/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake @@ -0,0 +1,4 @@ + +add_library(StaticLib empty.cpp) + +file(GENERATE OUTPUT test_output CONTENT $) diff --git a/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake b/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake new file mode 100644 index 0000000..30b9fee --- /dev/null +++ b/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake @@ -0,0 +1,4 @@ +include(RunCMake) + +run_cmake(NoTarget) +run_cmake(NotObjlibTarget) diff --git a/Tests/RunCMake/TargetObjects/empty.cpp b/Tests/RunCMake/TargetObjects/empty.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/TargetObjects/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} -- cgit v0.12 From 28e1d2f8fc08516e8fc3a009777437d3e086b8e6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 18 Mar 2014 16:21:08 +0100 Subject: cmStringCommand: Add GENEX_STRIP subcommand. Strip out any generator expressions in the input string. --- Help/command/string.rst | 5 +++++ Help/release/dev/string-GENEX_STRIP.rst | 6 ++++++ Source/cmStringCommand.cxx | 25 +++++++++++++++++++++++++ Source/cmStringCommand.h | 1 + Tests/StringFileTest/CMakeLists.txt | 6 ++++++ 5 files changed, 43 insertions(+) create mode 100644 Help/release/dev/string-GENEX_STRIP.rst diff --git a/Help/command/string.rst b/Help/command/string.rst index af18825..abde6ee 100644 --- a/Help/command/string.rst +++ b/Help/command/string.rst @@ -35,6 +35,7 @@ String operations. string(FIND [REVERSE]) string(TIMESTAMP [] [UTC]) string(MAKE_C_IDENTIFIER ) + string(GENEX_STRIP ) REGEX MATCH will match the regular expression once and store the match in the output variable. @@ -154,3 +155,7 @@ If no explicit is given it will default to: MAKE_C_IDENTIFIER will write a string which can be used as an identifier in C. + +``GENEX_STRIP`` will strip any +:manual:`generator expressions ` from the +``input string`` and store the result in the ``output variable``. diff --git a/Help/release/dev/string-GENEX_STRIP.rst b/Help/release/dev/string-GENEX_STRIP.rst new file mode 100644 index 0000000..b5b1074 --- /dev/null +++ b/Help/release/dev/string-GENEX_STRIP.rst @@ -0,0 +1,6 @@ +string-GENEX_STRIP +------------------ + +* The :command:`string` command learned a new ``GENEX_STRIP`` subcommand + which removes + :manual:`generator expression `. diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 7bc7b05..ea762eb 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -101,6 +101,10 @@ bool cmStringCommand { return this->HandleMakeCIdentifierCommand(args); } + else if(subCommand == "GENEX_STRIP") + { + return this->HandleGenexStripCommand(args); + } std::string e = "does not recognize sub-command "+subCommand; this->SetError(e); @@ -810,6 +814,27 @@ bool cmStringCommand } //---------------------------------------------------------------------------- +bool cmStringCommand +::HandleGenexStripCommand(std::vector const& args) +{ + if(args.size() != 3) + { + this->SetError("sub-command GENEX_STRIP requires two arguments."); + return false; + } + + const std::string& input = args[1]; + + std::string result = cmGeneratorExpression::Preprocess(input, + cmGeneratorExpression::StripAllGeneratorExpressions); + + const std::string& variableName = args[2]; + + this->Makefile->AddDefinition(variableName, result.c_str()); + return true; +} + +//---------------------------------------------------------------------------- bool cmStringCommand::HandleStripCommand( std::vector const& args) { diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h index b8053c5..5b7412d 100644 --- a/Source/cmStringCommand.h +++ b/Source/cmStringCommand.h @@ -75,6 +75,7 @@ protected: bool HandleFindCommand(std::vector const& args); bool HandleTimestampCommand(std::vector const& args); bool HandleMakeCIdentifierCommand(std::vector const& args); + bool HandleGenexStripCommand(std::vector const& args); class RegexReplacement { diff --git a/Tests/StringFileTest/CMakeLists.txt b/Tests/StringFileTest/CMakeLists.txt index 00383ab..be6d8fe 100644 --- a/Tests/StringFileTest/CMakeLists.txt +++ b/Tests/StringFileTest/CMakeLists.txt @@ -286,3 +286,9 @@ string(MAKE_C_IDENTIFIER "1one-two$" MCI_1) if(NOT MCI_1 STREQUAL _1one_two_) message(SEND_ERROR "MAKE_C_IDENTIFIER did not create expected result.") endif() + +string(GENEX_STRIP "one;$<1:two;three>;four;$" strip_result) + +if (NOT strip_result STREQUAL "one;four") + message(SEND_ERROR "GENEX_STRIP did not create expected result: ${strip_result}") +endif() -- cgit v0.12 From 857d30b52ef2fb011bad16249d34972fadae9b70 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 19 Mar 2014 09:11:11 +0100 Subject: cmGlobalGenerator: Add interface to call ForceLinkerLanguages Avoid calling it too early when cmGeneratorTarget instances don't yet exist. --- Source/cmGlobalGenerator.cxx | 7 +++++++ Source/cmGlobalGenerator.h | 2 ++ Source/cmGlobalXCodeGenerator.cxx | 1 - 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 07637b3..2f3c6c9 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -216,6 +216,11 @@ bool cmGlobalGenerator::GenerateImportFile(const std::string &file) return false; } +void cmGlobalGenerator::ForceLinkerLanguages() +{ + +} + bool cmGlobalGenerator::IsExportedTargetsFile(const std::string &filename) const { @@ -1194,6 +1199,8 @@ void cmGlobalGenerator::Generate() // Create per-target generator information. this->CreateGeneratorTargets(); + this->ForceLinkerLanguages(); + #ifdef CMAKE_BUILD_WITH_CMAKE for (AutogensType::iterator it = autogens.begin(); it != autogens.end(); ++it) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 49a418d..668bb6b 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -423,6 +423,8 @@ private: void WriteSummary(cmTarget* target); void FinalizeTargetCompileInfo(); + virtual void ForceLinkerLanguages(); + virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang, const char* envVar) const; void CheckCompilerIdCompatibility(cmMakefile* mf, diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 96b23d2..fdf73d6 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -343,7 +343,6 @@ void cmGlobalXCodeGenerator::Generate() // add ALL_BUILD, INSTALL, etc this->AddExtraTargets(root, it->second); } - this->ForceLinkerLanguages(); this->cmGlobalGenerator::Generate(); if(cmSystemTools::GetErrorOccuredFlag()) { -- cgit v0.12 From 85582d14fe19ba3d66c49ec95286bcaf7c675ca4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 31 Mar 2014 15:44:27 +0200 Subject: Help: Add option to create and install Qt .qch file. --- Utilities/Sphinx/CMakeLists.txt | 24 +++++++++++++++++++++++- Utilities/Sphinx/cmake.py | 18 ++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index 23dc6ae..51c83ba 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -24,6 +24,7 @@ project(CMakeHelp NONE) option(SPHINX_MAN "Build man pages with Sphinx" OFF) option(SPHINX_HTML "Build html help with Sphinx" OFF) +option(SPHINX_QTHELP "Build Qt help with Sphinx" OFF) option(SPHINX_TEXT "Build text help with Sphinx (not installed)" OFF) find_program(SPHINX_EXECUTABLE NAMES sphinx-build @@ -32,7 +33,7 @@ find_program(SPHINX_EXECUTABLE mark_as_advanced(SPHINX_TEXT) -if(NOT SPHINX_MAN AND NOT SPHINX_HTML AND NOT SPHINX_TEXT) +if(NOT SPHINX_MAN AND NOT SPHINX_HTML AND NOT SPHINX_QTHELP AND NOT SPHINX_TEXT) return() elseif(NOT SPHINX_EXECUTABLE) message(FATAL_ERROR "SPHINX_EXECUTABLE (sphinx-build) is not found!") @@ -63,6 +64,21 @@ endif() if(SPHINX_TEXT) list(APPEND doc_formats text) endif() +if(SPHINX_QTHELP) + find_program(QCOLLECTIONGENERATOR_EXECUTABLE + NAMES qcollectiongenerator + DOC "qcollectiongenerator tool" + ) + if (NOT QCOLLECTIONGENERATOR_EXECUTABLE) + message(FATAL_ERROR "QCOLLECTIONGENERATOR_EXECUTABLE (qcollectiongenerator) not found!") + endif() + list(APPEND doc_formats qthelp) + + set(qthelp_extra_commands + COMMAND qcollectiongenerator ${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake.qhcp + ) +endif() + set(doc_format_outputs "") set(doc_format_last "") @@ -78,6 +94,7 @@ foreach(format ${doc_formats}) ${CMake_SOURCE_DIR}/Help ${CMAKE_CURRENT_BINARY_DIR}/${format} > ${doc_format_log} # log stdout, pass stderr + ${${format}_extra_commands} DEPENDS ${doc_format_last} COMMENT "sphinx-build ${format}: see Utilities/Sphinx/${doc_format_log}" VERBATIM @@ -122,3 +139,8 @@ if(SPHINX_HTML) PATTERN objects.inv EXCLUDE ) endif() +if(SPHINX_QTHELP) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake.qch + DESTINATION ${CMAKE_DOC_DIR} + ) +endif() diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py index 336c74a..2d83376 100644 --- a/Utilities/Sphinx/cmake.py +++ b/Utilities/Sphinx/cmake.py @@ -21,6 +21,24 @@ from pygments.lexer import bygroups CMakeLexer.tokens["args"].append(('(\\$<)(.+?)(>)', bygroups(Operator, Name.Variable, Operator))) +# Monkey patch for sphinx generating invalid content for qcollectiongenerator +# https://bitbucket.org/birkenfeld/sphinx/issue/1435/qthelp-builder-should-htmlescape-keywords +from sphinx.util.pycompat import htmlescape +from sphinx.builders.qthelp import QtHelpBuilder +old_build_keywords = QtHelpBuilder.build_keywords +def new_build_keywords(self, title, refs, subitems): + old_items = old_build_keywords(self, title, refs, subitems) + new_items = [] + for item in old_items: + before, rest = item.split("ref=\"", 1) + ref, after = rest.split("\"") + if ("<" in ref and ">" in ref): + new_items.append(before + "ref=\"" + htmlescape(ref) + "\"" + after) + else: + new_items.append(item) + return new_items +QtHelpBuilder.build_keywords = new_build_keywords + from docutils.parsers.rst import Directive, directives from docutils.transforms import Transform -- cgit v0.12 From e3e1ba3f781c621835dc5e46783fecb6ccaad127 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 1 Apr 2014 00:01:05 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 4b27c72..27f2e91 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 0) -set(CMake_VERSION_PATCH 20140331) +set(CMake_VERSION_PATCH 20140401) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 065166cf76676dfc3408a2c315ab380271142b86 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 1 Apr 2014 08:58:23 -0400 Subject: CTestCustom: Suppress Clang "will never be executed" warnings in lexers Clang -Wunreachable-code-return warns on some generated lexer code. --- CTestCustom.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index 6010b64..2407da6 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -44,7 +44,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION "warning.*directory name.*CMake-Xcode.*/bin/.*does not exist.*" "stl_deque.h:1051" "(Lexer|Parser).*warning.*conversion.*may (alter its value|change the sign)" - "(Lexer|Parser).*warning.*statement is unreachable" + "(Lexer|Parser).*warning.*(statement is unreachable|will never be executed)" "PGC-W-0095-Type cast required for this conversion.*ProcessUNIX.c" "[Qq]t([Cc]ore|[Gg]ui).*warning.*conversion.*may alter its value" "warning:.*is.*very unsafe.*consider using.*" -- cgit v0.12 From 2e2939c365292d1771d5dd6d2cd8f04e3d2aea44 Mon Sep 17 00:00:00 2001 From: Jack Morrison Date: Tue, 1 Apr 2014 09:21:23 -0400 Subject: FindGTest: Teach GTEST_ADD_TESTS about TEST_P Previously the GTEST_ADD_TESTS function would miss parameterized tests because it only considered TEST and TEST_F. Add TEST_P to the list of considered tests and will run all instantiations of this parameterized test together. This is perhaps not as correct as searching for all instantiations of this parameterized test and separating those into separate runs, but this will at least run tests that were previously missing. For reference: https://code.google.com/p/googletest/wiki/Documentation --- Modules/FindGTest.cmake | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index aa3c235..c4f911d 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -115,11 +115,19 @@ function(GTEST_ADD_TESTS executable extra_args) # obtain sources used for building that executable get_property(ARGN TARGET ${executable} PROPERTY SOURCES) endif() + set(gtest_case_name_regex ".*\\( *([A-Za-z_0-9]+), *([A-Za-z_0-9]+) *\\).*") foreach(source ${ARGN}) file(READ "${source}" contents) - string(REGEX MATCHALL "TEST_?F?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents}) + string(REGEX MATCHALL "TEST_?[FP]?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents}) foreach(hit ${found_tests}) - string(REGEX REPLACE ".*\\( *([A-Za-z_0-9]+), *([A-Za-z_0-9]+) *\\).*" "\\1.\\2" test_name ${hit}) + string(REGEX MATCH "TEST_?[FP]?" test_type ${hit}) + + # Parameterized tests have a different signature for the filter + if(${test_type} STREQUAL "TEST_P") + string(REGEX REPLACE ${gtest_case_name_regex} "*/\\1.\\2/*" test_name ${hit}) + else() + string(REGEX REPLACE ${gtest_case_name_regex} "\\1.\\2" test_name ${hit}) + endif() add_test(${test_name} ${executable} --gtest_filter=${test_name} ${extra_args}) endforeach() endforeach() -- cgit v0.12 From f26147b8716adfbc46d93df0b05c7cde0c9413f4 Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Thu, 20 Mar 2014 09:57:38 +0100 Subject: UseSWIG: Enable NO_SONAME on swig modules (#14815) Swig modules are plugins and do not need the SONAME field set. --- Modules/UseSWIG.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 4ae6f81..9347687 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -201,6 +201,7 @@ macro(SWIG_ADD_MODULE name language) MODULE ${swig_generated_sources} ${swig_other_sources}) + set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES NO_SONAME ON) string(TOLOWER "${language}" swig_lowercase_language) if ("${swig_lowercase_language}" STREQUAL "octave") set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") -- cgit v0.12 From ff2451dc2483df34a70c611836b0ea887bfa3c82 Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Mon, 18 Nov 2013 12:03:58 +0100 Subject: ExternalProject: Strip trailing space from git hash --- Modules/ExternalProject.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 8235dda..e56cc37 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -454,6 +454,7 @@ execute_process( WORKING_DIRECTORY \"${work_dir}\" RESULT_VARIABLE error_code OUTPUT_VARIABLE head_sha + OUTPUT_STRIP_TRAILING_WHITESPACE ) if(error_code) message(FATAL_ERROR \"Failed to get the hash for HEAD\") @@ -479,6 +480,7 @@ execute_process( WORKING_DIRECTORY \"${work_dir}\" RESULT_VARIABLE error_code OUTPUT_VARIABLE tag_sha + OUTPUT_STRIP_TRAILING_WHITESPACE ) # Is the hash checkout out that we want? -- cgit v0.12 From f2128d4c2886ed4ac2532834f53b9522e6586601 Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Mon, 18 Nov 2013 11:36:18 +0100 Subject: ExternalProject: Improve handling of git remote branches ExternalProject handles git remote branches by commit hash. Due to this, the git repository ends in detached states, and local commits are discarded. Use "git rebase" for remote branches instead of "git checkout". If there are uncommitted changes, use "git stash save/pop" to save changes and restore them after the rebase. If any of these operations fails, try to restore the original status and exit with a fatal error, asking the user to resolve the conflicts manually. This also makes the behaviour of ExternalProject using git more similar to the svn version, and probably more likely to what the user expects by setting GIT_TAG to a branch. --- Modules/ExternalProject.cmake | 106 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 99 insertions(+), 7 deletions(-) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index e56cc37..e490e69 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -473,6 +473,17 @@ else() set(is_remote_ref 0) endif() +# Tag is in the form / (i.e. origin/master) we must strip +# the remote from the tag. +if(\"\${show_ref_output}\" MATCHES \"refs/remotes/${git_tag}\") + string(REGEX MATCH \"^([^/]+)/(.+)$\" _unused \"${git_tag}\") + set(git_remote \"\${CMAKE_MATCH_1}\") + set(git_tag \"\${CMAKE_MATCH_2}\") +else() + set(git_remote \"origin\") + set(git_tag \"${git_tag}\") +endif() + # This will fail if the tag does not exist (it probably has not been fetched # yet). execute_process( @@ -494,13 +505,94 @@ if(error_code OR is_remote_ref OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\" message(FATAL_ERROR \"Failed to fetch repository '${git_repository}'\") endif() - execute_process( - COMMAND \"${git_EXECUTABLE}\" checkout ${git_tag} - WORKING_DIRECTORY \"${work_dir}\" - RESULT_VARIABLE error_code - ) - if(error_code) - message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\") + if(is_remote_ref) + # Check if stash is needed + execute_process( + COMMAND \"${git_EXECUTABLE}\" status --porcelain + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + OUTPUT_VARIABLE repo_status + ) + if(error_code) + message(FATAL_ERROR \"Failed to get the status\") + endif() + string(LENGTH \"\${repo_status}\" need_stash) + + # If not in clean state, stash changes in order to be able to be able to + # perform git pull --rebase + if(need_stash) + execute_process( + COMMAND \"${git_EXECUTABLE}\" stash save --all --quiet + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) + if(error_code) + message(FATAL_ERROR \"Failed to stash changes\") + endif() + endif() + + # Pull changes from the remote branch + execute_process( + COMMAND \"${git_EXECUTABLE}\" rebase \${git_remote}/\${git_tag} + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) + if(error_code) + # Rebase failed: Restore previous state. + execute_process( + COMMAND \"${git_EXECUTABLE}\" rebase --abort + WORKING_DIRECTORY \"${work_dir}\" + ) + if(need_stash) + execute_process( + COMMAND \"${git_EXECUTABLE}\" stash pop --index --quiet + WORKING_DIRECTORY \"${work_dir}\" + ) + endif() + message(FATAL_ERROR \"\\nFailed to rebase in: '${work_dir}/${src_name}'.\\nYou will have to resolve the conflicts manually\") + endif() + + if(need_stash) + execute_process( + COMMAND \"${git_EXECUTABLE}\" stash pop --index --quiet + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) + if(error_code) + # Stash pop --index failed: Try again dropping the index + execute_process( + COMMAND \"${git_EXECUTABLE}\" reset --hard --quiet + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) + execute_process( + COMMAND \"${git_EXECUTABLE}\" stash pop --quiet + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) + if(error_code) + # Stash pop failed: Restore previous state. + execute_process( + COMMAND \"${git_EXECUTABLE}\" reset --hard --quiet \${head_sha} + WORKING_DIRECTORY \"${work_dir}\" + ) + execute_process( + COMMAND \"${git_EXECUTABLE}\" stash pop --index --quiet + WORKING_DIRECTORY \"${work_dir}\" + ) + message(FATAL_ERROR \"\\nFailed to unstash changes in: '${work_dir}/${src_name}'.\\nYou will have to resolve the conflicts manually\") + endif() + endif() + endif() + else() + execute_process( + COMMAND \"${git_EXECUTABLE}\" checkout ${git_tag} + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) + if(error_code) + message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\") + endif() endif() execute_process( -- cgit v0.12 From 2b896752567ceb771f0de0ff5afd7cd2de7205cc Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Mon, 31 Mar 2014 00:25:11 +0200 Subject: Ninja: Simplify code for linker commands Use GetCreateRuleVariable function instead of redundant code for Rule variable name. Use temporary variables to improve code. --- Source/cmNinjaNormalTargetGenerator.cxx | 80 ++++++++++++--------------------- 1 file changed, 29 insertions(+), 51 deletions(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 2d1bc76..20ce2c5 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -313,72 +313,49 @@ cmNinjaNormalTargetGenerator ::ComputeLinkCmd() { std::vector linkCmds; - cmTarget::TargetType targetType = this->GetTarget()->GetType(); - switch (targetType) { + cmMakefile* mf = this->GetMakefile(); + { + std::string linkCmdVar = "CMAKE_"; + linkCmdVar += this->TargetLinkLanguage; + linkCmdVar += this->GetGeneratorTarget()->GetCreateRuleVariable(); + const char *linkCmd = mf->GetDefinition(linkCmdVar); + if (linkCmd) + { + cmSystemTools::ExpandListArgument(linkCmd, linkCmds); + return linkCmds; + } + } + switch (this->GetTarget()->GetType()) { case cmTarget::STATIC_LIBRARY: { - // Check if you have a non archive way to create the static library. - { - std::string linkCmdVar = "CMAKE_"; - linkCmdVar += this->TargetLinkLanguage; - linkCmdVar += "_CREATE_STATIC_LIBRARY"; - if (const char *linkCmd = - this->GetMakefile()->GetDefinition(linkCmdVar)) - { - cmSystemTools::ExpandListArgument(linkCmd, linkCmds); - return linkCmds; - } - } - // We have archive link commands set. First, delete the existing archive. + { std::string cmakeCommand = this->GetLocalGenerator()->ConvertToOutputFormat( - this->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"), + mf->GetRequiredDefinition("CMAKE_COMMAND"), cmLocalGenerator::SHELL); linkCmds.push_back(cmakeCommand + " -E remove $out"); - + } // TODO: Use ARCHIVE_APPEND for archives over a certain size. { std::string linkCmdVar = "CMAKE_"; linkCmdVar += this->TargetLinkLanguage; linkCmdVar += "_ARCHIVE_CREATE"; - const char *linkCmd = - this->GetMakefile()->GetRequiredDefinition(linkCmdVar); + const char *linkCmd = mf->GetRequiredDefinition(linkCmdVar); cmSystemTools::ExpandListArgument(linkCmd, linkCmds); } { std::string linkCmdVar = "CMAKE_"; linkCmdVar += this->TargetLinkLanguage; linkCmdVar += "_ARCHIVE_FINISH"; - const char *linkCmd = - this->GetMakefile()->GetRequiredDefinition(linkCmdVar); + const char *linkCmd = mf->GetRequiredDefinition(linkCmdVar); cmSystemTools::ExpandListArgument(linkCmd, linkCmds); } return linkCmds; } case cmTarget::SHARED_LIBRARY: case cmTarget::MODULE_LIBRARY: - case cmTarget::EXECUTABLE: { - std::string linkCmdVar = "CMAKE_"; - linkCmdVar += this->TargetLinkLanguage; - switch (targetType) { - case cmTarget::SHARED_LIBRARY: - linkCmdVar += "_CREATE_SHARED_LIBRARY"; - break; - case cmTarget::MODULE_LIBRARY: - linkCmdVar += "_CREATE_SHARED_MODULE"; - break; - case cmTarget::EXECUTABLE: - linkCmdVar += "_LINK_EXECUTABLE"; - break; - default: - assert(0 && "Unexpected target type"); - } - - const char *linkCmd = - this->GetMakefile()->GetRequiredDefinition(linkCmdVar); - cmSystemTools::ExpandListArgument(linkCmd, linkCmds); - return linkCmds; - } + case cmTarget::EXECUTABLE: + break; default: assert(0 && "Unexpected target type"); } @@ -456,14 +433,17 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmNinjaDeps explicitDeps = this->GetObjects(); cmNinjaDeps implicitDeps = this->ComputeLinkDeps(); + cmMakefile* mf = this->GetMakefile(); + std::string frameworkPath; std::string linkPath; + cmGeneratorTarget* gtarget = this->GetGeneratorTarget(); this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"], vars["FLAGS"], vars["LINK_FLAGS"], frameworkPath, linkPath, - this->GetGeneratorTarget()); + gtarget); this->addPoolNinjaVariable("JOB_POOL_LINK", this->GetTarget(), vars); @@ -480,7 +460,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() ? vars["FLAGS"] : vars["ARCH_FLAGS"]); this->GetLocalGenerator()->AddArchitectureFlags(flags, - this->GetGeneratorTarget(), + gtarget, this->TargetLinkLanguage, this->GetConfigName()); if (targetType == cmTarget::EXECUTABLE) { @@ -490,7 +470,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } if (this->GetTarget()->HasSOName(this->GetConfigName())) { vars["SONAME_FLAG"] = - this->GetMakefile()->GetSONameFlag(this->TargetLinkLanguage); + mf->GetSONameFlag(this->TargetLinkLanguage); vars["SONAME"] = this->TargetNameSO; if (targetType == cmTarget::SHARED_LIBRARY) { std::string install_name_dir = this->GetTarget() @@ -513,7 +493,6 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() EnsureParentDirectoryExists(impLibPath); } - cmMakefile* mf = this->GetMakefile(); if (!this->SetMsvcTargetPdbVariable(vars)) { // It is common to place debug symbols at a specific place, @@ -556,8 +535,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() for (std::vector::const_iterator ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) { - cmCustomCommandGenerator ccg(*ci, this->GetConfigName(), - this->GetMakefile()); + cmCustomCommandGenerator ccg(*ci, this->GetConfigName(), mf); this->GetLocalGenerator()->AppendCustomCommandLines(ccg, *cmdLineLists[i]); } @@ -567,7 +545,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() // the link commands. if (!preLinkCmdLines.empty()) { const std::string homeOutDir = this->GetLocalGenerator() - ->ConvertToOutputFormat(this->GetMakefile()->GetHomeOutputDirectory(), + ->ConvertToOutputFormat(mf->GetHomeOutputDirectory(), cmLocalGenerator::SHELL); preLinkCmdLines.push_back("cd " + homeOutDir); } @@ -590,7 +568,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() int commandLineLengthLimit = 1; const char* forceRspFile = "CMAKE_NINJA_FORCE_RESPONSE_FILE"; - if (!this->GetMakefile()->IsDefinitionSet(forceRspFile) && + if (!mf->IsDefinitionSet(forceRspFile) && cmSystemTools::GetEnv(forceRspFile) == 0) { #ifdef _WIN32 commandLineLengthLimit = 8000 - linkRuleLength; -- cgit v0.12 From 0a1c0129617af6cbcc44a7f66fdb126603861e81 Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Wed, 4 Dec 2013 10:05:50 +0100 Subject: ExternalProject: Add EXCLUDE_FROM_MAIN option to ExternalProject_Add_Step When adding a new step using ExternalProject_Add_Step, the main target will depend on this step. This option allows one to add a step that will not be executed when the main target for the external project is executed. --- Modules/ExternalProject.cmake | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index e490e69..3c86331 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -119,6 +119,7 @@ # [DEPENDERS steps...] # Steps that depend on this step # [DEPENDS files...] # Files on which this step depends # [ALWAYS 1] # No stamp file, step always runs +# [EXCLUDE_FROM_MAIN 1] # Main target does not depend on this step # [WORKING_DIRECTORY dir] # Working directory for command # [LOG 1] # Wrap step in script to log output # ) @@ -1192,14 +1193,17 @@ function(ExternalProject_Add_Step name step) set(complete_stamp_file "${cmf_dir}${cfgdir}/${name}-complete") _ep_get_step_stampfile(${name} ${step} stamp_file) - add_custom_command(APPEND - OUTPUT ${complete_stamp_file} - DEPENDS ${stamp_file} - ) - _ep_parse_arguments(ExternalProject_Add_Step ${name} _EP_${step}_ "${ARGN}") + get_property(exclude_from_main TARGET ${name} PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN) + if(NOT exclude_from_main) + add_custom_command(APPEND + OUTPUT ${complete_stamp_file} + DEPENDS ${stamp_file} + ) + endif() + # Steps depending on this step. get_property(dependers TARGET ${name} PROPERTY _EP_${step}_DEPENDERS) foreach(depender IN LISTS dependers) -- cgit v0.12 From 1ddcc582c1a408e054efdcc32c00a8c07299d115 Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Fri, 6 Dec 2013 17:09:27 +0100 Subject: ExternalProject: Add EXCLUDE_FROM_ALL option to ExternalProject_Add When adding a new external project, the "all" target will depend on this. This option allows one to add an external project will not be executed when the "all" target is executed. The reason for this is that an external project could be useful, for example, only for running tests, and therefore not necessary during the build. --- Modules/ExternalProject.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 3c86331..0f651e9 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -16,6 +16,7 @@ # [LIST_SEPARATOR sep] # Sep to be replaced by ; in cmd lines # [TMP_DIR dir] # Directory to store temporary files # [STAMP_DIR dir] # Directory to store step timestamps +# [EXCLUDE_FROM_ALL 1] # The "all" target does not depend on this # #--Download step-------------- # [DOWNLOAD_NAME fname] # File name to store (if not end of URL) # [DOWNLOAD_DIR dir] # Directory to store downloaded files @@ -1913,6 +1914,9 @@ function(ExternalProject_Add name) set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles) set(complete_stamp_file "${cmf_dir}${cfgdir}/${name}-complete") + # The "ALL" option to add_custom_target just tells it to not set the + # EXCLUDE_FROM_ALL target property. Later, if the EXCLUDE_FROM_ALL + # argument was passed, we explicitly set it for the target. add_custom_target(${name} ALL DEPENDS ${complete_stamp_file}) set_property(TARGET ${name} PROPERTY _EP_IS_EXTERNAL_PROJECT 1) _ep_parse_arguments(ExternalProject_Add ${name} _EP_ "${ARGN}") @@ -1920,6 +1924,12 @@ function(ExternalProject_Add name) _ep_get_step_stampfile(${name} "done" done_stamp_file) _ep_get_step_stampfile(${name} "install" install_stamp_file) + # Set the EXCLUDE_FROM_ALL target property if required. + get_property(exclude_from_all TARGET ${name} PROPERTY _EP_EXCLUDE_FROM_ALL) + if(exclude_from_all) + set_property(TARGET ${name} PROPERTY EXCLUDE_FROM_ALL TRUE) + endif() + # The 'complete' step depends on all other steps and creates a # 'done' mark. A dependent external project's 'configure' step # depends on the 'done' mark so that it rebuilds when this project -- cgit v0.12 From 3a572290cc606039bae210309eefe82cfde85e54 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 1 Apr 2014 19:04:28 +0200 Subject: Help: Workaround Qt 4.8 assistant bug in CSS handling. Assistant in Qt 4.8 does not handle css import paths relative to the includer. This is fixed in Qt 4.8 commit b95750a275 (Assistant: Set the url on created QNetworkReply objects., 2014-03-31). It is unknown whether there will be a further Qt 4.8 release containing that commit. Use a CMake script to pre-replace the content prior to generating the qch file. An alternative workaround of moving the files or adding "_static" to the import path did not seem to work for existing Qt 4.8 versions. The bug was fixed in the Qt 5 branch before Qt 5.0. The Qt 5 assistant renders this workaround'ed version correctly too. --- Utilities/Sphinx/CMakeLists.txt | 4 ++++ Utilities/Sphinx/apply_qthelp_css_workaround.cmake | 15 +++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 Utilities/Sphinx/apply_qthelp_css_workaround.cmake diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index 51c83ba..4ae4bec 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -75,6 +75,10 @@ if(SPHINX_QTHELP) list(APPEND doc_formats qthelp) set(qthelp_extra_commands + # Workaround for assistant prior to + # https://codereview.qt-project.org/#change,82250 in Qt 4. + COMMAND ${CMAKE_COMMAND} "-DCSS_DIR=${CMAKE_CURRENT_BINARY_DIR}/qthelp/_static" + -P "${CMAKE_CURRENT_SOURCE_DIR}/apply_qthelp_css_workaround.cmake" COMMAND qcollectiongenerator ${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake.qhcp ) endif() diff --git a/Utilities/Sphinx/apply_qthelp_css_workaround.cmake b/Utilities/Sphinx/apply_qthelp_css_workaround.cmake new file mode 100644 index 0000000..8b74d12 --- /dev/null +++ b/Utilities/Sphinx/apply_qthelp_css_workaround.cmake @@ -0,0 +1,15 @@ + +file(READ "${CSS_DIR}/basic.css" BasicCssContent) + +file(READ "${CSS_DIR}/default.css" DefaultCssContent) +string(REPLACE + "@import url(\"basic.css\")" "${BasicCssContent}" + DefaultCssContent "${DefaultCssContent}" +) + +file(READ "${CSS_DIR}/cmake.css" CMakeCssContent) +string(REPLACE + "@import url(\"default.css\")" "${DefaultCssContent}" + CMakeCssContent "${CMakeCssContent}" +) +file(WRITE "${CSS_DIR}/cmake.css" "${CMakeCssContent}") -- cgit v0.12 From f2a3dd9d1acb252dd40c35859f9a148c2d0ff823 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 1 Apr 2014 14:54:28 -0400 Subject: cmIDEOptions: Factor FlagMap update out to separate method This will allow it to be re-used in other code paths. --- Source/cmIDEOptions.cxx | 59 +++++++++++++++++++++++++++---------------------- Source/cmIDEOptions.h | 1 + 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index e03223f..eda1ef6 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -99,33 +99,7 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table, (!(entry->special & cmIDEFlagTable::UserRequired) || static_cast(strlen(flag+1)) > n)) { - if(entry->special & cmIDEFlagTable::UserIgnored) - { - // Ignore the user-specified value. - this->FlagMap[entry->IDEName] = entry->value; - } - else if(entry->special & cmIDEFlagTable::SemicolonAppendable) - { - const char *new_value = flag+1+n; - - std::map::iterator itr; - itr = this->FlagMap.find(entry->IDEName); - if(itr != this->FlagMap.end()) - { - // Append to old value (if present) with semicolons; - itr->second += ";"; - itr->second += new_value; - } - else - { - this->FlagMap[entry->IDEName] = new_value; - } - } - else - { - // Use the user-specified value. - this->FlagMap[entry->IDEName] = flag+1+n; - } + this->FlagMapUpdate(entry, flag+n+1); entry_found = true; } } @@ -151,6 +125,37 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table, } //---------------------------------------------------------------------------- +void cmIDEOptions::FlagMapUpdate(cmIDEFlagTable const* entry, + const char* new_value) +{ + if(entry->special & cmIDEFlagTable::UserIgnored) + { + // Ignore the user-specified value. + this->FlagMap[entry->IDEName] = entry->value; + } + else if(entry->special & cmIDEFlagTable::SemicolonAppendable) + { + std::map::iterator itr; + itr = this->FlagMap.find(entry->IDEName); + if(itr != this->FlagMap.end()) + { + // Append to old value (if present) with semicolons; + itr->second += ";"; + itr->second += new_value; + } + else + { + this->FlagMap[entry->IDEName] = new_value; + } + } + else + { + // Use the user-specified value. + this->FlagMap[entry->IDEName] = new_value; + } +} + +//---------------------------------------------------------------------------- void cmIDEOptions::AddDefine(const std::string& def) { this->Defines.push_back(def); diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index 691893f..82c1a25 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -56,6 +56,7 @@ protected: void HandleFlag(const char* flag); bool CheckFlagTable(cmIDEFlagTable const* table, const char* flag, bool& flag_handled); + void FlagMapUpdate(cmIDEFlagTable const* entry, const char* new_value); virtual void StoreUnknownFlag(const char* flag) = 0; }; -- cgit v0.12 From 650199e7ca5821c160e5124e79aaf81141a7918f Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 1 Apr 2014 14:56:08 -0400 Subject: VS: Support mapping flags with values following separately (#14858) Add a "UserFollowing" special flag table entry indicator to say that a flag expects a value in a following argument. Teach cmIDEOptions to handle such flags. --- Source/cmIDEFlagTable.h | 1 + Source/cmIDEOptions.cxx | 21 +++++++++++++++++++-- Source/cmIDEOptions.h | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Source/cmIDEFlagTable.h b/Source/cmIDEFlagTable.h index e372c0a..d9a045d 100644 --- a/Source/cmIDEFlagTable.h +++ b/Source/cmIDEFlagTable.h @@ -31,6 +31,7 @@ struct cmIDEFlagTable // old value with semicolons (e.g. // /NODEFAULTLIB: => // IgnoreDefaultLibraryNames) + UserFollowing = (1<<5), // expect value in following argument UserValueIgnored = UserValue | UserIgnored, UserValueRequired = UserValue | UserRequired diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index eda1ef6..1f3c066 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -19,6 +19,7 @@ cmIDEOptions::cmIDEOptions() this->DoingDefine = false; this->AllowDefine = true; this->AllowSlash = false; + this->DoingFollowing = 0; for(int i=0; i < FlagTableCount; ++i) { this->FlagTable[i] = 0; @@ -41,6 +42,14 @@ void cmIDEOptions::HandleFlag(const char* flag) return; } + // If the last option expected a following value, this is it. + if(this->DoingFollowing) + { + this->FlagMapUpdate(this->DoingFollowing, flag); + this->DoingFollowing = 0; + return; + } + // Look for known arguments. if(flag[0] == '-' || (this->AllowSlash && flag[0] == '/')) { @@ -105,8 +114,16 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table, } else if(strcmp(flag+1, entry->commandFlag) == 0) { - // This flag table entry provides a fixed value. - this->FlagMap[entry->IDEName] = entry->value; + if(entry->special & cmIDEFlagTable::UserFollowing) + { + // This flag expects a value in the following argument. + this->DoingFollowing = entry; + } + else + { + // This flag table entry provides a fixed value. + this->FlagMap[entry->IDEName] = entry->value; + } entry_found = true; } diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index 82c1a25..e7749ec 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -51,6 +51,7 @@ protected: bool DoingDefine; bool AllowDefine; bool AllowSlash; + cmIDEFlagTable const* DoingFollowing; enum { FlagTableCount = 16 }; cmIDEFlagTable const* FlagTable[FlagTableCount]; void HandleFlag(const char* flag); -- cgit v0.12 From e8633e66785eb2f3618d7b31bfd22f26e7a38055 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 1 Apr 2014 14:59:20 -0400 Subject: VS: Fix /analyze:log flag mapping (#14858) Fix the VS 11 and VS 12 flag table entries for this flag. It requires a value in the following argument. Also drop the general "/analyze:" flag table entry so that such flags will be passed through as plain additional options. This is necessary because some such options have following values and some do not but not all have .vcxproj elements to hold the values. --- Source/cmVS11CLFlagTable.h | 9 +++------ Source/cmVS12CLFlagTable.h | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Source/cmVS11CLFlagTable.h b/Source/cmVS11CLFlagTable.h index 5ab8ebb..a61ab16 100644 --- a/Source/cmVS11CLFlagTable.h +++ b/Source/cmVS11CLFlagTable.h @@ -248,9 +248,9 @@ static cmVS7FlagTable cmVS11CLFlagTable[] = {"ForcedUsingFiles", "FU", "Forced #using File", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable}, - {"PREfastAdditionalOptions", "analyze:", - "Additional Code Analysis Native options", - "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable}, + {"PREfastLog", "analyze:log", + "Code Analysis Log", + "", cmVS7FlagTable::UserFollowing}, {"PREfastAdditionalPlugins", "analyze:plugin", "Additional Code Analysis Native plugins", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable}, @@ -283,9 +283,6 @@ static cmVS7FlagTable cmVS11CLFlagTable[] = "", cmVS7FlagTable::UserValue}, // Skip [XMLDocumentationFileName] - no command line Switch. // Skip [BrowseInformationFile] - no command line Switch. - {"PREfastLog", "analyze:log ", - "Code Analysis Log", - "", cmVS7FlagTable::UserValue}, // Skip [AdditionalOptions] - no command line Switch. {0,0,0,0,0} }; diff --git a/Source/cmVS12CLFlagTable.h b/Source/cmVS12CLFlagTable.h index 8f51319..0a7916f 100644 --- a/Source/cmVS12CLFlagTable.h +++ b/Source/cmVS12CLFlagTable.h @@ -254,9 +254,9 @@ static cmVS7FlagTable cmVS12CLFlagTable[] = {"ForcedUsingFiles", "FU", "Forced #using File", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable}, - {"PREfastAdditionalOptions", "analyze:", - "Additional Code Analysis Native options", - "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable}, + {"PREfastLog", "analyze:log", + "Code Analysis Log", + "", cmVS7FlagTable::UserFollowing}, {"PREfastAdditionalPlugins", "analyze:plugin", "Additional Code Analysis Native plugins", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable}, @@ -289,9 +289,6 @@ static cmVS7FlagTable cmVS12CLFlagTable[] = "", cmVS7FlagTable::UserValue}, // Skip [XMLDocumentationFileName] - no command line Switch. // Skip [BrowseInformationFile] - no command line Switch. - {"PREfastLog", "analyze:log ", - "Code Analysis Log", - "", cmVS7FlagTable::UserValue}, // Skip [AdditionalOptions] - no command line Switch. {0,0,0,0,0} }; -- cgit v0.12 From 5ada4be81bdb7695b2a4741db76ec66473ccd961 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 2 Apr 2014 00:01:06 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 27f2e91..aec1b18 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 0) -set(CMake_VERSION_PATCH 20140401) +set(CMake_VERSION_PATCH 20140402) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 936e00b92c9afe2be6b91d65166ade8ec1e06f48 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 27 Mar 2014 09:46:58 +0100 Subject: Simplify multiple config handling. Use conventional pattern of not repeating the loop body for empty config. --- Source/cmExportCommand.cxx | 15 ++++++--------- Source/cmGeneratorExpressionEvaluationFile.cxx | 15 ++++++--------- Source/cmLocalGenerator.cxx | 19 ++++++++----------- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index dcb77ba..2536ada 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -223,18 +223,15 @@ bool cmExportCommand // Compute the set of configurations exported. std::vector configurationTypes; this->Makefile->GetConfigurations(configurationTypes); - if(!configurationTypes.empty()) + if(configurationTypes.empty()) { - for(std::vector::const_iterator - ci = configurationTypes.begin(); - ci != configurationTypes.end(); ++ci) - { - ebfg->AddConfiguration(*ci); - } + configurationTypes.push_back(""); } - else + for(std::vector::const_iterator + ci = configurationTypes.begin(); + ci != configurationTypes.end(); ++ci) { - ebfg->AddConfiguration(""); + ebfg->AddConfiguration(*ci); } if (this->ExportSet) { diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index d41285d..95a946a 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -135,18 +135,15 @@ void cmGeneratorExpressionEvaluationFile::Generate() if (allConfigs.empty()) { - this->Generate("", inputExpression.get(), outputFiles); + allConfigs.push_back(""); } - else + for(std::vector::const_iterator li = allConfigs.begin(); + li != allConfigs.end(); ++li) { - for(std::vector::const_iterator li = allConfigs.begin(); - li != allConfigs.end(); ++li) + this->Generate(*li, inputExpression.get(), outputFiles); + if(cmSystemTools::GetFatalErrorOccured()) { - this->Generate(*li, inputExpression.get(), outputFiles); - if(cmSystemTools::GetFatalErrorOccured()) - { - return; - } + return; } } } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c47147c..9cafed1 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -542,6 +542,10 @@ void cmLocalGenerator::GenerateTargetManifest() // Collect the set of configuration types. std::vector configNames; this->Makefile->GetConfigurations(configNames); + if(configNames.empty()) + { + configNames.push_back(""); + } // Add our targets to the manifest for each configuration. cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); @@ -557,18 +561,11 @@ void cmLocalGenerator::GenerateTargetManifest() { continue; } - if(configNames.empty()) + for(std::vector::iterator ci = configNames.begin(); + ci != configNames.end(); ++ci) { - target.GenerateTargetManifest(""); - } - else - { - for(std::vector::iterator ci = configNames.begin(); - ci != configNames.end(); ++ci) - { - const char* config = ci->c_str(); - target.GenerateTargetManifest(config); - } + const char* config = ci->c_str(); + target.GenerateTargetManifest(config); } } } -- cgit v0.12 From 1e22b23c8133d4e5b8adb9dfca0cf544df7b6cc0 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Tue, 1 Apr 2014 21:20:41 +0200 Subject: Watcom: Cleanup Windows-wcl386 configuration * Remove Watcom linker caseexact options already defined in system definition. * Use win_dll system for SHARED_LIBRARY and SHARED_MODULE. * Use explicit target definition -bt=.. option for proper initialization of compiler Windows environment (predefined macros) * Reorganize compiler options to global options and configuration specific options * Use option to optimize out stack checking code for release version --- Modules/Platform/Windows-wcl386.cmake | 50 +++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake index 617761b..72a5929 100644 --- a/Modules/Platform/Windows-wcl386.cmake +++ b/Modules/Platform/Windows-wcl386.cmake @@ -12,13 +12,15 @@ else() set(CMAKE_LIB_QUIET "-q") endif() +set(CMAKE_EXE_LINKER_FLAGS_INIT) set(CMAKE_CREATE_WIN32_EXE "system nt_win" ) set(CMAKE_CREATE_CONSOLE_EXE "system nt" ) - -set (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "debug all" ) -set (CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT "debug all" ) -set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all" ) -set (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all" ) +set(CMAKE_SHARED_LINKER_FLAGS_INIT "system nt_dll") +set(CMAKE_MODULE_LINKER_FLAGS_INIT "system nt_dll") +foreach(type SHARED MODULE EXE) + set(CMAKE_${type}_LINKER_FLAGS_DEBUG_INIT "debug all opt map, symfile") + set(CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all opt map, symfile") +endforeach() set(CMAKE_C_COMPILE_OPTIONS_DLL "-bd") # Note: This variable is a ';' separated list set(CMAKE_SHARED_LIBRARY_C_FLAGS "-bd") # ... while this is a space separated string. @@ -26,18 +28,18 @@ set(CMAKE_SHARED_LIBRARY_C_FLAGS "-bd") # ... while this is a space separated st set(CMAKE_RC_COMPILER "rc" ) set(CMAKE_BUILD_TYPE_INIT Debug) -set (CMAKE_CXX_FLAGS_INIT "-w=3 -xs") -set (CMAKE_CXX_FLAGS_DEBUG_INIT "-br -bm -d2") -set (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-br -bm -os -dNDEBUG") -set (CMAKE_CXX_FLAGS_RELEASE_INIT "-br -bm -ot -dNDEBUG") -set (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-br -bm -d2 -ot -dNDEBUG") -set (CMAKE_C_FLAGS_INIT "-w=3 ") -set (CMAKE_C_FLAGS_DEBUG_INIT "-br -bm -d2 -od") -set (CMAKE_C_FLAGS_MINSIZEREL_INIT "-br -bm -os -dNDEBUG") -set (CMAKE_C_FLAGS_RELEASE_INIT "-br -bm -ot -dNDEBUG") -set (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-br -bm -d2 -ot -dNDEBUG") -set (CMAKE_C_STANDARD_LIBRARIES_INIT "library clbrdll.lib library plbrdll.lib library kernel32.lib library user32.lib library gdi32.lib library winspool.lib library comdlg32.lib library advapi32.lib library shell32.lib library ole32.lib library oleaut32.lib library uuid.lib library odbc32.lib library odbccp32.lib") -set (CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") + +# single/multi-threaded /-bm +# static/DLL run-time libraries /-br +# default is setup for multi-threaded + DLL run-time libraries +set (CMAKE_C_FLAGS_INIT "-bt=nt -w3 -dWIN32 -br -bm") +set (CMAKE_CXX_FLAGS_INIT "-bt=nt -xs -w3 -dWIN32 -br -bm") +foreach(lang C CXX) + set (CMAKE_${lang}_FLAGS_DEBUG_INIT "-d2") + set (CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-s -os -d0 -dNDEBUG") + set (CMAKE_${lang}_FLAGS_RELEASE_INIT "-s -ot -d0 -dNDEBUG") + set (CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-s -ot -d1 -dNDEBUG") +endforeach() foreach(type CREATE_SHARED_LIBRARY CREATE_SHARED_MODULE LINK_EXECUTABLE) set(CMAKE_C_${type}_USE_WATCOM_QUOTE 1) @@ -49,29 +51,29 @@ set(CMAKE_C_CREATE_IMPORT_LIBRARY set(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY}) set(CMAKE_C_LINK_EXECUTABLE - "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '' option caseexact file {} ${CMAKE_END_TEMP_FILE}") + "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '' file {} ${CMAKE_END_TEMP_FILE}") set(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE}) # compile a C++ file into an object file set(CMAKE_CXX_COMPILE_OBJECT - " ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -dWIN32 -d+ -fo -c -cc++ ${CMAKE_END_TEMP_FILE}") + " ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -d+ -fo -c -cc++ ${CMAKE_END_TEMP_FILE}") # compile a C file into an object file set(CMAKE_C_COMPILE_OBJECT - " ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -dWIN32 -d+ -fo -c -cc ${CMAKE_END_TEMP_FILE}") + " ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -d+ -fo -c -cc ${CMAKE_END_TEMP_FILE}") # preprocess a C source file set(CMAKE_C_CREATE_PREPROCESSED_SOURCE - " ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -dWIN32 -d+ -fo -pl -cc ${CMAKE_END_TEMP_FILE}") + " ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -d+ -fo -pl -cc ${CMAKE_END_TEMP_FILE}") # preprocess a C++ source file set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE - " ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -dWIN32 -d+ -fo -pl -cc++ ${CMAKE_END_TEMP_FILE}") + " ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -d+ -fo -pl -cc++ ${CMAKE_END_TEMP_FILE}") set(CMAKE_CXX_CREATE_SHARED_LIBRARY - "wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name '' option implib= option caseexact file {} ${CMAKE_END_TEMP_FILE}") + "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '' option implib= file {} ${CMAKE_END_TEMP_FILE}") string(REPLACE " option implib=" "" CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}") @@ -91,8 +93,10 @@ if(NOT _CMAKE_WATCOM_VERSION) set(_CMAKE_WATCOM_VERSION 1) if(CMAKE_C_COMPILER_VERSION) set(_compiler_version ${CMAKE_C_COMPILER_VERSION}) + set(_compiler_id ${CMAKE_C_COMPILER_ID}) else() set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION}) + set(_compiler_id ${CMAKE_CXX_COMPILER_ID}) endif() set(WATCOM16) set(WATCOM17) -- cgit v0.12 From 1de086855caa63063380387d70811e8acf1f3d05 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 2 Apr 2014 09:35:36 -0400 Subject: cmSystemTools: Restore unreachable return to silence warnings Some compilers do not recognize that the end of copy_data cannot be reached and complain that there is no return statement. Clang warns that there is an unreachable return statement if it appears. Conditionally add the return statement when not building with Clang. --- Source/cmSystemTools.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 2f5f493..21e3874 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1662,6 +1662,9 @@ long copy_data(struct archive *ar, struct archive *aw) return (r); } } +#if !defined(__clang__) + return r; /* this should not happen but it silences a warning */ +#endif } bool extract_tar(const char* outFileName, bool verbose, -- cgit v0.12 From fcdf86d004d1e5f07a7f2a8b97860da3ff65546e Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Wed, 26 Mar 2014 18:54:02 +0000 Subject: Help: Rewrite the cmake-developer.7 find module documentation As well as the traditional variables, providing imported targets is suggested, and the relative advantages and disadvantages briefly discussed. A mini-tutorial walking through creating a simple find module is provided. This changes the recommended version variable from Foo_VERSION_STRING to Foo_VERSION, because there is really no need to have different variable names for package version files vs. find modules. It notes the old variable name, though, and suggests setting it for compatibility. --- Help/manual/cmake-developer.7.rst | 545 ++++++++++++++++++++++++++------------ 1 file changed, 370 insertions(+), 175 deletions(-) diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst index d025d63..7f31970 100644 --- a/Help/manual/cmake-developer.7.rst +++ b/Help/manual/cmake-developer.7.rst @@ -664,213 +664,408 @@ For example, a ``Modules/Findxxx.cmake`` module may contain: endmacro() +After the top documentation block, leave a *BLANK* line, and then add a +copyright and licence notice block like this one (change only the year +range and name) + +.. code-block:: cmake + + #============================================================================= + # Copyright 2009-2011 Your Name + # + # Distributed under the OSI-approved BSD License (the "License"); + # see accompanying file Copyright.txt for details. + # + # This software is distributed WITHOUT ANY WARRANTY; without even the + # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + # See the License for more information. + #============================================================================= + # (To distribute this file outside of CMake, substitute the full + # License text for the above reference.) + +Test the documentation formatting by running +``cmake --help-module ``, and also by enabling the +``SPHINX_HTML`` and ``SPHINX_MAN`` options to build the documentation. +Edit the comments until generated documentation looks satisfactory. To +have a .cmake file in this directory NOT show up in the modules +documentation, simply leave out the ``Help/module/.rst`` +file and the ``Help/manual/cmake-modules.7.rst`` toctree entry. + + Find Modules ------------ A "find module" is a ``Modules/Find.cmake`` file to be loaded by the :command:`find_package` command when invoked for ````. -We would like all ``FindXxx.cmake`` files to produce consistent variable -names. Please use the following consistent variable names for general use. +The primary task of a find module is to determine whether a package +exists on the system, set the ``_FOUND`` variable to reflect +this and provide any variables, macros and imported targets required to +use the package. + +The traditional approach is to use variables for everything, including +libraries and executables: see the `Standard Variable Names`_ section +below. This is what most of the existing find modules provided by CMake +do. -Xxx_INCLUDE_DIRS - The final set of include directories listed in one variable for use by client - code. This should not be a cache entry. +The more modern approach is to behave as much like +``Config.cmake`` files as possible, by providing imported +targets. As well as matching how ``*Config.cmake`` files work, the +libraries, include directories and compile definitions are all set just +by using the target in a :command:`target_link_libraries` call. The +disadvantage is that ``*Config.cmake`` files of projects that use +imported targets from find modules may require more work to make sure +those imported targets that are in the link interface are available. + +In either case (or even when providing both variables and imported +targets), find modules should provide backwards compatibility with old +versions that had the same name. + +A FindFoo.cmake module will typically be loaded by the command:: + + find_package(Foo [major[.minor[.patch[.tweak]]]] + [EXACT] [QUIET] [REQUIRED] + [[COMPONENTS] [components...]] + [OPTIONAL_COMPONENTS components...] + [NO_POLICY_SCOPE]) + +See the :command:`find_package` documentation for details on what +variables are set for the find module. Most of these are dealt with by +using :module:`FindPackageHandleStandardArgs`. + +Briefly, the module should only locate versions of the package +compatible with the requested version, as described by the +``Foo_FIND_VERSION`` family of variables. If ``Foo_FIND_QUIETLY`` is +set to true, it should avoid printing messages, including anything +complaining about the package not being found. If ``Foo_FIND_REQUIRED`` +is set to true, the module should issue a ``FATAL_ERROR`` if the package +cannot be found. If neither are set to true, it should print a +non-fatal message if it cannot find the package. + +Packages that find multiple semi-independent parts (like bundles of +libraries) should search for the components listed in +``Foo_FIND_COMPONENTS`` if it is set , and only set ``Foo_FOUND`` to +true if for each searched-for component ```` that was not found, +``Foo_FIND_REQUIRED_`` is not set to true. The ``HANDLE_COMPONENTS`` +argument of ``find_package_handle_standard_args()`` can be used to +implement this. + +If ``Foo_FIND_COMPONENTS`` is not set, which modules are searched for +and required is up to the find module, but should be documented. + +For internal implementation, it is a generally accepted convention that +variables starting with underscore are for temporary use only. + +Like all modules, find modules should be properly documented. To add a +module to the CMake documentation, follow the steps in the `Module +Documentation`_ section above. + + + +Standard Variable Names +~~~~~~~~~~~~~~~~~~~~~~~ + +For a ``FindXxx.cmake`` module that takes the approach of setting +variables (either instead of or in addition to creating imported +targets), the following variable names should be used to keep things +consistent between find modules. Note that all variables start with +``Xxx_`` to make sure they do not interfere with other find modules; the +same consideration applies to macros, functions and imported targets. + +``Xxx_INCLUDE_DIRS`` + The final set of include directories listed in one variable for use by + client code. This should not be a cache entry. + +``Xxx_LIBRARIES`` + The libraries to link against to use Xxx. These should include full + paths. This should not be a cache entry. + +``Xxx_DEFINITIONS`` + Definitions to use when compiling code that uses Xxx. This really + shouldn't include options such as ``-DHAS_JPEG`` that a client + source-code file uses to decide whether to ``#include `` + +``Xxx_EXECUTABLE`` + Where to find the Xxx tool. + +``Xxx_Yyy_EXECUTABLE`` + Where to find the Yyy tool that comes with Xxx. + +``Xxx_LIBRARY_DIRS`` + Optionally, the final set of library directories listed in one + variable for use by client code. This should not be a cache entry. + +``Xxx_ROOT_DIR`` + Where to find the base directory of Xxx. + +``Xxx_VERSION_Yy`` + Expect Version Yy if true. Make sure at most one of these is ever true. + +``Xxx_WRAP_Yy`` + If False, do not try to use the relevant CMake wrapping command. + +``Xxx_Yy_FOUND`` + If False, optional Yy part of Xxx sytem is not available. -Xxx_LIBRARIES - The libraries to link against to use Xxx. These should include full paths. - This should not be a cache entry. +``Xxx_FOUND`` + Set to false, or undefined, if we haven't found, or don't want to use + Xxx. -Xxx_DEFINITIONS - Definitions to use when compiling code that uses Xxx. This really shouldn't - include options such as (-DHAS_JPEG)that a client source-code file uses to - decide whether to #include +``Xxx_NOT_FOUND_MESSAGE`` + Should be set by config-files in the case that it has set + ``Xxx_FOUND`` to FALSE. The contained message will be printed by the + :command:`find_package` command and by + ``find_package_handle_standard_args()`` to inform the user about the + problem. -Xxx_EXECUTABLE - Where to find the Xxx tool. +``Xxx_RUNTIME_LIBRARY_DIRS`` + Optionally, the runtime library search path for use when running an + executable linked to shared libraries. The list should be used by + user code to create the ``PATH`` on windows or ``LD_LIBRARY_PATH`` on + UNIX. This should not be a cache entry. -Xxx_Yyy_EXECUTABLE - Where to find the Yyy tool that comes with Xxx. +``Xxx_VERSION`` + The full version string of the package found, if any. Note that many + existing modules provide ``Xxx_VERSION_STRING`` instead. -Xxx_LIBRARY_DIRS - Optionally, the final set of library directories listed in one variable for - use by client code. This should not be a cache entry. +``Xxx_VERSION_MAJOR`` + The major version of the package found, if any. -Xxx_ROOT_DIR - Where to find the base directory of Xxx. +``Xxx_VERSION_MINOR`` + The minor version of the package found, if any. -Xxx_VERSION_Yy - Expect Version Yy if true. Make sure at most one of these is ever true. +``Xxx_VERSION_PATCH`` + The patch version of the package found, if any. -Xxx_WRAP_Yy - If False, do not try to use the relevant CMake wrapping command. +The following names should not usually be used in CMakeLists.txt files, but +are typically cache variables for users to edit and control the +behaviour of find modules (like entering the path to a library manually) -Xxx_Yy_FOUND - If False, optional Yy part of Xxx sytem is not available. +``Xxx_LIBRARY`` + The path of the Xxx library (as used with :command:`find_library`, for + example). -Xxx_FOUND - Set to false, or undefined, if we haven't found, or don't want to use Xxx. +``Xxx_Yy_LIBRARY`` + The path of the Yy library that is part of the Xxx system. It may or + may not be required to use Xxx. -Xxx_NOT_FOUND_MESSAGE - Should be set by config-files in the case that it has set Xxx_FOUND to FALSE. - The contained message will be printed by the find_package() command and by - find_package_handle_standard_args() to inform the user about the problem. +``Xxx_INCLUDE_DIR`` + Where to find headers for using the Xxx library. -Xxx_RUNTIME_LIBRARY_DIRS - Optionally, the runtime library search path for use when running an - executable linked to shared libraries. The list should be used by user code - to create the PATH on windows or LD_LIBRARY_PATH on unix. This should not be - a cache entry. +``Xxx_Yy_INCLUDE_DIR`` + Where to find headers for using the Yy library of the Xxx system. -Xxx_VERSION_STRING - A human-readable string containing the version of the package found, if any. +To prevent users being overwhelmed with settings to configure, try to +keep as many options as possible out of the cache, leaving at least one +option which can be used to disable use of the module, or locate a +not-found library (e.g. ``Xxx_ROOT_DIR``). For the same reason, mark +most cache options as advanced. -Xxx_VERSION_MAJOR - The major version of the package found, if any. +While these are the standard variable names, you should provide +backwards compatibility for any old names that were actually in use. +Make sure you comment them as deprecated, so that no-one starts using +them. -Xxx_VERSION_MINOR - The minor version of the package found, if any. -Xxx_VERSION_PATCH - The patch version of the package found, if any. -You do not have to provide all of the above variables. You should provide -Xxx_FOUND under most circumstances. If Xxx is a library, then Xxx_LIBRARIES, -should also be defined, and Xxx_INCLUDE_DIRS should usually be defined (I -guess libm.a might be an exception) +A Sample Find Module +~~~~~~~~~~~~~~~~~~~~ -The following names should not usually be used in CMakeLists.txt files, but -they may be usefully modified in users' CMake Caches to control stuff. +We will describe how to create a simple find module for a library +``Foo``. -Xxx_LIBRARY - Name of Xxx Library. A User may set this and Xxx_INCLUDE_DIR to ignore to - force non-use of Xxx. +The first thing that is needed is documentation. CMake's documentation +system requires you to start the file with a documentation marker and +the name of the module. You should follow this with a simple statement +of what the module does. -Xxx_Yy_LIBRARY - Name of Yy library that is part of the Xxx system. It may or may not be - required to use Xxx. +.. code-block:: cmake -Xxx_INCLUDE_DIR - Where to find xxx.h, etc. (Xxx_INCLUDE_PATH was considered bad because a path - includes an actual filename.) + #.rst: + # FindFoo + # ------- + # + # Finds the Foo library + # -Xxx_Yy_INCLUDE_DIR - Where to find xxx_yy.h, etc. +More description may be required for some packages. If there are +caveats or other details users of the module should be aware of, you can +add further paragraphs below this. Then you need to document what +variables and imported targets are set by the module, such as -For tidiness's sake, try to keep as many options as possible out of the cache, -leaving at least one option which can be used to disable use of the module, or -locate a not-found library (e.g. Xxx_ROOT_DIR). For the same reason, mark -most cache options as advanced. +.. code-block:: cmake -If you need other commands to do special things then it should still begin -with ``Xxx_``. This gives a sort of namespace effect and keeps things tidy for the -user. You should put comments describing all the exported settings, plus -descriptions of any the users can use to control stuff. + # This will define the following variables:: + # + # Foo_FOUND - True if the system has the Foo library + # Foo_VERSION - The version of the Foo library which was found + # + # and the following imported targets:: + # + # Foo::Foo - The Foo library -You really should also provide backwards compatibility any old settings that -were actually in use. Make sure you comment them as deprecated, so that -no-one starts using them. +If the package provides any macros, they should be listed here, but can +be documented where they are defined. See the `Module +Documentation`_ section above for more details. -To add a module to the CMake documentation, follow the steps in the -`Module Documentation`_ section above. Test the documentation formatting -by running ``cmake --help-module FindXxx``, and also by enabling the -``SPHINX_HTML`` and ``SPHINX_MAN`` options to build the documentation. -Edit the comments until generated documentation looks satisfactory. -To have a .cmake file in this directory NOT show up in the modules -documentation, simply leave out the ``Help/module/.rst`` file -and the ``Help/manual/cmake-modules.7.rst`` toctree entry. +After the documentation, leave a blank line, and then add a copyright and +licence notice block -After the documentation, leave a *BLANK* line, and then add a -copyright and licence notice block like this one:: +.. code-block:: cmake - #============================================================================= - # Copyright 2009-2011 Your Name - # - # Distributed under the OSI-approved BSD License (the "License"); - # see accompanying file Copyright.txt for details. - # - # This software is distributed WITHOUT ANY WARRANTY; without even the - # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - # See the License for more information. - #============================================================================= - # (To distribute this file outside of CMake, substitute the full - # License text for the above reference.) - -The layout of the notice block is strictly enforced by the ``ModuleNotices`` -test. Only the year range and name may be changed freely. - -A FindXxx.cmake module will typically be loaded by the command:: - - FIND_PACKAGE(Xxx [major[.minor[.patch[.tweak]]]] [EXACT] - [QUIET] [[REQUIRED|COMPONENTS] [components...]]) - -If any version numbers are given to the command it will set the following -variables before loading the module: - -Xxx_FIND_VERSION - full requested version string - -Xxx_FIND_VERSION_MAJOR - major version if requested, else 0 - -Xxx_FIND_VERSION_MINOR - minor version if requested, else 0 - -Xxx_FIND_VERSION_PATCH - patch version if requested, else 0 - -Xxx_FIND_VERSION_TWEAK - tweak version if requested, else 0 - -Xxx_FIND_VERSION_COUNT - number of version components, 0 to 4 - -Xxx_FIND_VERSION_EXACT - true if EXACT option was given - -If the find module supports versioning it should locate a version of -the package that is compatible with the version requested. If a -compatible version of the package cannot be found the module should -not report success. The version of the package found should be stored -in "Xxx_VERSION..." version variables documented by the module. - -If the QUIET option is given to the command it will set the variable -Xxx_FIND_QUIETLY to true before loading the FindXxx.cmake module. If -this variable is set the module should not complain about not being -able to find the package. If the -REQUIRED option is given to the command it will set the variable -Xxx_FIND_REQUIRED to true before loading the FindXxx.cmake module. If -this variable is set the module should issue a FATAL_ERROR if the -package cannot be found. -If neither the QUIET nor REQUIRED options are given then the -FindXxx.cmake module should look for the package and complain without -error if the module is not found. - -FIND_PACKAGE() will set the variable CMAKE_FIND_PACKAGE_NAME to -contain the actual name of the package. - -A package can provide sub-components. -Those components can be listed after the COMPONENTS (or REQUIRED) or -OPTIONAL_COMPONENTS keywords. The set of all listed components will be -specified in a Xxx_FIND_COMPONENTS variable. -For each package-specific component, say Yyy, a variable Xxx_FIND_REQUIRED_Yyy -will be set to true if it listed after COMPONENTS and it will be set to false -if it was listed after OPTIONAL_COMPONENTS. -Using those variables a FindXxx.cmake module and also a XxxConfig.cmake -package configuration file can determine whether and which components have -been requested, and whether they were requested as required or as optional. -For each of the requested components a Xxx_Yyy_FOUND variable should be set -accordingly. -The per-package Xxx_FOUND variable should be only set to true if all requested -required components have been found. A missing optional component should not -keep the Xxx_FOUND variable from being set to true. -If the package provides Xxx_INCLUDE_DIRS and Xxx_LIBRARIES variables, the -include dirs and libraries for all components which were requested and which -have been found should be added to those two variables. - -To get this behavior you can use the FIND_PACKAGE_HANDLE_STANDARD_ARGS() -macro, as an example see FindJPEG.cmake. - -For internal implementation, it's a generally accepted convention that -variables starting with underscore are for temporary use only. (variable -starting with an underscore are not intended as a reserved prefix). + #============================================================================= + # Copyright 2009-2011 Your Name + # + # Distributed under the OSI-approved BSD License (the "License"); + # see accompanying file Copyright.txt for details. + # + # This software is distributed WITHOUT ANY WARRANTY; without even the + # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + # See the License for more information. + #============================================================================= + # (To distribute this file outside of CMake, substitute the full + # License text for the above reference.) + +If the module is new to CMake, you may want to provide a warning for +projects that do not require a high enough CMake version. + +.. code-block:: cmake + + if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 3.0.0) + message(AUTHOR_WARNING "Your project should require at least CMake 3.0.0 to use FindFoo.cmake") + endif() + +Now the actual libraries and so on have to be found. The code here will +obviously vary from module to module (dealing with that, after all, is the +point of find modules), but there tends to be a common pattern for libraries. + +First, we try to use ``pkg-config`` to find the library. Note that we +cannot rely on this, as it may not be available, but it provides a good +starting point. + +.. code-block:: cmake + + find_package(PkgConfig) + pkg_check_modules(PC_Foo QUIET Foo) + +This should define some variables starting ``PC_Foo_`` that contain the +information from the ``Foo.pc`` file. + +Now we need to find the libraries and include files; we use the +information from ``pkg-config`` to provide hints to CMake about where to +look. + +.. code-block:: cmake + + find_path(Foo_INCLUDE_DIR + NAMES foo.h + PATHS ${PC_Foo_INCLUDE_DIRS} + # if you need to put #include in your code, add: + PATH_SUFFIXES Foo + ) + find_library(Foo_LIBRARY + NAMES foo + PATHS ${PC_Foo_LIBRARY_DIRS} + ) + +If you have a good way of getting the version (from a header file, for +example), you can use that information to set ``Foo_VERSION`` (although +note that find modules have traditionally used ``Foo_VERSION_STRING``, +so you may want to set both). Otherwise, attempt to use the information +from ``pkg-config`` + +.. code-block:: cmake + + set(Foo_VERSION ${PC_Foo_VERSION}) + +Now we can use :module:`FindPackageHandleStandardArgs` to do most of the +rest of the work for us + +.. code-block:: cmake + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(Foo + FOUND_VAR Foo_FOUND + REQUIRED_VARS + Foo_LIBRARY + Foo_INCLUDE_DIR + VERSION_VAR Foo_VERSION + ) + +This will check that the ``REQUIRED_VARS`` contain values (that do not +end in ``-NOTFOUND``) and set ``Foo_FOUND`` appropriately. It will also +cache those values. If ``Foo_VERSION`` is set, and a required version +was passed to :command:`find_package`, it will check the requested version +against the one in ``Foo_VERSION``. It will also print messages as +appropriate; note that if the package was found, it will print the +contents of the first required variable to indicate where it was found. + +At this point, we have to provide a way for users of the find module to +link to the library or libraries that were found. There are two +approaches, as discussed in the `Find Modules`_ section above. The +traditional variable approach looks like + +.. code-block:: cmake + + if(Foo_FOUND) + set(Foo_LIBRARIES ${Foo_LIBRARY}) + set(Foo_INCLUDE_DIRS ${Foo_INCLUDE_DIR}) + set(Foo_DEFINITIONS ${PC_Foo_CFLAGS_OTHER}) + endif() + +If more than one library was found, all of them should be included in +these variables (see the `Standard Variable Names`_ section for more +information). + +When providing imported targets, these should be namespaced (hence the +``Foo::`` prefix); CMake will recognize that values passed to +:command:`target_link_libraries` that contain ``::`` in their name are +supposed to be imported targets (rather than just library names), and +will produce appropriate diagnostic messages if that target does not +exist (see policy :policy:`CMP0028`). + +.. code-block:: cmake + + if(Foo_FOUND AND NOT TARGET Foo::Foo) + add_library(Foo::Foo UNKNOWN IMPORTED) + set_target_properties(Foo::Foo PROPERTIES + IMPORTED_LOCATION "${Foo_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PC_Foo_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Foo_INCLUDE_DIR}" + ) + endif() + +One thing to note about this is that the ``INTERFACE_INCLUDE_DIRECTORIES`` and +similar properties should only contain information about the target itself, and +not any of its dependencies. Instead, those dependencies should also be +targets, and CMake should be told that they are dependencies of this target. +CMake will then combine all the necessary information automatically. + +We should also provide some information about the package, such as where to +download it. + +.. code-block:: cmake + + include(FeatureSummary) + set_package_properties(Foo PROPERTIES + URL "http://www.foo.example.com/" + DESCRIPTION "A library for doing useful things" + ) + +Most of the cache variables should be hidden in the ``ccmake`` interface unless +the user explicitly asks to edit them. + +.. code-block:: cmake + + mark_as_advanced( + Foo_INCLUDE_DIR + Foo_LIBRARY + ) + +If this module replaces an older version, you should set compatibility variables +to cause the least disruption possible. + +.. code-block:: cmake + + # compatibility variables + set(Foo_VERSION_STRING ${Foo_VERSION}) -- cgit v0.12 From 391c73dbbf73f1830ab6e412b23b7b66a52b3883 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 2 Apr 2014 11:39:47 -0400 Subject: CTestCustom: Suppress conversion warnings in QtWidgets headers We already do so for QtCore and QtGui headers. --- CTestCustom.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index 6010b64..94a71b3 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -46,7 +46,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION "(Lexer|Parser).*warning.*conversion.*may (alter its value|change the sign)" "(Lexer|Parser).*warning.*statement is unreachable" "PGC-W-0095-Type cast required for this conversion.*ProcessUNIX.c" - "[Qq]t([Cc]ore|[Gg]ui).*warning.*conversion.*may alter its value" + "[Qq]t([Cc]ore|[Gg]ui|[Ww]idgets).*warning.*conversion.*may alter its value" "warning:.*is.*very unsafe.*consider using.*" "warning:.*is.*misused, please use.*" "CMakeSetupManifest.xml.*manifest authoring warning.*Unrecognized Element" -- cgit v0.12 From 13684e2b78bf273b20e6ea3acf9defe61e871327 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 2 Apr 2014 14:31:04 -0400 Subject: cmMakefile: Port PolicyOptionalWarningEnabled to string APIs This method was added in a commit based on a release branch that pre-dated the std::string API changes. Port the implementation to use the string APIs instead of c_str(). --- Source/cmMakefile.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index b0ff258..621b8ee 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4336,7 +4336,7 @@ bool cmMakefile::PolicyOptionalWarningEnabled(std::string const& var) // Check for an explicit CMAKE_POLICY_WARNING_CMP setting. if(!var.empty()) { - if(const char* val = this->GetDefinition(var.c_str())) + if(const char* val = this->GetDefinition(var)) { return cmSystemTools::IsOn(val); } -- cgit v0.12 From 5702e10677e72a75370e8c1bbe6f10fa5ad675a9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 18 Mar 2014 16:15:15 +0100 Subject: cmTarget: Include TARGET_OBJECTS genex in target SOURCES property. Add policy CMP0051 to control this behavior. --- Help/manual/cmake-policies.7.rst | 1 + Help/policy/CMP0051.rst | 24 +++++++++ Help/release/dev/target-SOURCES-genex.rst | 7 +++ Source/cmPolicies.cxx | 5 ++ Source/cmPolicies.h | 1 + Source/cmTarget.cxx | 69 ++++++++++++++++++++++---- Tests/RunCMake/CMP0051/CMP0051-NEW-result.txt | 1 + Tests/RunCMake/CMP0051/CMP0051-NEW-stderr.txt | 1 + Tests/RunCMake/CMP0051/CMP0051-NEW.cmake | 10 ++++ Tests/RunCMake/CMP0051/CMP0051-OLD-result.txt | 1 + Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt | 1 + Tests/RunCMake/CMP0051/CMP0051-OLD.cmake | 10 ++++ Tests/RunCMake/CMP0051/CMP0051-WARN-result.txt | 1 + Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt | 15 ++++++ Tests/RunCMake/CMP0051/CMP0051-WARN.cmake | 8 +++ Tests/RunCMake/CMP0051/CMakeLists.txt | 3 ++ Tests/RunCMake/CMP0051/RunCMakeTest.cmake | 5 ++ Tests/RunCMake/CMP0051/empty.cpp | 7 +++ Tests/RunCMake/CMakeLists.txt | 1 + 19 files changed, 160 insertions(+), 11 deletions(-) create mode 100644 Help/policy/CMP0051.rst create mode 100644 Help/release/dev/target-SOURCES-genex.rst create mode 100644 Tests/RunCMake/CMP0051/CMP0051-NEW-result.txt create mode 100644 Tests/RunCMake/CMP0051/CMP0051-NEW-stderr.txt create mode 100644 Tests/RunCMake/CMP0051/CMP0051-NEW.cmake create mode 100644 Tests/RunCMake/CMP0051/CMP0051-OLD-result.txt create mode 100644 Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt create mode 100644 Tests/RunCMake/CMP0051/CMP0051-OLD.cmake create mode 100644 Tests/RunCMake/CMP0051/CMP0051-WARN-result.txt create mode 100644 Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt create mode 100644 Tests/RunCMake/CMP0051/CMP0051-WARN.cmake create mode 100644 Tests/RunCMake/CMP0051/CMakeLists.txt create mode 100644 Tests/RunCMake/CMP0051/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/CMP0051/empty.cpp diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 8650a58..b763882 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -102,3 +102,4 @@ All Policies /policy/CMP0048 /policy/CMP0049 /policy/CMP0050 + /policy/CMP0051 diff --git a/Help/policy/CMP0051.rst b/Help/policy/CMP0051.rst new file mode 100644 index 0000000..7d85929 --- /dev/null +++ b/Help/policy/CMP0051.rst @@ -0,0 +1,24 @@ +CMP0051 +------- + +List TARGET_OBJECTS in SOURCES target property. + +CMake 3.0 and lower did not include the ``TARGET_OBJECTS`` +:manual:`generator expression ` when +returning the :prop_tgt:`SOURCES` target property. + +Configure-time CMake code is not able to handle generator expressions. If +using the :prop_tgt:`SOURCES` target property at configure time, it may be +necessary to first remove generator expressions using the +:command:`string(STRIP_GENEX)` command. Generate-time CMake code such as +:command:`file(GENERATE)` can handle the content without stripping. + +The ``OLD`` behavior for this policy is to omit ``TARGET_OBJECTS`` +expressions from the :prop_tgt:`SOURCES` target property. The ``NEW`` +behavior for this policy is to include ``TARGET_OBJECTS`` expressions +in the output. + +This policy was introduced in CMake version 3.1. +CMake version |release| warns when the policy is not set and uses +``OLD`` behavior. Use the :command:`cmake_policy` command to set it +to ``OLD`` or ``NEW`` explicitly. diff --git a/Help/release/dev/target-SOURCES-genex.rst b/Help/release/dev/target-SOURCES-genex.rst new file mode 100644 index 0000000..1ca6f66 --- /dev/null +++ b/Help/release/dev/target-SOURCES-genex.rst @@ -0,0 +1,7 @@ +target-SOURCES-genex +-------------------- + +* The :prop_tgt:`SOURCES` target property now contains + :manual:`generator expression ` + such as ``TARGET_OBJECTS`` when read at configure time, if + policy :policy:`CMP0051` is ``NEW``. diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 2bd553f..759df91 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -343,6 +343,11 @@ cmPolicies::cmPolicies() CMP0050, "CMP0050", "Disallow add_custom_command SOURCE signatures.", 3,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0051, "CMP0051", + "List TARGET_OBJECTS in SOURCES target property.", + 3,1,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index b77235d..7a08a34 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -104,6 +104,7 @@ public: CMP0048, ///< project() command manages VERSION variables CMP0049, ///< Do not expand variables in target source entries CMP0050, ///< Disallow add_custom_command SOURCE signatures + CMP0051, ///< List TARGET_OBJECTS in SOURCES target property /** \brief Always the last entry. * diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8bfc428..04ae5af 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -556,6 +556,10 @@ void cmTarget::GetSourceFiles(std::vector &files) const i != srcs.end(); ++i) { std::string src = *i; + if (cmGeneratorExpression::Find(src) != std::string::npos) + { + continue; + } cmSourceFile* sf = this->Makefile->GetOrCreateSource(src); std::string e; src = sf->GetFullPath(&e); @@ -743,6 +747,7 @@ void cmTarget::ProcessSourceExpression(std::string const& expr) { std::string objLibName = expr.substr(17, expr.size()-18); this->ObjectLibraries.push_back(objLibName); + this->AddSource(expr); } else { @@ -2876,20 +2881,62 @@ const char *cmTarget::GetProperty(const std::string& prop, for (std::vector::const_iterator li = files.begin(); li != files.end(); ++li) { - cmSourceFile *sf = this->Makefile->GetOrCreateSource(*li); - // Construct what is known about this source file location. - cmSourceFileLocation const& location = sf->GetLocation(); - std::string sname = location.GetDirectory(); - if(!sname.empty()) + if(cmHasLiteralPrefix(*li, "$size() - 1] == '>') { - sname += "/"; + std::string objLibName = li->substr(17, li->size()-18); + + bool addContent = false; + bool noMessage = true; + cmOStringStream e; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0051)) + { + case cmPolicies::WARN: + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0051)) << "\n"; + noMessage = false; + case cmPolicies::OLD: + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + addContent = true; + } + if (!noMessage) + { + e << "Target \"" << this->Name << "\" contains $ " + "generator expression in its sources list. This content was not " + "previously part of the SOURCES property when that property was " + "read at configure time. Code reading that property needs to be " + "adapted to ignore the generator expression using the " + "string(GENEX_STRIP) command."; + this->Makefile->IssueMessage(messageType, e.str()); + } + if (addContent) + { + ss << sep; + sep = ";"; + ss << *li; + } } - sname += location.GetName(); + else + { + cmSourceFile *sf = this->Makefile->GetOrCreateSource(*li); + // Construct what is known about this source file location. + cmSourceFileLocation const& location = sf->GetLocation(); + std::string sname = location.GetDirectory(); + if(!sname.empty()) + { + sname += "/"; + } + sname += location.GetName(); - ss << sep; - sep = ";"; - // Append this list entry. - ss << sname; + ss << sep; + sep = ";"; + // Append this list entry. + ss << sname; + } } } this->Properties.SetProperty("SOURCES", ss.str().c_str(), diff --git a/Tests/RunCMake/CMP0051/CMP0051-NEW-result.txt b/Tests/RunCMake/CMP0051/CMP0051-NEW-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0051/CMP0051-NEW-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0051/CMP0051-NEW-stderr.txt b/Tests/RunCMake/CMP0051/CMP0051-NEW-stderr.txt new file mode 100644 index 0000000..e5578ba --- /dev/null +++ b/Tests/RunCMake/CMP0051/CMP0051-NEW-stderr.txt @@ -0,0 +1 @@ +^Sources: "empty.cpp;\$"$ diff --git a/Tests/RunCMake/CMP0051/CMP0051-NEW.cmake b/Tests/RunCMake/CMP0051/CMP0051-NEW.cmake new file mode 100644 index 0000000..f304bf1 --- /dev/null +++ b/Tests/RunCMake/CMP0051/CMP0051-NEW.cmake @@ -0,0 +1,10 @@ + +cmake_policy(SET CMP0051 NEW) + +add_library(objects OBJECT empty.cpp) + +add_library(empty empty.cpp $) + +get_target_property(srcs empty SOURCES) + +message("Sources: \"${srcs}\"") diff --git a/Tests/RunCMake/CMP0051/CMP0051-OLD-result.txt b/Tests/RunCMake/CMP0051/CMP0051-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0051/CMP0051-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt b/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt new file mode 100644 index 0000000..cc17f33 --- /dev/null +++ b/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt @@ -0,0 +1 @@ +^Sources: "empty.cpp"$ diff --git a/Tests/RunCMake/CMP0051/CMP0051-OLD.cmake b/Tests/RunCMake/CMP0051/CMP0051-OLD.cmake new file mode 100644 index 0000000..0243e94 --- /dev/null +++ b/Tests/RunCMake/CMP0051/CMP0051-OLD.cmake @@ -0,0 +1,10 @@ + +cmake_policy(SET CMP0051 OLD) + +add_library(objects OBJECT empty.cpp) + +add_library(empty empty.cpp $) + +get_target_property(srcs empty SOURCES) + +message("Sources: \"${srcs}\"") diff --git a/Tests/RunCMake/CMP0051/CMP0051-WARN-result.txt b/Tests/RunCMake/CMP0051/CMP0051-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0051/CMP0051-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt b/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt new file mode 100644 index 0000000..f1b0357 --- /dev/null +++ b/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt @@ -0,0 +1,15 @@ +CMake Warning \(dev\) at CMP0051-WARN.cmake:6 \(get_target_property\): + Policy CMP0051 is not set: List TARGET_OBJECTS in SOURCES target property. + Run "cmake --help-policy CMP0051" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + Target "empty" contains \$ generator expression in its + sources list. This content was not previously part of the SOURCES property + when that property was read at configure time. Code reading that property + needs to be adapted to ignore the generator expression using the + string\(GENEX_STRIP\) command. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. + +Sources: "empty.cpp"$ diff --git a/Tests/RunCMake/CMP0051/CMP0051-WARN.cmake b/Tests/RunCMake/CMP0051/CMP0051-WARN.cmake new file mode 100644 index 0000000..fd595ce --- /dev/null +++ b/Tests/RunCMake/CMP0051/CMP0051-WARN.cmake @@ -0,0 +1,8 @@ + +add_library(objects OBJECT empty.cpp) + +add_library(empty empty.cpp $) + +get_target_property(srcs empty SOURCES) + +message("Sources: \"${srcs}\"") diff --git a/Tests/RunCMake/CMP0051/CMakeLists.txt b/Tests/RunCMake/CMP0051/CMakeLists.txt new file mode 100644 index 0000000..3482e6b --- /dev/null +++ b/Tests/RunCMake/CMP0051/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.0) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0051/RunCMakeTest.cmake b/Tests/RunCMake/CMP0051/RunCMakeTest.cmake new file mode 100644 index 0000000..621192d --- /dev/null +++ b/Tests/RunCMake/CMP0051/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0051-OLD) +run_cmake(CMP0051-NEW) +run_cmake(CMP0051-WARN) diff --git a/Tests/RunCMake/CMP0051/empty.cpp b/Tests/RunCMake/CMP0051/empty.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/CMP0051/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 31e7805..4f059d6 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -34,6 +34,7 @@ add_RunCMake_test(CMP0045) add_RunCMake_test(CMP0046) add_RunCMake_test(CMP0049) add_RunCMake_test(CMP0050) +add_RunCMake_test(CMP0051) add_RunCMake_test(CTest) if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") add_RunCMake_test(CompilerChange) -- cgit v0.12 From e5da9e51d02ba912bba4f556ecd6453dd187c8d8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 18 Mar 2014 16:40:46 +0100 Subject: cmTarget: Allow any generator expression in SOURCES property. Remove use of UseObjectLibraries from Makefile and Ninja generators. It is not needed now because those generators use GetExternalObjects which already contains the objects from object libraries. The VS10 generator calls both the UseObjectLibraries and the GetExternalObjects methods. Ensure that duplicates are not created by skipping objects from object libraries in handling of GetExternalObjects. Similarly, fix VS6, VS7 and Xcode object handling by skipping external objects from OBJECT_LIBRARY usage as appropriate. The error message in the BadSourceExpression1 test is now reported by the generator expression evaluator, so it has different text. --- Help/command/add_executable.rst | 7 ++- Help/command/add_library.rst | 6 ++- Help/release/dev/target-SOURCES-genex.rst | 5 ++ Source/cmGlobalXCodeGenerator.cxx | 5 +- Source/cmLocalVisualStudio6Generator.cxx | 10 ++++ Source/cmLocalVisualStudio7Generator.cxx | 4 ++ Source/cmMakefileTargetGenerator.cxx | 3 -- Source/cmNinjaTargetGenerator.cxx | 11 ----- Source/cmTarget.cxx | 57 ++++++++++++---------- Source/cmVisualStudio10TargetGenerator.cxx | 13 +++++ Tests/GeneratorExpression/CMakeLists.txt | 2 +- .../ObjectLibrary/BadSourceExpression1-stderr.txt | 4 +- 12 files changed, 80 insertions(+), 47 deletions(-) diff --git a/Help/command/add_executable.rst b/Help/command/add_executable.rst index 231eeed..4ed10e1 100644 --- a/Help/command/add_executable.rst +++ b/Help/command/add_executable.rst @@ -35,8 +35,11 @@ If ``EXCLUDE_FROM_ALL`` is given the corresponding property will be set on the created target. See documentation of the :prop_tgt:`EXCLUDE_FROM_ALL` target property for details. -See the :manual:`cmake-buildsystem(7)` manual for more on defining -buildsystem properties. +Source arguments to ``add_executable`` may use "generator expressions" with +the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` +manual for available expressions. See the :manual:`cmake-buildsystem(7)` +manual for more on defining buildsystem properties. + -------------------------------------------------------------------------- diff --git a/Help/command/add_library.rst b/Help/command/add_library.rst index 0944269..e93ef53 100644 --- a/Help/command/add_library.rst +++ b/Help/command/add_library.rst @@ -39,8 +39,10 @@ If ``EXCLUDE_FROM_ALL`` is given the corresponding property will be set on the created target. See documentation of the :prop_tgt:`EXCLUDE_FROM_ALL` target property for details. -See the :manual:`cmake-buildsystem(7)` manual for more on defining buildsystem -properties. +Source arguments to ``add_library`` may use "generator expressions" with +the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` +manual for available expressions. See the :manual:`cmake-buildsystem(7)` +manual for more on defining buildsystem properties. -------------------------------------------------------------------------- diff --git a/Help/release/dev/target-SOURCES-genex.rst b/Help/release/dev/target-SOURCES-genex.rst index 1ca6f66..9a65101 100644 --- a/Help/release/dev/target-SOURCES-genex.rst +++ b/Help/release/dev/target-SOURCES-genex.rst @@ -5,3 +5,8 @@ target-SOURCES-genex :manual:`generator expression ` such as ``TARGET_OBJECTS`` when read at configure time, if policy :policy:`CMP0051` is ``NEW``. + +* The :prop_tgt:`SOURCES` target property now generally supports + :manual:`generator expression `. The + generator expressions may be used in the :command:`add_library` and + :command:`add_executable` commands. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index fdf73d6..2a6e522 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1007,7 +1007,10 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, if(filetype && filetype->GetString() == "compiled.mach-o.objfile") { - externalObjFiles.push_back(xsf); + if ((*i)->GetObjectLibrary().empty()) + { + externalObjFiles.push_back(xsf); + } } else if(this->IsHeaderFile(*i) || (tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader) || diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index e99f3a4..11e9679 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -324,6 +324,11 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, for(std::vector::const_iterator i = classes.begin(); i != classes.end(); i++) { + if (!(*i)->GetObjectLibrary().empty()) + { + continue; + } + // Add the file to the list of sources. std::string source = (*i)->GetFullPath(); cmSourceGroup* sourceGroup = @@ -398,6 +403,11 @@ void cmLocalVisualStudio6Generator for(std::vector::const_iterator sf = sourceFiles.begin(); sf != sourceFiles.end(); ++sf) { + if (!(*sf)->GetObjectLibrary().empty()) + { + continue; + } + std::string source = (*sf)->GetFullPath(); const cmCustomCommand *command = (*sf)->GetCustomCommand(); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index e8562ca..8bac10d 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1401,6 +1401,10 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, for(std::vector::const_iterator i = classes.begin(); i != classes.end(); i++) { + if (!(*i)->GetObjectLibrary().empty()) + { + continue; + } // Add the file to the list of sources. std::string source = (*i)->GetFullPath(); if(cmSystemTools::UpperCase((*i)->GetExtension()) == "DEF") diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 6759d05..c520f9e 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -202,9 +202,6 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() // Generate this object file's rule file. this->WriteObjectRuleFiles(**si); } - - // Add object library contents as external objects. - this->GeneratorTarget->UseObjectLibraries(this->ExternalObjects); } //---------------------------------------------------------------------------- diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 8865b3d..b7eab7d 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -525,17 +525,6 @@ cmNinjaTargetGenerator this->ModuleDefinitionFile = this->ConvertToNinjaPath(def.c_str()); } - { - // Add object library contents as external objects. - std::vector objs; - this->GeneratorTarget->UseObjectLibraries(objs); - for(std::vector::iterator oi = objs.begin(); - oi != objs.end(); ++oi) - { - this->Objects.push_back(ConvertToNinjaPath(oi->c_str())); - } - } - this->GetBuildFileStream() << "\n"; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 04ae5af..aea6446 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -551,15 +551,16 @@ void cmTarget::GetSourceFiles(std::vector &files) const si != this->Internal->SourceEntries.end(); ++si) { std::vector srcs; - cmSystemTools::ExpandListArgument((*si)->ge->GetInput(), srcs); + cmSystemTools::ExpandListArgument((*si)->ge->Evaluate(this->Makefile, + "", + false, + this), + srcs); + for(std::vector::const_iterator i = srcs.begin(); i != srcs.end(); ++i) { std::string src = *i; - if (cmGeneratorExpression::Find(src) != std::string::npos) - { - continue; - } cmSourceFile* sf = this->Makefile->GetOrCreateSource(src); std::string e; src = sf->GetFullPath(&e); @@ -606,7 +607,14 @@ void cmTarget::AddSources(std::vector const& srcs) const char* src = i->c_str(); if(src[0] == '$' && src[1] == '<') { - this->ProcessSourceExpression(*i); + this->AddSource(src); + + if(cmHasLiteralPrefix(i->c_str(), "$size()-1] == '>') + { + std::string objLibName = i->substr(17, i->size()-18); + this->ObjectLibraries.push_back(objLibName); + } } else { @@ -734,28 +742,11 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) this->Internal->SourceEntries.push_back( new cmTargetInternals::TargetPropertyEntry(cge)); } - return this->Makefile->GetOrCreateSource(src); -} - - - -//---------------------------------------------------------------------------- -void cmTarget::ProcessSourceExpression(std::string const& expr) -{ - if(cmHasLiteralPrefix(expr.c_str(), "$') + if (cmGeneratorExpression::Find(src) != std::string::npos) { - std::string objLibName = expr.substr(17, expr.size()-18); - this->ObjectLibraries.push_back(objLibName); - this->AddSource(expr); - } - else - { - cmOStringStream e; - e << "Unrecognized generator expression:\n" - << " " << expr; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + return 0; } + return this->Makefile->GetOrCreateSource(src); } //---------------------------------------------------------------------------- @@ -2886,6 +2877,14 @@ const char *cmTarget::GetProperty(const std::string& prop, { std::string objLibName = li->substr(17, li->size()-18); + if (cmGeneratorExpression::Find(objLibName) != std::string::npos) + { + ss << sep; + sep = ";"; + ss << *li; + continue; + } + bool addContent = false; bool noMessage = true; cmOStringStream e; @@ -2920,6 +2919,12 @@ const char *cmTarget::GetProperty(const std::string& prop, ss << *li; } } + else if (cmGeneratorExpression::Find(*li) == std::string::npos) + { + ss << sep; + sep = ";"; + ss << *li; + } else { cmSourceFile *sf = this->Makefile->GetOrCreateSource(*li); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index bb76b7f..8d10e7c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1054,6 +1054,19 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() std::vector externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects); + for(std::vector::iterator + si = externalObjects.begin(); + si != externalObjects.end(); ) + { + if (!(*si)->GetObjectLibrary().empty()) + { + si = externalObjects.erase(si); + } + else + { + ++si; + } + } if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10) { // For VS >= 11 we use LinkObjects to avoid linking custom command diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 66b175a..b506853 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -166,7 +166,7 @@ add_library(imported4 SHARED IMPORTED) set_property(TARGET imported4 APPEND PROPERTY INCLUDE_DIRECTORIES $) -add_executable(someexe empty.cpp) +add_executable(someexe $<1:empty.cpp> $<0:does_not_exist>) add_executable(Alias::SomeExe ALIAS someexe) add_library(Alias::SomeLib ALIAS empty1) diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt index a1cac36..859dc3f 100644 --- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt @@ -1,6 +1,8 @@ CMake Error at BadSourceExpression1.cmake:1 \(add_library\): - Unrecognized generator expression: + Error evaluating generator expression: \$ + + Expression did not evaluate to a known generator expression Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) -- cgit v0.12 From c355d10865ba0dbaef06d0eafe678627c875a5f5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 18 Mar 2014 17:04:46 +0100 Subject: cmComputeTargetDepends: Track object library depends. Relieve cmGeneratorTarget of that responsibility. --- Source/cmComputeTargetDepends.cxx | 29 +++++++++++++++++++++++++++++ Source/cmGeneratorTarget.cxx | 1 - 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index b4dbce7..db8b7f3 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -16,6 +16,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmSystemTools.h" +#include "cmSourceFile.h" #include "cmTarget.h" #include "cmake.h" @@ -213,6 +214,34 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) { std::set emitted; { + cmGeneratorTarget* gt = depender->GetMakefile()->GetLocalGenerator() + ->GetGlobalGenerator() + ->GetGeneratorTarget(depender); + std::vector objectFiles; + gt->GetExternalObjects(objectFiles); + for(std::vector::const_iterator + it = objectFiles.begin(); it != objectFiles.end(); ++it) + { + std::string objLib = (*it)->GetObjectLibrary(); + if (!objLib.empty() && emitted.insert(objLib).second) + { + if(depender->GetType() != cmTarget::EXECUTABLE && + depender->GetType() != cmTarget::STATIC_LIBRARY && + depender->GetType() != cmTarget::SHARED_LIBRARY && + depender->GetType() != cmTarget::MODULE_LIBRARY) + { + this->GlobalGenerator->GetCMakeInstance() + ->IssueMessage(cmake::FATAL_ERROR, + "Only executables and non-OBJECT libraries may " + "reference target objects.", + depender->GetBacktrace()); + return; + } + const_cast(depender)->AddUtility(objLib); + } + } + } + { std::vector tlibs; depender->GetDirectLinkLibraries("", tlibs, depender); // A target should not depend on itself. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 834f9fd..66f6bdf 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -528,7 +528,6 @@ void cmGeneratorTarget::LookupObjectLibraries() this->Target->GetBacktrace()); return; } - this->Target->AddUtility(objLib->GetName()); this->ObjectLibraries.push_back(objLib); } else -- cgit v0.12 From fdcefe3c42fefdfcd27e6cf7b679f39cb99db4b9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 18 Mar 2014 17:07:56 +0100 Subject: cmGeneratorTarget: Compute consumed object libraries on demand. Remove up-front object library computation from cmGlobalGenerator. Adjust tests for message coming from the generator expression evaluation. --- Source/cmGeneratorTarget.cxx | 72 ++++++---------------- Source/cmGeneratorTarget.h | 3 - Source/cmGlobalGenerator.cxx | 1 - .../ObjectLibrary/BadSourceExpression2-stderr.txt | 4 ++ .../ObjectLibrary/BadSourceExpression3-stderr.txt | 4 ++ 5 files changed, 27 insertions(+), 57 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 66f6bdf..64ca863 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -504,57 +504,6 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files) const } //---------------------------------------------------------------------------- -void cmGeneratorTarget::LookupObjectLibraries() -{ - std::vector const& objLibs = - this->Target->GetObjectLibraries(); - for(std::vector::const_iterator oli = objLibs.begin(); - oli != objLibs.end(); ++oli) - { - std::string const& objLibName = *oli; - if(cmTarget* objLib = this->Makefile->FindTargetToUse(objLibName)) - { - if(objLib->GetType() == cmTarget::OBJECT_LIBRARY) - { - if(this->Target->GetType() != cmTarget::EXECUTABLE && - this->Target->GetType() != cmTarget::STATIC_LIBRARY && - this->Target->GetType() != cmTarget::SHARED_LIBRARY && - this->Target->GetType() != cmTarget::MODULE_LIBRARY) - { - this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, - "Only executables and non-OBJECT libraries may " - "reference target objects.", - this->Target->GetBacktrace()); - return; - } - this->ObjectLibraries.push_back(objLib); - } - else - { - cmOStringStream e; - e << "Objects of target \"" << objLibName - << "\" referenced but is not an OBJECT library."; - this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); - return; - } - } - else - { - cmOStringStream e; - e << "Objects of target \"" << objLibName - << "\" referenced but no such target exists."; - this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); - return; - } - } -} - -//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile() const { std::string data; @@ -566,9 +515,26 @@ std::string cmGeneratorTarget::GetModuleDefinitionFile() const void cmGeneratorTarget::UseObjectLibraries(std::vector& objs) const { + std::vector objectFiles; + this->GetExternalObjects(objectFiles); + std::vector objectLibraries; + std::set emitted; + for(std::vector::const_iterator + it = objectFiles.begin(); it != objectFiles.end(); ++it) + { + std::string objLib = (*it)->GetObjectLibrary(); + if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) + { + if (emitted.insert(tgt).second) + { + objectLibraries.push_back(tgt); + } + } + } + for(std::vector::const_iterator - ti = this->ObjectLibraries.begin(); - ti != this->ObjectLibraries.end(); ++ti) + ti = objectLibraries.begin(); + ti != objectLibraries.end(); ++ti) { cmTarget* objLib = *ti; cmGeneratorTarget* ogt = diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 53e27c5..cb59783 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -84,8 +84,6 @@ public: */ void TraceDependencies(); - void LookupObjectLibraries(); - /** Get sources that must be built before the given source. */ std::vector const* GetSourceDepends(cmSourceFile const* sf) const; @@ -127,7 +125,6 @@ private: std::map Objects; std::set ExplicitObjectName; - std::vector ObjectLibraries; mutable std::map > SystemIncludesCache; void ConstructSourceFileFlags() const; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 2f3c6c9..6caaee3 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1457,7 +1457,6 @@ void cmGlobalGenerator::ComputeGeneratorTargetObjects() continue; } cmGeneratorTarget* gt = ti->second; - gt->LookupObjectLibraries(); this->ComputeTargetObjects(gt); } } diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt index f1fcbe8..7060c61 100644 --- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt @@ -1,4 +1,8 @@ CMake Error at BadSourceExpression2.cmake:1 \(add_library\): + Error evaluating generator expression: + + \$ + Objects of target "DoesNotExist" referenced but no such target exists. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt index ad14a35..838b3d8 100644 --- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt +++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt @@ -1,4 +1,8 @@ CMake Error at BadSourceExpression3.cmake:2 \(add_library\): + Error evaluating generator expression: + + \$ + Objects of target "NotObjLib" referenced but is not an OBJECT library. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) -- cgit v0.12 From 042c1c834e69ee60b605b02bad8be87b2193a7d2 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 18 Mar 2014 19:23:45 +0100 Subject: cmTarget: Compute languages from object libraries on demand. --- Source/cmTarget.cxx | 67 +++++++++++++++++++++++++++++++++++++---------------- Source/cmTarget.h | 5 ---- 2 files changed, 47 insertions(+), 25 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index aea6446..61260be 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -608,13 +608,6 @@ void cmTarget::AddSources(std::vector const& srcs) if(src[0] == '$' && src[1] == '<') { this->AddSource(src); - - if(cmHasLiteralPrefix(i->c_str(), "$size()-1] == '>') - { - std::string objLibName = i->substr(17, i->size()-18); - this->ObjectLibraries.push_back(objLibName); - } } else { @@ -5013,6 +5006,53 @@ void cmTarget::GetLanguages(std::set& languages) const languages.insert(lang); } } + + std::vector objectLibraries; + std::vector externalObjects; + if (this->Makefile->GetGeneratorTargets().empty()) + { + // At configure-time, this method can be called as part of getting the + // LOCATION property or to export() a file to be include()d. However + // there is no cmGeneratorTarget at configure-time, so search the SOURCES + // for TARGET_OBJECTS instead for backwards compatibility with OLD + // behavior of CMP0024 and CMP0026 only. + std::vector srcs; + cmSystemTools::ExpandListArgument(this->GetProperty("SOURCES"), srcs); + for(std::vector::const_iterator it = srcs.begin(); + it != srcs.end(); ++it) + { + if (cmHasLiteralPrefix(*it, "$")) + { + std::string objLibName = it->substr(17, it->size()-18); + if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLibName)) + { + objectLibraries.push_back(tgt); + } + } + } + } + else + { + cmGeneratorTarget* gt = this->Makefile->GetLocalGenerator() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this); + gt->GetExternalObjects(externalObjects); + for(std::vector::const_iterator + i = externalObjects.begin(); i != externalObjects.end(); ++i) + { + std::string objLib = (*i)->GetObjectLibrary(); + if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) + { + objectLibraries.push_back(tgt); + } + } + } + for(std::vector::const_iterator + i = objectLibraries.begin(); i != objectLibraries.end(); ++i) + { + (*i)->GetLanguages(languages); + } } //---------------------------------------------------------------------------- @@ -6077,19 +6117,6 @@ cmTarget::ComputeLinkImplementationLanguages(LinkImplementation& impl) const std::set languages; // Get languages used in our source files. this->GetLanguages(languages); - // Get languages used in object library sources. - for(std::vector::const_iterator - i = this->ObjectLibraries.begin(); - i != this->ObjectLibraries.end(); ++i) - { - if(cmTarget* objLib = this->Makefile->FindTargetToUse(*i)) - { - if(objLib->GetType() == cmTarget::OBJECT_LIBRARY) - { - objLib->GetLanguages(languages); - } - } - } // Copy the set of langauges to the link implementation. for(std::set::iterator li = languages.begin(); li != languages.end(); ++li) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 45fca53..fcbff93 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -137,10 +137,6 @@ public: */ void GetSourceFiles(std::vector &files) const; void GetSourceFiles(std::vector &files) const; - std::vector const& GetObjectLibraries() const - { - return this->ObjectLibraries; - } /** * Add sources to the target. @@ -686,7 +682,6 @@ private: std::vector PreLinkCommands; std::vector PostBuildCommands; TargetType TargetTypeValue; - std::vector ObjectLibraries; LinkLibraryVectorType LinkLibraries; LinkLibraryVectorType PrevLinkedLibraries; bool LinkLibrariesAnalyzed; -- cgit v0.12 From aa0a3562dd47bdd6d9ca3058bd1dfd525e79d36d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 14 Mar 2014 13:21:26 +0100 Subject: cmGeneratorTarget: Compute target objects on demand Add a ComputeObjectMapping method to compute the object names. It takes mapping to populate as an out-parameter so that it can be extended in the future with parameters relevant to generator expression evaluation. Remove the supporting cmGeneratorTarget::AddObject method. It is no longer needed as the container member is populated directly. The ComputeObjectMapping method is called whenever objects are requested from the cmGeneratorTarget. Because the Xcode generator makes no such request, explicitly invoke the method from that generator so that the logic of checking for bad sources in object libraries is executed. In a follow-up, the UseObjectLibraries usage may be replaced by a true generator expression evaluator for TARGET_OBJECTS. That will require generators to use cmGeneratorTarget::GetExternalObjects which is not currently the case for Xcode and VS generators. --- Source/cmGeneratorTarget.cxx | 31 +++++++++++++++++++++----- Source/cmGeneratorTarget.h | 5 +++-- Source/cmGlobalGenerator.cxx | 46 --------------------------------------- Source/cmGlobalGenerator.h | 2 -- Source/cmGlobalXCodeGenerator.cxx | 2 ++ 5 files changed, 30 insertions(+), 56 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 64ca863..321dd42 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -311,18 +311,36 @@ cmGeneratorTarget ::GetObjectSources(std::vector &data) const { IMPLEMENT_VISIT(ObjectSources); + + if (!this->Objects.empty()) + { + return; + } + + for(std::vector::const_iterator it = data.begin(); + it != data.end(); ++it) + { + this->Objects[*it]; + } + + this->LocalGenerator->ComputeObjectFilenames(this->Objects, this); } -//---------------------------------------------------------------------------- -const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file) +void cmGeneratorTarget::ComputeObjectMapping() { - return this->Objects[file]; + if(!this->Objects.empty()) + { + return; + } + std::vector sourceFiles; + this->GetObjectSources(sourceFiles); } -void cmGeneratorTarget::AddObject(cmSourceFile const* sf, - std::string const&name) +//---------------------------------------------------------------------------- +const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file) { - this->Objects[sf] = name; + this->ComputeObjectMapping(); + return this->Objects[file]; } //---------------------------------------------------------------------------- @@ -334,6 +352,7 @@ void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile const* sf) //---------------------------------------------------------------------------- bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const { + const_cast(this)->ComputeObjectMapping(); std::set::const_iterator it = this->ExplicitObjectName.find(file); return it != this->ExplicitObjectName.end(); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index cb59783..38e6510 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -35,7 +35,6 @@ public: void GetObjectSources(std::vector &) const; const std::string& GetObjectName(cmSourceFile const* file); - void AddObject(cmSourceFile const* sf, std::string const&name); bool HasExplicitObjectName(cmSourceFile const* file) const; void AddExplicitObjectName(cmSourceFile const* sf); @@ -47,6 +46,8 @@ public: void GetCustomCommands(std::vector&) const; void GetExpectedResxHeaders(std::set&) const; + void ComputeObjectMapping(); + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; @@ -123,7 +124,7 @@ private: typedef std::map SourceEntriesType; SourceEntriesType SourceEntries; - std::map Objects; + mutable std::map Objects; std::set ExplicitObjectName; mutable std::map > SystemIncludesCache; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 6caaee3..66ccf39 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1222,8 +1222,6 @@ void cmGlobalGenerator::Generate() this->LocalGenerators[i]->GenerateTargetManifest(); } - this->ComputeGeneratorTargetObjects(); - this->ProcessEvaluationFiles(); // Compute the inter-target dependencies. @@ -1440,27 +1438,6 @@ void cmGlobalGenerator::CreateGeneratorTargets() } } -//---------------------------------------------------------------------------- -void cmGlobalGenerator::ComputeGeneratorTargetObjects() -{ - // Construct per-target generator information. - for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) - { - cmMakefile *mf = this->LocalGenerators[i]->GetMakefile(); - cmGeneratorTargetsType targets = mf->GetGeneratorTargets(); - for(cmGeneratorTargetsType::iterator ti = targets.begin(); - ti != targets.end(); ++ti) - { - if (ti->second->Target->IsImported() - || ti->second->Target->GetType() == cmTarget::INTERFACE_LIBRARY) - { - continue; - } - cmGeneratorTarget* gt = ti->second; - this->ComputeTargetObjects(gt); - } - } -} //---------------------------------------------------------------------------- void cmGlobalGenerator::ClearGeneratorMembers() @@ -1522,29 +1499,6 @@ cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const } //---------------------------------------------------------------------------- -void cmGlobalGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const -{ - std::vector objectSources; - gt->GetObjectSources(objectSources); - - std::map mapping; - for(std::vector::const_iterator it - = objectSources.begin(); it != objectSources.end(); ++it) - { - mapping[*it]; - } - - gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); - - for(std::map::const_iterator it - = mapping.begin(); it != mapping.end(); ++it) - { - assert(!it->second.empty()); - gt->AddObject(it->first, it->second); - } -} - -//---------------------------------------------------------------------------- void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const { } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 668bb6b..54f5f3b 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -444,8 +444,6 @@ private: friend class cmake; void CreateGeneratorTargets(cmMakefile* mf); void CreateGeneratorTargets(); - void ComputeGeneratorTargetObjects(); - void ComputeTargetObjects(cmGeneratorTarget* gt) const; void ClearGeneratorMembers(); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 2a6e522..d9d4927 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -987,6 +987,8 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, cmtarget.GetSourceFiles(classes); std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare()); + gtgt->ComputeObjectMapping(); + std::vector externalObjFiles; std::vector headerFiles; std::vector resourceFiles; -- cgit v0.12 From 5de63265e3a22d9a8aa5ad437a5030ccfcbcd02d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 20 Mar 2014 15:37:12 +0100 Subject: Genex: Only evaluate TARGET_OBJECTS to determine target sources. The output of this expression may contain macros for IDEs to replace such as $(Configuration), $(CURRENT_ARCH) etc. To avoid generating content which is not usable in other contexts, report an error if there is an attempt to use it in other contexts. This commit may be reverted in the future if a solution to the above difference is implemented. --- Help/manual/cmake-generator-expressions.7.rst | 4 +- Help/release/dev/file-GENERATE-TARGET_OBJECTS.rst | 6 --- Source/cmGeneratorExpression.cxx | 4 +- Source/cmGeneratorExpression.h | 6 +++ Source/cmGeneratorExpressionEvaluator.cxx | 10 +++++ Source/cmGeneratorExpressionEvaluator.h | 1 + Source/cmTarget.cxx | 1 + Tests/GeneratorExpression/CMakeLists.txt | 14 ------- Tests/GeneratorExpression/check_object_files.cmake | 48 ---------------------- Tests/GeneratorExpression/objlib1.c | 5 --- Tests/GeneratorExpression/objlib2.c | 5 --- Tests/RunCMake/TargetObjects/BadContext-result.txt | 1 + Tests/RunCMake/TargetObjects/BadContext-stderr.txt | 17 ++++++++ Tests/RunCMake/TargetObjects/BadContext.cmake | 4 ++ Tests/RunCMake/TargetObjects/NoTarget-result.txt | 1 - Tests/RunCMake/TargetObjects/NoTarget-stderr.txt | 8 ---- Tests/RunCMake/TargetObjects/NoTarget.cmake | 2 - .../TargetObjects/NotObjlibTarget-result.txt | 1 - .../TargetObjects/NotObjlibTarget-stderr.txt | 8 ---- Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake | 4 -- Tests/RunCMake/TargetObjects/RunCMakeTest.cmake | 3 +- Tests/RunCMake/TargetObjects/empty.cpp | 7 ---- 22 files changed, 47 insertions(+), 113 deletions(-) delete mode 100644 Help/release/dev/file-GENERATE-TARGET_OBJECTS.rst delete mode 100644 Tests/GeneratorExpression/check_object_files.cmake delete mode 100644 Tests/GeneratorExpression/objlib1.c delete mode 100644 Tests/GeneratorExpression/objlib2.c create mode 100644 Tests/RunCMake/TargetObjects/BadContext-result.txt create mode 100644 Tests/RunCMake/TargetObjects/BadContext-stderr.txt create mode 100644 Tests/RunCMake/TargetObjects/BadContext.cmake delete mode 100644 Tests/RunCMake/TargetObjects/NoTarget-result.txt delete mode 100644 Tests/RunCMake/TargetObjects/NoTarget-stderr.txt delete mode 100644 Tests/RunCMake/TargetObjects/NoTarget.cmake delete mode 100644 Tests/RunCMake/TargetObjects/NotObjlibTarget-result.txt delete mode 100644 Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt delete mode 100644 Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake delete mode 100644 Tests/RunCMake/TargetObjects/empty.cpp diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 17263d4..dfda8dc 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -190,4 +190,6 @@ property is non-empty:: Content of ``...`` converted to a C identifier. ``$`` List of objects resulting from build of ``objLib``. ``objLib`` must be an - object of type ``OBJECT_LIBRARY``. + object of type ``OBJECT_LIBRARY``. This expression may only be used in + the sources of :command:`add_library` and :command:`add_executable` + commands. diff --git a/Help/release/dev/file-GENERATE-TARGET_OBJECTS.rst b/Help/release/dev/file-GENERATE-TARGET_OBJECTS.rst deleted file mode 100644 index 853a803..0000000 --- a/Help/release/dev/file-GENERATE-TARGET_OBJECTS.rst +++ /dev/null @@ -1,6 +0,0 @@ -file-GENERATE-TARGET_OBJECTS ----------------------------- - -* The :command:`file(GENERATE)` subcommand learned to evaluate the - ``TARGET_OBJECTS`` - :manual:`generator expression `. diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index e127f3a..d09e950 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -90,6 +90,7 @@ const char *cmCompiledGeneratorExpression::Evaluate( context.HadError = false; context.HadContextSensitiveCondition = false; context.HeadTarget = headTarget; + context.EvaluateForBuildsystem = this->EvaluateForBuildsystem; context.CurrentTarget = currentTarget ? currentTarget : headTarget; context.Backtrace = this->Backtrace; @@ -124,7 +125,8 @@ cmCompiledGeneratorExpression::cmCompiledGeneratorExpression( cmListFileBacktrace const& backtrace, const std::string& input) : Backtrace(backtrace), Input(input), - HadContextSensitiveCondition(false) + HadContextSensitiveCondition(false), + EvaluateForBuildsystem(false) { cmGeneratorExpressionLexer l; std::vector tokens = diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index d0a6aef..da64515 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -112,6 +112,11 @@ public: return this->HadContextSensitiveCondition; } + void SetEvaluateForBuildsystem(bool eval) + { + this->EvaluateForBuildsystem = eval; + } + private: cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace, const std::string& input); @@ -131,6 +136,7 @@ private: mutable std::set SeenTargetProperties; mutable std::string Output; mutable bool HadContextSensitiveCondition; + bool EvaluateForBuildsystem; }; #endif diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 669694c..95227d2 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -1251,6 +1251,16 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode const GeneratorExpressionContent *content, cmGeneratorExpressionDAGChecker *) const { + if (!context->EvaluateForBuildsystem) + { + cmOStringStream e; + e << "The evaluation of the TARGET_OBJECTS generator expression " + "is only suitable for consumption by CMake. It is not suitable " + "for writing out elsewhere."; + reportError(context, content->GetOriginalExpression(), e.str()); + return std::string(); + } + std::string tgtName = parameters.front(); cmGeneratorTarget* gt = context->Makefile->FindGeneratorTargetToUse(tgtName.c_str()); diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h index a7099cb..54a2548 100644 --- a/Source/cmGeneratorExpressionEvaluator.h +++ b/Source/cmGeneratorExpressionEvaluator.h @@ -34,6 +34,7 @@ struct cmGeneratorExpressionContext bool Quiet; bool HadError; bool HadContextSensitiveCondition; + bool EvaluateForBuildsystem; }; struct cmGeneratorExpressionDAGChecker; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 61260be..aeb477d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -732,6 +732,7 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) this->Makefile->GetBacktrace(lfbt); cmGeneratorExpression ge(lfbt); cmsys::auto_ptr cge = ge.Parse(src); + cge->SetEvaluateForBuildsystem(true); this->Internal->SourceEntries.push_back( new cmTargetInternals::TargetPropertyEntry(cge)); } diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index b506853..758165c 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -258,17 +258,3 @@ set(CMP0044_TYPE NEW) add_subdirectory(CMP0044 ${CMAKE_BINARY_DIR}/CMP0044-NEW) set(CMP0044_TYPE OLD) add_subdirectory(CMP0044 ${CMAKE_BINARY_DIR}/CMP0044-OLD) - -add_library(objlib OBJECT objlib1.c objlib2.c) -file(GENERATE - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/objlib_files" - CONTENT "$,\n>\n" -) -add_custom_target(check_object_files ALL - COMMAND ${CMAKE_COMMAND} - "-DOBJLIB_LISTFILE=${CMAKE_CURRENT_BINARY_DIR}/objlib_files" - -DTEST_CONFIGURATION=${CMAKE_BUILD_TYPE} - -DEXPECTED_NUM_OBJECTFILES=2 - -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake" - DEPENDS objlib -) diff --git a/Tests/GeneratorExpression/check_object_files.cmake b/Tests/GeneratorExpression/check_object_files.cmake deleted file mode 100644 index 889fe80..0000000 --- a/Tests/GeneratorExpression/check_object_files.cmake +++ /dev/null @@ -1,48 +0,0 @@ - -if (NOT EXISTS ${OBJLIB_LISTFILE}) - message(SEND_ERROR "Object listing file \"${OBJLIB_LISTFILE}\" not found!") -endif() - -file(STRINGS ${OBJLIB_LISTFILE} objlib_files) - -list(LENGTH objlib_files num_objectfiles) -if (NOT EXPECTED_NUM_OBJECTFILES EQUAL num_objectfiles) - message(SEND_ERROR "Unexpected number of entries in object list file (${num_objectfiles} instead of ${EXPECTED_NUM_OBJECTFILES})") -endif() - -foreach(objlib_file ${objlib_files}) - set(file_exists False) - if (EXISTS ${objlib_file}) - set(file_exists True) - endif() - - if (NOT file_exists) - if (objlib_file MATCHES ".(CURRENT_ARCH)") - string(REPLACE "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)" "*" config_file "${objlib_file}") - string(REPLACE "$(PROJECT_NAME)" "GeneratorExpression" config_file "${config_file}") - string(REPLACE "$(CURRENT_ARCH)" "*" config_file "${config_file}") - file(GLOB_RECURSE files "${config_file}") - list(LENGTH files num_files) - if (NOT files) - message(SEND_ERROR "Got no files for expression ${config_file}") - endif() - set(file_exists True) - else() - foreach(config_macro "$(Configuration)" "$(OutDir)" "$(IntDir)") - string(REPLACE "${config_macro}" "${TEST_CONFIGURATION}" config_file "${objlib_file}") - list(APPEND attempts ${config_file}) - if (EXISTS ${config_file}) - set(file_exists True) - endif() - endforeach() - endif() - endif() - - if (NOT file_exists) - if(attempts) - list(REMOVE_DUPLICATES attempts) - set(tried " Tried ${attempts}") - endif() - message(SEND_ERROR "File \"${objlib_file}\" does not exist!${tried}") - endif() -endforeach() diff --git a/Tests/GeneratorExpression/objlib1.c b/Tests/GeneratorExpression/objlib1.c deleted file mode 100644 index aa8de0a..0000000 --- a/Tests/GeneratorExpression/objlib1.c +++ /dev/null @@ -1,5 +0,0 @@ - -void objlib1() -{ - -} diff --git a/Tests/GeneratorExpression/objlib2.c b/Tests/GeneratorExpression/objlib2.c deleted file mode 100644 index 3c7307a..0000000 --- a/Tests/GeneratorExpression/objlib2.c +++ /dev/null @@ -1,5 +0,0 @@ - -void objlib2() -{ - -} diff --git a/Tests/RunCMake/TargetObjects/BadContext-result.txt b/Tests/RunCMake/TargetObjects/BadContext-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/TargetObjects/BadContext-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/TargetObjects/BadContext-stderr.txt b/Tests/RunCMake/TargetObjects/BadContext-stderr.txt new file mode 100644 index 0000000..92f2c91 --- /dev/null +++ b/Tests/RunCMake/TargetObjects/BadContext-stderr.txt @@ -0,0 +1,17 @@ +CMake Error at BadContext.cmake:2 \(file\): + Error evaluating generator expression: + + \$ + + The evaluation of the TARGET_OBJECTS generator expression is only suitable + for consumption by CMake. It is not suitable for writing out elsewhere. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error: + Error evaluating generator expression: + + \$ + + The evaluation of the TARGET_OBJECTS generator expression is only suitable + for consumption by CMake. It is not suitable for writing out elsewhere. diff --git a/Tests/RunCMake/TargetObjects/BadContext.cmake b/Tests/RunCMake/TargetObjects/BadContext.cmake new file mode 100644 index 0000000..67962a4 --- /dev/null +++ b/Tests/RunCMake/TargetObjects/BadContext.cmake @@ -0,0 +1,4 @@ + +file(GENERATE OUTPUT test_output CONTENT $) + +install(FILES $ DESTINATION objects) diff --git a/Tests/RunCMake/TargetObjects/NoTarget-result.txt b/Tests/RunCMake/TargetObjects/NoTarget-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/TargetObjects/NoTarget-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/TargetObjects/NoTarget-stderr.txt b/Tests/RunCMake/TargetObjects/NoTarget-stderr.txt deleted file mode 100644 index 2c4f877..0000000 --- a/Tests/RunCMake/TargetObjects/NoTarget-stderr.txt +++ /dev/null @@ -1,8 +0,0 @@ -CMake Error at NoTarget.cmake:2 \(file\): - Error evaluating generator expression: - - \$ - - Objects of target "NoTarget" referenced but no such target exists. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/TargetObjects/NoTarget.cmake b/Tests/RunCMake/TargetObjects/NoTarget.cmake deleted file mode 100644 index f203c23..0000000 --- a/Tests/RunCMake/TargetObjects/NoTarget.cmake +++ /dev/null @@ -1,2 +0,0 @@ - -file(GENERATE OUTPUT test_output CONTENT $) diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget-result.txt b/Tests/RunCMake/TargetObjects/NotObjlibTarget-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/TargetObjects/NotObjlibTarget-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt b/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt deleted file mode 100644 index bb83934..0000000 --- a/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt +++ /dev/null @@ -1,8 +0,0 @@ -CMake Error at NotObjlibTarget.cmake:4 \(file\): - Error evaluating generator expression: - - \$ - - Objects of target "StaticLib" referenced but is not an OBJECT library. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake b/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake deleted file mode 100644 index c7f8a71..0000000 --- a/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake +++ /dev/null @@ -1,4 +0,0 @@ - -add_library(StaticLib empty.cpp) - -file(GENERATE OUTPUT test_output CONTENT $) diff --git a/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake b/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake index 30b9fee..85c76e2 100644 --- a/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake @@ -1,4 +1,3 @@ include(RunCMake) -run_cmake(NoTarget) -run_cmake(NotObjlibTarget) +run_cmake(BadContext) diff --git a/Tests/RunCMake/TargetObjects/empty.cpp b/Tests/RunCMake/TargetObjects/empty.cpp deleted file mode 100644 index bfbbdde..0000000 --- a/Tests/RunCMake/TargetObjects/empty.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#ifdef _WIN32 -__declspec(dllexport) -#endif -int empty() -{ - return 0; -} -- cgit v0.12 From 869328aac31f8e702ac7039ce72c6fa485432733 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 25 Mar 2014 13:34:38 +0100 Subject: cmComputeTargetDepends: Use valid config to compute target depends. If CMAKE_BUILD_TYPE is set, and user code contains: target_link_libraries(myexe prefix_$<$:debug>) then the computation with an empty config was computing a target-level dependency on a target or library called prefix_, and a dependency on a target or library called prefix_debug (as expected). The existing logic skips 'prefix_' because it is not a known target, and defers to the link-dependencies logic to find the library. The link-dependencies logic does not incorrectly handle the config as cmComputeTargetDepends did, and so did not encounter 'prefix_' during its computation. This likely had no effect on the generated buildsystem. --- Source/cmComputeTargetDepends.cxx | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index db8b7f3..f07bccb 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -241,25 +241,12 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) } } } - { - std::vector tlibs; - depender->GetDirectLinkLibraries("", tlibs, depender); - // A target should not depend on itself. - emitted.insert(depender->GetName()); - for(std::vector::const_iterator lib = tlibs.begin(); - lib != tlibs.end(); ++lib) - { - // Don't emit the same library twice for this target. - if(emitted.insert(*lib).second) - { - this->AddTargetDepend(depender_index, *lib, true); - this->AddInterfaceDepends(depender_index, *lib, - true, emitted); - } - } - } std::vector configs; depender->GetMakefile()->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } for (std::vector::const_iterator it = configs.begin(); it != configs.end(); ++it) { -- cgit v0.12 From df753df94bb1e995372baabb0240585560c72ded Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 27 Mar 2014 17:06:34 +0100 Subject: cmGeneratorTarget: Don't add computed sources to the target. When config-specifig generator expressions are supported, a target may have SOURCES: src1.cpp $<$:src2.cpp> $<$:src3.cpp> and computation in cmTargetTraceDependencies would add each of the src2.cpp and src3.cpp sources back to the target without a config-guard. That would make the sources be used later when generating the buildsystem, regardless of the configuration. Avoid calling AddSource on the target with the result of the GetSourceFiles call. --- Source/cmGeneratorTarget.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 321dd42..8688f78 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -619,7 +619,11 @@ cmTargetTraceDependencies for(std::vector::const_iterator si = sources.begin(); si != sources.end(); ++si) { - this->QueueSource(*si); + if(this->SourcesQueued.insert(*si).second) + { + this->SourceQueue.push(*si); + this->Makefile->GetOrCreateSource(*si); + } } } -- cgit v0.12 From e6971df6ab647031ba9689c9afbbde78cc62e35f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 13 Feb 2014 17:25:00 +0100 Subject: cmTarget: Make the source files depend on the config. Disallow the use of config-specific source files with the Visual Studio and Xcode generators. They don't have any way to represent the condition currently. Use the same common-config API in cmQtAutoGenerators. While it accepts config-specific files, it doesn't have to support multiple configurations yet. Loop over the configs in cmTargetTraceDependencies and cmGlobalGenerator::WriteSummary and consume all source files. Loop over the configs in cmComputeTargetDepends and compute the object library dependencies for each config. --- Source/cmComputeTargetDepends.cxx | 49 ++++++------- Source/cmExtraCodeBlocksGenerator.cxx | 3 +- Source/cmExtraCodeLiteGenerator.cxx | 3 +- Source/cmExtraEclipseCDT4Generator.cxx | 3 +- Source/cmExtraSublimeTextGenerator.cxx | 3 +- Source/cmFLTKWrapUICommand.cxx | 2 +- Source/cmGeneratorExpressionEvaluator.cxx | 2 +- Source/cmGeneratorTarget.cxx | 71 +++++++++++++----- Source/cmGeneratorTarget.h | 32 +++++--- Source/cmGlobalGenerator.cxx | 17 ++++- Source/cmGlobalKdevelopGenerator.cxx | 3 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 3 +- Source/cmGlobalVisualStudioGenerator.cxx | 10 ++- Source/cmGlobalXCodeGenerator.cxx | 28 +++++-- Source/cmLocalGenerator.cxx | 7 +- Source/cmLocalUnixMakefileGenerator3.cxx | 6 +- Source/cmLocalVisualStudio6Generator.cxx | 37 +++++++++- Source/cmLocalVisualStudio7Generator.cxx | 9 ++- Source/cmMakefileTargetGenerator.cxx | 29 +++++--- Source/cmNinjaNormalTargetGenerator.cxx | 3 +- Source/cmNinjaTargetGenerator.cxx | 16 ++-- Source/cmNinjaUtilityTargetGenerator.cxx | 4 +- Source/cmQtAutoGenerators.cxx | 4 +- Source/cmTarget.cxx | 85 +++++++++++++++++++--- Source/cmTarget.h | 13 +++- Source/cmVisualStudio10TargetGenerator.cxx | 29 ++++---- Tests/CMakeLists.txt | 4 + Tests/ConfigSources/CMakeLists.txt | 9 +++ Tests/ConfigSources/main.cpp | 5 ++ Tests/QtAutogen/CMakeLists.txt | 8 +- Tests/QtAutogen/debug_class.cpp | 9 +++ Tests/QtAutogen/debug_class.h | 20 +++++ Tests/QtAutogen/debug_class.ui | 45 ++++++++++++ Tests/QtAutogen/debug_resource.qrc | 5 ++ Tests/QtAutogen/main.cpp | 9 +++ Tests/QtAutogen/resourcetester.cpp | 4 + Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/TargetSources/CMakeLists.txt | 3 + .../TargetSources/ConfigNotAllowed-result.txt | 1 + .../TargetSources/ConfigNotAllowed-stderr.txt | 14 ++++ .../RunCMake/TargetSources/ConfigNotAllowed.cmake | 2 + Tests/RunCMake/TargetSources/RunCMakeTest.cmake | 6 ++ Tests/RunCMake/TargetSources/empty_1.cpp | 7 ++ Tests/RunCMake/TargetSources/empty_2.cpp | 7 ++ 44 files changed, 492 insertions(+), 138 deletions(-) create mode 100644 Tests/ConfigSources/CMakeLists.txt create mode 100644 Tests/ConfigSources/main.cpp create mode 100644 Tests/QtAutogen/debug_class.cpp create mode 100644 Tests/QtAutogen/debug_class.h create mode 100644 Tests/QtAutogen/debug_class.ui create mode 100644 Tests/QtAutogen/debug_resource.qrc create mode 100644 Tests/RunCMake/TargetSources/CMakeLists.txt create mode 100644 Tests/RunCMake/TargetSources/ConfigNotAllowed-result.txt create mode 100644 Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt create mode 100644 Tests/RunCMake/TargetSources/ConfigNotAllowed.cmake create mode 100644 Tests/RunCMake/TargetSources/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/TargetSources/empty_1.cpp create mode 100644 Tests/RunCMake/TargetSources/empty_2.cpp diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index f07bccb..8655cb7 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -213,34 +213,10 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // deal with config-specific dependencies. { std::set emitted; - { cmGeneratorTarget* gt = depender->GetMakefile()->GetLocalGenerator() ->GetGlobalGenerator() ->GetGeneratorTarget(depender); - std::vector objectFiles; - gt->GetExternalObjects(objectFiles); - for(std::vector::const_iterator - it = objectFiles.begin(); it != objectFiles.end(); ++it) - { - std::string objLib = (*it)->GetObjectLibrary(); - if (!objLib.empty() && emitted.insert(objLib).second) - { - if(depender->GetType() != cmTarget::EXECUTABLE && - depender->GetType() != cmTarget::STATIC_LIBRARY && - depender->GetType() != cmTarget::SHARED_LIBRARY && - depender->GetType() != cmTarget::MODULE_LIBRARY) - { - this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, - "Only executables and non-OBJECT libraries may " - "reference target objects.", - depender->GetBacktrace()); - return; - } - const_cast(depender)->AddUtility(objLib); - } - } - } + std::vector configs; depender->GetMakefile()->GetConfigurations(configs); if (configs.empty()) @@ -250,6 +226,29 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) for (std::vector::const_iterator it = configs.begin(); it != configs.end(); ++it) { + std::vector objectFiles; + gt->GetExternalObjects(objectFiles, *it); + for(std::vector::const_iterator + oi = objectFiles.begin(); oi != objectFiles.end(); ++oi) + { + std::string objLib = (*oi)->GetObjectLibrary(); + if (!objLib.empty() && emitted.insert(objLib).second) + { + if(depender->GetType() != cmTarget::EXECUTABLE && + depender->GetType() != cmTarget::STATIC_LIBRARY && + depender->GetType() != cmTarget::SHARED_LIBRARY && + depender->GetType() != cmTarget::MODULE_LIBRARY) + { + this->GlobalGenerator->GetCMakeInstance() + ->IssueMessage(cmake::FATAL_ERROR, + "Only executables and non-OBJECT libraries may " + "reference target objects.", + depender->GetBacktrace()); + return; + } + const_cast(depender)->AddUtility(objLib); + } + } std::vector tlibs; depender->GetDirectLinkLibraries(*it, tlibs, depender); diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index e99bf04..6f76dc4 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -399,7 +399,8 @@ void cmExtraCodeBlocksGenerator case cmTarget::UTILITY: // can have sources since 2.6.3 { std::vector sources; - ti->second.GetSourceFiles(sources); + ti->second.GetSourceFiles(sources, + makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); for (std::vector::const_iterator si=sources.begin(); si!=sources.end(); si++) { diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 1cbd057..33ffc90 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -214,7 +214,8 @@ void cmExtraCodeLiteGenerator case cmTarget::MODULE_LIBRARY: { std::vector sources; - ti->second.GetSourceFiles(sources); + ti->second.GetSourceFiles(sources, + makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); for (std::vector::const_iterator si=sources.begin(); si!=sources.end(); si++) { diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index fcb95a0..e23551e 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -560,7 +560,8 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets( // get the files from the source lists then add them to the groups cmTarget* tgt = const_cast(&ti->second); std::vector files; - tgt->GetSourceFiles(files); + tgt->GetSourceFiles(files, + makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::vector::const_iterator sfIt = files.begin(); sfIt != files.end(); sfIt++) diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index ec5ffc2..7fe47c3 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -238,7 +238,8 @@ void cmExtraSublimeTextGenerator:: cmGeneratorTarget *gtgt = this->GlobalGenerator ->GetGeneratorTarget(target); std::vector sourceFiles; - target->GetSourceFiles(sourceFiles); + target->GetSourceFiles(sourceFiles, + makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); std::vector::const_iterator sourceFilesEnd = sourceFiles.end(); for (std::vector::const_iterator iter = diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index e2b114a..f7d8243 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -133,7 +133,7 @@ void cmFLTKWrapUICommand::FinalPass() return; } std::vector srcs; - target->GetSourceFiles(srcs); + target->GetSourceFiles(srcs, ""); bool found = false; for (unsigned int i = 0; i < srcs.size(); ++i) { diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 669694c..a392675 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -1272,7 +1272,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode } std::vector objectSources; - gt->GetObjectSources(objectSources); + gt->GetObjectSources(objectSources, context->Config); std::map mapping; for(std::vector::const_iterator it diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 8688f78..01fad26 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -289,7 +289,7 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt, #define IMPLEMENT_VISIT_IMPL(DATA, DATATYPE) \ { \ std::vector sourceFiles; \ - this->Target->GetSourceFiles(sourceFiles); \ + this->Target->GetSourceFiles(sourceFiles, config); \ TagVisitor visitor(this->Target, data); \ for(std::vector::const_iterator si = sourceFiles.begin(); \ si != sourceFiles.end(); ++si) \ @@ -308,7 +308,8 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt, //---------------------------------------------------------------------------- void cmGeneratorTarget -::GetObjectSources(std::vector &data) const +::GetObjectSources(std::vector &data, + const std::string& config) const { IMPLEMENT_VISIT(ObjectSources); @@ -332,8 +333,19 @@ void cmGeneratorTarget::ComputeObjectMapping() { return; } - std::vector sourceFiles; - this->GetObjectSources(sourceFiles); + + std::vector configs; + this->Makefile->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } + for(std::vector::const_iterator ci = configs.begin(); + ci != configs.end(); ++ci) + { + std::vector sourceFiles; + this->GetObjectSources(sourceFiles, *ci); + } } //---------------------------------------------------------------------------- @@ -360,7 +372,8 @@ bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const //---------------------------------------------------------------------------- void cmGeneratorTarget -::GetIDLSources(std::vector& data) const +::GetIDLSources(std::vector& data, + const std::string& config) const { IMPLEMENT_VISIT(IDLSources); } @@ -368,14 +381,16 @@ void cmGeneratorTarget //---------------------------------------------------------------------------- void cmGeneratorTarget -::GetHeaderSources(std::vector& data) const +::GetHeaderSources(std::vector& data, + const std::string& config) const { IMPLEMENT_VISIT(HeaderSources); } //---------------------------------------------------------------------------- void cmGeneratorTarget -::GetExtraSources(std::vector& data) const +::GetExtraSources(std::vector& data, + const std::string& config) const { IMPLEMENT_VISIT(ExtraSources); } @@ -383,7 +398,8 @@ void cmGeneratorTarget //---------------------------------------------------------------------------- void cmGeneratorTarget -::GetCustomCommands(std::vector& data) const +::GetCustomCommands(std::vector& data, + const std::string& config) const { IMPLEMENT_VISIT(CustomCommands); } @@ -391,14 +407,16 @@ cmGeneratorTarget //---------------------------------------------------------------------------- void cmGeneratorTarget -::GetExternalObjects(std::vector& data) const +::GetExternalObjects(std::vector& data, + const std::string& config) const { IMPLEMENT_VISIT(ExternalObjects); } //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetExpectedResxHeaders(std::set& srcs) const +cmGeneratorTarget::GetExpectedResxHeaders(std::set& srcs, + const std::string& config) const { ResxData data; IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData) @@ -407,7 +425,8 @@ cmGeneratorTarget::GetExpectedResxHeaders(std::set& srcs) const //---------------------------------------------------------------------------- void cmGeneratorTarget -::GetResxSources(std::vector& srcs) const +::GetResxSources(std::vector& srcs, + const std::string& config) const { ResxData data; IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData) @@ -517,13 +536,15 @@ bool cmGeneratorTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetSourceFiles(std::vector &files) const +void cmGeneratorTarget::GetSourceFiles(std::vector &files, + const std::string& config) const { - this->Target->GetSourceFiles(files); + this->Target->GetSourceFiles(files, config); } //---------------------------------------------------------------------------- -std::string cmGeneratorTarget::GetModuleDefinitionFile() const +std::string +cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { std::string data; IMPLEMENT_VISIT_IMPL(ModuleDefinitionFile, COMMA std::string) @@ -532,10 +553,11 @@ std::string cmGeneratorTarget::GetModuleDefinitionFile() const //---------------------------------------------------------------------------- void -cmGeneratorTarget::UseObjectLibraries(std::vector& objs) const +cmGeneratorTarget::UseObjectLibraries(std::vector& objs, + const std::string &config) const { std::vector objectFiles; - this->GetExternalObjects(objectFiles); + this->GetExternalObjects(objectFiles, config); std::vector objectLibraries; std::set emitted; for(std::vector::const_iterator @@ -559,7 +581,7 @@ cmGeneratorTarget::UseObjectLibraries(std::vector& objs) const cmGeneratorTarget* ogt = this->GlobalGenerator->GetGeneratorTarget(objLib); std::vector objectSources; - ogt->GetObjectSources(objectSources); + ogt->GetObjectSources(objectSources, config); for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) @@ -615,11 +637,22 @@ cmTargetTraceDependencies if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) { std::vector sources; - this->Target->GetSourceFiles(sources); + std::vector configs; + this->Makefile->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } + for(std::vector::const_iterator ci = configs.begin(); + ci != configs.end(); ++ci) + { + this->Target->GetSourceFiles(sources, *ci); + } + std::set emitted; for(std::vector::const_iterator si = sources.begin(); si != sources.end(); ++si) { - if(this->SourcesQueued.insert(*si).second) + if(emitted.insert(*si).second && this->SourcesQueued.insert(*si).second) { this->SourceQueue.push(*si); this->Makefile->GetOrCreateSource(*si); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 38e6510..9d13e6c 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -30,21 +30,30 @@ public: std::string GetName() const; const char *GetProperty(const std::string& prop) const; bool GetPropertyAsBool(const std::string& prop) const; - void GetSourceFiles(std::vector& files) const; + void GetSourceFiles(std::vector& files, + const std::string& config) const; - void GetObjectSources(std::vector &) const; + void GetObjectSources(std::vector &, + const std::string& config) const; const std::string& GetObjectName(cmSourceFile const* file); bool HasExplicitObjectName(cmSourceFile const* file) const; void AddExplicitObjectName(cmSourceFile const* sf); - void GetResxSources(std::vector&) const; - void GetIDLSources(std::vector&) const; - void GetExternalObjects(std::vector&) const; - void GetHeaderSources(std::vector&) const; - void GetExtraSources(std::vector&) const; - void GetCustomCommands(std::vector&) const; - void GetExpectedResxHeaders(std::set&) const; + void GetResxSources(std::vector&, + const std::string& config) const; + void GetIDLSources(std::vector&, + const std::string& config) const; + void GetExternalObjects(std::vector&, + const std::string& config) const; + void GetHeaderSources(std::vector&, + const std::string& config) const; + void GetExtraSources(std::vector&, + const std::string& config) const; + void GetCustomCommands(std::vector&, + const std::string& config) const; + void GetExpectedResxHeaders(std::set&, + const std::string& config) const; void ComputeObjectMapping(); @@ -53,14 +62,15 @@ public: cmLocalGenerator* LocalGenerator; cmGlobalGenerator const* GlobalGenerator; - std::string GetModuleDefinitionFile() const; + std::string GetModuleDefinitionFile(const std::string& config) const; /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ std::string ObjectDirectory; - void UseObjectLibraries(std::vector& objs) const; + void UseObjectLibraries(std::vector& objs, + const std::string& config) const; void GetAppleArchs(const std::string& config, std::vector& archVec) const; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 66ccf39..0f7dfe8 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2900,10 +2900,25 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target) // List the source files with any per-source labels. fout << "# Source files and their labels\n"; std::vector sources; - target->GetSourceFiles(sources); + std::vector configs; + target->GetMakefile()->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } + for(std::vector::const_iterator ci = configs.begin(); + ci != configs.end(); ++ci) + { + target->GetSourceFiles(sources, *ci); + } + std::set emitted; for(std::vector::const_iterator si = sources.begin(); si != sources.end(); ++si) { + if (!emitted.insert(*si).second) + { + continue; + } cmSourceFile* sf = *si; fout << sf->GetFullPath() << "\n"; if(const char* svalue = sf->GetProperty("LABELS")) diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index df3ce10..89d25c4 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -139,7 +139,8 @@ bool cmGlobalKdevelopGenerator ti != targets.end(); ti++) { std::vector sources; - ti->second.GetSourceFiles(sources); + ti->second.GetSourceFiles(sources, ti->second.GetMakefile() + ->GetSafeDefinition("CMAKE_BUILD_TYPE")); for (std::vector::const_iterator si=sources.begin(); si!=sources.end(); si++) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 3aa293e..8dae81b 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -1081,7 +1081,8 @@ bool cmGlobalUnixMakefileGenerator3 ::NeedRequiresStep(cmTarget const& target) { std::set languages; - target.GetLanguages(languages); + target.GetLanguages(languages, + target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::set::const_iterator l = languages.begin(); l != languages.end(); ++l) { diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 38f709f..c5a0e29 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -815,7 +815,15 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) { // check to see if this is a fortran build std::set languages; - target.GetLanguages(languages); + { + // Issue diagnostic if the source files depend on the config. + std::vector sources; + if (!target.GetConfigCommonSourceFiles(sources)) + { + return false; + } + } + target.GetLanguages(languages, ""); if(languages.size() == 1) { if(*languages.begin() == "Fortran") diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d9d4927..b3975b4 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -984,7 +984,10 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // organize the sources std::vector classes; - cmtarget.GetSourceFiles(classes); + if (!cmtarget.GetConfigCommonSourceFiles(classes)) + { + return; + } std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare()); gtgt->ComputeObjectMapping(); @@ -1043,7 +1046,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // the externalObjFiles above, except each one is not a cmSourceFile // within the target.) std::vector objs; - gtgt->UseObjectLibraries(objs); + gtgt->UseObjectLibraries(objs, ""); for(std::vector::const_iterator oi = objs.begin(); oi != objs.end(); ++oi) { @@ -1359,7 +1362,10 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } std::vector classes; - cmtarget.GetSourceFiles(classes); + if (!cmtarget.GetConfigCommonSourceFiles(classes)) + { + return; + } // add all the sources std::vector commands; for(std::vector::const_iterator i = classes.begin(); @@ -2439,7 +2445,11 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) if(cmtarget.GetType() == cmTarget::UTILITY) { std::vector sources; - cmtarget.GetSourceFiles(sources); + if (!cmtarget.GetConfigCommonSourceFiles(sources)) + { + return 0; + } + for(std::vector::const_iterator i = sources.begin(); i != sources.end(); ++i) { @@ -2808,7 +2818,7 @@ void cmGlobalXCodeGenerator std::string linkObjs; const char* sep = ""; std::vector objs; - this->GetGeneratorTarget(cmtarget)->UseObjectLibraries(objs); + this->GetGeneratorTarget(cmtarget)->UseObjectLibraries(objs, ""); for(std::vector::const_iterator oi = objs.begin(); oi != objs.end(); ++oi) { @@ -2943,8 +2953,10 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, } std::vector classes; - cmtarget.GetSourceFiles(classes); - + if (!cmtarget.GetConfigCommonSourceFiles(classes)) + { + return; + } // Put cmSourceFile instances in proper groups: for(std::vector::const_iterator s = classes.begin(); s != classes.end(); s++) @@ -2962,7 +2974,7 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, // Put OBJECT_LIBRARY objects in proper groups: std::vector objs; - this->GetGeneratorTarget(&cmtarget)->UseObjectLibraries(objs); + this->GetGeneratorTarget(&cmtarget)->UseObjectLibraries(objs, ""); for(std::vector::const_iterator oi = objs.begin(); oi != objs.end(); ++oi) { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 61d2a80..e2f8375 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -662,7 +662,8 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, std::vector objVector; // Add all the sources outputs to the depends of the target std::vector classes; - target.GetSourceFiles(classes); + target.GetSourceFiles(classes, + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::vector::const_iterator i = classes.begin(); i != classes.end(); ++i) { @@ -1644,7 +1645,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) { std::vector sources; - target->GetSourceFiles(sources); + target->GetSourceFiles(sources, buildType); for(std::vector::const_iterator i = sources.begin(); i != sources.end(); ++i) { @@ -1692,7 +1693,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition(build); linkFlags += " "; } - std::string linkLanguage = target->Target->GetLinkerLanguage(); + std::string linkLanguage = target->Target->GetLinkerLanguage(buildType); if(linkLanguage.empty()) { cmSystemTools::Error diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index cc872d5..bbd350d 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -200,7 +200,8 @@ GetLocalObjectFiles(std::map &localObjectFiles) continue; } std::vector objectSources; - gt->GetObjectSources(objectSources); + gt->GetObjectSources(objectSources, this->Makefile + ->GetSafeDefinition("CMAKE_BUILD_TYPE")); // Compute full path to object file directory for this target. std::string dir; dir += gt->Makefile->GetCurrentOutputDirectory(); @@ -1262,7 +1263,8 @@ cmLocalUnixMakefileGenerator3 { // Get the set of source languages in the target. std::set languages; - target.GetLanguages(languages); + target.GetLanguages(languages, + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); fout << "\n" << "# Per-language clean rules from dependency scanning.\n" << "foreach(lang"; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 11e9679..5db735f 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -317,7 +317,10 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, // get the classes from the source lists then add them to the groups std::vector classes; - target.GetSourceFiles(classes); + if (!target.GetConfigCommonSourceFiles(classes)) + { + return; + } // now all of the source files have been properly assigned to the target // now stick them into source groups using the reg expressions @@ -1269,7 +1272,20 @@ void cmLocalVisualStudio6Generator if(targetBuilds) { // Get the language to use for linking. - const std::string& linkLanguage = target.GetLinkerLanguage(); + std::vector configs; + target.GetMakefile()->GetConfigurations(configs); + std::vector::const_iterator it = configs.begin(); + const std::string& linkLanguage = target.GetLinkerLanguage(*it); + for ( ; it != configs.end(); ++it) + { + const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + if (configLinkLanguage != linkLanguage) + { + cmSystemTools::Error + ("Linker language must not vary by configuration for target: ", + target.GetName().c_str()); + } + } if(linkLanguage.empty()) { cmSystemTools::Error @@ -1691,7 +1707,20 @@ void cmLocalVisualStudio6Generator if(target.GetType() >= cmTarget::EXECUTABLE && target.GetType() <= cmTarget::OBJECT_LIBRARY) { - const std::string& linkLanguage = target.GetLinkerLanguage(); + std::vector configs; + target.GetMakefile()->GetConfigurations(configs); + std::vector::const_iterator it = configs.begin(); + const std::string& linkLanguage = target.GetLinkerLanguage(*it); + for ( ; it != configs.end(); ++it) + { + const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + if (configLinkLanguage != linkLanguage) + { + cmSystemTools::Error + ("Linker language must not vary by configuration for target: ", + target.GetName().c_str()); + } + } if(linkLanguage.empty()) { cmSystemTools::Error @@ -1889,7 +1918,7 @@ void cmLocalVisualStudio6Generator cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(&target); std::vector objs; - gt->UseObjectLibraries(objs); + gt->UseObjectLibraries(objs, ""); for(std::vector::const_iterator oi = objs.begin(); oi != objs.end(); ++oi) { diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 8bac10d..47f9826 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1330,7 +1330,7 @@ cmLocalVisualStudio7GeneratorInternals cmGeneratorTarget* gt = lg->GetGlobalGenerator()->GetGeneratorTarget(t); std::vector objs; - gt->UseObjectLibraries(objs); + gt->UseObjectLibraries(objs, ""); const char* sep = isep? isep : ""; for(std::vector::const_iterator oi = objs.begin(); oi != objs.end(); ++oi) @@ -1397,7 +1397,10 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, // get the classes from the source lists then add them to the groups this->ModuleDefinitionFile = ""; std::vector classes; - target.GetSourceFiles(classes); + if (!target.GetConfigCommonSourceFiles(classes)) + { + return; + } for(std::vector::const_iterator i = classes.begin(); i != classes.end(); i++) { @@ -1438,7 +1441,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(&target); std::vector objs; - gt->UseObjectLibraries(objs); + gt->UseObjectLibraries(objs, ""); if(!objs.empty()) { // TODO: Separate sub-filter for each object library used? diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index c520f9e..2d55621 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -128,14 +128,15 @@ void cmMakefileTargetGenerator::CreateRuleFile() //---------------------------------------------------------------------------- void cmMakefileTargetGenerator::WriteTargetBuildRules() { + const std::string& config = + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); + // write the custom commands for this target // Look for files registered for cleaning in this directory. if(const char* additional_clean_files = this->Makefile->GetProperty ("ADDITIONAL_MAKE_CLEAN_FILES")) { - const std::string& config = - this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); cmListFileBacktrace lfbt; cmGeneratorExpression ge(lfbt); cmsys::auto_ptr cge = @@ -154,7 +155,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() // First generate the object rule files. Save a list of all object // files for this target. std::vector customCommands; - this->GeneratorTarget->GetCustomCommands(customCommands); + this->GeneratorTarget->GetCustomCommands(customCommands, config); for(std::vector::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) @@ -177,17 +178,17 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() } } std::vector headerSources; - this->GeneratorTarget->GetHeaderSources(headerSources); + this->GeneratorTarget->GetHeaderSources(headerSources, config); this->OSXBundleGenerator->GenerateMacOSXContentStatements( headerSources, this->MacOSXContentGenerator); std::vector extraSources; - this->GeneratorTarget->GetExtraSources(extraSources); + this->GeneratorTarget->GetExtraSources(extraSources, config); this->OSXBundleGenerator->GenerateMacOSXContentStatements( extraSources, this->MacOSXContentGenerator); std::vector externalObjects; - this->GeneratorTarget->GetExternalObjects(externalObjects); + this->GeneratorTarget->GetExternalObjects(externalObjects, config); for(std::vector::const_iterator si = externalObjects.begin(); si != externalObjects.end(); ++si) @@ -195,7 +196,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() this->ExternalObjects.push_back((*si)->GetFullPath()); } std::vector objectSources; - this->GeneratorTarget->GetObjectSources(objectSources); + this->GeneratorTarget->GetObjectSources(objectSources, config); for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { @@ -344,7 +345,8 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() { // write language flags for target std::set languages; - this->Target->GetLanguages(languages); + this->Target->GetLanguages(languages, + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); // put the compiler in the rules.make file so that if it changes // things rebuild for(std::set::const_iterator l = languages.begin(); @@ -1173,7 +1175,8 @@ cmMakefileTargetGenerator { // Depend on all custom command outputs. std::vector sources; - this->Target->GetSourceFiles(sources); + this->Target->GetSourceFiles(sources, + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::vector::const_iterator source = sources.begin(); source != sources.end(); ++source) { @@ -1670,7 +1673,8 @@ void cmMakefileTargetGenerator this->AppendTargetDepends(depends); // Add a dependency on the link definitions file, if any. - std::string def = this->GeneratorTarget->GetModuleDefinitionFile(); + std::string def = this->GeneratorTarget->GetModuleDefinitionFile( + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); if(!def.empty()) { depends.push_back(def); @@ -2064,7 +2068,7 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags) { std::vector includes; const std::string& config = - this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, "C", config); @@ -2083,7 +2087,8 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags) //---------------------------------------------------------------------------- void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags) { - std::string def = this->GeneratorTarget->GetModuleDefinitionFile(); + std::string def = this->GeneratorTarget->GetModuleDefinitionFile( + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); if(def.empty()) { return; diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 2d1bc76..853319e 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -111,7 +111,8 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules() #endif std::set languages; - this->GetTarget()->GetLanguages(languages); + this->GetTarget()->GetLanguages(languages, + this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); for(std::set::const_iterator l = languages.begin(); l != languages.end(); ++l) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index b7eab7d..56155ef 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -485,8 +485,9 @@ cmNinjaTargetGenerator << this->GetTargetName() << "\n\n"; + std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); std::vector customCommands; - this->GeneratorTarget->GetCustomCommands(customCommands); + this->GeneratorTarget->GetCustomCommands(customCommands, config); for(std::vector::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) @@ -495,17 +496,17 @@ cmNinjaTargetGenerator this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget()); } std::vector headerSources; - this->GeneratorTarget->GetHeaderSources(headerSources); + this->GeneratorTarget->GetHeaderSources(headerSources, config); this->OSXBundleGenerator->GenerateMacOSXContentStatements( headerSources, this->MacOSXContentGenerator); std::vector extraSources; - this->GeneratorTarget->GetExtraSources(extraSources); + this->GeneratorTarget->GetExtraSources(extraSources, config); this->OSXBundleGenerator->GenerateMacOSXContentStatements( extraSources, this->MacOSXContentGenerator); std::vector externalObjects; - this->GeneratorTarget->GetExternalObjects(externalObjects); + this->GeneratorTarget->GetExternalObjects(externalObjects, config); for(std::vector::const_iterator si = externalObjects.begin(); si != externalObjects.end(); ++si) @@ -513,13 +514,13 @@ cmNinjaTargetGenerator this->Objects.push_back(this->GetSourceFilePath(*si)); } std::vector objectSources; - this->GeneratorTarget->GetObjectSources(objectSources); + this->GeneratorTarget->GetObjectSources(objectSources, config); for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { this->WriteObjectBuildStatement(*si); } - std::string def = this->GeneratorTarget->GetModuleDefinitionFile(); + std::string def = this->GeneratorTarget->GetModuleDefinitionFile(config); if(!def.empty()) { this->ModuleDefinitionFile = this->ConvertToNinjaPath(def.c_str()); @@ -565,7 +566,8 @@ cmNinjaTargetGenerator // Add order-only dependencies on custom command outputs. std::vector customCommands; - this->GeneratorTarget->GetCustomCommands(customCommands); + std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); + this->GeneratorTarget->GetCustomCommands(customCommands, config); for(std::vector::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 0fb40c0..f5d18dc 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -46,7 +46,9 @@ void cmNinjaUtilityTargetGenerator::Generate() } std::vector sources; - this->GetTarget()->GetSourceFiles(sources); + std::string config = this->GetMakefile() + ->GetSafeDefinition("CMAKE_BUILD_TYPE"); + this->GetTarget()->GetSourceFiles(sources, config); for(std::vector::const_iterator source = sources.begin(); source != sources.end(); ++source) { diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 71c4630..ae11462 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -472,7 +472,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) const char* sepHeaders = ""; std::vector srcFiles; - target->GetSourceFiles(srcFiles); + target->GetConfigCommonSourceFiles(srcFiles); const char *skipMocSep = ""; const char *skipUicSep = ""; @@ -862,7 +862,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) cmMakefile *makefile = target->GetMakefile(); std::vector srcFiles; - target->GetSourceFiles(srcFiles); + target->GetConfigCommonSourceFiles(srcFiles); std::string rccFileFiles; std::string rccFileOptions; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 61260be..fbd7315 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -543,7 +543,8 @@ bool cmTarget::IsBundleOnApple() const } //---------------------------------------------------------------------------- -void cmTarget::GetSourceFiles(std::vector &files) const +void cmTarget::GetSourceFiles(std::vector &files, + const std::string& config) const { assert(this->GetType() != INTERFACE_LIBRARY); for(std::vector::const_iterator @@ -552,7 +553,7 @@ void cmTarget::GetSourceFiles(std::vector &files) const { std::vector srcs; cmSystemTools::ExpandListArgument((*si)->ge->Evaluate(this->Makefile, - "", + config, false, this), srcs); @@ -580,10 +581,68 @@ void cmTarget::GetSourceFiles(std::vector &files) const } //---------------------------------------------------------------------------- -void cmTarget::GetSourceFiles(std::vector &files) const +bool +cmTarget::GetConfigCommonSourceFiles(std::vector& files) const +{ + std::vector configs; + this->Makefile->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } + + std::vector::const_iterator it = configs.begin(); + const std::string& firstConfig = *it; + this->GetSourceFiles(files, firstConfig); + + for ( ; it != configs.end(); ++it) + { + std::vector configFiles; + this->GetSourceFiles(configFiles, *it); + if (configFiles != files) + { + std::string firstConfigFiles; + const char* sep = ""; + for (std::vector::const_iterator fi = files.begin(); + fi != files.end(); ++fi) + { + firstConfigFiles += sep; + firstConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + + std::string thisConfigFiles; + sep = ""; + for (std::vector::const_iterator fi = configFiles.begin(); + fi != configFiles.end(); ++fi) + { + thisConfigFiles += sep; + thisConfigFiles += (*fi)->GetFullPath(); + sep = "\n "; + } + cmOStringStream e; + e << "Target \"" << this->Name << "\" has source files which vary by " + "configuration. This is not supported by the \"" + << this->Makefile->GetLocalGenerator() + ->GetGlobalGenerator()->GetName() + << "\" generator.\n" + "Config \"" << firstConfig << "\":\n" + " " << firstConfigFiles << "\n" + "Config \"" << *it << "\":\n" + " " << thisConfigFiles << "\n"; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + } + return true; +} + +//---------------------------------------------------------------------------- +void cmTarget::GetSourceFiles(std::vector &files, + const std::string& config) const { std::vector srcs; - this->GetSourceFiles(srcs); + this->GetSourceFiles(srcs, config); std::set emitted; @@ -4993,10 +5052,11 @@ bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, } //---------------------------------------------------------------------------- -void cmTarget::GetLanguages(std::set& languages) const +void cmTarget::GetLanguages(std::set& languages, + const std::string& config) const { std::vector sourceFiles; - this->GetSourceFiles(sourceFiles); + this->GetSourceFiles(sourceFiles, config); for(std::vector::const_iterator i = sourceFiles.begin(); i != sourceFiles.end(); ++i) { @@ -5037,7 +5097,7 @@ void cmTarget::GetLanguages(std::set& languages) const cmGeneratorTarget* gt = this->Makefile->GetLocalGenerator() ->GetGlobalGenerator() ->GetGeneratorTarget(this); - gt->GetExternalObjects(externalObjects); + gt->GetExternalObjects(externalObjects, config); for(std::vector::const_iterator i = externalObjects.begin(); i != externalObjects.end(); ++i) { @@ -5051,7 +5111,7 @@ void cmTarget::GetLanguages(std::set& languages) const for(std::vector::const_iterator i = objectLibraries.begin(); i != objectLibraries.end(); ++i) { - (*i)->GetLanguages(languages); + (*i)->GetLanguages(languages, config); } } @@ -5990,7 +6050,7 @@ cmTarget::GetLinkImplementation(const std::string& config, // Compute the link implementation for this configuration. LinkImplementation impl; this->ComputeLinkImplementation(config, impl, head); - this->ComputeLinkImplementationLanguages(impl); + this->ComputeLinkImplementationLanguages(config, impl); // Store the information for this configuration. cmTargetInternals::LinkImplMapType::value_type entry(key, impl); @@ -5998,7 +6058,7 @@ cmTarget::GetLinkImplementation(const std::string& config, } else if (i->second.Languages.empty()) { - this->ComputeLinkImplementationLanguages(i->second); + this->ComputeLinkImplementationLanguages(config, i->second); } return &i->second; @@ -6111,12 +6171,13 @@ void cmTarget::ComputeLinkImplementation(const std::string& config, //---------------------------------------------------------------------------- void -cmTarget::ComputeLinkImplementationLanguages(LinkImplementation& impl) const +cmTarget::ComputeLinkImplementationLanguages(const std::string& config, + LinkImplementation& impl) const { // This target needs runtime libraries for its source languages. std::set languages; // Get languages used in our source files. - this->GetLanguages(languages); + this->GetLanguages(languages, config); // Copy the set of langauges to the link implementation. for(std::set::iterator li = languages.begin(); li != languages.end(); ++li) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index fcbff93..042b441 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -135,8 +135,11 @@ public: /** * Get the list of the source files used by this target */ - void GetSourceFiles(std::vector &files) const; - void GetSourceFiles(std::vector &files) const; + void GetSourceFiles(std::vector &files, + const std::string& config) const; + void GetSourceFiles(std::vector &files, + const std::string& config) const; + bool GetConfigCommonSourceFiles(std::vector& files) const; /** * Add sources to the target. @@ -465,7 +468,8 @@ public: // when source file properties are changed and we do not have enough // information to forward these property changes to the targets // until we have per-target object file properties. - void GetLanguages(std::set& languages) const; + void GetLanguages(std::set& languages, + const std::string& config) const; /** Return whether this target is an executable with symbol exports enabled. */ @@ -738,7 +742,8 @@ private: void ComputeLinkImplementation(const std::string& config, LinkImplementation& impl, cmTarget const* head) const; - void ComputeLinkImplementationLanguages(LinkImplementation& impl) const; + void ComputeLinkImplementationLanguages(const std::string& config, + LinkImplementation& impl) const; void ComputeLinkClosure(const std::string& config, LinkClosure& lc, cmTarget const* head) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 8d10e7c..a999b2d 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -379,7 +379,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences() void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() { std::vector resxObjs; - this->GeneratorTarget->GetResxSources(resxObjs); + this->GeneratorTarget->GetResxSources(resxObjs, ""); if(!resxObjs.empty()) { this->WriteString("\n", 1); @@ -553,7 +553,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommands() { this->SourcesVisited.clear(); std::vector customCommands; - this->GeneratorTarget->GetCustomCommands(customCommands); + this->GeneratorTarget->GetCustomCommands(customCommands, ""); for(std::vector::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) @@ -704,7 +704,10 @@ void cmVisualStudio10TargetGenerator::WriteGroups() std::vector sourceGroups = this->Makefile->GetSourceGroups(); std::vector classes; - this->Target->GetSourceFiles(classes); + if (!this->Target->GetConfigCommonSourceFiles(classes)) + { + return; + } std::set groupsUsed; for(std::vector::const_iterator s = classes.begin(); @@ -749,7 +752,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() } std::vector resxObjs; - this->GeneratorTarget->GetResxSources(resxObjs); + this->GeneratorTarget->GetResxSources(resxObjs, ""); if(!resxObjs.empty()) { this->WriteString("\n", 1); @@ -768,7 +771,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() // Add object library contents as external objects. std::vector objs; - this->GeneratorTarget->UseObjectLibraries(objs); + this->GeneratorTarget->UseObjectLibraries(objs, ""); if(!objs.empty()) { this->WriteString("\n", 1); @@ -1005,14 +1008,14 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() this->WriteString("\n", 1); std::vector headerSources; - this->GeneratorTarget->GetHeaderSources(headerSources); + this->GeneratorTarget->GetHeaderSources(headerSources, ""); this->WriteSources("ClInclude", headerSources); std::vector idlSources; - this->GeneratorTarget->GetIDLSources(idlSources); + this->GeneratorTarget->GetIDLSources(idlSources, ""); this->WriteSources("Midl", idlSources); std::vector objectSources; - this->GeneratorTarget->GetObjectSources(objectSources); + this->GeneratorTarget->GetObjectSources(objectSources, ""); for(std::vector::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) @@ -1053,7 +1056,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } std::vector externalObjects; - this->GeneratorTarget->GetExternalObjects(externalObjects); + this->GeneratorTarget->GetExternalObjects(externalObjects, ""); for(std::vector::iterator si = externalObjects.begin(); si != externalObjects.end(); ) @@ -1088,12 +1091,12 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } std::vector extraSources; - this->GeneratorTarget->GetExtraSources(extraSources); + this->GeneratorTarget->GetExtraSources(extraSources, ""); this->WriteSources("None", extraSources); // Add object library contents as external objects. std::vector objs; - this->GeneratorTarget->UseObjectLibraries(objs); + this->GeneratorTarget->UseObjectLibraries(objs, ""); for(std::vector::const_iterator oi = objs.begin(); oi != objs.end(); ++oi) { @@ -1694,7 +1697,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) linkOptions.AddFlag("ImportLibrary", imLib.c_str()); linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str()); linkOptions.Parse(flags.c_str()); - std::string def = this->GeneratorTarget->GetModuleDefinitionFile(); + std::string def = this->GeneratorTarget->GetModuleDefinitionFile(""); if(!def.empty()) { linkOptions.AddFlag("ModuleDefinitionFile", def.c_str()); @@ -1924,7 +1927,7 @@ bool cmVisualStudio10TargetGenerator:: IsResxHeader(const std::string& headerFile) { std::set expectedResxHeaders; - this->GeneratorTarget->GetExpectedResxHeaders(expectedResxHeaders); + this->GeneratorTarget->GetExpectedResxHeaders(expectedResxHeaders, ""); std::set::const_iterator it = expectedResxHeaders.find(headerFile); diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 726e790..e77133a 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -278,6 +278,10 @@ if(BUILD_TESTING) ADD_TEST_MACRO(AliasTarget AliasTarget) ADD_TEST_MACRO(StagingPrefix StagingPrefix) ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary) + if (CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]") + set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=Debug) + ADD_TEST_MACRO(ConfigSources ConfigSources) + endif() set_tests_properties(EmptyLibrary PROPERTIES PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test") ADD_TEST_MACRO(CrossCompile CrossCompile) diff --git a/Tests/ConfigSources/CMakeLists.txt b/Tests/ConfigSources/CMakeLists.txt new file mode 100644 index 0000000..68a4233 --- /dev/null +++ b/Tests/ConfigSources/CMakeLists.txt @@ -0,0 +1,9 @@ + +cmake_minimum_required(VERSION 3.0) + +project(ConfigSources) + +add_executable(ConfigSources + $<$:main.cpp> + $<$:does_not_exist.cpp> +) diff --git a/Tests/ConfigSources/main.cpp b/Tests/ConfigSources/main.cpp new file mode 100644 index 0000000..1c19e8d --- /dev/null +++ b/Tests/ConfigSources/main.cpp @@ -0,0 +1,5 @@ + +int main(int argc, char** argv) +{ + return 0; +} diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index d2116aa..3973653 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -64,9 +64,15 @@ add_custom_command( DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in" ) +message("CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}") +if (CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]" AND NOT CMAKE_CONFIGURATION_TYPES) + set(debug_srcs "$<$:debug_class.cpp>" $<$:debug_resource.qrc>) + add_definitions(-DTEST_DEBUG_CLASS) +endif() + add_executable(QtAutogen main.cpp calwidget.cpp second_widget.cpp foo.cpp blub.cpp bar.cpp abc.cpp xyz.cpp yaf.cpp gadget.cpp $ - test.qrc second_resource.qrc resourcetester.cpp generated.cpp + test.qrc second_resource.qrc resourcetester.cpp generated.cpp ${debug_srcs} ) set_property(TARGET QtAutogen APPEND PROPERTY AUTOGEN_TARGET_DEPENDS generate_moc_input "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h") diff --git a/Tests/QtAutogen/debug_class.cpp b/Tests/QtAutogen/debug_class.cpp new file mode 100644 index 0000000..58e72e4 --- /dev/null +++ b/Tests/QtAutogen/debug_class.cpp @@ -0,0 +1,9 @@ + +#include "debug_class.h" +#include "ui_debug_class.h" + +DebugClass::DebugClass(QWidget *parent) + : QWidget(parent), ui(new Ui::DebugClass) +{ + ui->setupUi(this); +} diff --git a/Tests/QtAutogen/debug_class.h b/Tests/QtAutogen/debug_class.h new file mode 100644 index 0000000..71bc104 --- /dev/null +++ b/Tests/QtAutogen/debug_class.h @@ -0,0 +1,20 @@ + +#include + +namespace Ui +{ +class DebugClass; +} + +class DebugClass : public QWidget +{ + Q_OBJECT +public: + explicit DebugClass(QWidget *parent = 0); + +signals: + void someSignal(); + +private: + Ui::DebugClass *ui; +}; diff --git a/Tests/QtAutogen/debug_class.ui b/Tests/QtAutogen/debug_class.ui new file mode 100644 index 0000000..dc2e1ac --- /dev/null +++ b/Tests/QtAutogen/debug_class.ui @@ -0,0 +1,45 @@ + + + DebugClass + + + + 0 + 0 + 400 + 300 + + + + DebugClass + + + + + 50 + 20 + 82 + 21 + + + + CheckBox + + + + + + 40 + 70 + 94 + 24 + + + + PushButton + + + + + + diff --git a/Tests/QtAutogen/debug_resource.qrc b/Tests/QtAutogen/debug_resource.qrc new file mode 100644 index 0000000..db98b9b --- /dev/null +++ b/Tests/QtAutogen/debug_resource.qrc @@ -0,0 +1,5 @@ + + + debug_class.ui + + diff --git a/Tests/QtAutogen/main.cpp b/Tests/QtAutogen/main.cpp index c8a036e..eb59665 100644 --- a/Tests/QtAutogen/main.cpp +++ b/Tests/QtAutogen/main.cpp @@ -51,6 +51,11 @@ #include "yaf.h" #include "libC.h" #include "resourcetester.h" +#ifdef TEST_DEBUG_CLASS +#include "debug_class.h" +#include +#endif + int main(int argv, char **args) { @@ -81,5 +86,9 @@ int main(int argv, char **args) QTimer::singleShot(0, &rt, SLOT(doTest())); +#ifdef TEST_DEBUG_CLASS + std::cout << DebugClass::staticMetaObject.className() << std::endl; +#endif + return app.exec(); } diff --git a/Tests/QtAutogen/resourcetester.cpp b/Tests/QtAutogen/resourcetester.cpp index 0c64d80..043ec75 100644 --- a/Tests/QtAutogen/resourcetester.cpp +++ b/Tests/QtAutogen/resourcetester.cpp @@ -18,6 +18,10 @@ void ResourceTester::doTest() qApp->exit(EXIT_FAILURE); if (!QFile::exists(":/main.cpp")) qApp->exit(EXIT_FAILURE); +#ifdef TEST_DEBUG_CLASS + if (!QFile::exists(":/debug_class.ui")) + qApp->exit(EXIT_FAILURE); +#endif QTimer::singleShot(0, qApp, SLOT(quit())); } diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 4f059d6..851de42 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -51,6 +51,7 @@ add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) add_RunCMake_test(ObjectLibrary) add_RunCMake_test(TargetObjects) +add_RunCMake_test(TargetSources) add_RunCMake_test(find_dependency) if(NOT WIN32) add_RunCMake_test(PositionIndependentCode) diff --git a/Tests/RunCMake/TargetSources/CMakeLists.txt b/Tests/RunCMake/TargetSources/CMakeLists.txt new file mode 100644 index 0000000..12cd3c7 --- /dev/null +++ b/Tests/RunCMake/TargetSources/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.4) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/TargetSources/ConfigNotAllowed-result.txt b/Tests/RunCMake/TargetSources/ConfigNotAllowed-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/TargetSources/ConfigNotAllowed-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt b/Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt new file mode 100644 index 0000000..1de5dd7 --- /dev/null +++ b/Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt @@ -0,0 +1,14 @@ +CMake Error in CMakeLists.txt: + Target "somelib" has source files which vary by configuration. This is not + supported by the "[^"]+" generator. + + Config "Debug": + + .*/Tests/RunCMake/TargetSources/empty_1.cpp + .*/Tests/RunCMake/TargetSources/empty_2.cpp + .*/Tests/RunCMake/TargetSources/CMakeLists.txt + + Config "Release": + + .*/Tests/RunCMake/TargetSources/empty_1.cpp + .*/Tests/RunCMake/TargetSources/CMakeLists.txt diff --git a/Tests/RunCMake/TargetSources/ConfigNotAllowed.cmake b/Tests/RunCMake/TargetSources/ConfigNotAllowed.cmake new file mode 100644 index 0000000..02af379 --- /dev/null +++ b/Tests/RunCMake/TargetSources/ConfigNotAllowed.cmake @@ -0,0 +1,2 @@ + +add_library(somelib empty_1.cpp $<$:empty_2.cpp>) diff --git a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake new file mode 100644 index 0000000..1a3a7fa --- /dev/null +++ b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake @@ -0,0 +1,6 @@ +include(RunCMake) + +if(RunCMake_GENERATOR MATCHES Xcode + OR RunCMake_GENERATOR MATCHES "Visual Studio") + run_cmake(ConfigNotAllowed) +endif() diff --git a/Tests/RunCMake/TargetSources/empty_1.cpp b/Tests/RunCMake/TargetSources/empty_1.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/TargetSources/empty_1.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/TargetSources/empty_2.cpp b/Tests/RunCMake/TargetSources/empty_2.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/TargetSources/empty_2.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} -- cgit v0.12 From 3676fb49634efd01755aa5c12d58e2f2bf20d09f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 13 Feb 2014 20:52:21 +0100 Subject: cmTarget: Allow transitive evaluation of SOURCES property. Extend the cmGeneratorExpressionDAGChecker with an interface returning the name of the top target. Use that to determine when there is a DAG violation, as required by the RunCMake.Languages tests. --- Help/manual/cmake-properties.7.rst | 1 + Help/prop_tgt/INTERFACE_SOURCES.rst | 15 ++ Help/release/dev/target-INTERFACE_SOURCES.rst | 5 + Source/cmGeneratorExpressionDAGChecker.cxx | 12 ++ Source/cmGeneratorExpressionDAGChecker.h | 5 +- Source/cmGeneratorExpressionEvaluator.cxx | 7 +- Source/cmTarget.cxx | 191 +++++++++++++++++++++----- Source/cmTarget.h | 12 +- Tests/CMakeLists.txt | 1 + Tests/ConfigSources/CMakeLists.txt | 8 ++ Tests/ConfigSources/iface_debug.h | 4 + Tests/ConfigSources/iface_debug_src.cpp | 7 + Tests/ConfigSources/iface_src.cpp | 5 + Tests/ConfigSources/main.cpp | 4 +- Tests/SourcesProperty/CMakeLists.txt | 10 ++ Tests/SourcesProperty/iface.cpp | 5 + Tests/SourcesProperty/iface.h | 2 + Tests/SourcesProperty/main.cpp | 7 + 18 files changed, 258 insertions(+), 43 deletions(-) create mode 100644 Help/prop_tgt/INTERFACE_SOURCES.rst create mode 100644 Help/release/dev/target-INTERFACE_SOURCES.rst create mode 100644 Tests/ConfigSources/iface_debug.h create mode 100644 Tests/ConfigSources/iface_debug_src.cpp create mode 100644 Tests/ConfigSources/iface_src.cpp create mode 100644 Tests/SourcesProperty/CMakeLists.txt create mode 100644 Tests/SourcesProperty/iface.cpp create mode 100644 Tests/SourcesProperty/iface.h create mode 100644 Tests/SourcesProperty/main.cpp diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 6ea5839..fd16eb9 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -152,6 +152,7 @@ Properties on Targets /prop_tgt/INTERFACE_INCLUDE_DIRECTORIES /prop_tgt/INTERFACE_LINK_LIBRARIES /prop_tgt/INTERFACE_POSITION_INDEPENDENT_CODE + /prop_tgt/INTERFACE_SOURCES /prop_tgt/INTERFACE_SYSTEM_INCLUDE_DIRECTORIES /prop_tgt/INTERPROCEDURAL_OPTIMIZATION_CONFIG /prop_tgt/INTERPROCEDURAL_OPTIMIZATION diff --git a/Help/prop_tgt/INTERFACE_SOURCES.rst b/Help/prop_tgt/INTERFACE_SOURCES.rst new file mode 100644 index 0000000..fb28231 --- /dev/null +++ b/Help/prop_tgt/INTERFACE_SOURCES.rst @@ -0,0 +1,15 @@ +INTERFACE_SOURCES +----------------- + +List of interface sources to pass to the compiler. + +Targets may populate this property to publish the sources +for consuming targets to compile. Consuming +targets can add entries to their own :prop_tgt:`SOURCES` property +such as ``$`` to use the +sources specified in the interface of ``foo``. + +Contents of ``INTERFACE_SOURCES`` may use "generator expressions" +with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` +manual for available expressions. See the :manual:`cmake-buildsystem(7)` +manual for more on defining buildsystem properties. diff --git a/Help/release/dev/target-INTERFACE_SOURCES.rst b/Help/release/dev/target-INTERFACE_SOURCES.rst new file mode 100644 index 0000000..4e34943 --- /dev/null +++ b/Help/release/dev/target-INTERFACE_SOURCES.rst @@ -0,0 +1,5 @@ +target-INTERFACE_SOURCES +------------------------ + +* A new :prop_tgt:`INTERFACE_SOURCES` target property was introduced. This is + consumed by dependent targets, which compile and link the listed sources. diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 07efba9..7f8e694 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -179,6 +179,18 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(const char *tgt) || strcmp(prop, "INTERFACE_LINK_LIBRARIES") == 0; } +std::string cmGeneratorExpressionDAGChecker::TopTarget() const +{ + const cmGeneratorExpressionDAGChecker *top = this; + const cmGeneratorExpressionDAGChecker *parent = this->Parent; + while (parent) + { + top = parent; + parent = parent->Parent; + } + return top->Target; +} + enum TransitiveProperty { #define DEFINE_ENUM_ENTRY(NAME) NAME, CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(DEFINE_ENUM_ENTRY) diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 6cbbd2a..b3147f7 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -25,7 +25,8 @@ SELECT(F, EvaluatingSystemIncludeDirectories, SYSTEM_INCLUDE_DIRECTORIES) \ SELECT(F, EvaluatingCompileDefinitions, COMPILE_DEFINITIONS) \ SELECT(F, EvaluatingCompileOptions, COMPILE_OPTIONS) \ - SELECT(F, EvaluatingAutoUicOptions, AUTOUIC_OPTIONS) + SELECT(F, EvaluatingAutoUicOptions, AUTOUIC_OPTIONS) \ + SELECT(F, EvaluatingSources, SOURCES) #define CM_FOR_EACH_TRANSITIVE_PROPERTY(F) \ CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_BOTH) @@ -70,6 +71,8 @@ struct cmGeneratorExpressionDAGChecker void SetTransitivePropertiesOnly() { this->TransitivePropertiesOnly = true; } + std::string TopTarget() const; + private: Result CheckGraph() const; diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index a392675..59e3aec 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -985,7 +985,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (propertyName == "LINKER_LANGUAGE") { if (target->LinkLanguagePropagatesToDependents() && - dagCheckerParent && dagCheckerParent->EvaluatingLinkLibraries()) + dagCheckerParent && (dagCheckerParent->EvaluatingLinkLibraries() + || dagCheckerParent->EvaluatingSources())) { reportError(context, content->GetOriginalExpression(), "LINKER_LANGUAGE target property can not be used while evaluating " @@ -1569,7 +1570,9 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode "Target \"" + name + "\" is not an executable or library."); return std::string(); } - if (dagChecker && dagChecker->EvaluatingLinkLibraries(name.c_str())) + if (dagChecker && (dagChecker->EvaluatingLinkLibraries(name.c_str()) + || (dagChecker->EvaluatingSources() + && name == dagChecker->TopTarget()))) { ::reportError(context, content->GetOriginalExpression(), "Expressions which require the linker language may not " diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index fbd7315..0b5734d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -159,10 +159,13 @@ public: CachedLinkInterfaceCompileOptionsEntries; mutable std::map > CachedLinkInterfaceCompileDefinitionsEntries; + mutable std::map > + CachedLinkInterfaceSourcesEntries; mutable std::map CacheLinkInterfaceIncludeDirectoriesDone; mutable std::map CacheLinkInterfaceCompileDefinitionsDone; mutable std::map CacheLinkInterfaceCompileOptionsDone; + mutable std::map CacheLinkInterfaceSourcesDone; }; //---------------------------------------------------------------------------- @@ -198,6 +201,7 @@ cmTargetInternals::~cmTargetInternals() deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries); deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries); deleteAndClear(this->CachedLinkInterfaceCompileDefinitionsEntries); + deleteAndClear(this->CachedLinkInterfaceSourcesEntries); } //---------------------------------------------------------------------------- @@ -543,44 +547,158 @@ bool cmTarget::IsBundleOnApple() const } //---------------------------------------------------------------------------- -void cmTarget::GetSourceFiles(std::vector &files, - const std::string& config) const +static void processSources(cmTarget const* tgt, + const std::vector &entries, + std::vector &srcs, + std::set &uniqueSrcs, + cmGeneratorExpressionDAGChecker *dagChecker, + cmTarget const* head, + std::string const& config) { - assert(this->GetType() != INTERFACE_LIBRARY); - for(std::vector::const_iterator - si = this->Internal->SourceEntries.begin(); - si != this->Internal->SourceEntries.end(); ++si) - { - std::vector srcs; - cmSystemTools::ExpandListArgument((*si)->ge->Evaluate(this->Makefile, - config, - false, - this), - srcs); + cmMakefile *mf = tgt->GetMakefile(); - for(std::vector::const_iterator i = srcs.begin(); - i != srcs.end(); ++i) + for (std::vector::const_iterator + it = entries.begin(), end = entries.end(); it != end; ++it) + { + bool cacheSources = false; + std::vector entrySources = (*it)->CachedEntries; + if(entrySources.empty()) { - std::string src = *i; - cmSourceFile* sf = this->Makefile->GetOrCreateSource(src); - std::string e; - src = sf->GetFullPath(&e); - if(src.empty()) + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + head ? head : tgt, + tgt, + dagChecker), + entrySources); + if (mf->IsGeneratingBuildSystem() + && !(*it)->ge->GetHadContextSensitiveCondition()) + { + cacheSources = true; + } + + for(std::vector::iterator i = entrySources.begin(); + i != entrySources.end(); ++i) { - if(!e.empty()) + std::string& src = *i; + + cmSourceFile* sf = mf->GetOrCreateSource(src); + std::string e; + src = sf->GetFullPath(&e); + if(src.empty()) { - cmake* cm = this->Makefile->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e, - this->GetBacktrace()); + if(!e.empty()) + { + cmake* cm = mf->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e, + tgt->GetBacktrace()); + } + return; } - return; } - files.push_back(src); + if (cacheSources) + { + (*it)->CachedEntries = entrySources; + } + } + for(std::vector::iterator + li = entrySources.begin(); li != entrySources.end(); ++li) + { + std::string src = *li; + + if(uniqueSrcs.insert(src).second) + { + srcs.push_back(src); + } } } } //---------------------------------------------------------------------------- +void cmTarget::GetSourceFiles(std::vector &files, + const std::string& config, + cmTarget const* head) const +{ + assert(this->GetType() != INTERFACE_LIBRARY); + + + cmListFileBacktrace lfbt; + + cmGeneratorExpressionDAGChecker dagChecker(lfbt, + this->GetName(), + "SOURCES", 0, 0); + + std::set uniqueSrcs; + processSources(this, + this->Internal->SourceEntries, + files, + uniqueSrcs, + &dagChecker, + head, + config); + + if (!this->Internal->CacheLinkInterfaceSourcesDone[config]) + { + for (std::vector::const_iterator + it = this->Internal->LinkImplementationPropertyEntries.begin(), + end = this->Internal->LinkImplementationPropertyEntries.end(); + it != end; ++it) + { + if (!cmGeneratorExpression::IsValidTargetName(it->Value) + && cmGeneratorExpression::Find(it->Value) == std::string::npos) + { + continue; + } + { + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr cge = + ge.Parse(it->Value); + std::string targetResult = cge->Evaluate(this->Makefile, config, + false, this, 0, &dagChecker); + if (!this->Makefile->FindTargetToUse(targetResult)) + { + continue; + } + } + std::string sourceGenex = "$Value + ",INTERFACE_SOURCES>"; + if (cmGeneratorExpression::Find(it->Value) != std::string::npos) + { + // Because it->Value is a generator expression, ensure that it + // evaluates to the non-empty string before being used in the + // TARGET_PROPERTY expression. + sourceGenex = "$<$Value + ">:" + sourceGenex + ">"; + } + cmGeneratorExpression ge(it->Backtrace); + cmsys::auto_ptr cge = ge.Parse( + sourceGenex); + + this->Internal + ->CachedLinkInterfaceSourcesEntries[config].push_back( + new cmTargetInternals::TargetPropertyEntry(cge, + it->Value)); + } + } + + processSources(this, + this->Internal->CachedLinkInterfaceSourcesEntries[config], + files, + uniqueSrcs, + &dagChecker, + head, + config); + + if (!this->Makefile->IsGeneratingBuildSystem()) + { + deleteAndClear(this->Internal->CachedLinkInterfaceSourcesEntries); + } + else + { + this->Internal->CacheLinkInterfaceSourcesDone[config] = true; + } +} + +//---------------------------------------------------------------------------- bool cmTarget::GetConfigCommonSourceFiles(std::vector& files) const { @@ -639,10 +757,11 @@ cmTarget::GetConfigCommonSourceFiles(std::vector& files) const //---------------------------------------------------------------------------- void cmTarget::GetSourceFiles(std::vector &files, - const std::string& config) const + const std::string& config, + cmTarget const* head) const { std::vector srcs; - this->GetSourceFiles(srcs, config); + this->GetSourceFiles(srcs, config, head); std::set emitted; @@ -5053,10 +5172,11 @@ bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, //---------------------------------------------------------------------------- void cmTarget::GetLanguages(std::set& languages, - const std::string& config) const + const std::string& config, + cmTarget const* head) const { std::vector sourceFiles; - this->GetSourceFiles(sourceFiles, config); + this->GetSourceFiles(sourceFiles, config, head); for(std::vector::const_iterator i = sourceFiles.begin(); i != sourceFiles.end(); ++i) { @@ -5111,7 +5231,7 @@ void cmTarget::GetLanguages(std::set& languages, for(std::vector::const_iterator i = objectLibraries.begin(); i != objectLibraries.end(); ++i) { - (*i)->GetLanguages(languages, config); + (*i)->GetLanguages(languages, config, head); } } @@ -6050,7 +6170,7 @@ cmTarget::GetLinkImplementation(const std::string& config, // Compute the link implementation for this configuration. LinkImplementation impl; this->ComputeLinkImplementation(config, impl, head); - this->ComputeLinkImplementationLanguages(config, impl); + this->ComputeLinkImplementationLanguages(config, impl, head); // Store the information for this configuration. cmTargetInternals::LinkImplMapType::value_type entry(key, impl); @@ -6058,7 +6178,7 @@ cmTarget::GetLinkImplementation(const std::string& config, } else if (i->second.Languages.empty()) { - this->ComputeLinkImplementationLanguages(config, i->second); + this->ComputeLinkImplementationLanguages(config, i->second, head); } return &i->second; @@ -6172,12 +6292,13 @@ void cmTarget::ComputeLinkImplementation(const std::string& config, //---------------------------------------------------------------------------- void cmTarget::ComputeLinkImplementationLanguages(const std::string& config, - LinkImplementation& impl) const + LinkImplementation& impl, + cmTarget const* head) const { // This target needs runtime libraries for its source languages. std::set languages; // Get languages used in our source files. - this->GetLanguages(languages, config); + this->GetLanguages(languages, config, head); // Copy the set of langauges to the link implementation. for(std::set::iterator li = languages.begin(); li != languages.end(); ++li) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 042b441..15c49ea 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -136,9 +136,11 @@ public: * Get the list of the source files used by this target */ void GetSourceFiles(std::vector &files, - const std::string& config) const; + const std::string& config, + cmTarget const* head = 0) const; void GetSourceFiles(std::vector &files, - const std::string& config) const; + const std::string& config, + cmTarget const* head = 0) const; bool GetConfigCommonSourceFiles(std::vector& files) const; /** @@ -469,7 +471,8 @@ public: // information to forward these property changes to the targets // until we have per-target object file properties. void GetLanguages(std::set& languages, - const std::string& config) const; + std::string const& config, + cmTarget const* head = 0) const; /** Return whether this target is an executable with symbol exports enabled. */ @@ -743,7 +746,8 @@ private: LinkImplementation& impl, cmTarget const* head) const; void ComputeLinkImplementationLanguages(const std::string& config, - LinkImplementation& impl) const; + LinkImplementation& impl, + cmTarget const* head) const; void ComputeLinkClosure(const std::string& config, LinkClosure& lc, cmTarget const* head) const; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index e77133a..1c474ab 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -282,6 +282,7 @@ if(BUILD_TESTING) set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=Debug) ADD_TEST_MACRO(ConfigSources ConfigSources) endif() + ADD_TEST_MACRO(SourcesProperty SourcesProperty) set_tests_properties(EmptyLibrary PROPERTIES PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test") ADD_TEST_MACRO(CrossCompile CrossCompile) diff --git a/Tests/ConfigSources/CMakeLists.txt b/Tests/ConfigSources/CMakeLists.txt index 68a4233..c272257 100644 --- a/Tests/ConfigSources/CMakeLists.txt +++ b/Tests/ConfigSources/CMakeLists.txt @@ -3,7 +3,15 @@ cmake_minimum_required(VERSION 3.0) project(ConfigSources) +add_library(iface INTERFACE) +set_property(TARGET iface PROPERTY INTERFACE_SOURCES + iface_src.cpp + $<$:iface_debug_src.cpp> + $<$:does_not_exist.cpp> +) + add_executable(ConfigSources $<$:main.cpp> $<$:does_not_exist.cpp> ) +target_link_libraries(ConfigSources iface) diff --git a/Tests/ConfigSources/iface_debug.h b/Tests/ConfigSources/iface_debug.h new file mode 100644 index 0000000..a23d737 --- /dev/null +++ b/Tests/ConfigSources/iface_debug.h @@ -0,0 +1,4 @@ + +int iface_src(); + +int iface_debug(); diff --git a/Tests/ConfigSources/iface_debug_src.cpp b/Tests/ConfigSources/iface_debug_src.cpp new file mode 100644 index 0000000..63b22fc --- /dev/null +++ b/Tests/ConfigSources/iface_debug_src.cpp @@ -0,0 +1,7 @@ + +#include "iface_debug.h" + +int iface_debug() +{ + return 0; +} diff --git a/Tests/ConfigSources/iface_src.cpp b/Tests/ConfigSources/iface_src.cpp new file mode 100644 index 0000000..c3a0c8f --- /dev/null +++ b/Tests/ConfigSources/iface_src.cpp @@ -0,0 +1,5 @@ + +int iface_src() +{ + return 0; +} diff --git a/Tests/ConfigSources/main.cpp b/Tests/ConfigSources/main.cpp index 1c19e8d..71af72f 100644 --- a/Tests/ConfigSources/main.cpp +++ b/Tests/ConfigSources/main.cpp @@ -1,5 +1,7 @@ +#include "iface_debug.h" + int main(int argc, char** argv) { - return 0; + return iface_src() + iface_debug(); } diff --git a/Tests/SourcesProperty/CMakeLists.txt b/Tests/SourcesProperty/CMakeLists.txt new file mode 100644 index 0000000..0b3097e --- /dev/null +++ b/Tests/SourcesProperty/CMakeLists.txt @@ -0,0 +1,10 @@ + +cmake_minimum_required(VERSION 3.0) + +project(SourcesProperty) + +add_library(iface INTERFACE) +set_property(TARGET iface PROPERTY INTERFACE_SOURCES iface.cpp) + +add_executable(SourcesProperty main.cpp) +target_link_libraries(SourcesProperty iface) diff --git a/Tests/SourcesProperty/iface.cpp b/Tests/SourcesProperty/iface.cpp new file mode 100644 index 0000000..e38ac37 --- /dev/null +++ b/Tests/SourcesProperty/iface.cpp @@ -0,0 +1,5 @@ + +int iface() +{ + return 0; +} diff --git a/Tests/SourcesProperty/iface.h b/Tests/SourcesProperty/iface.h new file mode 100644 index 0000000..2cac248 --- /dev/null +++ b/Tests/SourcesProperty/iface.h @@ -0,0 +1,2 @@ + +int iface(); diff --git a/Tests/SourcesProperty/main.cpp b/Tests/SourcesProperty/main.cpp new file mode 100644 index 0000000..ae4f305 --- /dev/null +++ b/Tests/SourcesProperty/main.cpp @@ -0,0 +1,7 @@ + +#include "iface.h" + +int main(int argc, char** argv) +{ + return iface(); +} -- cgit v0.12 From 6e636f2ebaf78141f4d0a36c96804b9a1bc89857 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 27 Mar 2014 13:16:59 +0100 Subject: cmTarget: Make the SOURCES origin tracable. --- Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst | 3 +- Source/cmTarget.cxx | 39 ++++++++++++++++++++-- Source/cmTarget.h | 1 + .../RunCMake/TargetSources/OriginDebug-result.txt | 1 + .../RunCMake/TargetSources/OriginDebug-stderr.txt | 15 +++++++++ Tests/RunCMake/TargetSources/OriginDebug.cmake | 14 ++++++++ .../TargetSources/OriginDebugIDE-result.txt | 1 + .../TargetSources/OriginDebugIDE-stderr.txt | 22 ++++++++++++ Tests/RunCMake/TargetSources/OriginDebugIDE.cmake | 4 +++ Tests/RunCMake/TargetSources/RunCMakeTest.cmake | 3 ++ 10 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 Tests/RunCMake/TargetSources/OriginDebug-result.txt create mode 100644 Tests/RunCMake/TargetSources/OriginDebug-stderr.txt create mode 100644 Tests/RunCMake/TargetSources/OriginDebug.cmake create mode 100644 Tests/RunCMake/TargetSources/OriginDebugIDE-result.txt create mode 100644 Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt create mode 100644 Tests/RunCMake/TargetSources/OriginDebugIDE.cmake diff --git a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst index 11aed0c..edd8fa1 100644 --- a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst +++ b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst @@ -6,7 +6,8 @@ Enables tracing output for target properties. This variable can be populated with a list of properties to generate debug output for when evaluating target properties. Currently it can only be used when evaluating the :prop_tgt:`INCLUDE_DIRECTORIES`, -:prop_tgt:`COMPILE_DEFINITIONS`, :prop_tgt:`COMPILE_OPTIONS`, :prop_tgt:`AUTOUIC_OPTIONS`, +:prop_tgt:`COMPILE_DEFINITIONS`, :prop_tgt:`COMPILE_OPTIONS`, +:prop_tgt:`AUTOUIC_OPTIONS`, :prop_tgt:`SOURCES`, :prop_tgt:`POSITION_INDEPENDENT_CODE` target properties and any other property listed in :prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other ``COMPATIBLE_INTERFACE_`` properties. It outputs an origin for each entry in the target property. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0b5734d..10ecbfa 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -224,6 +224,7 @@ cmTarget::cmTarget() this->DebugIncludesDone = false; this->DebugCompileOptionsDone = false; this->DebugCompileDefinitionsDone = false; + this->DebugSourcesDone = false; } //---------------------------------------------------------------------------- @@ -553,7 +554,7 @@ static void processSources(cmTarget const* tgt, std::set &uniqueSrcs, cmGeneratorExpressionDAGChecker *dagChecker, cmTarget const* head, - std::string const& config) + std::string const& config, bool debugSources) { cmMakefile *mf = tgt->GetMakefile(); @@ -601,6 +602,7 @@ static void processSources(cmTarget const* tgt, (*it)->CachedEntries = entrySources; } } + std::string usedSources; for(std::vector::iterator li = entrySources.begin(); li != entrySources.end(); ++li) { @@ -609,8 +611,19 @@ static void processSources(cmTarget const* tgt, if(uniqueSrcs.insert(src).second) { srcs.push_back(src); + if (debugSources) + { + usedSources += " * " + src + "\n"; + } } } + if (!usedSources.empty()) + { + mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + std::string("Used sources for target ") + + tgt->GetName() + ":\n" + + usedSources, (*it)->ge->GetBacktrace()); + } } } @@ -621,6 +634,24 @@ void cmTarget::GetSourceFiles(std::vector &files, { assert(this->GetType() != INTERFACE_LIBRARY); + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugSources = !this->DebugSourcesDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "SOURCES") + != debugProperties.end(); + + if (this->Makefile->IsGeneratingBuildSystem()) + { + this->DebugSourcesDone = true; + } cmListFileBacktrace lfbt; @@ -635,7 +666,8 @@ void cmTarget::GetSourceFiles(std::vector &files, uniqueSrcs, &dagChecker, head, - config); + config, + debugSources); if (!this->Internal->CacheLinkInterfaceSourcesDone[config]) { @@ -686,7 +718,8 @@ void cmTarget::GetSourceFiles(std::vector &files, uniqueSrcs, &dagChecker, head, - config); + config, + debugSources); if (!this->Makefile->IsGeneratingBuildSystem()) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 15c49ea..055e029 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -710,6 +710,7 @@ private: mutable std::map DebugCompatiblePropertiesDone; mutable bool DebugCompileOptionsDone; mutable bool DebugCompileDefinitionsDone; + mutable bool DebugSourcesDone; mutable std::set LinkImplicitNullProperties; bool BuildInterfaceIncludesAppended; diff --git a/Tests/RunCMake/TargetSources/OriginDebug-result.txt b/Tests/RunCMake/TargetSources/OriginDebug-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/TargetSources/OriginDebug-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt b/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt new file mode 100644 index 0000000..dad9fee --- /dev/null +++ b/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt @@ -0,0 +1,15 @@ +CMake Debug Log at OriginDebug.cmake:13 \(add_library\): + Used sources for target OriginDebug: + + \* .*Tests/RunCMake/TargetSources/empty_2.cpp + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Debug Log at OriginDebug.cmake:14 \(target_link_libraries\): + Used sources for target OriginDebug: + + \* .*Tests/RunCMake/TargetSources/empty_1.cpp + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/TargetSources/OriginDebug.cmake b/Tests/RunCMake/TargetSources/OriginDebug.cmake new file mode 100644 index 0000000..911a7d4 --- /dev/null +++ b/Tests/RunCMake/TargetSources/OriginDebug.cmake @@ -0,0 +1,14 @@ + +cmake_minimum_required(VERSION 3.0) + +project(OriginDebug) + +set(CMAKE_DEBUG_TARGET_PROPERTIES SOURCES) + +add_library(iface INTERFACE) +set_property(TARGET iface PROPERTY INTERFACE_SOURCES + empty_1.cpp +) + +add_library(OriginDebug empty_2.cpp) +target_link_libraries(OriginDebug iface) diff --git a/Tests/RunCMake/TargetSources/OriginDebugIDE-result.txt b/Tests/RunCMake/TargetSources/OriginDebugIDE-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/TargetSources/OriginDebugIDE-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt b/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt new file mode 100644 index 0000000..9797870 --- /dev/null +++ b/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt @@ -0,0 +1,22 @@ +CMake Debug Log at OriginDebug.cmake:13 \(add_library\): + Used sources for target OriginDebug: + + \* .*Tests/RunCMake/TargetSources/empty_2.cpp + +Call Stack \(most recent call first\): + OriginDebugIDE.cmake:4 \(include\) + CMakeLists.txt:3 \(include\) ++ +CMake Debug Log: + Used sources for target OriginDebug: + + * .*CMakeLists.txt ++ +CMake Debug Log at OriginDebug.cmake:14 \(target_link_libraries\): + Used sources for target OriginDebug: + + \* .*Tests/RunCMake/TargetSources/empty_1.cpp + +Call Stack \(most recent call first\): + OriginDebugIDE.cmake:4 \(include\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/TargetSources/OriginDebugIDE.cmake b/Tests/RunCMake/TargetSources/OriginDebugIDE.cmake new file mode 100644 index 0000000..a3cc3a8 --- /dev/null +++ b/Tests/RunCMake/TargetSources/OriginDebugIDE.cmake @@ -0,0 +1,4 @@ + +# Separate test for the IDEs, because they show the CMakeLists.txt file +# as a source file. +include(${CMAKE_CURRENT_LIST_DIR}/OriginDebug.cmake) diff --git a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake index 1a3a7fa..b9095f9 100644 --- a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake @@ -3,4 +3,7 @@ include(RunCMake) if(RunCMake_GENERATOR MATCHES Xcode OR RunCMake_GENERATOR MATCHES "Visual Studio") run_cmake(ConfigNotAllowed) + run_cmake(OriginDebugIDE) +else() + run_cmake(OriginDebug) endif() -- cgit v0.12 From 81ad69e056d6c6dd2360e3345f6d99f268ee9e54 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 8 Jul 2013 20:18:42 +0200 Subject: Make the SOURCES target property writable. --- Help/prop_tgt/SOURCES.rst | 3 +- Help/release/dev/target-SOURCES-write.rst | 6 ++++ Source/cmTarget.cxx | 38 ++++++++++++++++++++++ .../RunCMake/TargetSources/OriginDebug-stderr.txt | 8 +++++ Tests/RunCMake/TargetSources/OriginDebug.cmake | 4 +++ .../TargetSources/OriginDebugIDE-stderr.txt | 9 +++++ Tests/RunCMake/TargetSources/empty_3.cpp | 7 ++++ Tests/SourcesProperty/CMakeLists.txt | 2 ++ Tests/SourcesProperty/iface.h | 2 ++ Tests/SourcesProperty/main.cpp | 2 +- Tests/SourcesProperty/prop.cpp | 5 +++ 11 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 Help/release/dev/target-SOURCES-write.rst create mode 100644 Tests/RunCMake/TargetSources/empty_3.cpp create mode 100644 Tests/SourcesProperty/prop.cpp diff --git a/Help/prop_tgt/SOURCES.rst b/Help/prop_tgt/SOURCES.rst index 833b65a..493643e 100644 --- a/Help/prop_tgt/SOURCES.rst +++ b/Help/prop_tgt/SOURCES.rst @@ -3,5 +3,4 @@ SOURCES Source names specified for a target. -Read-only list of sources specified for a target. The names returned -are suitable for passing to the set_source_files_properties command. +List of sources specified for a target. diff --git a/Help/release/dev/target-SOURCES-write.rst b/Help/release/dev/target-SOURCES-write.rst new file mode 100644 index 0000000..a754a73 --- /dev/null +++ b/Help/release/dev/target-SOURCES-write.rst @@ -0,0 +1,6 @@ +target-SOURCES-write.rst +------------------------ + +* It is now possible to write and append to the :prop_tgt:`SOURCES` target + property. The :variable:`CMAKE_DEBUG_TARGET_PROPERTIES` variable may be + used to trace the origin of sources. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 10ecbfa..475bcdb 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1697,6 +1697,25 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) this->Internal->LinkImplementationPropertyEntries.push_back(entry); return; } + if (prop == "SOURCES") + { + if(this->IsImported()) + { + cmOStringStream e; + e << "SOURCES property can't be set on imported targets (\"" + << this->Name << "\")\n"; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + this->Internal->SourceEntries.clear(); + cmsys::auto_ptr cge = ge.Parse(value); + this->Internal->SourceEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); + return; + } this->Properties.SetProperty(prop, value, cmProperty::TARGET); this->MaybeInvalidatePropertyCache(prop); } @@ -1764,6 +1783,25 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, this->Internal->LinkImplementationPropertyEntries.push_back(entry); return; } + if (prop == "SOURCES") + { + if(this->IsImported()) + { + cmOStringStream e; + e << "SOURCES property can't be set on imported targets (\"" + << this->Name << "\")\n"; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr cge = ge.Parse(value); + this->Internal->SourceEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); + return; + } this->Properties.AppendProperty(prop, value, cmProperty::TARGET, asString); this->MaybeInvalidatePropertyCache(prop); } diff --git a/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt b/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt index dad9fee..6b7453f 100644 --- a/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt +++ b/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt @@ -6,6 +6,14 @@ CMake Debug Log at OriginDebug.cmake:13 \(add_library\): Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + +CMake Debug Log at OriginDebug.cmake:16 \(set_property\): + Used sources for target OriginDebug: + + \* .*Tests/RunCMake/TargetSources/empty_3.cpp + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ CMake Debug Log at OriginDebug.cmake:14 \(target_link_libraries\): Used sources for target OriginDebug: diff --git a/Tests/RunCMake/TargetSources/OriginDebug.cmake b/Tests/RunCMake/TargetSources/OriginDebug.cmake index 911a7d4..3fa5858 100644 --- a/Tests/RunCMake/TargetSources/OriginDebug.cmake +++ b/Tests/RunCMake/TargetSources/OriginDebug.cmake @@ -12,3 +12,7 @@ set_property(TARGET iface PROPERTY INTERFACE_SOURCES add_library(OriginDebug empty_2.cpp) target_link_libraries(OriginDebug iface) + +set_property(TARGET OriginDebug APPEND PROPERTY SOURCES + empty_3.cpp +) diff --git a/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt b/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt index 9797870..683c2e9 100644 --- a/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt +++ b/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt @@ -7,6 +7,15 @@ Call Stack \(most recent call first\): OriginDebugIDE.cmake:4 \(include\) CMakeLists.txt:3 \(include\) + +CMake Debug Log at OriginDebug.cmake:16 \(set_property\): + Used sources for target OriginDebug: + + \* .*Tests/RunCMake/TargetSources/empty_3.cpp + +Call Stack \(most recent call first\): + OriginDebugIDE.cmake:4 \(include\) + CMakeLists.txt:3 \(include\) ++ CMake Debug Log: Used sources for target OriginDebug: diff --git a/Tests/RunCMake/TargetSources/empty_3.cpp b/Tests/RunCMake/TargetSources/empty_3.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/TargetSources/empty_3.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/SourcesProperty/CMakeLists.txt b/Tests/SourcesProperty/CMakeLists.txt index 0b3097e..6c99e00 100644 --- a/Tests/SourcesProperty/CMakeLists.txt +++ b/Tests/SourcesProperty/CMakeLists.txt @@ -8,3 +8,5 @@ set_property(TARGET iface PROPERTY INTERFACE_SOURCES iface.cpp) add_executable(SourcesProperty main.cpp) target_link_libraries(SourcesProperty iface) + +set_property(TARGET SourcesProperty APPEND PROPERTY SOURCES prop.cpp) diff --git a/Tests/SourcesProperty/iface.h b/Tests/SourcesProperty/iface.h index 2cac248..6da80a4 100644 --- a/Tests/SourcesProperty/iface.h +++ b/Tests/SourcesProperty/iface.h @@ -1,2 +1,4 @@ int iface(); + +int prop(); diff --git a/Tests/SourcesProperty/main.cpp b/Tests/SourcesProperty/main.cpp index ae4f305..33a97f4 100644 --- a/Tests/SourcesProperty/main.cpp +++ b/Tests/SourcesProperty/main.cpp @@ -3,5 +3,5 @@ int main(int argc, char** argv) { - return iface(); + return iface() + prop(); } diff --git a/Tests/SourcesProperty/prop.cpp b/Tests/SourcesProperty/prop.cpp new file mode 100644 index 0000000..e343431 --- /dev/null +++ b/Tests/SourcesProperty/prop.cpp @@ -0,0 +1,5 @@ + +int prop() +{ + return 0; +} -- cgit v0.12 From 9407174b1a0f1b4f8edf7fe08cc85ab6e990d59f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 8 Jul 2013 20:18:42 +0200 Subject: target_sources: New command to add sources to target. --- Help/command/target_sources.rst | 28 ++++++++++ Help/manual/cmake-commands.7.rst | 1 + Help/release/dev/target_sources-command.rst | 5 ++ Source/CMakeLists.txt | 1 + Source/cmTargetSourcesCommand.cxx | 64 ++++++++++++++++++++++ Source/cmTargetSourcesCommand.h | 55 +++++++++++++++++++ .../RunCMake/TargetSources/OriginDebug-stderr.txt | 8 +++ Tests/RunCMake/TargetSources/OriginDebug.cmake | 2 + .../TargetSources/OriginDebugIDE-stderr.txt | 9 +++ Tests/RunCMake/TargetSources/empty_4.cpp | 7 +++ 10 files changed, 180 insertions(+) create mode 100644 Help/command/target_sources.rst create mode 100644 Help/release/dev/target_sources-command.rst create mode 100644 Source/cmTargetSourcesCommand.cxx create mode 100644 Source/cmTargetSourcesCommand.h create mode 100644 Tests/RunCMake/TargetSources/empty_4.cpp diff --git a/Help/command/target_sources.rst b/Help/command/target_sources.rst new file mode 100644 index 0000000..ff756b4 --- /dev/null +++ b/Help/command/target_sources.rst @@ -0,0 +1,28 @@ +target_sources +-------------- + +Add sources to a target. + +:: + + target_sources( + [items1...] + [ [items2...] ...]) + +Specify sources to use when compiling a given target. The +named ```` must have been created by a command such as +:command:`add_executable` or :command:`add_library` and must not be an +:prop_tgt:`IMPORTED Target`. + +The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to +specify the scope of the following arguments. ``PRIVATE`` and ``PUBLIC`` +items will populate the :prop_tgt:`SOURCES` property of +````. ``PUBLIC`` and ``INTERFACE`` items will populate the +:prop_tgt:`INTERFACE_SOURCES` property of ````. The +following arguments specify sources. Repeated calls for the same +```` append items in the order called. + +Arguments to ``target_sources`` may use "generator expressions" +with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` +manual for available expressions. See the :manual:`cmake-buildsystem(7)` +manual for more on defining buildsystem properties. diff --git a/Help/manual/cmake-commands.7.rst b/Help/manual/cmake-commands.7.rst index fb0d2b5..4b1dbed 100644 --- a/Help/manual/cmake-commands.7.rst +++ b/Help/manual/cmake-commands.7.rst @@ -94,6 +94,7 @@ These commands may be used freely in CMake projects. /command/target_compile_options /command/target_include_directories /command/target_link_libraries + /command/target_sources /command/try_compile /command/try_run /command/unset diff --git a/Help/release/dev/target_sources-command.rst b/Help/release/dev/target_sources-command.rst new file mode 100644 index 0000000..abfb303 --- /dev/null +++ b/Help/release/dev/target_sources-command.rst @@ -0,0 +1,5 @@ +target_sources-command +---------------------- + +* The :command:`target_sources` command was added to add to the + :prop_tgt:`SOURCES` target property. diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 27d099d..4c678d8 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -348,6 +348,7 @@ foreach(command_file cmTargetCompileDefinitionsCommand cmTargetCompileOptionsCommand cmTargetIncludeDirectoriesCommand + cmTargetSourcesCommand cmUseMangledMesaCommand cmUtilitySourceCommand cmVariableRequiresCommand diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx new file mode 100644 index 0000000..e82b36d --- /dev/null +++ b/Source/cmTargetSourcesCommand.cxx @@ -0,0 +1,64 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Stephen Kelly + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmTargetSourcesCommand.h" + +#include "cmGeneratorExpression.h" + +//---------------------------------------------------------------------------- +bool cmTargetSourcesCommand +::InitialPass(std::vector const& args, cmExecutionStatus &) +{ + return this->HandleArguments(args, "SOURCES"); +} + +//---------------------------------------------------------------------------- +void cmTargetSourcesCommand +::HandleImportedTarget(const std::string &tgt) +{ + cmOStringStream e; + e << "Cannot specify sources for imported target \"" + << tgt << "\"."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); +} + +//---------------------------------------------------------------------------- +void cmTargetSourcesCommand +::HandleMissingTarget(const std::string &name) +{ + cmOStringStream e; + e << "Cannot specify sources for target \"" << name << "\" " + "which is not built by this project."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); +} + +//---------------------------------------------------------------------------- +std::string cmTargetSourcesCommand +::Join(const std::vector &content) +{ + std::string srcs; + std::string sep; + for(std::vector::const_iterator it = content.begin(); + it != content.end(); ++it) + { + srcs += sep + *it; + sep = ";"; + } + return srcs; +} + +//---------------------------------------------------------------------------- +void cmTargetSourcesCommand +::HandleDirectContent(cmTarget *tgt, const std::vector &content, + bool, bool) +{ + tgt->AppendProperty("SOURCES", this->Join(content).c_str()); +} diff --git a/Source/cmTargetSourcesCommand.h b/Source/cmTargetSourcesCommand.h new file mode 100644 index 0000000..dae78c4 --- /dev/null +++ b/Source/cmTargetSourcesCommand.h @@ -0,0 +1,55 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 Stephen Kelly + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmTargetSourcesCommand_h +#define cmTargetSourcesCommand_h + +#include "cmTargetPropCommandBase.h" + +//---------------------------------------------------------------------------- +class cmTargetSourcesCommand : public cmTargetPropCommandBase +{ +public: + /** + * This is a virtual constructor for the command. + */ + virtual cmCommand* Clone() + { + return new cmTargetSourcesCommand; + } + + /** + * This is called when the command is first encountered in + * the CMakeLists.txt file. + */ + virtual bool InitialPass(std::vector const& args, + cmExecutionStatus &status); + + /** + * The name of the command as specified in CMakeList.txt. + */ + virtual std::string GetName() const { return "target_sources";} + + cmTypeMacro(cmTargetSourcesCommand, cmTargetPropCommandBase); + +private: + virtual void HandleImportedTarget(const std::string &tgt); + virtual void HandleMissingTarget(const std::string &name); + + virtual void HandleDirectContent(cmTarget *tgt, + const std::vector &content, + bool prepend, bool system); + + virtual std::string Join(const std::vector &content); +}; + +#endif diff --git a/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt b/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt index 6b7453f..0200dcb 100644 --- a/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt +++ b/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt @@ -14,6 +14,14 @@ CMake Debug Log at OriginDebug.cmake:16 \(set_property\): Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + +CMake Debug Log at OriginDebug.cmake:20 \(target_sources\): + Used sources for target OriginDebug: + + \* .*Tests/RunCMake/TargetSources/empty_4.cpp + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ CMake Debug Log at OriginDebug.cmake:14 \(target_link_libraries\): Used sources for target OriginDebug: diff --git a/Tests/RunCMake/TargetSources/OriginDebug.cmake b/Tests/RunCMake/TargetSources/OriginDebug.cmake index 3fa5858..5fe9ba7 100644 --- a/Tests/RunCMake/TargetSources/OriginDebug.cmake +++ b/Tests/RunCMake/TargetSources/OriginDebug.cmake @@ -16,3 +16,5 @@ target_link_libraries(OriginDebug iface) set_property(TARGET OriginDebug APPEND PROPERTY SOURCES empty_3.cpp ) + +target_sources(OriginDebug PRIVATE empty_4.cpp) diff --git a/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt b/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt index 683c2e9..fad7073 100644 --- a/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt +++ b/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt @@ -16,6 +16,15 @@ Call Stack \(most recent call first\): OriginDebugIDE.cmake:4 \(include\) CMakeLists.txt:3 \(include\) + +CMake Debug Log at OriginDebug.cmake:20 \(target_sources\): + Used sources for target OriginDebug: + + \* .*Tests/RunCMake/TargetSources/empty_4.cpp + +Call Stack \(most recent call first\): + OriginDebugIDE.cmake:4 \(include\) + CMakeLists.txt:3 \(include\) ++ CMake Debug Log: Used sources for target OriginDebug: diff --git a/Tests/RunCMake/TargetSources/empty_4.cpp b/Tests/RunCMake/TargetSources/empty_4.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/TargetSources/empty_4.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} -- cgit v0.12 From 9f69a34f9990faefc28ac095fd874404cf07963b Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 3 Apr 2014 00:01:06 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index aec1b18..7b9db16 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 0) -set(CMake_VERSION_PATCH 20140402) +set(CMake_VERSION_PATCH 20140403) #set(CMake_VERSION_RC 1) -- cgit v0.12 From eccc425af6ffeb52963cc2dd94a36a24c271108b Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 2 Apr 2014 09:08:42 -0400 Subject: KWSys 2014-04-02 (39f98b5d) Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ 39f98b5d | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' a8aa1014..39f98b5d Brad King (1): 39f98b5d Encoding: Add self-assignment check to CommandLineArguments Jiri Malak (1): 36982798 SystemTools: add Watcom single Quote processing Change-Id: Ib8e67dc0c29ee62e6489c068987e4206fa4adaf3 --- EncodingCXX.cxx | 19 +++++++++++-------- System.c | 30 ++++++++++++++++++++++++++++-- System.h.in | 9 +++++++-- 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/EncodingCXX.cxx b/EncodingCXX.cxx index f76deb5..251a56d 100644 --- a/EncodingCXX.cxx +++ b/EncodingCXX.cxx @@ -110,16 +110,19 @@ Encoding::CommandLineArguments:: Encoding::CommandLineArguments& Encoding::CommandLineArguments::operator=(const CommandLineArguments& other) { - size_t i; - for(i=0; iargv_.size(); i++) + if(this != &other) { - free(this->argv_[i]); - } + size_t i; + for(i=0; iargv_.size(); i++) + { + free(this->argv_[i]); + } - this->argv_.resize(other.argv_.size()); - for(i=0; iargv_.size(); i++) - { - this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0; + this->argv_.resize(other.argv_.size()); + for(i=0; iargv_.size(); i++) + { + this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0; + } } return *this; diff --git a/System.c b/System.c index 5d178bf..1ee26fa 100644 --- a/System.c +++ b/System.c @@ -353,6 +353,10 @@ static int kwsysSystem_Shell__GetArgumentSize(const char* in, if(kwsysSystem_Shell__ArgumentNeedsQuotes(in, isUnix, flags)) { /* Surrounding quotes are needed. Allocate space for them. */ + if((flags & kwsysSystem_Shell_Flag_WatcomQuote) && (isUnix)) + { + size += 2; + } size += 2; /* We must escape all ending backslashes when quoting on windows. */ @@ -377,7 +381,18 @@ static char* kwsysSystem_Shell__GetArgument(const char* in, char* out, if(needQuotes) { /* Add the opening quote for this argument. */ - *out++ = '"'; + if(flags & kwsysSystem_Shell_Flag_WatcomQuote) + { + if(isUnix) + { + *out++ = '"'; + } + *out++ = '\''; + } + else + { + *out++ = '"'; + } } /* Scan the string for characters that require escaping or quoting. */ @@ -549,7 +564,18 @@ static char* kwsysSystem_Shell__GetArgument(const char* in, char* out, } /* Add the closing quote for this argument. */ - *out++ = '"'; + if(flags & kwsysSystem_Shell_Flag_WatcomQuote) + { + *out++ = '\''; + if(isUnix) + { + *out++ = '"'; + } + } + else + { + *out++ = '"'; + } } /* Store a terminating null without incrementing. */ diff --git a/System.h.in b/System.h.in index 549db90..f21bf0d 100644 --- a/System.h.in +++ b/System.h.in @@ -36,6 +36,7 @@ # define kwsysSystem_Shell_Flag_MinGWMake kwsys_ns(System_Shell_Flag_MinGWMake) # define kwsysSystem_Shell_Flag_NMake kwsys_ns(System_Shell_Flag_NMake) # define kwsysSystem_Shell_Flag_AllowMakeVariables kwsys_ns(System_Shell_Flag_AllowMakeVariables) +# define kwsysSystem_Shell_Flag_WatcomQuote kwsys_ns(System_Shell_Flag_WatcomQuote) #endif #ifdef __VMS @@ -102,14 +103,17 @@ enum kwsysSystem_Shell_Flag_e kwsysSystem_Shell_Flag_MinGWMake = (1<<4), /** The target shell is in a NMake makefile. */ - kwsysSystem_Shell_Flag_NMake = (1<<6), + kwsysSystem_Shell_Flag_NMake = (1<<5), /** Make variable reference syntax $(MAKEVAR) should not be escaped to allow a build tool to replace it. Replacement values containing spaces, quotes, backslashes, or other non-alphanumeric characters that have significance to some makes or shells produce undefined behavior. */ - kwsysSystem_Shell_Flag_AllowMakeVariables = (1<<5) + kwsysSystem_Shell_Flag_AllowMakeVariables = (1<<6), + + /** The target shell quoting uses extra single Quotes for Watcom tools. */ + kwsysSystem_Shell_Flag_WatcomQuote = (1<<7) }; /** @@ -156,6 +160,7 @@ kwsysEXPORT char** kwsysSystem_Parse_CommandForUnix(const char* command, # undef kwsysSystem_Shell_Flag_MinGWMake # undef kwsysSystem_Shell_Flag_NMake # undef kwsysSystem_Shell_Flag_AllowMakeVariables +# undef kwsysSystem_Shell_Flag_WatcomQuote # endif #endif -- cgit v0.12 From f4fe632297c4ffb825eae15e2e627178f2f53431 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Apr 2014 13:14:29 -0400 Subject: Help: Add notes for topic 'ExternalProject_exclude-from-all' --- Help/release/dev/ExternalProject_exclude-from-all.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Help/release/dev/ExternalProject_exclude-from-all.rst diff --git a/Help/release/dev/ExternalProject_exclude-from-all.rst b/Help/release/dev/ExternalProject_exclude-from-all.rst new file mode 100644 index 0000000..1d62b3a --- /dev/null +++ b/Help/release/dev/ExternalProject_exclude-from-all.rst @@ -0,0 +1,11 @@ +ExternalProject_exclude-from-all +-------------------------------- + +* The :module:`ExternalProject` module ``ExternalProject_Add`` command + learned a new ``EXCLUDE_FROM_ALL`` option to cause the external + project target to have the :prop_tgt:`EXCLUDE_FROM_ALL` target + property set. + +* The :module:`ExternalProject` module ``ExternalProject_Add_Step`` command + learned a new ``EXCLUDE_FROM_MAIN`` option to cause the step to not be + a direct dependency of the main external project target. -- cgit v0.12 From c4059a21a9935f376d243f3526f8635800146e77 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Apr 2014 14:04:46 -0400 Subject: cmTarget: Remove abort() after INTERNAL_ERROR reports After reporting an internal error we should continue rather than aborting. Remove such statements that are left from debugging. --- Source/cmTarget.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a87ec31..b6bb2d3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2684,7 +2684,6 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo( msg += " which has type "; msg += cmTarget::GetTargetTypeName(this->GetType()); this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - abort(); return 0; } @@ -2729,7 +2728,6 @@ cmTarget::CompileInfo const* cmTarget::GetCompileInfo( msg += " which has type "; msg += cmTarget::GetTargetTypeName(this->GetType()); this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - abort(); return 0; } -- cgit v0.12 From 64713ae3ffddf6fbbfa7ea762c3d756cb245a066 Mon Sep 17 00:00:00 2001 From: LibArchive Upstream Date: Mon, 17 Mar 2014 20:43:07 -0700 Subject: libarchive 3.1.2-218-g00f4bd83 (reduced) Extract upstream libarchive using the following shell code. url=git://github.com/libarchive/libarchive.git && v=3.1.2-218-g00f4bd83 && r=00f4bd83 && paths=" CMakeLists.txt COPYING CTestConfig.cmake build/cmake build/pkgconfig build/utils build/version libarchive/*.* " && mkdir libarchive-$v-g$r-reduced && git clone $url libarchive-git && date=$(cd libarchive-git && git log -n 1 --format='%cd' $r) && (cd libarchive-git && git archive --format=tar $r -- $paths) | (cd libarchive-$v-g$r-reduced && tar xv) && fromdos libarchive-$v-g$r-reduced/build/cmake/Find*.cmake && echo "g$r date: $date" --- CMakeLists.txt | 122 +- build/cmake/CreatePkgConfigFile.cmake | 31 + build/cmake/LibarchiveCheckCSourceCompiles.cmake | 106 - build/cmake/LibarchiveCheckCSourceRuns.cmake | 102 - build/cmake/LibarchiveCodeCoverage.cmake | 68 + build/cmake/config.h.in | 5 + libarchive/CMakeLists.txt | 3 + libarchive/archive.h | 74 +- libarchive/archive_endian.h | 36 +- libarchive/archive_entry.c | 41 + libarchive/archive_entry.h | 13 +- libarchive/archive_entry_private.h | 5 + libarchive/archive_entry_sparse.c | 2 +- libarchive/archive_getdate.c | 9 +- libarchive/archive_match.c | 2 +- libarchive/archive_pack_dev.c | 329 +++ libarchive/archive_pack_dev.h | 50 + libarchive/archive_platform.h | 7 +- libarchive/archive_read.c | 66 +- libarchive/archive_read_disk_entry_from_file.c | 22 +- libarchive/archive_read_disk_posix.c | 2 +- libarchive/archive_read_disk_windows.c | 8 +- libarchive/archive_read_open_filename.c | 4 +- libarchive/archive_read_private.h | 22 +- libarchive/archive_read_set_options.3 | 22 + libarchive/archive_read_set_options.c | 32 +- libarchive/archive_read_support_filter_lzop.c | 9 +- libarchive/archive_read_support_filter_xz.c | 2 +- libarchive/archive_read_support_format_7zip.c | 162 +- libarchive/archive_read_support_format_ar.c | 4 +- libarchive/archive_read_support_format_cab.c | 4 +- libarchive/archive_read_support_format_cpio.c | 4 +- libarchive/archive_read_support_format_empty.c | 2 + libarchive/archive_read_support_format_iso9660.c | 4 +- libarchive/archive_read_support_format_lha.c | 4 +- libarchive/archive_read_support_format_mtree.c | 416 +-- libarchive/archive_read_support_format_rar.c | 79 +- libarchive/archive_read_support_format_raw.c | 4 +- libarchive/archive_read_support_format_tar.c | 176 +- libarchive/archive_read_support_format_xar.c | 16 +- libarchive/archive_read_support_format_zip.c | 3013 ++++++++++++---------- libarchive/archive_util.c | 109 + libarchive/archive_virtual.c | 16 +- libarchive/archive_windows.c | 10 +- libarchive/archive_windows.h | 12 +- libarchive/archive_write.c | 16 +- libarchive/archive_write_add_filter_lrzip.c | 7 +- libarchive/archive_write_disk_acl.c | 16 +- libarchive/archive_write_disk_windows.c | 2 +- libarchive/archive_write_format.3 | 5 +- libarchive/archive_write_set_format.c | 3 +- libarchive/archive_write_set_format_by_name.c | 1 + libarchive/archive_write_set_format_mtree.c | 37 +- libarchive/archive_write_set_format_raw.c | 125 + libarchive/archive_write_set_format_shar.c | 1 + libarchive/archive_write_set_format_zip.c | 1082 ++++---- libarchive/filter_fork_windows.c | 2 +- libarchive/mtree.5 | 78 +- 58 files changed, 4269 insertions(+), 2335 deletions(-) create mode 100644 build/cmake/CreatePkgConfigFile.cmake delete mode 100644 build/cmake/LibarchiveCheckCSourceCompiles.cmake delete mode 100644 build/cmake/LibarchiveCheckCSourceRuns.cmake create mode 100644 build/cmake/LibarchiveCodeCoverage.cmake create mode 100644 libarchive/archive_pack_dev.c create mode 100644 libarchive/archive_pack_dev.h create mode 100644 libarchive/archive_write_set_format_raw.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cdb9fb..2069c23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ SET(LIBARCHIVE_VERSION_NUMBER "${_version_number}") SET(LIBARCHIVE_VERSION_STRING "${VERSION}") # INTERFACE_VERSION increments with every release -# libarchive 2.7 == interface version 9 = 2 + 7 +# libarchive 2.7 == interface version 9 = 2 + 7 # libarchive 2.8 == interface version 10 = 2 + 8 # libarchive 2.9 == interface version 11 = 2 + 9 # libarchive 3.0 == interface version 12 @@ -97,6 +97,20 @@ IF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wmissing-prototypes") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wcast-qual") ENDIF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$") +IF ("CMAKE_C_COMPILER_ID" MATCHES "^Clang$") + SET(CMAKE_REQUIRED_FLAGS "-Wall -Wformat -Wformat-security") + ################################################################# + # Set compile flags for all build types. + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wformat -Wformat-security") + ################################################################# + # Set compile flags for debug build. + # This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug" + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Werror -Wextra -Wunused") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wshadow") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wmissing-prototypes") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wcast-qual") +ENDIF ("CMAKE_C_COMPILER_ID" MATCHES "^Clang$") IF (MSVC) ################################################################# # Set compile flags for debug build. @@ -143,6 +157,13 @@ include(CTest) OPTION(ENABLE_NETTLE "Enable use of Nettle" ON) OPTION(ENABLE_OPENSSL "Enable use of OpenSSL" ON) +OPTION(ENABLE_LZMA "Enable the use of the system found LZMA library if found" ON) +OPTION(ENABLE_ZLIB "Enable the use of the system found ZLIB library if found" ON) +OPTION(ENABLE_BZip2 "Enable the use of the system found BZip2 library if found" ON) +OPTION(ENABLE_EXPAT "Enable the use of the system found EXPAT library if found" ON) +OPTION(ENABLE_PCREPOSIX "Enable the use of the system found PCREPOSIX library if found" ON) +OPTION(ENABLE_LibGCC "Enable the use of the system found LibGCC library if found" ON) + OPTION(ENABLE_TAR "Enable tar building" ON) OPTION(ENABLE_TAR_SHARED "Enable dynamic build of tar" FALSE) OPTION(ENABLE_CPIO "Enable cpio building" ON) @@ -151,10 +172,16 @@ OPTION(ENABLE_XATTR "Enable extended attribute support" ON) OPTION(ENABLE_ACL "Enable ACL support" ON) OPTION(ENABLE_ICONV "Enable iconv support" ON) OPTION(ENABLE_TEST "Enable unit and regression tests" ON) +OPTION(ENABLE_COVERAGE "Enable code coverage (GCC only, automatically sets ENABLE_TEST to ON)" FALSE) + SET(POSIX_REGEX_LIB "AUTO" CACHE STRING "Choose what library should provide POSIX regular expression support") SET(ENABLE_SAFESEH "AUTO" CACHE STRING "Enable use of /SAFESEH linker flag (MSVC only)") SET(WINDOWS_VERSION "" CACHE STRING "Set Windows version to use (Windows only)") +IF(ENABLE_COVERAGE) + include(LibarchiveCodeCoverage) +ENDIF(ENABLE_COVERAGE) + IF(ENABLE_TEST) ENABLE_TESTING() ENDIF(ENABLE_TEST) @@ -184,12 +211,12 @@ IF(MSVC) SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH") SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH") - SET(CMAKE_REQUIRED_LINKER_FLAGS "/SAFESEH") + SET(ENV{LDFLAGS} "$ENV{LDFLAGS} /SAFESEH") ELSEIF(ENABLE_SAFESEH STREQUAL "NO") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO") SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO") - SET(CMAKE_REQUIRED_LINKER_FLAGS "/SAFESEH:NO") + SET(ENV{LDFLAGS} "$ENV{LDFLAGS} /SAFESEH:NO") ENDIF(ENABLE_SAFESEH STREQUAL "YES") ENDIF(MSVC) @@ -198,8 +225,8 @@ IF("${CMAKE_C_PLATFORM_ID}" MATCHES "^(HP-UX)$") ENDIF() # -INCLUDE(LibarchiveCheckCSourceCompiles) -INCLUDE(LibarchiveCheckCSourceRuns) +INCLUDE(CheckCSourceCompiles) +INCLUDE(CheckCSourceRuns) INCLUDE(CheckFileOffsetBits) INCLUDE(CheckFuncs) INCLUDE(CheckHeaderDirent) @@ -263,9 +290,9 @@ MACRO (TRY_MACRO_FOR_LIBRARY INCLUDES LIBRARIES ENDIF(NOT "${PREV_VAR_WITH_LIB}" STREQUAL "${LIBRARIES}") # Check if the library can be used with the macro. IF("${TRY_TYPE}" MATCHES "COMPILES") - LIBARCHIVE_CHECK_C_SOURCE_COMPILES("${SAMPLE_SOURCE}" ${VAR}) + CHECK_C_SOURCE_COMPILES("${SAMPLE_SOURCE}" ${VAR}) ELSEIF("${TRY_TYPE}" MATCHES "RUNS") - LIBARCHIVE_CHECK_C_SOURCE_RUNS("${SAMPLE_SOURCE}" ${VAR}) + CHECK_C_SOURCE_RUNS("${SAMPLE_SOURCE}" ${VAR}) ELSE("${TRY_TYPE}" MATCHES "COMPILES") MESSAGE(FATAL_ERROR "UNKNOWN KEYWORD \"${TRY_TYPE}\" FOR TRY_TYPE") ENDIF("${TRY_TYPE}" MATCHES "COMPILES") @@ -301,7 +328,7 @@ IF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}") #--- zconf.h.orig 2005-07-21 00:40:26.000000000 #+++ zconf.h 2009-01-19 11:39:10.093750000 #@@ -286,7 +286,7 @@ - # + # # #if 1 /* HAVE_UNISTD_H -- this line is updated by ./configure */ # # include /* for off_t */ #-# include /* for SEEK_* and off_t */ @@ -315,7 +342,11 @@ SET(ADDITIONAL_LIBS "") # # Find ZLIB # -FIND_PACKAGE(ZLIB) +IF(ENABLE_ZLIB) + FIND_PACKAGE(ZLIB) +ELSE() + SET(ZLIB_FOUND FALSE) # Override cached value +ENDIF() IF(ZLIB_FOUND) SET(HAVE_LIBZ 1) SET(HAVE_ZLIB_H 1) @@ -350,7 +381,11 @@ MARK_AS_ADVANCED(CLEAR ZLIB_LIBRARY) # # Find BZip2 # -FIND_PACKAGE(BZip2) +IF(ENABLE_BZip2) + FIND_PACKAGE(BZip2) +ELSE() + SET(BZIP2_FOUND FALSE) # Override cached value +ENDIF() IF(BZIP2_FOUND) SET(HAVE_LIBBZ2 1) SET(HAVE_BZLIB_H 1) @@ -370,10 +405,18 @@ IF(BZIP2_FOUND) ENDIF(BZIP2_FOUND) MARK_AS_ADVANCED(CLEAR BZIP2_INCLUDE_DIR) MARK_AS_ADVANCED(CLEAR BZIP2_LIBRARIES) + + # # Find LZMA # -FIND_PACKAGE(LZMA) +IF(ENABLE_LZMA) + FIND_PACKAGE(LZMA) +ELSE() + SET(LZMA_FOUND FALSE) # Override cached value + SET(LZMADEC_FOUND FALSE) # Override cached value +ENDIF() + IF(LZMA_FOUND) SET(HAVE_LIBLZMA 1) SET(HAVE_LZMA_H 1) @@ -393,6 +436,8 @@ ELSEIF(LZMADEC_FOUND) SET(HAVE_LZMADEC_H 1) INCLUDE_DIRECTORIES(${LZMADEC_INCLUDE_DIR}) LIST(APPEND ADDITIONAL_LIBS ${LZMADEC_LIBRARIES}) +ELSE(LZMA_FOUND) +# LZMA not found and will not be used. ENDIF(LZMA_FOUND) # # Find LZO2 @@ -444,7 +489,7 @@ LA_CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H) LA_CHECK_INCLUDE_FILE("errno.h" HAVE_ERRNO_H) LA_CHECK_INCLUDE_FILE("ext2fs/ext2_fs.h" HAVE_EXT2FS_EXT2_FS_H) -LIBARCHIVE_CHECK_C_SOURCE_COMPILES("#include +CHECK_C_SOURCE_COMPILES("#include #include int main(void) { return EXT2_IOC_GETFLAGS; }" HAVE_WORKING_EXT2_IOC_GETFLAGS) @@ -507,7 +552,7 @@ FOREACH (it ${_HEADER}) SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n") ENDFOREACH (it) -LIBARCHIVE_CHECK_C_SOURCE_COMPILES( +CHECK_C_SOURCE_COMPILES( "#define __EXTENSIONS__ 1 ${_INCLUDE_FILES} int main() { return 0;}" @@ -619,16 +664,10 @@ main(int argc, char **argv) FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_crypto_md.c" "${SOURCE}") MESSAGE(STATUS "Checking support for ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}") - IF(CMAKE_REQUIRED_LINKER_FLAGS) - SET(CHECK_CRYPTO_ADD_LINKER_FLAGS - "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS}") - ELSE(CMAKE_REQUIRED_LINKER_FLAGS) - SET(CHECK_CRYPTO_ADD_LINKER_FLAGS) - ENDIF(CMAKE_REQUIRED_LINKER_FLAGS) TRY_COMPILE(ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_crypto_md.c - CMAKE_FLAGS ${CHECK_CRYPTO_ADD_LINKER_FLAGS} + CMAKE_FLAGS "${TRY_CRYPTO_REQUIRED_LIBS}" "${TRY_CRYPTO_REQUIRED_INCLUDES}" OUTPUT_VARIABLE OUTPUT) @@ -713,16 +752,10 @@ main(int argc, char **argv) FILE(WRITE "${SOURCE_FILE}" "${SOURCE}") MESSAGE(STATUS "Checking support for ARCHIVE_CRYPTO_${CRYPTO}_WIN") - IF(CMAKE_REQUIRED_LINKER_FLAGS) - SET(CHECK_CRYPTO_WIN_ADD_LINKER_FLAGS - "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS}") - ELSE(CMAKE_REQUIRED_LINKER_FLAGS) - SET(CHECK_CRYPTO_WIN_ADD_LINKER_FLAGS) - ENDIF(CMAKE_REQUIRED_LINKER_FLAGS) TRY_COMPILE(ARCHIVE_CRYPTO_${CRYPTO}_WIN ${CMAKE_BINARY_DIR} ${SOURCE_FILE} - CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}/libarchive" ${CHECK_CRYPTO_WIN_ADD_LINKER_FLAGS} + CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}/libarchive" OUTPUT_VARIABLE OUTPUT) IF (ARCHIVE_CRYPTO_${CRYPTO}_WIN) @@ -768,7 +801,7 @@ MACRO(CHECK_ICONV LIB TRY_ICONV_CONST) SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} /WX") ENDIF (MSVC) # - LIBARCHIVE_CHECK_C_SOURCE_COMPILES( + CHECK_C_SOURCE_COMPILES( "#include #include int main() { @@ -883,8 +916,8 @@ ENDIF(ENABLE_ICONV) # # Find Libxml2 -# FIND_PACKAGE(LibXml2) +# IF(LIBXML2_FOUND) CMAKE_PUSH_CHECK_STATE() # Save the state of the variables INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) @@ -979,8 +1012,16 @@ IF(NOT FOUND_POSIX_REGEX_LIB AND POSIX_REGEX_LIB MATCHES "^(AUTO|LIBPCREPOSIX)$" # # If requested, try finding library for PCREPOSIX # - FIND_PACKAGE(LibGCC) - FIND_PACKAGE(PCREPOSIX) + IF(ENABLE_LibGCC) + FIND_PACKAGE(LibGCC) + ELSE() + SET(LIBGCC_FOUND FALSE) # Override cached value + ENDIF() + IF(ENABLE_PCREPOSIX) + FIND_PACKAGE(PCREPOSIX) + ELSE() + SET(PCREPOSIX_FOUND FALSE) # Override cached value + ENDIF() IF(PCREPOSIX_FOUND) INCLUDE_DIRECTORIES(${PCRE_INCLUDE_DIR}) LIST(APPEND ADDITIONAL_LIBS ${PCREPOSIX_LIBRARIES}) @@ -1131,14 +1172,14 @@ CMAKE_POP_CHECK_STATE() # Restore the state of the variables # Make sure we have the POSIX version of readdir_r, not the # older 2-argument version. -LIBARCHIVE_CHECK_C_SOURCE_COMPILES( +CHECK_C_SOURCE_COMPILES( "#include \nint main() {DIR *d = opendir(\".\"); struct dirent e,*r; return readdir_r(d,&e,&r);}" HAVE_READDIR_R) # Only detect readlinkat() if we also have AT_FDCWD in unistd.h. # NOTE: linux requires fcntl.h for AT_FDCWD. -LIBARCHIVE_CHECK_C_SOURCE_COMPILES( +CHECK_C_SOURCE_COMPILES( "#include \n#include \nint main() {char buf[10]; return readlinkat(AT_FDCWD, \"\", buf, 0);}" HAVE_READLINKAT) @@ -1147,10 +1188,10 @@ LIBARCHIVE_CHECK_C_SOURCE_COMPILES( # of interest and verify that the result can be linked. # CHECK_FUNCTION_EXISTS doesn't accept a header argument, # CHECK_SYMBOL_EXISTS doesn't test linkage. -LIBARCHIVE_CHECK_C_SOURCE_COMPILES( +CHECK_C_SOURCE_COMPILES( "#include \nint main() { return major(256); }" MAJOR_IN_MKDEV) -LIBARCHIVE_CHECK_C_SOURCE_COMPILES( +CHECK_C_SOURCE_COMPILES( "#include \nint main() { return major(256); }" MAJOR_IN_SYSMACROS) @@ -1242,13 +1283,13 @@ CHECK_TYPE_SIZE("unsigned long long" SIZE_OF_UNSIGNED_LONG_LONG) CHECK_TYPE_SIZE("__int64" __INT64) CHECK_TYPE_SIZE("unsigned __int64" UNSIGNED___INT64) -CHECK_TYPE_SIZE(int16_t INT16_T) +CHECK_TYPE_SIZE(int16_t INT16_T) CHECK_TYPE_SIZE(int32_t INT32_T) CHECK_TYPE_SIZE(int64_t INT64_T) CHECK_TYPE_SIZE(intmax_t INTMAX_T) -CHECK_TYPE_SIZE(uint8_t UINT8_T) -CHECK_TYPE_SIZE(uint16_t UINT16_T) -CHECK_TYPE_SIZE(uint32_t UINT32_T) +CHECK_TYPE_SIZE(uint8_t UINT8_T) +CHECK_TYPE_SIZE(uint16_t UINT16_T) +CHECK_TYPE_SIZE(uint32_t UINT32_T) CHECK_TYPE_SIZE(uint64_t UINT64_T) CHECK_TYPE_SIZE(uintmax_t UINTMAX_T) @@ -1491,6 +1532,9 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.h.in INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) ADD_DEFINITIONS(-DHAVE_CONFIG_H) +# Handle generation of the libarchive.pc file for pkg-config +INCLUDE(CreatePkgConfigFile) + # # Register installation of PDF documents. # diff --git a/build/cmake/CreatePkgConfigFile.cmake b/build/cmake/CreatePkgConfigFile.cmake new file mode 100644 index 0000000..f96bbef --- /dev/null +++ b/build/cmake/CreatePkgConfigFile.cmake @@ -0,0 +1,31 @@ +# - Generate a libarchive.pc like autotools for pkg-config +# + +# Set the required variables (we use the same input file as autotools) +SET(prefix ${CMAKE_INSTALL_PREFIX}) +SET(exec_prefix \${prefix}) +SET(libdir \${exec_prefix}/lib) +SET(includedir \${prefix}/include) +# Now, this is not particularly pretty, nor is it terribly accurate... +# Loop over all our additional libs +FOREACH(mylib ${ADDITIONAL_LIBS}) + # Extract the filename from the absolute path + GET_FILENAME_COMPONENT(mylib_name ${mylib} NAME_WE) + # Strip the lib prefix + STRING(REGEX REPLACE "^lib" "" mylib_name ${mylib_name}) + # Append it to our LIBS string + SET(LIBS "${LIBS} -l${mylib_name}") +ENDFOREACH() +# libxml2 is easier, since it's already using pkg-config +FOREACH(mylib ${PC_LIBXML_STATIC_LDFLAGS}) + SET(LIBS "${LIBS} ${mylib}") +ENDFOREACH() +# FIXME: The order of the libraries doesn't take dependencies into account, +# thus there's a good chance it'll make some binutils versions unhappy... +# This only affects Libs.private (looked up for static builds) though. +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc.in + ${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc + @ONLY) +# And install it, of course ;). +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc + DESTINATION "lib/pkgconfig") diff --git a/build/cmake/LibarchiveCheckCSourceCompiles.cmake b/build/cmake/LibarchiveCheckCSourceCompiles.cmake deleted file mode 100644 index 6b6f593..0000000 --- a/build/cmake/LibarchiveCheckCSourceCompiles.cmake +++ /dev/null @@ -1,106 +0,0 @@ -# - Check if given C source compiles and links into an executable -# CHECK_C_SOURCE_COMPILES( [FAIL_REGEX ]) -# - source code to try to compile, must define 'main' -# - variable to store whether the source code compiled -# - fail if test output matches this regex -# The following variables may be set before calling this macro to -# modify the way the check is run: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_INCLUDES = list of include directories -# CMAKE_REQUIRED_LIBRARIES = list of libraries to link - -#============================================================================= -# Copyright 2005-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -# -# Extra arguments added by libarchive -# CMAKE_REQUIRED_LINKER_FLAGS = string of linker command line flags -# - -include(CMakeExpandImportedTargets) - - -macro(LIBARCHIVE_CHECK_C_SOURCE_COMPILES SOURCE VAR) - if("${VAR}" MATCHES "^${VAR}$") - set(_FAIL_REGEX) - set(_key) - foreach(arg ${ARGN}) - if("${arg}" MATCHES "^(FAIL_REGEX)$") - set(_key "${arg}") - elseif(_key) - list(APPEND _${_key} "${arg}") - else() - message(FATAL_ERROR "Unknown argument:\n ${arg}\n") - endif() - endforeach() - set(MACRO_CHECK_FUNCTION_DEFINITIONS - "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") - if(CMAKE_REQUIRED_LIBRARIES) - # this one translates potentially used imported library targets to their files on disk - CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}") - set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}") - else() - set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES) - endif() - if(CMAKE_REQUIRED_INCLUDES) - set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES - "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") - else() - set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES) - endif() - if(CMAKE_REQUIRED_LINKER_FLAGS) - set(CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS - "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS}") - else() - set(CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS) - endif() - file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c" - "${SOURCE}\n") - - message(STATUS "Performing Test ${VAR}") - try_compile(${VAR} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} ${CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS} - "${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}" - "${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}" - OUTPUT_VARIABLE OUTPUT) - - foreach(_regex ${_FAIL_REGEX}) - if("${OUTPUT}" MATCHES "${_regex}") - set(${VAR} 0) - endif() - endforeach() - - if(${VAR}) - set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") - message(STATUS "Performing Test ${VAR} - Success") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${SOURCE}\n") - else() - message(STATUS "Performing Test ${VAR} - Failed") - set(${VAR} "" CACHE INTERNAL "Test ${VAR}") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Performing C SOURCE FILE Test ${VAR} failed with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${SOURCE}\n") - endif() - endif() -endmacro() - diff --git a/build/cmake/LibarchiveCheckCSourceRuns.cmake b/build/cmake/LibarchiveCheckCSourceRuns.cmake deleted file mode 100644 index 498f522..0000000 --- a/build/cmake/LibarchiveCheckCSourceRuns.cmake +++ /dev/null @@ -1,102 +0,0 @@ -# - Check if the given C source code compiles and runs. -# CHECK_C_SOURCE_RUNS( ) -# - source code to try to compile -# - variable to store the result -# (1 for success, empty for failure) -# The following variables may be set before calling this macro to -# modify the way the check is run: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_INCLUDES = list of include directories -# CMAKE_REQUIRED_LIBRARIES = list of libraries to link - -#============================================================================= -# Copyright 2006-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -# -# Extra arguments added by libarchive -# CMAKE_REQUIRED_LINKER_FLAGS = string of linker command line flags -# - -include(CMakeExpandImportedTargets) - - -macro(LIBARCHIVE_CHECK_C_SOURCE_RUNS SOURCE VAR) - if("${VAR}" MATCHES "^${VAR}$") - set(MACRO_CHECK_FUNCTION_DEFINITIONS - "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") - if(CMAKE_REQUIRED_LIBRARIES) - # this one translates potentially used imported library targets to their files on disk - CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}") - set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}") - else() - set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES) - endif() - if(CMAKE_REQUIRED_INCLUDES) - set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES - "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") - else() - set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES) - endif() - if(CMAKE_REQUIRED_LINKER_FLAGS) - set(CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS - "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS}") - else() - set(CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS) - endif() - file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c" - "${SOURCE}\n") - - message(STATUS "Performing Test ${VAR}") - try_run(${VAR}_EXITCODE ${VAR}_COMPILED - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} ${CHECK_C_SOURCE_COMPILES_ADD_LINKER_FLAGS} - -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH} - "${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}" - "${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}" - COMPILE_OUTPUT_VARIABLE OUTPUT) - # if it did not compile make the return value fail code of 1 - if(NOT ${VAR}_COMPILED) - set(${VAR}_EXITCODE 1) - endif() - # if the return value was 0 then it worked - if("${${VAR}_EXITCODE}" EQUAL 0) - set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") - message(STATUS "Performing Test ${VAR} - Success") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n" - "${OUTPUT}\n" - "Return value: ${${VAR}}\n" - "Source file was:\n${SOURCE}\n") - else() - if(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN") - set(${VAR} "${${VAR}_EXITCODE}") - else() - set(${VAR} "" CACHE INTERNAL "Test ${VAR}") - endif() - - message(STATUS "Performing Test ${VAR} - Failed") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Performing C SOURCE FILE Test ${VAR} failed with the following output:\n" - "${OUTPUT}\n" - "Return value: ${${VAR}_EXITCODE}\n" - "Source file was:\n${SOURCE}\n") - - endif() - endif() -endmacro() - diff --git a/build/cmake/LibarchiveCodeCoverage.cmake b/build/cmake/LibarchiveCodeCoverage.cmake new file mode 100644 index 0000000..297b886 --- /dev/null +++ b/build/cmake/LibarchiveCodeCoverage.cmake @@ -0,0 +1,68 @@ +################################################################# +# Adds a build target called "coverage" for code coverage. +# +# This compiles the code using special GCC flags, run the tests, +# and then generates a nice HTML output. This new "coverage" make +# target will only be available if you build using GCC in Debug +# mode. If any of the required programs (lcov and genhtml) were +# not found, a FATAL_ERROR message is printed. +# +# If not already done, this code will set ENABLE_TEST to ON. +# +# To build the code coverage and open it in your browser do this: +# +# mkdir debug +# cd debug +# cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON .. +# make -j4 +# make coverage +# xdg-open coverage/index.html +################################################################# + +# Find programs we need +FIND_PROGRAM(LCOV_EXECUTABLE lcov DOC "Full path to lcov executable") +FIND_PROGRAM(GENHTML_EXECUTABLE genhtml DOC "Full path to genhtml executable") +MARK_AS_ADVANCED(LCOV_EXECUTABLE GENHTML_EXECUTABLE) + +# Check, compiler, build types and programs are available +IF(NOT CMAKE_COMPILER_IS_GNUCC) +MESSAGE(FATAL_ERROR "Coverage can only be built on GCC") +ELSEIF(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") +MESSAGE(FATAL_ERROR "Coverage can only be built in Debug mode") +ELSEIF(NOT LCOV_EXECUTABLE) +MESSAGE(FATAL_ERROR "lcov executable not found") +ELSEIF(NOT GENHTML_EXECUTABLE) +MESSAGE(FATAL_ERROR "genhtml executable not found") +ENDIF(NOT CMAKE_COMPILER_IS_GNUCC) + +# Enable testing if not already done +SET(ENABLE_TEST ON) + +################################################################# +# Set special compiler and linker flags for test coverage +################################################################# +# 0. Enable debug: -g +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") +# 1. Disable optimizations: -O0 +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0") +# 2. Enable all kind of warnings: +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -W") +# 3. Enable special coverage flag (HINT: --coverage is a synonym for -fprofile-arcs -ftest-coverage) +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") +SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") +SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") +################################################################# + +ADD_CUSTOM_TARGET(coverage +COMMAND ${CMAKE_COMMAND} -E echo "Beginning test coverage. Output is written to coverage.log." +COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-1/5: Reset all execution counts to zero" +COMMAND ${LCOV_EXECUTABLE} --directory . --zerocounters > coverage.log 2>&1 +COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-2/5: Run testrunner" +COMMAND ${CMAKE_CTEST_COMMAND} >> coverage.log 2>&1 +COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-3/5: Collect coverage data" +COMMAND ${LCOV_EXECUTABLE} --capture --directory . --output-file "./coverage.info" >> coverage.log 2>&1 +COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-4/5: Generate HTML from coverage data" +COMMAND ${GENHTML_EXECUTABLE} "coverage.info" --title="libarchive-${LIBARCHIVE_VERSION_STRING}" --show-details --legend --output-directory "./coverage" >> coverage.log 2>&1 +COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-5/5: Open test coverage HTML output in browser: xdg-open ./coverage/index.html" +COMMENT "Runs testrunner and generates coverage output (formats: .info and .html)") + diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in index c04314e..a6933f6 100644 --- a/build/cmake/config.h.in +++ b/build/cmake/config.h.in @@ -1106,8 +1106,13 @@ typedef uint64_t uintmax_t; #cmakedefine _LARGE_FILES ${_LARGE_FILES} /* Define for Windows to use Windows 2000+ APIs. */ +#ifndef _WIN32_WINNT #cmakedefine _WIN32_WINNT ${_WIN32_WINNT} +#endif // _WIN32_WINNT + +#ifndef WINVER #cmakedefine WINVER ${WINVER} +#endif // WINVER /* Define to empty if `const' does not conform to ANSI C. */ #cmakedefine const ${const} diff --git a/libarchive/CMakeLists.txt b/libarchive/CMakeLists.txt index ecb0409..986af97 100644 --- a/libarchive/CMakeLists.txt +++ b/libarchive/CMakeLists.txt @@ -35,6 +35,8 @@ SET(libarchive_SOURCES archive_match.c archive_options.c archive_options_private.h + archive_pack_dev.h + archive_pack_dev.c archive_pathmatch.c archive_pathmatch.h archive_platform.h @@ -125,6 +127,7 @@ SET(libarchive_SOURCES archive_write_set_format_iso9660.c archive_write_set_format_mtree.c archive_write_set_format_pax.c + archive_write_set_format_raw.c archive_write_set_format_shar.c archive_write_set_format_ustar.c archive_write_set_format_v7tar.c diff --git a/libarchive/archive.h b/libarchive/archive.h index f56bc38..e90cb49 100644 --- a/libarchive/archive.h +++ b/libarchive/archive.h @@ -47,7 +47,7 @@ /* Get appropriate definitions of standard POSIX-style types. */ /* These should match the types used in 'struct stat' */ -#if defined(_WIN32) && !defined(__CYGWIN__) +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) # define __LA_INT64_T __int64 # if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_) # define __LA_SSIZE_T ssize_t @@ -133,6 +133,11 @@ __LA_DECL int archive_version_number(void); #define ARCHIVE_VERSION_STRING "libarchive 3.1.2" __LA_DECL const char * archive_version_string(void); +/* + * Detailed textual name/version of the library and its dependencies. + */ +__LA_DECL const char * archive_version_details(void); + /* Declare our basic types. */ struct archive; struct archive_entry; @@ -285,6 +290,30 @@ typedef int archive_switch_callback(struct archive *, void *_client_data1, #define ARCHIVE_FORMAT_RAR 0xD0000 #define ARCHIVE_FORMAT_7ZIP 0xE0000 +/* + * Codes returned by archive_read_format_capabilities(). + * + * This list can be extended with values between 0 and 0xffff. + * The original purpose of this list was to let different archive + * format readers expose their general capabilities in terms of + * encryption. + */ +#define ARCHIVE_READ_FORMAT_CAPS_NONE (0) /* no special capabilities */ +#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA (1<<0) /* reader can detect encrypted data */ +#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA (1<<1) /* reader can detect encryptable metadata (pathname, mtime, etc.) */ + +/* + * Codes returned by archive_read_has_encrypted_entries(). + * + * In case the archive does not support encryption detection at all + * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. If the reader + * for some other reason (e.g. not enough bytes read) cannot say if + * there are encrypted entries, ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW + * is returned. + */ +#define ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED -2 +#define ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW -1 + /*- * Basic outline for reading an archive: * 1) Ask archive_read_new for an archive reader object. @@ -370,7 +399,15 @@ __LA_DECL int archive_read_support_format_rar(struct archive *); __LA_DECL int archive_read_support_format_raw(struct archive *); __LA_DECL int archive_read_support_format_tar(struct archive *); __LA_DECL int archive_read_support_format_xar(struct archive *); +/* archive_read_support_format_zip() enables both streamable and seekable + * zip readers. */ __LA_DECL int archive_read_support_format_zip(struct archive *); +/* Reads Zip archives as stream from beginning to end. Doesn't + * correctly handle SFX ZIP files or ZIP archives that have been modified + * in-place. */ +__LA_DECL int archive_read_support_format_zip_streamable(struct archive *); +/* Reads starting from central directory; requires seekable input. */ +__LA_DECL int archive_read_support_format_zip_seekable(struct archive *); /* Functions to manually set the format and filters to be used. This is * useful to bypass the bidding process when the format and filters to use @@ -466,6 +503,32 @@ __LA_DECL int archive_read_next_header2(struct archive *, */ __LA_DECL __LA_INT64_T archive_read_header_position(struct archive *); +/* + * Returns 1 if the archive contains at least one encrypted entry. + * If the archive format not support encryption at all + * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. + * If for any other reason (e.g. not enough data read so far) + * we cannot say whether there are encrypted entries, then + * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned. + * In general, this function will return values below zero when the + * reader is uncertain or totally uncapable of encryption support. + * When this function returns 0 you can be sure that the reader + * supports encryption detection but no encrypted entries have + * been found yet. + * + * NOTE: If the metadata/header of an archive is also encrypted, you + * cannot rely on the number of encrypted entries. That is why this + * function does not return the number of encrypted entries but# + * just shows that there are some. + */ +__LA_DECL int archive_read_has_encrypted_entries(struct archive *); + +/* + * Returns a bitmask of capabilities that are supported by the archive format reader. + * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned. + */ +__LA_DECL int archive_read_format_capabilities(struct archive *); + /* Read data from the body of an entry. Similar to read(2). */ __LA_DECL __LA_SSIZE_T archive_read_data(struct archive *, void *, size_t); @@ -670,6 +733,7 @@ __LA_DECL int archive_write_set_format_mtree_classic(struct archive *); /* TODO: int archive_write_set_format_old_tar(struct archive *); */ __LA_DECL int archive_write_set_format_pax(struct archive *); __LA_DECL int archive_write_set_format_pax_restricted(struct archive *); +__LA_DECL int archive_write_set_format_raw(struct archive *); __LA_DECL int archive_write_set_format_shar(struct archive *); __LA_DECL int archive_write_set_format_shar_dump(struct archive *); __LA_DECL int archive_write_set_format_ustar(struct archive *); @@ -879,6 +943,10 @@ __LA_DECL int archive_read_disk_set_metadata_filter_callback(struct archive *, int (*_metadata_filter_func)(struct archive *, void *, struct archive_entry *), void *_client_data); +/* Simplified cleanup interface; + * This calls archive_read_free() or archive_write_free() as needed. */ +__LA_DECL int archive_free(struct archive *); + /* * Accessor functions to read/set various information in * the struct archive object: @@ -1025,6 +1093,10 @@ __LA_DECL int archive_match_include_gname(struct archive *, const char *); __LA_DECL int archive_match_include_gname_w(struct archive *, const wchar_t *); +/* Utility functions */ +/* Convenience function to sort a NULL terminated list of strings */ +__LA_DECL int archive_utility_string_sort(char **); + #ifdef __cplusplus } #endif diff --git a/libarchive/archive_endian.h b/libarchive/archive_endian.h index 68123b0..750e190 100644 --- a/libarchive/archive_endian.h +++ b/libarchive/archive_endian.h @@ -58,7 +58,13 @@ archive_be16dec(const void *pp) { unsigned char const *p = (unsigned char const *)pp; - return ((p[0] << 8) | p[1]); + /* Store into unsigned temporaries before left shifting, to avoid + promotion to signed int and then left shifting into the sign bit, + which is undefined behaviour. */ + unsigned int p1 = p[1]; + unsigned int p0 = p[0]; + + return ((p0 << 8) | p1); } static inline uint32_t @@ -66,7 +72,15 @@ archive_be32dec(const void *pp) { unsigned char const *p = (unsigned char const *)pp; - return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); + /* Store into unsigned temporaries before left shifting, to avoid + promotion to signed int and then left shifting into the sign bit, + which is undefined behaviour. */ + unsigned int p3 = p[3]; + unsigned int p2 = p[2]; + unsigned int p1 = p[1]; + unsigned int p0 = p[0]; + + return ((p0 << 24) | (p1 << 16) | (p2 << 8) | p3); } static inline uint64_t @@ -82,7 +96,13 @@ archive_le16dec(const void *pp) { unsigned char const *p = (unsigned char const *)pp; - return ((p[1] << 8) | p[0]); + /* Store into unsigned temporaries before left shifting, to avoid + promotion to signed int and then left shifting into the sign bit, + which is undefined behaviour. */ + unsigned int p1 = p[1]; + unsigned int p0 = p[0]; + + return ((p1 << 8) | p0); } static inline uint32_t @@ -90,7 +110,15 @@ archive_le32dec(const void *pp) { unsigned char const *p = (unsigned char const *)pp; - return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]); + /* Store into unsigned temporaries before left shifting, to avoid + promotion to signed int and then left shifting into the sign bit, + which is undefined behaviour. */ + unsigned int p3 = p[3]; + unsigned int p2 = p[2]; + unsigned int p1 = p[1]; + unsigned int p0 = p[0]; + + return ((p3 << 24) | (p2 << 16) | (p1 << 8) | p0); } static inline uint64_t diff --git a/libarchive/archive_entry.c b/libarchive/archive_entry.c index 386e51d..293c701 100644 --- a/libarchive/archive_entry.c +++ b/libarchive/archive_entry.c @@ -201,6 +201,9 @@ archive_entry_clone(struct archive_entry *entry) entry2->ae_set = entry->ae_set; archive_mstring_copy(&entry2->ae_uname, &entry->ae_uname); + /* Copy encryption status */ + entry2->encryption = entry->encryption; + /* Copy ACL data over. */ archive_acl_copy(&entry2->acl, &entry->acl); @@ -695,6 +698,24 @@ _archive_entry_uname_l(struct archive_entry *entry, return (archive_mstring_get_mbs_l(&entry->ae_uname, p, len, sc)); } +int +archive_entry_is_data_encrypted(struct archive_entry *entry) +{ + return ((entry->encryption & AE_ENCRYPTION_DATA) == AE_ENCRYPTION_DATA); +} + +int +archive_entry_is_metadata_encrypted(struct archive_entry *entry) +{ + return ((entry->encryption & AE_ENCRYPTION_METADATA) == AE_ENCRYPTION_METADATA); +} + +int +archive_entry_is_encrypted(struct archive_entry *entry) +{ + return (entry->encryption & (AE_ENCRYPTION_DATA|AE_ENCRYPTION_METADATA)); +} + /* * Functions to set archive_entry properties. */ @@ -1216,6 +1237,26 @@ archive_entry_update_uname_utf8(struct archive_entry *entry, const char *name) return (0); } +void +archive_entry_set_is_data_encrypted(struct archive_entry *entry, char is_encrypted) +{ + if (is_encrypted) { + entry->encryption |= AE_ENCRYPTION_DATA; + } else { + entry->encryption &= ~AE_ENCRYPTION_DATA; + } +} + +void +archive_entry_set_is_metadata_encrypted(struct archive_entry *entry, char is_encrypted) +{ + if (is_encrypted) { + entry->encryption |= AE_ENCRYPTION_METADATA; + } else { + entry->encryption &= ~AE_ENCRYPTION_METADATA; + } +} + int _archive_entry_copy_uname_l(struct archive_entry *entry, const char *name, size_t len, struct archive_string_conv *sc) diff --git a/libarchive/archive_entry.h b/libarchive/archive_entry.h index a905065..dfba11b 100644 --- a/libarchive/archive_entry.h +++ b/libarchive/archive_entry.h @@ -43,12 +43,8 @@ #include /* for wchar_t */ #include -#if defined(_WIN32) && !defined(__CYGWIN__) -#include -#endif - /* Get a suitable 64-bit integer type. */ -#if defined(_WIN32) && !defined(__CYGWIN__) +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) # define __LA_INT64_T __int64 #else #include @@ -63,7 +59,7 @@ #if ARCHIVE_VERSION_NUMBER >= 3999000 /* Switch to plain 'int' for libarchive 4.0. It's less broken than 'mode_t' */ # define __LA_MODE_T int -#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) +#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) && !defined(__WATCOMC__) # define __LA_MODE_T unsigned short #else # define __LA_MODE_T mode_t @@ -235,6 +231,9 @@ __LA_DECL const wchar_t *archive_entry_symlink_w(struct archive_entry *); __LA_DECL __LA_INT64_T archive_entry_uid(struct archive_entry *); __LA_DECL const char *archive_entry_uname(struct archive_entry *); __LA_DECL const wchar_t *archive_entry_uname_w(struct archive_entry *); +__LA_DECL int archive_entry_is_data_encrypted(struct archive_entry *); +__LA_DECL int archive_entry_is_metadata_encrypted(struct archive_entry *); +__LA_DECL int archive_entry_is_encrypted(struct archive_entry *); /* * Set fields in an archive_entry. @@ -306,6 +305,8 @@ __LA_DECL void archive_entry_set_uname(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_uname(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_uname_w(struct archive_entry *, const wchar_t *); __LA_DECL int archive_entry_update_uname_utf8(struct archive_entry *, const char *); +__LA_DECL void archive_entry_set_is_data_encrypted(struct archive_entry *, char is_encrypted); +__LA_DECL void archive_entry_set_is_metadata_encrypted(struct archive_entry *, char is_encrypted); /* * Routines to bulk copy fields to/from a platform-native "struct * stat." Libarchive used to just store a struct stat inside of each diff --git a/libarchive/archive_entry_private.h b/libarchive/archive_entry_private.h index e3547c3..c69233e 100644 --- a/libarchive/archive_entry_private.h +++ b/libarchive/archive_entry_private.h @@ -154,6 +154,11 @@ struct archive_entry { /* Not used within libarchive; useful for some clients. */ struct archive_mstring ae_sourcepath; /* Path this entry is sourced from. */ +#define AE_ENCRYPTION_NONE 0 +#define AE_ENCRYPTION_DATA 1 +#define AE_ENCRYPTION_METADATA 2 + char encryption; + void *mac_metadata; size_t mac_metadata_size; diff --git a/libarchive/archive_entry_sparse.c b/libarchive/archive_entry_sparse.c index 10c5447..fed74f5 100644 --- a/libarchive/archive_entry_sparse.c +++ b/libarchive/archive_entry_sparse.c @@ -58,7 +58,7 @@ archive_entry_sparse_add_entry(struct archive_entry *entry, if (offset < 0 || length < 0) /* Invalid value */ return; - if (offset + length < 0 || + if (offset > INT64_MAX - length || offset + length > archive_entry_size(entry)) /* A value of "length" parameter is too large. */ return; diff --git a/libarchive/archive_getdate.c b/libarchive/archive_getdate.c index f8b5a28..aaa9d6f 100644 --- a/libarchive/archive_getdate.c +++ b/libarchive/archive_getdate.c @@ -369,8 +369,8 @@ relunitphrase(struct gdstate *gds) && gds->tokenp[1].token == tSEC_UNIT) { /* "1 day" */ gds->HaveRel++; - gds->RelSeconds += gds->tokenp[1].value * gds->tokenp[2].value; - gds->tokenp += 3; + gds->RelSeconds += gds->tokenp[0].value * gds->tokenp[1].value; + gds->tokenp += 2; return 1; } if (gds->tokenp[0].token == '-' @@ -403,7 +403,7 @@ relunitphrase(struct gdstate *gds) /* "now", "tomorrow" */ gds->HaveRel++; gds->RelSeconds += gds->tokenp[0].value; - ++gds->tokenp; + gds->tokenp += 1; return 1; } if (gds->tokenp[0].token == tMONTH_UNIT) { @@ -1022,10 +1022,11 @@ int main(int argc, char **argv) { time_t d; + time_t now = time(NULL); while (*++argv != NULL) { (void)printf("Input: %s\n", *argv); - d = get_date(*argv); + d = get_date(now, *argv); if (d == -1) (void)printf("Bad format - couldn't convert.\n"); else diff --git a/libarchive/archive_match.c b/libarchive/archive_match.c index 6b6be9c..6fb8644 100644 --- a/libarchive/archive_match.c +++ b/libarchive/archive_match.c @@ -1152,7 +1152,7 @@ set_timefilter_pathname_mbs(struct archive_match *a, int timetype, { /* NOTE: stat() on Windows cannot handle nano seconds. */ HANDLE h; - WIN32_FIND_DATA d; + WIN32_FIND_DATAA d; if (path == NULL || *path == '\0') { archive_set_error(&(a->archive), EINVAL, "pathname is empty"); diff --git a/libarchive/archive_pack_dev.c b/libarchive/archive_pack_dev.c new file mode 100644 index 0000000..c90d8de --- /dev/null +++ b/libarchive/archive_pack_dev.c @@ -0,0 +1,329 @@ +/* $NetBSD: pack_dev.c,v 1.12 2013/06/14 16:28:20 tsutsui Exp $ */ + +/*- + * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* Originally from NetBSD's mknod(8) source. */ + +#include "archive_platform.h" + +#if HAVE_SYS_CDEFS_H +#include +#endif +#if !defined(lint) +__RCSID("$NetBSD$"); +#endif /* not lint */ + +#ifdef HAVE_LIMITS_H +#include +#endif + +#include +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif + +#include "archive_pack_dev.h" + +static pack_t pack_netbsd; +static pack_t pack_freebsd; +static pack_t pack_8_8; +static pack_t pack_12_20; +static pack_t pack_14_18; +static pack_t pack_8_24; +static pack_t pack_bsdos; +static int compare_format(const void *, const void *); + +static const char iMajorError[] = "invalid major number"; +static const char iMinorError[] = "invalid minor number"; +static const char tooManyFields[] = "too many fields for format"; + +/* This is blatantly stolen from libarchive/archive_entry.c, + * in an attempt to get this to play nice on MinGW... */ +#if !defined(HAVE_MAJOR) && !defined(major) +/* Replacement for major/minor/makedev. */ +#define major(x) ((int)(0x00ff & ((x) >> 8))) +#define minor(x) ((int)(0xffff00ff & (x))) +#define makedev(maj,min) ((0xff00 & ((maj)<<8)) | (0xffff00ff & (min))) +#endif + +/* Play games to come up with a suitable makedev() definition. */ +#ifdef __QNXNTO__ +/* QNX. */ +#include +#define apd_makedev(maj, min) makedev(ND_LOCAL_NODE, (maj), (min)) +#elif defined makedev +/* There's a "makedev" macro. */ +#define apd_makedev(maj, min) makedev((maj), (min)) +#elif defined mkdev || ((defined _WIN32 || defined __WIN32__) && !defined(__CYGWIN__)) +/* Windows. */ +#define apd_makedev(maj, min) mkdev((maj), (min)) +#else +/* There's a "makedev" function. */ +#define apd_makedev(maj, min) makedev((maj), (min)) +#endif + +/* exported */ +dev_t +pack_native(int n, u_long numbers[], const char **error) +{ + dev_t dev = 0; + + if (n == 2) { + dev = apd_makedev(numbers[0], numbers[1]); + if ((u_long)major(dev) != numbers[0]) + *error = iMajorError; + else if ((u_long)minor(dev) != numbers[1]) + *error = iMinorError; + } else + *error = tooManyFields; + return (dev); +} + + +static dev_t +pack_netbsd(int n, u_long numbers[], const char **error) +{ + dev_t dev = 0; + + if (n == 2) { + dev = makedev_netbsd(numbers[0], numbers[1]); + if ((u_long)major_netbsd(dev) != numbers[0]) + *error = iMajorError; + else if ((u_long)minor_netbsd(dev) != numbers[1]) + *error = iMinorError; + } else + *error = tooManyFields; + return (dev); +} + + +#define major_freebsd(x) ((int32_t)(((x) & 0x0000ff00) >> 8)) +#define minor_freebsd(x) ((int32_t)(((x) & 0xffff00ff) >> 0)) +#define makedev_freebsd(x,y) ((dev_t)((((x) << 8) & 0x0000ff00) | \ + (((y) << 0) & 0xffff00ff))) + +static dev_t +pack_freebsd(int n, u_long numbers[], const char **error) +{ + dev_t dev = 0; + + if (n == 2) { + dev = makedev_freebsd(numbers[0], numbers[1]); + if ((u_long)major_freebsd(dev) != numbers[0]) + *error = iMajorError; + if ((u_long)minor_freebsd(dev) != numbers[1]) + *error = iMinorError; + } else + *error = tooManyFields; + return (dev); +} + + +#define major_8_8(x) ((int32_t)(((x) & 0x0000ff00) >> 8)) +#define minor_8_8(x) ((int32_t)(((x) & 0x000000ff) >> 0)) +#define makedev_8_8(x,y) ((dev_t)((((x) << 8) & 0x0000ff00) | \ + (((y) << 0) & 0x000000ff))) + +static dev_t +pack_8_8(int n, u_long numbers[], const char **error) +{ + dev_t dev = 0; + + if (n == 2) { + dev = makedev_8_8(numbers[0], numbers[1]); + if ((u_long)major_8_8(dev) != numbers[0]) + *error = iMajorError; + if ((u_long)minor_8_8(dev) != numbers[1]) + *error = iMinorError; + } else + *error = tooManyFields; + return (dev); +} + + +#define major_12_20(x) ((int32_t)(((x) & 0xfff00000) >> 20)) +#define minor_12_20(x) ((int32_t)(((x) & 0x000fffff) >> 0)) +#define makedev_12_20(x,y) ((dev_t)((((x) << 20) & 0xfff00000) | \ + (((y) << 0) & 0x000fffff))) + +static dev_t +pack_12_20(int n, u_long numbers[], const char **error) +{ + dev_t dev = 0; + + if (n == 2) { + dev = makedev_12_20(numbers[0], numbers[1]); + if ((u_long)major_12_20(dev) != numbers[0]) + *error = iMajorError; + if ((u_long)minor_12_20(dev) != numbers[1]) + *error = iMinorError; + } else + *error = tooManyFields; + return (dev); +} + + +#define major_14_18(x) ((int32_t)(((x) & 0xfffc0000) >> 18)) +#define minor_14_18(x) ((int32_t)(((x) & 0x0003ffff) >> 0)) +#define makedev_14_18(x,y) ((dev_t)((((x) << 18) & 0xfffc0000) | \ + (((y) << 0) & 0x0003ffff))) + +static dev_t +pack_14_18(int n, u_long numbers[], const char **error) +{ + dev_t dev = 0; + + if (n == 2) { + dev = makedev_14_18(numbers[0], numbers[1]); + if ((u_long)major_14_18(dev) != numbers[0]) + *error = iMajorError; + if ((u_long)minor_14_18(dev) != numbers[1]) + *error = iMinorError; + } else + *error = tooManyFields; + return (dev); +} + + +#define major_8_24(x) ((int32_t)(((x) & 0xff000000) >> 24)) +#define minor_8_24(x) ((int32_t)(((x) & 0x00ffffff) >> 0)) +#define makedev_8_24(x,y) ((dev_t)((((x) << 24) & 0xff000000) | \ + (((y) << 0) & 0x00ffffff))) + +static dev_t +pack_8_24(int n, u_long numbers[], const char **error) +{ + dev_t dev = 0; + + if (n == 2) { + dev = makedev_8_24(numbers[0], numbers[1]); + if ((u_long)major_8_24(dev) != numbers[0]) + *error = iMajorError; + if ((u_long)minor_8_24(dev) != numbers[1]) + *error = iMinorError; + } else + *error = tooManyFields; + return (dev); +} + + +#define major_12_12_8(x) ((int32_t)(((x) & 0xfff00000) >> 20)) +#define unit_12_12_8(x) ((int32_t)(((x) & 0x000fff00) >> 8)) +#define subunit_12_12_8(x) ((int32_t)(((x) & 0x000000ff) >> 0)) +#define makedev_12_12_8(x,y,z) ((dev_t)((((x) << 20) & 0xfff00000) | \ + (((y) << 8) & 0x000fff00) | \ + (((z) << 0) & 0x000000ff))) + +static dev_t +pack_bsdos(int n, u_long numbers[], const char **error) +{ + dev_t dev = 0; + + if (n == 2) { + dev = makedev_12_20(numbers[0], numbers[1]); + if ((u_long)major_12_20(dev) != numbers[0]) + *error = iMajorError; + if ((u_long)minor_12_20(dev) != numbers[1]) + *error = iMinorError; + } else if (n == 3) { + dev = makedev_12_12_8(numbers[0], numbers[1], numbers[2]); + if ((u_long)major_12_12_8(dev) != numbers[0]) + *error = iMajorError; + if ((u_long)unit_12_12_8(dev) != numbers[1]) + *error = "invalid unit number"; + if ((u_long)subunit_12_12_8(dev) != numbers[2]) + *error = "invalid subunit number"; + } else + *error = tooManyFields; + return (dev); +} + + + /* list of formats and pack functions */ + /* this list must be sorted lexically */ +static struct format { + const char *name; + pack_t *pack; +} formats[] = { + {"386bsd", pack_8_8}, + {"4bsd", pack_8_8}, + {"bsdos", pack_bsdos}, + {"freebsd", pack_freebsd}, + {"hpux", pack_8_24}, + {"isc", pack_8_8}, + {"linux", pack_8_8}, + {"native", pack_native}, + {"netbsd", pack_netbsd}, + {"osf1", pack_12_20}, + {"sco", pack_8_8}, + {"solaris", pack_14_18}, + {"sunos", pack_8_8}, + {"svr3", pack_8_8}, + {"svr4", pack_14_18}, + {"ultrix", pack_8_8}, +}; + +static int +compare_format(const void *key, const void *element) +{ + const char *name; + const struct format *format; + + name = key; + format = element; + + return (strcmp(name, format->name)); +} + + +pack_t * +pack_find(const char *name) +{ + struct format *format; + + format = bsearch(name, formats, + sizeof(formats)/sizeof(formats[0]), + sizeof(formats[0]), compare_format); + if (format == 0) + return (NULL); + return (format->pack); +} diff --git a/libarchive/archive_pack_dev.h b/libarchive/archive_pack_dev.h new file mode 100644 index 0000000..7c7b80b --- /dev/null +++ b/libarchive/archive_pack_dev.h @@ -0,0 +1,50 @@ +/* $NetBSD: pack_dev.h,v 1.8 2013/06/14 16:28:20 tsutsui Exp $ */ + +/*- + * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* Originally from NetBSD's mknod(8) source. */ + +#ifndef _PACK_DEV_H +#define _PACK_DEV_H + +typedef dev_t pack_t(int, u_long [], const char **); +typedef unsigned long u_long; + +pack_t *pack_find(const char *); +pack_t pack_native; + +#define major_netbsd(x) ((int32_t)((((x) & 0x000fff00) >> 8))) +#define minor_netbsd(x) ((int32_t)((((x) & 0xfff00000) >> 12) | \ + (((x) & 0x000000ff) >> 0))) +#define makedev_netbsd(x,y) ((dev_t)((((x) << 8) & 0x000fff00) | \ + (((y) << 12) & 0xfff00000) | \ + (((y) << 0) & 0x000000ff))) + +#endif /* _PACK_DEV_H */ diff --git a/libarchive/archive_platform.h b/libarchive/archive_platform.h index ce2f482..faeb5ef 100644 --- a/libarchive/archive_platform.h +++ b/libarchive/archive_platform.h @@ -66,15 +66,18 @@ * headers as required. */ -/* Get a real definition for __FBSDID if we can */ +/* Get a real definition for __FBSDID or __RCSID if we can */ #if HAVE_SYS_CDEFS_H #include #endif -/* If not, define it so as to avoid dangling semicolons. */ +/* If not, define them so as to avoid dangling semicolons. */ #ifndef __FBSDID #define __FBSDID(a) struct _undefined_hack #endif +#ifndef __RCSID +#define __RCSID(a) struct _undefined_hack +#endif /* Try to get standard C99-style integer type definitions. */ #if HAVE_INTTYPES_H diff --git a/libarchive/archive_read.c b/libarchive/archive_read.c index 048c316..c9f28b8 100644 --- a/libarchive/archive_read.c +++ b/libarchive/archive_read.c @@ -747,6 +747,59 @@ archive_read_header_position(struct archive *_a) } /* + * Returns 1 if the archive contains at least one encrypted entry. + * If the archive format not support encryption at all + * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. + * If for any other reason (e.g. not enough data read so far) + * we cannot say whether there are encrypted entries, then + * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned. + * In general, this function will return values below zero when the + * reader is uncertain or totally uncapable of encryption support. + * When this function returns 0 you can be sure that the reader + * supports encryption detection but no encrypted entries have + * been found yet. + * + * NOTE: If the metadata/header of an archive is also encrypted, you + * cannot rely on the number of encrypted entries. That is why this + * function does not return the number of encrypted entries but# + * just shows that there are some. + */ +int +archive_read_has_encrypted_entries(struct archive *_a) +{ + struct archive_read *a = (struct archive_read *)_a; + int format_supports_encryption = archive_read_format_capabilities(_a) + & (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA); + + if (!_a || !format_supports_encryption) { + /* Format in general doesn't support encryption */ + return ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED; + } + + /* A reader potentially has read enough data now. */ + if (a->format && a->format->has_encrypted_entries) { + return (a->format->has_encrypted_entries)(a); + } + + /* For any other reason we cannot say how many entries are there. */ + return ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW; +} + +/* + * Returns a bitmask of capabilities that are supported by the archive format reader. + * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned. + */ +int +archive_read_format_capabilities(struct archive *_a) +{ + struct archive_read *a = (struct archive_read *)_a; + if (a && a->format && a->format->format_capabilties) { + return (a->format->format_capabilties)(a); + } + return ARCHIVE_READ_FORMAT_CAPS_NONE; +} + +/* * Read data from an archive entry, using a read(2)-style interface. * This is a convenience routine that just calls * archive_read_data_block and copies the results into the client @@ -1094,7 +1147,9 @@ __archive_read_register_format(struct archive_read *a, int (*read_data)(struct archive_read *, const void **, size_t *, int64_t *), int (*read_data_skip)(struct archive_read *), int64_t (*seek_data)(struct archive_read *, int64_t, int), - int (*cleanup)(struct archive_read *)) + int (*cleanup)(struct archive_read *), + int (*format_capabilities)(struct archive_read *), + int (*has_encrypted_entries)(struct archive_read *)) { int i, number_slots; @@ -1117,6 +1172,8 @@ __archive_read_register_format(struct archive_read *a, a->formats[i].cleanup = cleanup; a->formats[i].data = format_data; a->formats[i].name = name; + a->formats[i].format_capabilties = format_capabilities; + a->formats[i].has_encrypted_entries = has_encrypted_entries; return (ARCHIVE_OK); } } @@ -1557,10 +1614,9 @@ __archive_read_filter_seek(struct archive_read_filter *filter, int64_t offset, client->dataset[++cursor].begin_position = r; } offset -= client->dataset[cursor].begin_position; - if (offset < 0) - offset = 0; - else if (offset > client->dataset[cursor].total_size - 1) - offset = client->dataset[cursor].total_size - 1; + if (offset < 0 + || offset > client->dataset[cursor].total_size) + return ARCHIVE_FATAL; if ((r = client_seek_proxy(filter, offset, SEEK_SET)) < 0) return r; break; diff --git a/libarchive/archive_read_disk_entry_from_file.c b/libarchive/archive_read_disk_entry_from_file.c index e984aaa..e81cbec 100644 --- a/libarchive/archive_read_disk_entry_from_file.c +++ b/libarchive/archive_read_disk_entry_from_file.c @@ -399,7 +399,7 @@ setup_mac_metadata(struct archive_read_disk *a, #endif -#if defined(HAVE_POSIX_ACL) && defined(ACL_TYPE_NFS4) +#ifdef HAVE_POSIX_ACL static int translate_acl(struct archive_read_disk *a, struct archive_entry *entry, acl_t acl, int archive_entry_acl_type); @@ -419,6 +419,7 @@ setup_acls(struct archive_read_disk *a, archive_entry_acl_clear(entry); +#ifdef ACL_TYPE_NFS4 /* Try NFS4 ACL first. */ if (*fd >= 0) acl = acl_get_fd(*fd); @@ -447,6 +448,7 @@ setup_acls(struct archive_read_disk *a, acl_free(acl); return (ARCHIVE_OK); } +#endif /* Retrieve access ACL from file. */ if (*fd >= 0) @@ -492,6 +494,7 @@ static struct { {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE}, {ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE}, {ARCHIVE_ENTRY_ACL_READ, ACL_READ}, +#ifdef ACL_TYPE_NFS4 {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA}, {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY}, {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA}, @@ -508,8 +511,10 @@ static struct { {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_ACL}, {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_WRITE_OWNER}, {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE} +#endif }; +#ifdef ACL_TYPE_NFS4 static struct { int archive_inherit; int platform_inherit; @@ -519,21 +524,25 @@ static struct { {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_NO_PROPAGATE_INHERIT}, {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY} }; - +#endif static int translate_acl(struct archive_read_disk *a, struct archive_entry *entry, acl_t acl, int default_entry_acl_type) { acl_tag_t acl_tag; +#ifdef ACL_TYPE_NFS4 acl_entry_type_t acl_type; acl_flagset_t acl_flagset; + int brand, r; +#endif acl_entry_t acl_entry; acl_permset_t acl_permset; - int brand, i, r, entry_acl_type; + int i, entry_acl_type; int s, ae_id, ae_tag, ae_perm; const char *ae_name; +#ifdef ACL_TYPE_NFS4 // FreeBSD "brands" ACLs as POSIX.1e or NFSv4 // Make sure the "brand" on this ACL is consistent // with the default_entry_acl_type bits provided. @@ -560,6 +569,7 @@ translate_acl(struct archive_read_disk *a, return ARCHIVE_FAILED; break; } +#endif s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry); @@ -592,9 +602,11 @@ translate_acl(struct archive_read_disk *a, case ACL_OTHER: ae_tag = ARCHIVE_ENTRY_ACL_OTHER; break; +#ifdef ACL_TYPE_NFS4 case ACL_EVERYONE: ae_tag = ARCHIVE_ENTRY_ACL_EVERYONE; break; +#endif default: /* Skip types that libarchive can't support. */ s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry); @@ -605,6 +617,7 @@ translate_acl(struct archive_read_disk *a, // XXX acl_get_entry_type_np on FreeBSD returns EINVAL for // non-NFSv4 ACLs entry_acl_type = default_entry_acl_type; +#ifdef ACL_TYPE_NFS4 r = acl_get_entry_type_np(acl_entry, &acl_type); if (r == 0) { switch (acl_type) { @@ -634,9 +647,10 @@ translate_acl(struct archive_read_disk *a, ae_perm |= acl_inherit_map[i].archive_inherit; } +#endif acl_get_permset(acl_entry, &acl_permset); - for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) { + for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) { /* * acl_get_perm() is spelled differently on different * platforms; see above. diff --git a/libarchive/archive_read_disk_posix.c b/libarchive/archive_read_disk_posix.c index a13dbbf..94eb5e7 100644 --- a/libarchive/archive_read_disk_posix.c +++ b/libarchive/archive_read_disk_posix.c @@ -1973,7 +1973,7 @@ tree_dup(int fd) static volatile int can_dupfd_cloexec = 1; if (can_dupfd_cloexec) { - new_fd = fcntl(fd, F_DUPFD_CLOEXEC); + new_fd = fcntl(fd, F_DUPFD_CLOEXEC, 0); if (new_fd != -1) return (new_fd); /* Linux 2.6.18 - 2.6.23 declare F_DUPFD_CLOEXEC, diff --git a/libarchive/archive_read_disk_windows.c b/libarchive/archive_read_disk_windows.c index 9c5420d..5c0f366 100644 --- a/libarchive/archive_read_disk_windows.c +++ b/libarchive/archive_read_disk_windows.c @@ -929,7 +929,7 @@ next_entry(struct archive_read_disk *a, struct tree *t, else flags |= FILE_FLAG_SEQUENTIAL_SCAN; t->entry_fh = CreateFileW(tree_current_access_path(t), - GENERIC_READ, 0, NULL, OPEN_EXISTING, flags, NULL); + GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, flags, NULL); if (t->entry_fh == INVALID_HANDLE_VALUE) { archive_set_error(&a->archive, errno, "Couldn't open %ls", tree_current_path(a->tree)); @@ -1886,7 +1886,7 @@ tree_current_file_information(struct tree *t, BY_HANDLE_FILE_INFORMATION *st, if (sim_lstat && tree_current_is_physical_link(t)) flag |= FILE_FLAG_OPEN_REPARSE_POINT; - h = CreateFileW(tree_current_access_path(t), 0, 0, NULL, + h = CreateFileW(tree_current_access_path(t), 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, flag, NULL); if (h == INVALID_HANDLE_VALUE) { la_dosmaperr(GetLastError()); @@ -2115,7 +2115,7 @@ archive_read_disk_entry_from_file(struct archive *_a, } else desiredAccess = GENERIC_READ; - h = CreateFileW(path, desiredAccess, 0, NULL, + h = CreateFileW(path, desiredAccess, FILE_SHARE_READ, NULL, OPEN_EXISTING, flag, NULL); if (h == INVALID_HANDLE_VALUE) { la_dosmaperr(GetLastError()); @@ -2162,7 +2162,7 @@ archive_read_disk_entry_from_file(struct archive *_a, if (fd >= 0) { h = (HANDLE)_get_osfhandle(fd); } else { - h = CreateFileW(path, GENERIC_READ, 0, NULL, + h = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); if (h == INVALID_HANDLE_VALUE) { la_dosmaperr(GetLastError()); diff --git a/libarchive/archive_read_open_filename.c b/libarchive/archive_read_open_filename.c index fefcd90..622c960 100644 --- a/libarchive/archive_read_open_filename.c +++ b/libarchive/archive_read_open_filename.c @@ -103,7 +103,9 @@ int archive_read_open_filename(struct archive *a, const char *filename, size_t block_size) { - const char *filenames[2] = { filename, NULL }; + const char *filenames[2]; + filenames[0] = filename; + filenames[1] = NULL; return archive_read_open_filenames(a, filenames, block_size); } diff --git a/libarchive/archive_read_private.h b/libarchive/archive_read_private.h index 8a6c859..6636a59 100644 --- a/libarchive/archive_read_private.h +++ b/libarchive/archive_read_private.h @@ -207,6 +207,8 @@ struct archive_read { int (*read_data_skip)(struct archive_read *); int64_t (*seek_data)(struct archive_read *, int64_t, int); int (*cleanup)(struct archive_read *); + int (*format_capabilties)(struct archive_read *); + int (*has_encrypted_entries)(struct archive_read *); } formats[16]; struct archive_format_descriptor *format; /* Active format. */ @@ -218,15 +220,17 @@ struct archive_read { }; int __archive_read_register_format(struct archive_read *a, - void *format_data, - const char *name, - int (*bid)(struct archive_read *, int), - int (*options)(struct archive_read *, const char *, const char *), - int (*read_header)(struct archive_read *, struct archive_entry *), - int (*read_data)(struct archive_read *, const void **, size_t *, int64_t *), - int (*read_data_skip)(struct archive_read *), - int64_t (*seek_data)(struct archive_read *, int64_t, int), - int (*cleanup)(struct archive_read *)); + void *format_data, + const char *name, + int (*bid)(struct archive_read *, int), + int (*options)(struct archive_read *, const char *, const char *), + int (*read_header)(struct archive_read *, struct archive_entry *), + int (*read_data)(struct archive_read *, const void **, size_t *, int64_t *), + int (*read_data_skip)(struct archive_read *), + int64_t (*seek_data)(struct archive_read *, int64_t, int), + int (*cleanup)(struct archive_read *), + int (*format_capabilities)(struct archive_read *), + int (*has_encrypted_entries)(struct archive_read *)); int __archive_read_get_bidder(struct archive_read *a, struct archive_read_filter_bidder **bidder); diff --git a/libarchive/archive_read_set_options.3 b/libarchive/archive_read_set_options.3 index 6fe9f90..1a251ce 100644 --- a/libarchive/archive_read_set_options.3 +++ b/libarchive/archive_read_set_options.3 @@ -193,6 +193,28 @@ Defaults to enabled, use .Cm !rockridge to disable. .El +.It Format tar +.Bl -tag -compact -width indent +.It Cm compat-2x +Libarchive 2.x incorrectly encoded Unicode filenames on +some platforms. +This option mimics the libarchive 2.x filename handling +so that such archives can be read correctly. +.It Cm hdrcharset +The value is used as a character set name that will be +used when translating filenames. +.It Cm mac-ext +Support Mac OS metadata extension that records data in special +files beginning with a period and underscore. +Defaults to enabled on Mac OS, disabled on other platforms. +Use +.Cm !mac-ext +to disable. +.It Cm read_concatenated_archives +Ignore zeroed blocks in the archive, which occurs when multiple tar archives +have been concatenated together. Without this option, only the contents of +the first concatenated archive would be read. +.El .El .\" .Sh ERRORS diff --git a/libarchive/archive_read_set_options.c b/libarchive/archive_read_set_options.c index 793f8f7..46678b1 100644 --- a/libarchive/archive_read_set_options.c +++ b/libarchive/archive_read_set_options.c @@ -78,7 +78,7 @@ archive_set_format_option(struct archive *_a, const char *m, const char *o, struct archive_read *a = (struct archive_read *)_a; struct archive_format_descriptor *format; size_t i; - int r, rv = ARCHIVE_WARN; + int r, rv = ARCHIVE_WARN, matched_modules = 0; for (i = 0; i < sizeof(a->formats)/sizeof(a->formats[0]); i++) { format = &a->formats[i]; @@ -86,8 +86,11 @@ archive_set_format_option(struct archive *_a, const char *m, const char *o, format->name == NULL) /* This format does not support option. */ continue; - if (m != NULL && strcmp(format->name, m) != 0) - continue; + if (m != NULL) { + if (strcmp(format->name, m) != 0) + continue; + ++matched_modules; + } a->format = format; r = format->options(a, o, v); @@ -96,16 +99,13 @@ archive_set_format_option(struct archive *_a, const char *m, const char *o, if (r == ARCHIVE_FATAL) return (ARCHIVE_FATAL); - if (m != NULL) - return (r); - if (r == ARCHIVE_OK) rv = ARCHIVE_OK; } /* If the format name didn't match, return a special code for * _archive_set_option[s]. */ - if (rv == ARCHIVE_WARN && m != NULL) - rv = ARCHIVE_WARN - 1; + if (m != NULL && matched_modules == 0) + return ARCHIVE_WARN - 1; return (rv); } @@ -116,7 +116,7 @@ archive_set_filter_option(struct archive *_a, const char *m, const char *o, struct archive_read *a = (struct archive_read *)_a; struct archive_read_filter *filter; struct archive_read_filter_bidder *bidder; - int r, rv = ARCHIVE_WARN; + int r, rv = ARCHIVE_WARN, matched_modules = 0; for (filter = a->filter; filter != NULL; filter = filter->upstream) { bidder = filter->bidder; @@ -125,24 +125,24 @@ archive_set_filter_option(struct archive *_a, const char *m, const char *o, if (bidder->options == NULL) /* This bidder does not support option */ continue; - if (m != NULL && strcmp(filter->name, m) != 0) - continue; + if (m != NULL) { + if (strcmp(filter->name, m) != 0) + continue; + ++matched_modules; + } r = bidder->options(bidder, o, v); if (r == ARCHIVE_FATAL) return (ARCHIVE_FATAL); - if (m != NULL) - return (r); - if (r == ARCHIVE_OK) rv = ARCHIVE_OK; } /* If the filter name didn't match, return a special code for * _archive_set_option[s]. */ - if (rv == ARCHIVE_WARN && m != NULL) - rv = ARCHIVE_WARN - 1; + if (m != NULL && matched_modules == 0) + return ARCHIVE_WARN - 1; return (rv); } diff --git a/libarchive/archive_read_support_filter_lzop.c b/libarchive/archive_read_support_filter_lzop.c index 713af31..f8d04bd 100644 --- a/libarchive/archive_read_support_filter_lzop.c +++ b/libarchive/archive_read_support_filter_lzop.c @@ -242,10 +242,11 @@ consume_header(struct archive_read_filter *self) if (version >= 0x940) { unsigned level = *p++; - if (method == 1 && level == 0) level = 3; - if (method == 2 && level == 0) level = 1; - if (method == 3 && level == 0) level = 9; - if (level < 1 && level > 9) { + unsigned default_level[] = {0, 3, 1, 9}; + if (level == 0) + /* Method is 1..3 here due to check above. */ + level = default_level[method]; + else if (level > 9) { archive_set_error(&self->archive->archive, ARCHIVE_ERRNO_MISC, "Invalid level"); return (ARCHIVE_FAILED); diff --git a/libarchive/archive_read_support_filter_xz.c b/libarchive/archive_read_support_filter_xz.c index 15824b1..7bda263 100644 --- a/libarchive/archive_read_support_filter_xz.c +++ b/libarchive/archive_read_support_filter_xz.c @@ -601,7 +601,7 @@ lzip_init(struct archive_read_filter *self) return (ARCHIVE_FATAL); } ret = lzma_raw_decoder(&(state->stream), filters); -#if LZMA_VERSION < 50000030 +#if LZMA_VERSION < 50010000 free(filters[0].options); #endif if (ret != LZMA_OK) { diff --git a/libarchive/archive_read_support_format_7zip.c b/libarchive/archive_read_support_format_7zip.c index 194b8d5..c69d873 100644 --- a/libarchive/archive_read_support_format_7zip.c +++ b/libarchive/archive_read_support_format_7zip.c @@ -69,7 +69,11 @@ __FBSDID("$FreeBSD$"); #define _7Z_BZ2 0x040202 #define _7Z_PPMD 0x030401 #define _7Z_DELTA 0x03 -#define _7Z_CRYPTO 0x06F10701 +#define _7Z_CRYPTO_MAIN_ZIP 0x06F10101 /* Main Zip crypto algo */ +#define _7Z_CRYPTO_RAR_29 0x06F10303 /* Rar29 AES-128 + (modified SHA-1) */ +#define _7Z_CRYPTO_AES_256_SHA_256 0x06F10701 /* AES-256 + SHA-256 */ + + #define _7Z_X86 0x03030103 #define _7Z_X86_BCJ2 0x0303011B #define _7Z_POWERPC 0x03030205 @@ -322,8 +326,13 @@ struct _7zip { struct archive_string_conv *sconv; char format_name[64]; + + /* Custom value that is non-zero if this archive contains encrypted entries. */ + int has_encrypted_entries; }; +static int archive_read_format_7zip_has_encrypted_entries(struct archive_read *); +static int archive_read_support_format_7zip_capabilities(struct archive_read *a); static int archive_read_format_7zip_bid(struct archive_read *, int); static int archive_read_format_7zip_cleanup(struct archive_read *); static int archive_read_format_7zip_read_data(struct archive_read *, @@ -401,6 +410,13 @@ archive_read_support_format_7zip(struct archive *_a) return (ARCHIVE_FATAL); } + /* + * Until enough data has been read, we cannot tell about + * any encrypted entries yet. + */ + zip->has_encrypted_entries = ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW; + + r = __archive_read_register_format(a, zip, "7zip", @@ -410,7 +426,9 @@ archive_read_support_format_7zip(struct archive *_a) archive_read_format_7zip_read_data, archive_read_format_7zip_read_data_skip, NULL, - archive_read_format_7zip_cleanup); + archive_read_format_7zip_cleanup, + archive_read_support_format_7zip_capabilities, + archive_read_format_7zip_has_encrypted_entries); if (r != ARCHIVE_OK) free(zip); @@ -418,6 +436,27 @@ archive_read_support_format_7zip(struct archive *_a) } static int +archive_read_support_format_7zip_capabilities(struct archive_read * a) +{ + (void)a; /* UNUSED */ + return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA | + ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA); +} + + +static int +archive_read_format_7zip_has_encrypted_entries(struct archive_read *_a) +{ + if (_a && _a->format) { + struct _7zip * zip = (struct _7zip *)_a->format->data; + if (zip) { + return zip->has_encrypted_entries; + } + } + return ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW; +} + +static int archive_read_format_7zip_bid(struct archive_read *a, int best_bid) { const char *p; @@ -476,7 +515,7 @@ check_7zip_header_in_sfx(const char *p) switch ((unsigned char)p[5]) { case 0x1C: if (memcmp(p, _7ZIP_SIGNATURE, 6) != 0) - return (6); + return (6); /* * Test the CRC because its extraction code has 7-Zip * Magic Code, so we should do this in order not to @@ -484,15 +523,15 @@ check_7zip_header_in_sfx(const char *p) */ if (crc32(0, (const unsigned char *)p + 12, 20) != archive_le32dec(p + 8)) - return (6); + return (6); /* Hit the header! */ return (0); - case 0x37: return (5); - case 0x7A: return (4); - case 0xBC: return (3); - case 0xAF: return (2); - case 0x27: return (1); - default: return (6); + case 0x37: return (5); + case 0x7A: return (4); + case 0xBC: return (3); + case 0xAF: return (2); + case 0x27: return (1); + default: return (6); } } @@ -568,6 +607,19 @@ archive_read_format_7zip_read_header(struct archive_read *a, struct _7zip *zip = (struct _7zip *)a->format->data; struct _7zip_entry *zip_entry; int r, ret = ARCHIVE_OK; + struct _7z_folder *folder = 0; + uint64_t fidx = 0; + + /* + * It should be sufficient to call archive_read_next_header() for + * a reader to determine if an entry is encrypted or not. If the + * encryption of an entry is only detectable when calling + * archive_read_data(), so be it. We'll do the same check there + * as well. + */ + if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) { + zip->has_encrypted_entries = 0; + } a->archive.archive_format = ARCHIVE_FORMAT_7ZIP; if (a->archive.archive_format_name == NULL) @@ -604,6 +656,32 @@ archive_read_format_7zip_read_header(struct archive_read *a, return (ARCHIVE_FATAL); } + /* Figure out if the entry is encrypted by looking at the folder + that is associated to the current 7zip entry. If the folder + has a coder with a _7Z_CRYPTO codec then the folder is encrypted. + Hence the entry must also be encrypted. */ + if (zip_entry && zip_entry->folderIndex < zip->si.ci.numFolders) { + folder = &(zip->si.ci.folders[zip_entry->folderIndex]); + for (fidx=0; folder && fidxnumCoders; fidx++) { + switch(folder->coders[fidx].codec) { + case _7Z_CRYPTO_MAIN_ZIP: + case _7Z_CRYPTO_RAR_29: + case _7Z_CRYPTO_AES_256_SHA_256: { + archive_entry_set_is_data_encrypted(entry, 1); + zip->has_encrypted_entries = 1; + break; + } + } + } + } + + /* Now that we've checked for encryption, if there were still no + * encrypted entries found we can say for sure that there are none. + */ + if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) { + zip->has_encrypted_entries = 0; + } + if (archive_entry_copy_pathname_l(entry, (const char *)zip_entry->utf16name, zip_entry->name_len, zip->sconv) != 0) { @@ -707,6 +785,10 @@ archive_read_format_7zip_read_data(struct archive_read *a, zip = (struct _7zip *)(a->format->data); + if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) { + zip->has_encrypted_entries = 0; + } + if (zip->pack_stream_bytes_unconsumed) read_consume(a); @@ -969,7 +1051,7 @@ init_decompression(struct archive_read *a, struct _7zip *zip, { lzma_options_delta delta_opt; lzma_filter filters[LZMA_FILTERS_MAX]; -#if LZMA_VERSION < 50000030 +#if LZMA_VERSION < 50010000 lzma_filter *ff; #endif int fi = 0; @@ -994,7 +1076,7 @@ init_decompression(struct archive_read *a, struct _7zip *zip, * for BCJ+LZMA. If we were able to tell the uncompressed * size to liblzma when using lzma_raw_decoder() liblzma * could correctly deal with BCJ+LZMA. But unfortunately - * there is no way to do that. + * there is no way to do that. * Discussion about this can be found at XZ Utils forum. */ if (coder2 != NULL) { @@ -1056,7 +1138,7 @@ init_decompression(struct archive_read *a, struct _7zip *zip, else filters[fi].id = LZMA_FILTER_LZMA1; filters[fi].options = NULL; -#if LZMA_VERSION < 50000030 +#if LZMA_VERSION < 50010000 ff = &filters[fi]; #endif r = lzma_properties_decode(&filters[fi], NULL, @@ -1070,7 +1152,7 @@ init_decompression(struct archive_read *a, struct _7zip *zip, filters[fi].id = LZMA_VLI_UNKNOWN; filters[fi].options = NULL; r = lzma_raw_decoder(&(zip->lzstream), filters); -#if LZMA_VERSION < 50000030 +#if LZMA_VERSION < 50010000 free(ff->options); #endif if (r != LZMA_OK) { @@ -1203,6 +1285,17 @@ init_decompression(struct archive_read *a, struct _7zip *zip, archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Unexpected codec ID: %lX", zip->codec); return (ARCHIVE_FAILED); + case _7Z_CRYPTO_MAIN_ZIP: + case _7Z_CRYPTO_RAR_29: + case _7Z_CRYPTO_AES_256_SHA_256: + if (a->entry) { + archive_entry_set_is_metadata_encrypted(a->entry, 1); + archive_entry_set_is_data_encrypted(a->entry, 1); + zip->has_encrypted_entries = 1; + } + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "Crypto codec not supported yet (ID: 0x%lX)", zip->codec); + return (ARCHIVE_FAILED); default: archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Unknown codec ID: %lX", zip->codec); @@ -1426,7 +1519,7 @@ decompress(struct archive_read *a, struct _7zip *zip, do { int sym; - + sym = __archive_ppmd7_functions.Ppmd7_DecodeSymbol( &(zip->ppmd7_context), &(zip->range_dec.p)); if (sym < 0) { @@ -2755,6 +2848,7 @@ slurp_central_directory(struct archive_read *a, struct _7zip *zip, zip->header_crc32 = 0; zip->header_is_encoded = 0; zip->header_is_being_read = 1; + zip->has_encrypted_entries = 0; check_header_crc = 1; if ((p = header_bytes(a, 1)) == NULL) { @@ -3170,7 +3264,7 @@ read_stream(struct archive_read *a, const void **buff, size_t size, return (r); /* - * Skip the bytes we alrady has skipped in skip_stream(). + * Skip the bytes we alrady has skipped in skip_stream(). */ while (skip_bytes) { ssize_t skipped; @@ -3235,16 +3329,36 @@ setup_decode_folder(struct archive_read *a, struct _7z_folder *folder, * Check coder types. */ for (i = 0; i < folder->numCoders; i++) { - if (folder->coders[i].codec == _7Z_CRYPTO) { - archive_set_error(&(a->archive), - ARCHIVE_ERRNO_MISC, - "The %s is encrypted, " - "but currently not supported", cname); - return (ARCHIVE_FATAL); + switch(folder->coders[i].codec) { + case _7Z_CRYPTO_MAIN_ZIP: + case _7Z_CRYPTO_RAR_29: + case _7Z_CRYPTO_AES_256_SHA_256: { + /* For entry that is associated with this folder, mark + it as encrypted (data+metadata). */ + zip->has_encrypted_entries = 1; + if (a->entry) { + archive_entry_set_is_data_encrypted(a->entry, 1); + archive_entry_set_is_metadata_encrypted(a->entry, 1); + } + archive_set_error(&(a->archive), + ARCHIVE_ERRNO_MISC, + "The %s is encrypted, " + "but currently not supported", cname); + return (ARCHIVE_FATAL); + } + case _7Z_X86_BCJ2: { + found_bcj2++; + break; + } } - if (folder->coders[i].codec == _7Z_X86_BCJ2) - found_bcj2++; } + /* Now that we've checked for encryption, if there were still no + * encrypted entries found we can say for sure that there are none. + */ + if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) { + zip->has_encrypted_entries = 0; + } + if ((folder->numCoders > 2 && !found_bcj2) || found_bcj2 > 1) { archive_set_error(&(a->archive), ARCHIVE_ERRNO_MISC, diff --git a/libarchive/archive_read_support_format_ar.c b/libarchive/archive_read_support_format_ar.c index 40be18c..82756c9 100644 --- a/libarchive/archive_read_support_format_ar.c +++ b/libarchive/archive_read_support_format_ar.c @@ -122,7 +122,9 @@ archive_read_support_format_ar(struct archive *_a) archive_read_format_ar_read_data, archive_read_format_ar_skip, NULL, - archive_read_format_ar_cleanup); + archive_read_format_ar_cleanup, + NULL, + NULL); if (r != ARCHIVE_OK) { free(ar); diff --git a/libarchive/archive_read_support_format_cab.c b/libarchive/archive_read_support_format_cab.c index 3c9f94c..fc70684 100644 --- a/libarchive/archive_read_support_format_cab.c +++ b/libarchive/archive_read_support_format_cab.c @@ -383,7 +383,9 @@ archive_read_support_format_cab(struct archive *_a) archive_read_format_cab_read_data, archive_read_format_cab_read_data_skip, NULL, - archive_read_format_cab_cleanup); + archive_read_format_cab_cleanup, + NULL, + NULL); if (r != ARCHIVE_OK) free(cab); diff --git a/libarchive/archive_read_support_format_cpio.c b/libarchive/archive_read_support_format_cpio.c index 819f4a4..0b69689 100644 --- a/libarchive/archive_read_support_format_cpio.c +++ b/libarchive/archive_read_support_format_cpio.c @@ -243,7 +243,9 @@ archive_read_support_format_cpio(struct archive *_a) archive_read_format_cpio_read_data, archive_read_format_cpio_skip, NULL, - archive_read_format_cpio_cleanup); + archive_read_format_cpio_cleanup, + NULL, + NULL); if (r != ARCHIVE_OK) free(cpio); diff --git a/libarchive/archive_read_support_format_empty.c b/libarchive/archive_read_support_format_empty.c index 3660738..c641eb9 100644 --- a/libarchive/archive_read_support_format_empty.c +++ b/libarchive/archive_read_support_format_empty.c @@ -54,6 +54,8 @@ archive_read_support_format_empty(struct archive *_a) archive_read_format_empty_read_data, NULL, NULL, + NULL, + NULL, NULL); return (r); diff --git a/libarchive/archive_read_support_format_iso9660.c b/libarchive/archive_read_support_format_iso9660.c index 914bc71..86d07fe 100644 --- a/libarchive/archive_read_support_format_iso9660.c +++ b/libarchive/archive_read_support_format_iso9660.c @@ -478,7 +478,9 @@ archive_read_support_format_iso9660(struct archive *_a) archive_read_format_iso9660_read_data, archive_read_format_iso9660_read_data_skip, NULL, - archive_read_format_iso9660_cleanup); + archive_read_format_iso9660_cleanup, + NULL, + NULL); if (r != ARCHIVE_OK) { free(iso9660); diff --git a/libarchive/archive_read_support_format_lha.c b/libarchive/archive_read_support_format_lha.c index f702949..b88731a 100644 --- a/libarchive/archive_read_support_format_lha.c +++ b/libarchive/archive_read_support_format_lha.c @@ -320,7 +320,9 @@ archive_read_support_format_lha(struct archive *_a) archive_read_format_lha_read_data, archive_read_format_lha_read_data_skip, NULL, - archive_read_format_lha_cleanup); + archive_read_format_lha_cleanup, + NULL, + NULL); if (r != ARCHIVE_OK) free(lha); diff --git a/libarchive/archive_read_support_format_mtree.c b/libarchive/archive_read_support_format_mtree.c index c4e7021..d82d4c1 100644 --- a/libarchive/archive_read_support_format_mtree.c +++ b/libarchive/archive_read_support_format_mtree.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_mtree.c 2011 #include "archive_private.h" #include "archive_read_private.h" #include "archive_string.h" +#include "archive_pack_dev.h" #ifndef O_BINARY #define O_BINARY 0 @@ -103,6 +104,7 @@ struct mtree { struct archive_entry_linkresolver *resolver; int64_t cur_size; + char checkfs; }; static int bid_keycmp(const char *, const char *, ssize_t); @@ -173,6 +175,29 @@ get_time_t_min(void) #endif } +static int +archive_read_format_mtree_options(struct archive_read *a, + const char *key, const char *val) +{ + struct mtree *mtree; + + mtree = (struct mtree *)(a->format->data); + if (strcmp(key, "checkfs") == 0) { + /* Allows to read information missing from the mtree from the file system */ + if (val == NULL || val[0] == 0) { + mtree->checkfs = 0; + } else { + mtree->checkfs = 1; + } + return (ARCHIVE_OK); + } + + /* Note: The "warn" return is just to inform the options + * supervisor that we didn't handle it. It will generate + * a suitable error if no one used this option. */ + return (ARCHIVE_WARN); +} + static void free_options(struct mtree_option *head) { @@ -205,7 +230,7 @@ archive_read_support_format_mtree(struct archive *_a) mtree->fd = -1; r = __archive_read_register_format(a, mtree, "mtree", - mtree_bid, NULL, read_header, read_data, skip, NULL, cleanup); + mtree_bid, archive_read_format_mtree_options, read_header, read_data, skip, NULL, cleanup, NULL, NULL); if (r != ARCHIVE_OK) free(mtree); @@ -367,7 +392,7 @@ bid_keyword(const char *p, ssize_t len) "gid", "gname", NULL }; static const char *keys_il[] = { - "ignore", "link", NULL + "ignore", "inode", "link", NULL }; static const char *keys_m[] = { "md5", "md5digest", "mode", NULL @@ -376,7 +401,7 @@ bid_keyword(const char *p, ssize_t len) "nlink", "nochange", "optional", NULL }; static const char *keys_r[] = { - "rmd160", "rmd160digest", NULL + "resdevice", "rmd160", "rmd160digest", NULL }; static const char *keys_s[] = { "sha1", "sha1digest", @@ -1103,162 +1128,164 @@ parse_file(struct archive_read *a, struct archive_entry *entry, mtree->current_dir.length = n; } - /* - * Try to open and stat the file to get the real size - * and other file info. It would be nice to avoid - * this here so that getting a listing of an mtree - * wouldn't require opening every referenced contents - * file. But then we wouldn't know the actual - * contents size, so I don't see a really viable way - * around this. (Also, we may want to someday pull - * other unspecified info from the contents file on - * disk.) - */ - mtree->fd = -1; - if (archive_strlen(&mtree->contents_name) > 0) - path = mtree->contents_name.s; - else - path = archive_entry_pathname(entry); - - if (archive_entry_filetype(entry) == AE_IFREG || - archive_entry_filetype(entry) == AE_IFDIR) { - mtree->fd = open(path, O_RDONLY | O_BINARY | O_CLOEXEC); - __archive_ensure_cloexec_flag(mtree->fd); - if (mtree->fd == -1 && - (errno != ENOENT || - archive_strlen(&mtree->contents_name) > 0)) { - archive_set_error(&a->archive, errno, - "Can't open %s", path); - r = ARCHIVE_WARN; + if (mtree->checkfs) { + /* + * Try to open and stat the file to get the real size + * and other file info. It would be nice to avoid + * this here so that getting a listing of an mtree + * wouldn't require opening every referenced contents + * file. But then we wouldn't know the actual + * contents size, so I don't see a really viable way + * around this. (Also, we may want to someday pull + * other unspecified info from the contents file on + * disk.) + */ + mtree->fd = -1; + if (archive_strlen(&mtree->contents_name) > 0) + path = mtree->contents_name.s; + else + path = archive_entry_pathname(entry); + + if (archive_entry_filetype(entry) == AE_IFREG || + archive_entry_filetype(entry) == AE_IFDIR) { + mtree->fd = open(path, O_RDONLY | O_BINARY | O_CLOEXEC); + __archive_ensure_cloexec_flag(mtree->fd); + if (mtree->fd == -1 && + (errno != ENOENT || + archive_strlen(&mtree->contents_name) > 0)) { + archive_set_error(&a->archive, errno, + "Can't open %s", path); + r = ARCHIVE_WARN; + } } - } - st = &st_storage; - if (mtree->fd >= 0) { - if (fstat(mtree->fd, st) == -1) { - archive_set_error(&a->archive, errno, - "Could not fstat %s", path); - r = ARCHIVE_WARN; - /* If we can't stat it, don't keep it open. */ - close(mtree->fd); - mtree->fd = -1; + st = &st_storage; + if (mtree->fd >= 0) { + if (fstat(mtree->fd, st) == -1) { + archive_set_error(&a->archive, errno, + "Could not fstat %s", path); + r = ARCHIVE_WARN; + /* If we can't stat it, don't keep it open. */ + close(mtree->fd); + mtree->fd = -1; + st = NULL; + } + } else if (lstat(path, st) == -1) { st = NULL; } - } else if (lstat(path, st) == -1) { - st = NULL; - } - /* - * Check for a mismatch between the type in the specification and - * the type of the contents object on disk. - */ - if (st != NULL) { - if ( - ((st->st_mode & S_IFMT) == S_IFREG && - archive_entry_filetype(entry) == AE_IFREG) + /* + * Check for a mismatch between the type in the specification and + * the type of the contents object on disk. + */ + if (st != NULL) { + if ( + ((st->st_mode & S_IFMT) == S_IFREG && + archive_entry_filetype(entry) == AE_IFREG) #ifdef S_IFLNK - || ((st->st_mode & S_IFMT) == S_IFLNK && - archive_entry_filetype(entry) == AE_IFLNK) + || ((st->st_mode & S_IFMT) == S_IFLNK && + archive_entry_filetype(entry) == AE_IFLNK) #endif #ifdef S_IFSOCK - || ((st->st_mode & S_IFSOCK) == S_IFSOCK && - archive_entry_filetype(entry) == AE_IFSOCK) + || ((st->st_mode & S_IFSOCK) == S_IFSOCK && + archive_entry_filetype(entry) == AE_IFSOCK) #endif #ifdef S_IFCHR - || ((st->st_mode & S_IFMT) == S_IFCHR && - archive_entry_filetype(entry) == AE_IFCHR) + || ((st->st_mode & S_IFMT) == S_IFCHR && + archive_entry_filetype(entry) == AE_IFCHR) #endif #ifdef S_IFBLK - || ((st->st_mode & S_IFMT) == S_IFBLK && - archive_entry_filetype(entry) == AE_IFBLK) + || ((st->st_mode & S_IFMT) == S_IFBLK && + archive_entry_filetype(entry) == AE_IFBLK) #endif - || ((st->st_mode & S_IFMT) == S_IFDIR && - archive_entry_filetype(entry) == AE_IFDIR) + || ((st->st_mode & S_IFMT) == S_IFDIR && + archive_entry_filetype(entry) == AE_IFDIR) #ifdef S_IFIFO - || ((st->st_mode & S_IFMT) == S_IFIFO && - archive_entry_filetype(entry) == AE_IFIFO) + || ((st->st_mode & S_IFMT) == S_IFIFO && + archive_entry_filetype(entry) == AE_IFIFO) #endif - ) { - /* Types match. */ - } else { - /* Types don't match; bail out gracefully. */ - if (mtree->fd >= 0) - close(mtree->fd); - mtree->fd = -1; - if (parsed_kws & MTREE_HAS_OPTIONAL) { - /* It's not an error for an optional entry - to not match disk. */ - *use_next = 1; - } else if (r == ARCHIVE_OK) { - archive_set_error(&a->archive, - ARCHIVE_ERRNO_MISC, - "mtree specification has different type for %s", - archive_entry_pathname(entry)); - r = ARCHIVE_WARN; - } - return r; + ) { + /* Types match. */ + } else { + /* Types don't match; bail out gracefully. */ + if (mtree->fd >= 0) + close(mtree->fd); + mtree->fd = -1; + if (parsed_kws & MTREE_HAS_OPTIONAL) { + /* It's not an error for an optional entry + to not match disk. */ + *use_next = 1; + } else if (r == ARCHIVE_OK) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_MISC, + "mtree specification has different type for %s", + archive_entry_pathname(entry)); + r = ARCHIVE_WARN; + } + return r; + } } - } - /* - * If there is a contents file on disk, pick some of the metadata - * from that file. For most of these, we only set it from the contents - * if it wasn't already parsed from the specification. - */ - if (st != NULL) { - if (((parsed_kws & MTREE_HAS_DEVICE) == 0 || - (parsed_kws & MTREE_HAS_NOCHANGE) != 0) && - (archive_entry_filetype(entry) == AE_IFCHR || - archive_entry_filetype(entry) == AE_IFBLK)) - archive_entry_set_rdev(entry, st->st_rdev); - if ((parsed_kws & (MTREE_HAS_GID | MTREE_HAS_GNAME)) == 0 || - (parsed_kws & MTREE_HAS_NOCHANGE) != 0) - archive_entry_set_gid(entry, st->st_gid); - if ((parsed_kws & (MTREE_HAS_UID | MTREE_HAS_UNAME)) == 0 || - (parsed_kws & MTREE_HAS_NOCHANGE) != 0) - archive_entry_set_uid(entry, st->st_uid); - if ((parsed_kws & MTREE_HAS_MTIME) == 0 || - (parsed_kws & MTREE_HAS_NOCHANGE) != 0) { + /* + * If there is a contents file on disk, pick some of the metadata + * from that file. For most of these, we only set it from the contents + * if it wasn't already parsed from the specification. + */ + if (st != NULL) { + if (((parsed_kws & MTREE_HAS_DEVICE) == 0 || + (parsed_kws & MTREE_HAS_NOCHANGE) != 0) && + (archive_entry_filetype(entry) == AE_IFCHR || + archive_entry_filetype(entry) == AE_IFBLK)) + archive_entry_set_rdev(entry, st->st_rdev); + if ((parsed_kws & (MTREE_HAS_GID | MTREE_HAS_GNAME)) == 0 || + (parsed_kws & MTREE_HAS_NOCHANGE) != 0) + archive_entry_set_gid(entry, st->st_gid); + if ((parsed_kws & (MTREE_HAS_UID | MTREE_HAS_UNAME)) == 0 || + (parsed_kws & MTREE_HAS_NOCHANGE) != 0) + archive_entry_set_uid(entry, st->st_uid); + if ((parsed_kws & MTREE_HAS_MTIME) == 0 || + (parsed_kws & MTREE_HAS_NOCHANGE) != 0) { #if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC - archive_entry_set_mtime(entry, st->st_mtime, - st->st_mtimespec.tv_nsec); + archive_entry_set_mtime(entry, st->st_mtime, + st->st_mtimespec.tv_nsec); #elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC - archive_entry_set_mtime(entry, st->st_mtime, - st->st_mtim.tv_nsec); + archive_entry_set_mtime(entry, st->st_mtime, + st->st_mtim.tv_nsec); #elif HAVE_STRUCT_STAT_ST_MTIME_N - archive_entry_set_mtime(entry, st->st_mtime, - st->st_mtime_n); + archive_entry_set_mtime(entry, st->st_mtime, + st->st_mtime_n); #elif HAVE_STRUCT_STAT_ST_UMTIME - archive_entry_set_mtime(entry, st->st_mtime, - st->st_umtime*1000); + archive_entry_set_mtime(entry, st->st_mtime, + st->st_umtime*1000); #elif HAVE_STRUCT_STAT_ST_MTIME_USEC - archive_entry_set_mtime(entry, st->st_mtime, - st->st_mtime_usec*1000); + archive_entry_set_mtime(entry, st->st_mtime, + st->st_mtime_usec*1000); #else - archive_entry_set_mtime(entry, st->st_mtime, 0); + archive_entry_set_mtime(entry, st->st_mtime, 0); #endif + } + if ((parsed_kws & MTREE_HAS_NLINK) == 0 || + (parsed_kws & MTREE_HAS_NOCHANGE) != 0) + archive_entry_set_nlink(entry, st->st_nlink); + if ((parsed_kws & MTREE_HAS_PERM) == 0 || + (parsed_kws & MTREE_HAS_NOCHANGE) != 0) + archive_entry_set_perm(entry, st->st_mode); + if ((parsed_kws & MTREE_HAS_SIZE) == 0 || + (parsed_kws & MTREE_HAS_NOCHANGE) != 0) + archive_entry_set_size(entry, st->st_size); + archive_entry_set_ino(entry, st->st_ino); + archive_entry_set_dev(entry, st->st_dev); + + archive_entry_linkify(mtree->resolver, &entry, &sparse_entry); + } else if (parsed_kws & MTREE_HAS_OPTIONAL) { + /* + * Couldn't open the entry, stat it or the on-disk type + * didn't match. If this entry is optional, just ignore it + * and read the next header entry. + */ + *use_next = 1; + return ARCHIVE_OK; } - if ((parsed_kws & MTREE_HAS_NLINK) == 0 || - (parsed_kws & MTREE_HAS_NOCHANGE) != 0) - archive_entry_set_nlink(entry, st->st_nlink); - if ((parsed_kws & MTREE_HAS_PERM) == 0 || - (parsed_kws & MTREE_HAS_NOCHANGE) != 0) - archive_entry_set_perm(entry, st->st_mode); - if ((parsed_kws & MTREE_HAS_SIZE) == 0 || - (parsed_kws & MTREE_HAS_NOCHANGE) != 0) - archive_entry_set_size(entry, st->st_size); - archive_entry_set_ino(entry, st->st_ino); - archive_entry_set_dev(entry, st->st_dev); - - archive_entry_linkify(mtree->resolver, &entry, &sparse_entry); - } else if (parsed_kws & MTREE_HAS_OPTIONAL) { - /* - * Couldn't open the entry, stat it or the on-disk type - * didn't match. If this entry is optional, just ignore it - * and read the next header entry. - */ - *use_next = 1; - return ARCHIVE_OK; } mtree->cur_size = archive_entry_size(entry); @@ -1292,33 +1319,82 @@ parse_line(struct archive_read *a, struct archive_entry *entry, /* * Device entries have one of the following forms: - * raw dev_t - * format,major,minor[,subdevice] - * - * Just use major and minor, no translation etc is done - * between formats. + * - raw dev_t + * - format,major,minor[,subdevice] + * When parsing succeeded, `pdev' will contain the appropriate dev_t value. */ -static int -parse_device(struct archive *a, struct archive_entry *entry, char *val) + +/* strsep() is not in C90, but strcspn() is. */ +/* Taken from http://unixpapa.com/incnote/string.html */ +static char * +la_strsep(char **sp, char *sep) { - char *comma1, *comma2; + char *p, *s; + if (sp == NULL || *sp == NULL || **sp == '\0') + return(NULL); + s = *sp; + p = s + strcspn(s, sep); + if (*p != '\0') + *p++ = '\0'; + *sp = p; + return(s); +} - comma1 = strchr(val, ','); - if (comma1 == NULL) { - archive_entry_set_dev(entry, (dev_t)mtree_atol10(&val)); - return (ARCHIVE_OK); - } - ++comma1; - comma2 = strchr(comma1, ','); - if (comma2 == NULL) { - archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT, - "Malformed device attribute"); - return (ARCHIVE_WARN); +static int +parse_device(dev_t *pdev, struct archive *a, char *val) +{ +#define MAX_PACK_ARGS 3 + unsigned long numbers[MAX_PACK_ARGS]; + char *p, *dev; + int argc; + pack_t *pack; + dev_t result; + const char *error = NULL; + + memset(pdev, 0, sizeof(*pdev)); + if ((dev = strchr(val, ',')) != NULL) { + /* + * Device's major/minor are given in a specified format. + * Decode and pack it accordingly. + */ + *dev++ = '\0'; + if ((pack = pack_find(val)) == NULL) { + archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT, + "Unknown format `%s'", val); + return ARCHIVE_WARN; + } + argc = 0; + while ((p = la_strsep(&dev, ",")) != NULL) { + if (*p == '\0') { + archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT, + "Missing number"); + return ARCHIVE_WARN; + } + numbers[argc++] = mtree_atol(&p); + if (argc > MAX_PACK_ARGS) { + archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT, + "Too many arguments"); + return ARCHIVE_WARN; + } + } + if (argc < 2) { + archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT, + "Not enough arguments"); + return ARCHIVE_WARN; + } + result = (*pack)(argc, numbers, &error); + if (error != NULL) { + archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT, + "%s", error); + return ARCHIVE_WARN; + } + } else { + /* file system raw value. */ + result = (dev_t)mtree_atol(&val); } - ++comma2; - archive_entry_set_rdevmajor(entry, (dev_t)mtree_atol(&comma1)); - archive_entry_set_rdevminor(entry, (dev_t)mtree_atol(&comma2)); - return (ARCHIVE_OK); + *pdev = result; + return ARCHIVE_OK; +#undef MAX_PACK_ARGS } /* @@ -1374,8 +1450,16 @@ parse_keyword(struct archive_read *a, struct mtree *mtree, break; case 'd': if (strcmp(key, "device") == 0) { + /* stat(2) st_rdev field, e.g. the major/minor IDs + * of a char/block special file */ + int r; + dev_t dev; + *parsed_kws |= MTREE_HAS_DEVICE; - return parse_device(&a->archive, entry, val); + r = parse_device(&dev, &a->archive, val); + if (r == ARCHIVE_OK) + archive_entry_set_rdev(entry, dev); + return r; } case 'f': if (strcmp(key, "flags") == 0) { @@ -1394,6 +1478,11 @@ parse_keyword(struct archive_read *a, struct mtree *mtree, archive_entry_copy_gname(entry, val); break; } + case 'i': + if (strcmp(key, "inode") == 0) { + archive_entry_set_ino(entry, mtree_atol10(&val)); + break; + } case 'l': if (strcmp(key, "link") == 0) { archive_entry_copy_symlink(entry, val); @@ -1423,6 +1512,17 @@ parse_keyword(struct archive_read *a, struct mtree *mtree, break; } case 'r': + if (strcmp(key, "resdevice") == 0) { + /* stat(2) st_dev field, e.g. the device ID where the + * inode resides */ + int r; + dev_t dev; + + r = parse_device(&dev, &a->archive, val); + if (r == ARCHIVE_OK) + archive_entry_set_dev(entry, dev); + return r; + } if (strcmp(key, "rmd160") == 0 || strcmp(key, "rmd160digest") == 0) break; diff --git a/libarchive/archive_read_support_format_rar.c b/libarchive/archive_read_support_format_rar.c index 99c57a0..ae302a6 100644 --- a/libarchive/archive_read_support_format_rar.c +++ b/libarchive/archive_read_support_format_rar.c @@ -304,8 +304,15 @@ struct rar ssize_t avail_in; const unsigned char *next_in; } br; + + /* + * Custom field to denote that this archive contains encrypted entries + */ + int has_encrypted_entries; }; +static int archive_read_support_format_rar_capabilities(struct archive_read *); +static int archive_read_format_rar_has_encrypted_entries(struct archive_read *); static int archive_read_format_rar_bid(struct archive_read *, int); static int archive_read_format_rar_options(struct archive_read *, const char *, const char *); @@ -646,6 +653,12 @@ archive_read_support_format_rar(struct archive *_a) } memset(rar, 0, sizeof(*rar)); + /* + * Until enough data has been read, we cannot tell about + * any encrypted entries yet. + */ + rar->has_encrypted_entries = ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW; + r = __archive_read_register_format(a, rar, "rar", @@ -655,7 +668,9 @@ archive_read_support_format_rar(struct archive *_a) archive_read_format_rar_read_data, archive_read_format_rar_read_data_skip, archive_read_format_rar_seek_data, - archive_read_format_rar_cleanup); + archive_read_format_rar_cleanup, + archive_read_support_format_rar_capabilities, + archive_read_format_rar_has_encrypted_entries); if (r != ARCHIVE_OK) free(rar); @@ -663,6 +678,27 @@ archive_read_support_format_rar(struct archive *_a) } static int +archive_read_support_format_rar_capabilities(struct archive_read * a) +{ + (void)a; /* UNUSED */ + return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA + | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA); +} + +static int +archive_read_format_rar_has_encrypted_entries(struct archive_read *_a) +{ + if (_a && _a->format) { + struct rar * rar = (struct rar *)_a->format->data; + if (rar) { + return rar->has_encrypted_entries; + } + } + return ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW; +} + + +static int archive_read_format_rar_bid(struct archive_read *a, int best_bid) { const char *p; @@ -755,7 +791,7 @@ archive_read_format_rar_options(struct archive_read *a, { struct rar *rar; int ret = ARCHIVE_FAILED; - + rar = (struct rar *)(a->format->data); if (strcmp(key, "hdrcharset") == 0) { if (val == NULL || val[0] == 0) @@ -797,6 +833,17 @@ archive_read_format_rar_read_header(struct archive_read *a, rar = (struct rar *)(a->format->data); + /* + * It should be sufficient to call archive_read_next_header() for + * a reader to determine if an entry is encrypted or not. If the + * encryption of an entry is only detectable when calling + * archive_read_data(), so be it. We'll do the same check there + * as well. + */ + if (rar->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) { + rar->has_encrypted_entries = 0; + } + /* RAR files can be generated without EOF headers, so return ARCHIVE_EOF if * this fails. */ @@ -857,9 +904,14 @@ archive_read_format_rar_read_header(struct archive_read *a, sizeof(rar->reserved2)); } + /* Main header is password encrytped, so we cannot read any + file names or any other info about files from the header. */ if (rar->main_flags & MHD_PASSWORD) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + archive_entry_set_is_metadata_encrypted(entry, 1); + archive_entry_set_is_data_encrypted(entry, 1); + rar->has_encrypted_entries = 1; + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "RAR encryption support unavailable."); return (ARCHIVE_FATAL); } @@ -938,6 +990,10 @@ archive_read_format_rar_read_data(struct archive_read *a, const void **buff, struct rar *rar = (struct rar *)(a->format->data); int ret; + if (rar->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) { + rar->has_encrypted_entries = 0; + } + if (rar->bytes_unconsumed > 0) { /* Consume as much as the decompressor actually used. */ __archive_read_consume(a, rar->bytes_unconsumed); @@ -957,7 +1013,7 @@ archive_read_format_rar_read_data(struct archive_read *a, const void **buff, { case COMPRESS_METHOD_STORE: ret = read_data_stored(a, buff, size, offset); - break; + break; case COMPRESS_METHOD_FASTEST: case COMPRESS_METHOD_FAST: @@ -967,13 +1023,13 @@ archive_read_format_rar_read_data(struct archive_read *a, const void **buff, ret = read_data_compressed(a, buff, size, offset); if (ret != ARCHIVE_OK && ret != ARCHIVE_WARN) __archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context, &g_szalloc); - break; + break; default: archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Unsupported compression method for RAR file."); ret = ARCHIVE_FATAL; - break; + break; } return (ret); } @@ -1290,9 +1346,14 @@ read_header(struct archive_read *a, struct archive_entry *entry, if (rar->file_flags & FHD_PASSWORD) { + archive_entry_set_is_data_encrypted(entry, 1); + rar->has_encrypted_entries = 1; archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "RAR encryption support unavailable."); - return (ARCHIVE_FATAL); + /* Since it is only the data part itself that is encrypted we can at least + extract information about the currently processed entry and don't need + to return ARCHIVE_FATAL here. */ + /*return (ARCHIVE_FATAL);*/ } if (rar->file_flags & FHD_LARGE) @@ -1377,7 +1438,7 @@ read_header(struct archive_read *a, struct archive_entry *entry, flagbyte = *(p + offset++); flagbits = 8; } - + flagbits -= 2; switch((flagbyte >> flagbits) & 3) { @@ -2611,7 +2672,7 @@ expand(struct archive_read *a, int64_t end) if ((symbol = read_next_symbol(a, &rar->maincode)) < 0) return (ARCHIVE_FATAL); rar->output_last_match = 0; - + if (symbol < 256) { lzss_emit_literal(rar, symbol); diff --git a/libarchive/archive_read_support_format_raw.c b/libarchive/archive_read_support_format_raw.c index 8434978..efa2c6a 100644 --- a/libarchive/archive_read_support_format_raw.c +++ b/libarchive/archive_read_support_format_raw.c @@ -78,7 +78,9 @@ archive_read_support_format_raw(struct archive *_a) archive_read_format_raw_read_data, archive_read_format_raw_read_data_skip, NULL, - archive_read_format_raw_cleanup); + archive_read_format_raw_cleanup, + NULL, + NULL); if (r != ARCHIVE_OK) free(info); return (r); diff --git a/libarchive/archive_read_support_format_tar.c b/libarchive/archive_read_support_format_tar.c index e9523cb..734424d 100644 --- a/libarchive/archive_read_support_format_tar.c +++ b/libarchive/archive_read_support_format_tar.c @@ -151,6 +151,8 @@ struct tar { struct archive_string_conv *sconv_default; int init_default_conversion; int compat_2x; + int process_mac_extensions; + int read_concatenated_archives; }; static int archive_block_is_null(const char *p); @@ -241,6 +243,10 @@ archive_read_support_format_tar(struct archive *_a) ARCHIVE_STATE_NEW, "archive_read_support_format_tar"); tar = (struct tar *)calloc(1, sizeof(*tar)); +#ifdef HAVE_COPYFILE_H + /* Set this by default on Mac OS. */ + tar->process_mac_extensions = 1; +#endif if (tar == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate tar data"); @@ -254,7 +260,9 @@ archive_read_support_format_tar(struct archive *_a) archive_read_format_tar_read_data, archive_read_format_tar_skip, NULL, - archive_read_format_tar_cleanup); + archive_read_format_tar_cleanup, + NULL, + NULL); if (r != ARCHIVE_OK) free(tar); @@ -368,7 +376,7 @@ archive_read_format_tar_options(struct archive_read *a, tar = (struct tar *)(a->format->data); if (strcmp(key, "compat-2x") == 0) { /* Handle UTF-8 filnames as libarchive 2.x */ - tar->compat_2x = (val != NULL)?1:0; + tar->compat_2x = (val != NULL && val[0] != 0); tar->init_default_conversion = tar->compat_2x; return (ARCHIVE_OK); } else if (strcmp(key, "hdrcharset") == 0) { @@ -385,6 +393,12 @@ archive_read_format_tar_options(struct archive_read *a, ret = ARCHIVE_FATAL; } return (ret); + } else if (strcmp(key, "mac-ext") == 0) { + tar->process_mac_extensions = (val != NULL && val[0] != 0); + return (ARCHIVE_OK); + } else if (strcmp(key, "read_concatenated_archives") == 0) { + tar->read_concatenated_archives = (val != NULL && val[0] != 0); + return (ARCHIVE_OK); } /* Note: The "warn" return is just to inform the options @@ -397,7 +411,7 @@ archive_read_format_tar_options(struct archive_read *a, * how much unconsumed data we have floating around, and to consume * anything outstanding since we're going to do read_aheads */ -static void +static void tar_flush_unconsumed(struct archive_read *a, size_t *unconsumed) { if (*unconsumed) { @@ -590,7 +604,7 @@ archive_read_format_tar_skip(struct archive_read *a) tar = (struct tar *)(a->format->data); bytes_skipped = __archive_read_consume(a, - tar->entry_bytes_remaining + tar->entry_padding + + tar->entry_bytes_remaining + tar->entry_padding + tar->entry_bytes_unconsumed); if (bytes_skipped < 0) return (ARCHIVE_FATAL); @@ -619,36 +633,50 @@ tar_read_header(struct archive_read *a, struct tar *tar, const struct archive_entry_header_ustar *header; const struct archive_entry_header_gnutar *gnuheader; - tar_flush_unconsumed(a, unconsumed); + /* Loop until we find a workable header record. */ + for (;;) { + tar_flush_unconsumed(a, unconsumed); - /* Read 512-byte header record */ - h = __archive_read_ahead(a, 512, &bytes); - if (bytes < 0) - return ((int)bytes); - if (bytes == 0) { /* EOF at a block boundary. */ - /* Some writers do omit the block of nulls. */ - return (ARCHIVE_EOF); - } - if (bytes < 512) { /* Short block at EOF; this is bad. */ - archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, - "Truncated tar archive"); - return (ARCHIVE_FATAL); - } - *unconsumed = 512; + /* Read 512-byte header record */ + h = __archive_read_ahead(a, 512, &bytes); + if (bytes < 0) + return ((int)bytes); + if (bytes == 0) { /* EOF at a block boundary. */ + /* Some writers do omit the block of nulls. */ + return (ARCHIVE_EOF); + } + if (bytes < 512) { /* Short block at EOF; this is bad. */ + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Truncated tar archive"); + return (ARCHIVE_FATAL); + } + *unconsumed = 512; - /* Check for end-of-archive mark. */ - if (h[0] == 0 && archive_block_is_null(h)) { - /* Try to consume a second all-null record, as well. */ - tar_flush_unconsumed(a, unconsumed); - h = __archive_read_ahead(a, 512, NULL); - if (h != NULL) - __archive_read_consume(a, 512); - archive_clear_error(&a->archive); + /* Header is workable if it's not an end-of-archive mark. */ + if (h[0] != 0 || !archive_block_is_null(h)) + break; + + /* Ensure format is set for archives with only null blocks. */ if (a->archive.archive_format_name == NULL) { a->archive.archive_format = ARCHIVE_FORMAT_TAR; a->archive.archive_format_name = "tar"; } - return (ARCHIVE_EOF); + + if (!tar->read_concatenated_archives) { + /* Try to consume a second all-null record, as well. */ + tar_flush_unconsumed(a, unconsumed); + h = __archive_read_ahead(a, 512, NULL); + if (h != NULL && h[0] == 0 && archive_block_is_null(h)) + __archive_read_consume(a, 512); + archive_clear_error(&a->archive); + return (ARCHIVE_EOF); + } + + /* + * We're reading concatenated archives, ignore this block and + * loop to get the next. + */ } /* @@ -683,6 +711,8 @@ tar_read_header(struct archive_read *a, struct tar *tar, a->archive.archive_format = ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE; a->archive.archive_format_name = "POSIX pax interchange format"; err = header_pax_global(a, tar, entry, h, unconsumed); + if (err == ARCHIVE_EOF) + return (err); break; case 'K': /* Long link name (GNU tar, others) */ err = header_longlink(a, tar, entry, h, unconsumed); @@ -735,9 +765,9 @@ tar_read_header(struct archive_read *a, struct tar *tar, * extensions for both the AppleDouble extension entry and the * regular entry. */ - /* TODO: Should this be disabled on non-Mac platforms? */ if ((err == ARCHIVE_WARN || err == ARCHIVE_OK) && - tar->header_recursion_depth == 0) { + tar->header_recursion_depth == 0 && + tar->process_mac_extensions) { int err2 = read_mac_metadata_blob(a, tar, entry, h, unconsumed); if (err2 < err) err = err2; @@ -780,12 +810,20 @@ checksum(struct archive_read *a, const void *h) { const unsigned char *bytes; const struct archive_entry_header_ustar *header; - int check, i, sum; + int check, sum; + size_t i; (void)a; /* UNUSED */ bytes = (const unsigned char *)h; header = (const struct archive_entry_header_ustar *)h; + /* Checksum field must hold an octal number */ + for (i = 0; i < sizeof(header->checksum); ++i) { + char c = header->checksum[i]; + if (c != ' ' && c != '\0' && (c < '0' || c > '7')) + return 0; + } + /* * Test the checksum. Note that POSIX specifies _unsigned_ * bytes for this calculation. @@ -1277,7 +1315,7 @@ read_mac_metadata_blob(struct archive_read *a, struct tar *tar, if (wp[0] == '/' && wp[1] != L'\0') wname = wp + 1; } - /* + /* * If last path element starts with "._", then * this is a Mac extension. */ @@ -1292,7 +1330,7 @@ read_mac_metadata_blob(struct archive_read *a, struct tar *tar, if (p[0] == '/' && p[1] != '\0') name = p + 1; } - /* + /* * If last path element starts with "._", then * this is a Mac extension. */ @@ -2412,9 +2450,10 @@ tar_atol(const char *p, size_t char_cnt) static int64_t tar_atol_base_n(const char *p, size_t char_cnt, int base) { - int64_t l, limit, last_digit_limit; + int64_t l, maxval, limit, last_digit_limit; int digit, sign; + maxval = INT64_MAX; limit = INT64_MAX / base; last_digit_limit = INT64_MAX % base; @@ -2431,6 +2470,10 @@ tar_atol_base_n(const char *p, size_t char_cnt, int base) sign = -1; p++; char_cnt--; + + maxval = INT64_MIN; + limit = -(INT64_MIN / base); + last_digit_limit = INT64_MIN % base; } l = 0; @@ -2438,8 +2481,7 @@ tar_atol_base_n(const char *p, size_t char_cnt, int base) digit = *p - '0'; while (digit >= 0 && digit < base && char_cnt != 0) { if (l>limit || (l == limit && digit > last_digit_limit)) { - l = INT64_MAX; /* Truncate on overflow. */ - break; + return maxval; /* Truncate on overflow. */ } l = (l * base) + digit; digit = *++p - '0'; @@ -2462,36 +2504,56 @@ tar_atol10(const char *p, size_t char_cnt) } /* - * Parse a base-256 integer. This is just a straight signed binary - * value in big-endian order, except that the high-order bit is - * ignored. + * Parse a base-256 integer. This is just a variable-length + * twos-complement signed binary value in big-endian order, except + * that the high-order bit is ignored. The values here can be up to + * 12 bytes, so we need to be careful about overflowing 64-bit + * (8-byte) integers. + * + * This code unashamedly assumes that the local machine uses 8-bit + * bytes and twos-complement arithmetic. */ static int64_t tar_atol256(const char *_p, size_t char_cnt) { - int64_t l, upper_limit, lower_limit; + uint64_t l; const unsigned char *p = (const unsigned char *)_p; + unsigned char c, neg; + + /* Extend 7-bit 2s-comp to 8-bit 2s-comp, decide sign. */ + c = *p; + if (c & 0x40) { + neg = 0xff; + c |= 0x80; + l = ~ARCHIVE_LITERAL_ULL(0); + } else { + neg = 0; + c &= 0x7f; + l = 0; + } - upper_limit = INT64_MAX / 256; - lower_limit = INT64_MIN / 256; + /* If more than 8 bytes, check that we can ignore + * high-order bits without overflow. */ + while (char_cnt > sizeof(int64_t)) { + --char_cnt; + if (c != neg) + return neg ? INT64_MIN : INT64_MAX; + c = *++p; + } - /* Pad with 1 or 0 bits, depending on sign. */ - if ((0x40 & *p) == 0x40) - l = (int64_t)-1; - else - l = 0; - l = (l << 6) | (0x3f & *p++); + /* c is first byte that fits; if sign mismatch, return overflow */ + if ((c ^ neg) & 0x80) { + return neg ? INT64_MIN : INT64_MAX; + } + + /* Accumulate remaining bytes. */ while (--char_cnt > 0) { - if (l > upper_limit) { - l = INT64_MAX; /* Truncate on overflow */ - break; - } else if (l < lower_limit) { - l = INT64_MIN; - break; - } - l = (l << 8) | (0xff & (int64_t)*p++); + l = (l << 8) | c; + c = *++p; } - return (l); + l = (l << 8) | c; + /* Return signed twos-complement value. */ + return (int64_t)(l); } /* diff --git a/libarchive/archive_read_support_format_xar.c b/libarchive/archive_read_support_format_xar.c index 780e749..b0f5352 100644 --- a/libarchive/archive_read_support_format_xar.c +++ b/libarchive/archive_read_support_format_xar.c @@ -468,7 +468,9 @@ archive_read_support_format_xar(struct archive *_a) xar_read_data, xar_read_data_skip, NULL, - xar_cleanup); + xar_cleanup, + NULL, + NULL); if (r != ARCHIVE_OK) free(xar); return (r); @@ -967,10 +969,14 @@ move_reading_point(struct archive_read *a, uint64_t offset) return ((int)step); xar->offset += step; } else { - archive_set_error(&(a->archive), - ARCHIVE_ERRNO_MISC, - "Cannot seek."); - return (ARCHIVE_FAILED); + int64_t pos = __archive_read_seek(a, offset, SEEK_SET); + if (pos == ARCHIVE_FAILED) { + archive_set_error(&(a->archive), + ARCHIVE_ERRNO_MISC, + "Cannot seek."); + return (ARCHIVE_FAILED); + } + xar->offset = pos; } } return (ARCHIVE_OK); diff --git a/libarchive/archive_read_support_format_zip.c b/libarchive/archive_read_support_format_zip.c index 450a6f7..4460b30 100644 --- a/libarchive/archive_read_support_format_zip.c +++ b/libarchive/archive_read_support_format_zip.c @@ -1,6 +1,7 @@ /*- - * Copyright (c) 2004 Tim Kientzle + * Copyright (c) 2004-2013 Tim Kientzle * Copyright (c) 2011-2012 Michihiro NAKAJIMA + * Copyright (c) 2013 Konrad Kleine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,6 +28,20 @@ #include "archive_platform.h" __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_zip.c 201102 2009-12-28 03:11:36Z kientzle $"); +/* + * The definitive documentation of the Zip file format is: + * http://www.pkware.com/documents/casestudies/APPNOTE.TXT + * + * The Info-Zip project has pioneered various extensions to better + * support Zip on Unix, including the 0x5455 "UT", 0x5855 "UX", 0x7855 + * "Ux", and 0x7875 "ux" extensions for time and ownership + * information. + * + * History of this code: The streaming Zip reader was first added to + * libarchive in January 2005. Support for seekable input sources was + * added in Nov 2011. + */ + #ifdef HAVE_ERRNO_H #include #endif @@ -51,42 +66,55 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_zip.c 201102 struct zip_entry { struct archive_rb_node node; + struct zip_entry *next; int64_t local_header_offset; int64_t compressed_size; int64_t uncompressed_size; int64_t gid; int64_t uid; - struct archive_entry *entry; struct archive_string rsrcname; time_t mtime; time_t atime; time_t ctime; uint32_t crc32; uint16_t mode; - uint16_t flags; - char compression; - char system; + uint16_t zip_flags; /* From GP Flags Field */ + unsigned char compression; + unsigned char system; /* From "version written by" */ + unsigned char flags; /* Our extra markers. */ }; +/* Bits used in zip_flags. */ +#define ZIP_ENCRYPTED (1 << 0) +#define ZIP_LENGTH_AT_END (1 << 3) +#define ZIP_STRONG_ENCRYPTED (1 << 6) +#define ZIP_UTF8_NAME (1 << 11) +/* See "7.2 Single Password Symmetric Encryption Method" + in http://www.pkware.com/documents/casestudies/APPNOTE.TXT */ +#define ZIP_CENTRAL_DIRECTORY_ENCRYPTED (1 << 13) + +/* Bits used in flags. */ +#define LA_USED_ZIP64 (1 << 0) +#define LA_FROM_CENTRAL_DIRECTORY (1 << 1) + struct zip { /* Structural information about the archive. */ - int64_t end_of_central_directory_offset; + char format_name[64]; int64_t central_directory_offset; - size_t central_directory_size; - size_t central_directory_entries; - char have_central_directory; - int64_t offset; + size_t central_directory_entries_total; + size_t central_directory_entries_on_this_disk; + int has_encrypted_entries; /* List of entries (seekable Zip only) */ - size_t entries_remaining; struct zip_entry *zip_entries; - struct zip_entry *entry; struct archive_rb_tree tree; struct archive_rb_tree tree_rsrc; + /* Bytes read but not yet consumed via __archive_read_consume() */ size_t unconsumed; - /* entry_bytes_remaining is the number of bytes we expect. */ + /* Information about entry we're currently reading. */ + struct zip_entry *entry; int64_t entry_bytes_remaining; /* These count the number of bytes actually read for the entry. */ @@ -95,652 +123,566 @@ struct zip { /* Running CRC32 of the decompressed data */ unsigned long entry_crc32; + unsigned long (*crc32func)(unsigned long, const void *, size_t); + char ignore_crc32; /* Flags to mark progress of decompression. */ char decompress_init; char end_of_entry; - ssize_t filename_length; - ssize_t extra_length; - +#ifdef HAVE_ZLIB_H unsigned char *uncompressed_buffer; size_t uncompressed_buffer_size; -#ifdef HAVE_ZLIB_H z_stream stream; char stream_valid; #endif - struct archive_string extra; struct archive_string_conv *sconv; struct archive_string_conv *sconv_default; struct archive_string_conv *sconv_utf8; int init_default_conversion; - char format_name[64]; + int process_mac_extensions; }; -#define ZIP_LENGTH_AT_END 8 -#define ZIP_ENCRYPTED (1<<0) -#define ZIP_STRONG_ENCRYPTED (1<<6) -#define ZIP_UTF8_NAME (1<<11) - -static int archive_read_format_zip_streamable_bid(struct archive_read *, - int); -static int archive_read_format_zip_seekable_bid(struct archive_read *, - int); -static int archive_read_format_zip_options(struct archive_read *, - const char *, const char *); -static int archive_read_format_zip_cleanup(struct archive_read *); -static int archive_read_format_zip_read_data(struct archive_read *, - const void **, size_t *, int64_t *); -static int archive_read_format_zip_read_data_skip(struct archive_read *a); -static int archive_read_format_zip_seekable_read_header( - struct archive_read *, struct archive_entry *); -static int archive_read_format_zip_streamable_read_header( - struct archive_read *, struct archive_entry *); -static ssize_t zip_get_local_file_header_size(struct archive_read *, size_t); -#ifdef HAVE_ZLIB_H -static int zip_deflate_init(struct archive_read *, struct zip *); -static int zip_read_data_deflate(struct archive_read *a, const void **buff, - size_t *size, int64_t *offset); -#endif -static int zip_read_data_none(struct archive_read *a, const void **buff, - size_t *size, int64_t *offset); -static int zip_read_local_file_header(struct archive_read *a, - struct archive_entry *entry, struct zip *); -static time_t zip_time(const char *); -static const char *compression_name(int compression); -static void process_extra(const char *, size_t, struct zip_entry *); - -int archive_read_support_format_zip_streamable(struct archive *); -int archive_read_support_format_zip_seekable(struct archive *); - -int -archive_read_support_format_zip_streamable(struct archive *_a) -{ - struct archive_read *a = (struct archive_read *)_a; - struct zip *zip; - int r; - - archive_check_magic(_a, ARCHIVE_READ_MAGIC, - ARCHIVE_STATE_NEW, "archive_read_support_format_zip"); - - zip = (struct zip *)malloc(sizeof(*zip)); - if (zip == NULL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate zip data"); - return (ARCHIVE_FATAL); - } - memset(zip, 0, sizeof(*zip)); - - r = __archive_read_register_format(a, - zip, - "zip", - archive_read_format_zip_streamable_bid, - archive_read_format_zip_options, - archive_read_format_zip_streamable_read_header, - archive_read_format_zip_read_data, - archive_read_format_zip_read_data_skip, - NULL, - archive_read_format_zip_cleanup); - - if (r != ARCHIVE_OK) - free(zip); - return (ARCHIVE_OK); -} - -int -archive_read_support_format_zip_seekable(struct archive *_a) -{ - struct archive_read *a = (struct archive_read *)_a; - struct zip *zip; - int r; - - archive_check_magic(_a, ARCHIVE_READ_MAGIC, - ARCHIVE_STATE_NEW, "archive_read_support_format_zip_seekable"); - - zip = (struct zip *)malloc(sizeof(*zip)); - if (zip == NULL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate zip data"); - return (ARCHIVE_FATAL); - } - memset(zip, 0, sizeof(*zip)); - - r = __archive_read_register_format(a, - zip, - "zip", - archive_read_format_zip_seekable_bid, - archive_read_format_zip_options, - archive_read_format_zip_seekable_read_header, - archive_read_format_zip_read_data, - archive_read_format_zip_read_data_skip, - NULL, - archive_read_format_zip_cleanup); - - if (r != ARCHIVE_OK) - free(zip); - return (ARCHIVE_OK); -} +/* Many systems define min or MIN, but not all. */ +#define zipmin(a,b) ((a) < (b) ? (a) : (b)) -int -archive_read_support_format_zip(struct archive *a) -{ - int r; - r = archive_read_support_format_zip_streamable(a); - if (r != ARCHIVE_OK) - return r; - return (archive_read_support_format_zip_seekable(a)); -} +/* ------------------------------------------------------------------------ */ /* - * TODO: This is a performance sink because it forces the read core to - * drop buffered data from the start of file, which will then have to - * be re-read again if this bidder loses. + * Common code for streaming or seeking modes. * - * We workaround this a little by passing in the best bid so far so - * that later bidders can do nothing if they know they'll never - * outbid. But we can certainly do better... + * Includes code to read local file headers, decompress data + * from entry bodies, and common API. */ -static int -archive_read_format_zip_seekable_bid(struct archive_read *a, int best_bid) -{ - struct zip *zip = (struct zip *)a->format->data; - int64_t filesize; - const char *p; - - /* If someone has already bid more than 32, then avoid - trashing the look-ahead buffers with a seek. */ - if (best_bid > 32) - return (-1); - - filesize = __archive_read_seek(a, -22, SEEK_END); - /* If we can't seek, then we can't bid. */ - if (filesize <= 0) - return 0; - - /* TODO: More robust search for end of central directory record. */ - if ((p = __archive_read_ahead(a, 22, NULL)) == NULL) - return 0; - /* First four bytes are signature for end of central directory - record. Four zero bytes ensure this isn't a multi-volume - Zip file (which we don't yet support). */ - if (memcmp(p, "PK\005\006\000\000\000\000", 8) != 0) { - int64_t i, tail; - int found; - - /* - * If there is a comment in end of central directory - * record, 22 bytes are too short. we have to read more - * to properly detect the record. Hopefully, a length - * of the comment is not longer than 16362 bytes(16K-22). - */ - if (filesize + 22 > 1024 * 16) { - tail = 1024 * 16; - filesize = __archive_read_seek(a, tail * -1, SEEK_END); - } else { - tail = filesize + 22; - filesize = __archive_read_seek(a, 0, SEEK_SET); - } - if (filesize < 0) - return 0; - if ((p = __archive_read_ahead(a, (size_t)tail, NULL)) == NULL) - return 0; - for (found = 0, i = 0;!found && i < tail - 22;) { - switch (p[i]) { - case 'P': - if (memcmp(p+i, - "PK\005\006\000\000\000\000", 8) == 0) { - p += i; - filesize += tail - - (22 + archive_le16dec(p+20)); - found = 1; - } else - i += 8; - break; - case 'K': i += 7; break; - case 005: i += 6; break; - case 006: i += 5; break; - default: i += 1; break; - } - } - if (!found) - return 0; - } - - /* Since we've already done the hard work of finding the - end of central directory record, let's save the important - information. */ - zip->central_directory_entries = archive_le16dec(p + 10); - zip->central_directory_size = archive_le32dec(p + 12); - zip->central_directory_offset = archive_le32dec(p + 16); - zip->end_of_central_directory_offset = filesize; - - /* Just one volume, so central dir must all be on this volume. */ - if (zip->central_directory_entries != archive_le16dec(p + 8)) - return 0; - /* Central directory can't extend beyond end of this file. */ - if (zip->central_directory_offset + - (int64_t)zip->central_directory_size > filesize) - return 0; - - /* This is just a tiny bit higher than the maximum returned by - the streaming Zip bidder. This ensures that the more accurate - seeking Zip parser wins whenever seek is available. */ - return 32; -} -static int -cmp_node(const struct archive_rb_node *n1, const struct archive_rb_node *n2) +static unsigned long +real_crc32(unsigned long crc, const void *buff, size_t len) { - const struct zip_entry *e1 = (const struct zip_entry *)n1; - const struct zip_entry *e2 = (const struct zip_entry *)n2; - - return ((int)(e2->local_header_offset - e1->local_header_offset)); + return crc32(crc, buff, len); } -static int -cmp_key(const struct archive_rb_node *n, const void *key) +static unsigned long +fake_crc32(unsigned long crc, const void *buff, size_t len) { - /* This function won't be called */ - (void)n; /* UNUSED */ - (void)key; /* UNUSED */ - return 1; + (void)crc; /* UNUSED */ + (void)buff; /* UNUSED */ + (void)len; /* UNUSED */ + return 0; } -static int -rsrc_cmp_node(const struct archive_rb_node *n1, - const struct archive_rb_node *n2) -{ - const struct zip_entry *e1 = (const struct zip_entry *)n1; - const struct zip_entry *e2 = (const struct zip_entry *)n2; - - return (strcmp(e2->rsrcname.s, e1->rsrcname.s)); -} +static struct { + int id; + const char * name; +} compression_methods[] = { + {0, "uncompressed"}, /* The file is stored (no compression) */ + {1, "shrinking"}, /* The file is Shrunk */ + {2, "reduced-1"}, /* The file is Reduced with compression factor 1 */ + {3, "reduced-2"}, /* The file is Reduced with compression factor 2 */ + {4, "reduced-3"}, /* The file is Reduced with compression factor 3 */ + {5, "reduced-4"}, /* The file is Reduced with compression factor 4 */ + {6, "imploded"}, /* The file is Imploded */ + {7, "reserved"}, /* Reserved for Tokenizing compression algorithm */ + {8, "deflation"}, /* The file is Deflated */ + {9, "deflation-64-bit"}, /* Enhanced Deflating using Deflate64(tm) */ + {10, "ibm-terse"}, /* PKWARE Data Compression Library Imploding (old IBM TERSE) */ + {11, "reserved"}, /* Reserved by PKWARE */ + {12, "bzip"}, /* File is compressed using BZIP2 algorithm */ + {13, "reserved"}, /* Reserved by PKWARE */ + {14, "lzma"}, /* LZMA (EFS) */ + {15, "reserved"}, /* Reserved by PKWARE */ + {16, "reserved"}, /* Reserved by PKWARE */ + {17, "reserved"}, /* Reserved by PKWARE */ + {18, "ibm-terse-new"}, /* File is compressed using IBM TERSE (new) */ + {19, "ibm-lz777"}, /* IBM LZ77 z Architecture (PFS) */ + {97, "wav-pack"}, /* WavPack compressed data */ + {98, "ppmd-1"} /* PPMd version I, Rev 1 */ +}; -static int -rsrc_cmp_key(const struct archive_rb_node *n, const void *key) +static const char * +compression_name(const int compression) { - const struct zip_entry *e = (const struct zip_entry *)n; - return (strcmp((const char *)key, e->rsrcname.s)); + static const int num_compression_methods = sizeof(compression_methods)/sizeof(compression_methods[0]); + int i=0; + while(compression >= 0 && i++ < num_compression_methods) { + if (compression_methods[i].id == compression) { + return compression_methods[i].name; + } + } + return "??"; } -static const char * -rsrc_basename(const char *name, size_t name_length) +/* Convert an MSDOS-style date/time into Unix-style time. */ +static time_t +zip_time(const char *p) { - const char *s, *r; + int msTime, msDate; + struct tm ts; - r = s = name; - for (;;) { - s = memchr(s, '/', name_length - (s - name)); - if (s == NULL) - break; - r = ++s; - } - return (r); + msTime = (0xff & (unsigned)p[0]) + 256 * (0xff & (unsigned)p[1]); + msDate = (0xff & (unsigned)p[2]) + 256 * (0xff & (unsigned)p[3]); + + memset(&ts, 0, sizeof(ts)); + ts.tm_year = ((msDate >> 9) & 0x7f) + 80; /* Years since 1900. */ + ts.tm_mon = ((msDate >> 5) & 0x0f) - 1; /* Month number. */ + ts.tm_mday = msDate & 0x1f; /* Day of month. */ + ts.tm_hour = (msTime >> 11) & 0x1f; + ts.tm_min = (msTime >> 5) & 0x3f; + ts.tm_sec = (msTime << 1) & 0x3e; + ts.tm_isdst = -1; + return mktime(&ts); } +/* + * The extra data is stored as a list of + * id1+size1+data1 + id2+size2+data2 ... + * triplets. id and size are 2 bytes each. + */ static void -expose_parent_dirs(struct zip *zip, const char *name, size_t name_length) +process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry) { - struct archive_string str; - struct zip_entry *dir; - char *s; + unsigned offset = 0; - archive_string_init(&str); - archive_strncpy(&str, name, name_length); - for (;;) { - s = strrchr(str.s, '/'); - if (s == NULL) + while (offset < extra_length - 4) + { + unsigned short headerid = archive_le16dec(p + offset); + unsigned short datasize = archive_le16dec(p + offset + 2); + offset += 4; + if (offset + datasize > extra_length) break; - *s = '\0'; - /* Transfer the parent directory from zip->tree_rsrc RB - * tree to zip->tree RB tree to expose. */ - dir = (struct zip_entry *) - __archive_rb_tree_find_node(&zip->tree_rsrc, str.s); - if (dir == NULL) +#ifdef DEBUG + fprintf(stderr, "Header id 0x%x, length %d\n", + headerid, datasize); +#endif + switch (headerid) { + case 0x0001: + /* Zip64 extended information extra field. */ + zip_entry->flags |= LA_USED_ZIP64; + if (zip_entry->uncompressed_size == 0xffffffff) { + if (datasize < 8) + break; + zip_entry->uncompressed_size = + archive_le64dec(p + offset); + offset += 8; + datasize -= 8; + } + if (zip_entry->compressed_size == 0xffffffff) { + if (datasize < 8) + break; + zip_entry->compressed_size = + archive_le64dec(p + offset); + offset += 8; + datasize -= 8; + } + if (zip_entry->local_header_offset == 0xffffffff) { + if (datasize < 8) + break; + zip_entry->local_header_offset = + archive_le64dec(p + offset); + offset += 8; + datasize -= 8; + } + /* archive_le32dec(p + offset) gives disk + * on which file starts, but we don't handle + * multi-volume Zip files. */ + break; + case 0x5455: + { + /* Extended time field "UT". */ + int flags = p[offset]; + offset++; + datasize--; + /* Flag bits indicate which dates are present. */ + if (flags & 0x01) + { +#ifdef DEBUG + fprintf(stderr, "mtime: %lld -> %d\n", + (long long)zip_entry->mtime, + archive_le32dec(p + offset)); +#endif + if (datasize < 4) + break; + zip_entry->mtime = archive_le32dec(p + offset); + offset += 4; + datasize -= 4; + } + if (flags & 0x02) + { + if (datasize < 4) + break; + zip_entry->atime = archive_le32dec(p + offset); + offset += 4; + datasize -= 4; + } + if (flags & 0x04) + { + if (datasize < 4) + break; + zip_entry->ctime = archive_le32dec(p + offset); + offset += 4; + datasize -= 4; + } break; - __archive_rb_tree_remove_node(&zip->tree_rsrc, &dir->node); - archive_string_free(&dir->rsrcname); - __archive_rb_tree_insert_node(&zip->tree, &dir->node); - } - archive_string_free(&str); -} - -static int -slurp_central_directory(struct archive_read *a, struct zip *zip) -{ - unsigned i; - int64_t correction; - static const struct archive_rb_tree_ops rb_ops = { - &cmp_node, &cmp_key - }; - static const struct archive_rb_tree_ops rb_rsrc_ops = { - &rsrc_cmp_node, &rsrc_cmp_key - }; - - /* - * Consider the archive file we are reading may be SFX. - * So we have to calculate a SFX header size to revise - * ZIP header offsets. - */ - correction = zip->end_of_central_directory_offset - - (zip->central_directory_offset + zip->central_directory_size); - /* The central directory offset is relative value, and so - * we revise this offset for SFX. */ - zip->central_directory_offset += correction; - - __archive_read_seek(a, zip->central_directory_offset, SEEK_SET); - zip->offset = zip->central_directory_offset; - __archive_rb_tree_init(&zip->tree, &rb_ops); - __archive_rb_tree_init(&zip->tree_rsrc, &rb_rsrc_ops); - - zip->zip_entries = calloc(zip->central_directory_entries, - sizeof(struct zip_entry)); - for (i = 0; i < zip->central_directory_entries; ++i) { - struct zip_entry *zip_entry = &zip->zip_entries[i]; - size_t filename_length, extra_length, comment_length; - uint32_t external_attributes; - const char *name, *p, *r; - - if ((p = __archive_read_ahead(a, 46, NULL)) == NULL) - return ARCHIVE_FATAL; - if (memcmp(p, "PK\001\002", 4) != 0) { - archive_set_error(&a->archive, - -1, "Invalid central directory signature"); - return ARCHIVE_FATAL; - } - zip->have_central_directory = 1; - /* version = p[4]; */ - zip_entry->system = p[5]; - /* version_required = archive_le16dec(p + 6); */ - zip_entry->flags = archive_le16dec(p + 8); - zip_entry->compression = (char)archive_le16dec(p + 10); - zip_entry->mtime = zip_time(p + 12); - zip_entry->crc32 = archive_le32dec(p + 16); - zip_entry->compressed_size = archive_le32dec(p + 20); - zip_entry->uncompressed_size = archive_le32dec(p + 24); - filename_length = archive_le16dec(p + 28); - extra_length = archive_le16dec(p + 30); - comment_length = archive_le16dec(p + 32); - /* disk_start = archive_le16dec(p + 34); */ /* Better be zero. */ - /* internal_attributes = archive_le16dec(p + 36); */ /* text bit */ - external_attributes = archive_le32dec(p + 38); - zip_entry->local_header_offset = - archive_le32dec(p + 42) + correction; - - /* If we can't guess the mode, leave it zero here; - when we read the local file header we might get - more information. */ - zip_entry->mode = 0; - if (zip_entry->system == 3) { - zip_entry->mode = external_attributes >> 16; } - - /* - * Mac resource fork files are stored under the - * "__MACOSX/" directory, so we should check if - * it is. - */ - /* Make sure we have the file name. */ - if ((p = __archive_read_ahead(a, 46 + filename_length, NULL)) - == NULL) - return ARCHIVE_FATAL; - name = p + 46; - r = rsrc_basename(name, filename_length); - if (filename_length >= 9 && - strncmp("__MACOSX/", name, 9) == 0) { - /* If this file is not a resource fork nor - * a directory. We should treat it as a non - * resource fork file to expose it. */ - if (name[filename_length-1] != '/' && - (r - name < 3 || r[0] != '.' || r[1] != '_')) { - __archive_rb_tree_insert_node(&zip->tree, - &zip_entry->node); - /* Expose its parent directories. */ - expose_parent_dirs(zip, name, filename_length); - } else { - /* This file is a resource fork file or - * a directory. */ - archive_strncpy(&(zip_entry->rsrcname), name, - filename_length); - __archive_rb_tree_insert_node(&zip->tree_rsrc, - &zip_entry->node); + case 0x5855: + { + /* Info-ZIP Unix Extra Field (old version) "UX". */ + if (datasize >= 8) { + zip_entry->atime = archive_le32dec(p + offset); + zip_entry->mtime = + archive_le32dec(p + offset + 4); } - } else { - /* Generate resource fork name to find its resource - * file at zip->tree_rsrc. */ - archive_strcpy(&(zip_entry->rsrcname), "__MACOSX/"); - archive_strncat(&(zip_entry->rsrcname), name, r - name); - archive_strcat(&(zip_entry->rsrcname), "._"); - archive_strncat(&(zip_entry->rsrcname), - name + (r - name), filename_length - (r - name)); - /* Register an entry to RB tree to sort it by - * file offset. */ - __archive_rb_tree_insert_node(&zip->tree, - &zip_entry->node); + if (datasize >= 12) { + zip_entry->uid = + archive_le16dec(p + offset + 8); + zip_entry->gid = + archive_le16dec(p + offset + 10); + } + break; } + case 0x6c65: + { + /* Experimental 'el' field */ + /* + * Introduced Dec 2013 to provide a way to + * include external file attributes in local file + * header. This provides file type and permission + * information necessary to support full streaming + * extraction. Currently being discussed with + * other Zip developers... subject to change. + */ + int bitmap, bitmap_last; - /* We don't read the filename until we get to the - local file header. Reading it here would speed up - table-of-contents operations (removing the need to - find and read local file header to get the - filename) at the cost of requiring a lot of extra - space. */ - /* We don't read the extra block here. We assume it - will be duplicated at the local file header. */ - __archive_read_consume(a, - 46 + filename_length + extra_length + comment_length); - } + if (datasize < 1) + break; + bitmap_last = bitmap = 0xff & p[offset]; + offset += 1; + datasize -= 1; + + /* We only support first 7 bits of bitmap; skip rest. */ + while ((bitmap_last & 0x80) != 0 + && datasize >= 1) { + bitmap_last = p[offset]; + offset += 1; + datasize -= 1; + } - return ARCHIVE_OK; -} + if (bitmap & 1) { + // 2 byte "version made by" + if (datasize < 2) + break; + zip_entry->system + = archive_le16dec(p + offset) >> 8; + offset += 2; + datasize -= 2; + } + if (bitmap & 2) { + // 2 byte "internal file attributes" + uint32_t internal_attributes; + if (datasize < 2) + break; + internal_attributes + = archive_le16dec(p + offset); + // Not used by libarchive at present. + (void)internal_attributes; /* UNUSED */ + offset += 2; + datasize -= 2; + } + if (bitmap & 4) { + // 4 byte "external file attributes" + uint32_t external_attributes; + if (datasize < 4) + break; + external_attributes + = archive_le32dec(p + offset); + if (zip_entry->system == 3) { + zip_entry->mode + = external_attributes >> 16; + } + offset += 4; + datasize -= 4; + } + if (bitmap & 8) { + // 2 byte comment length + comment + uint32_t comment_length; + if (datasize < 2) + break; + comment_length + = archive_le16dec(p + offset); + offset += 2; + datasize -= 2; -static int64_t -zip_read_consume(struct archive_read *a, int64_t bytes) -{ - struct zip *zip = (struct zip *)a->format->data; - int64_t skip; + if (datasize < comment_length) + break; + // Comment is not supported by libarchive + offset += comment_length; + datasize -= comment_length; + } + break; + } + case 0x7855: + /* Info-ZIP Unix Extra Field (type 2) "Ux". */ +#ifdef DEBUG + fprintf(stderr, "uid %d gid %d\n", + archive_le16dec(p + offset), + archive_le16dec(p + offset + 2)); +#endif + if (datasize >= 2) + zip_entry->uid = archive_le16dec(p + offset); + if (datasize >= 4) + zip_entry->gid = + archive_le16dec(p + offset + 2); + break; + case 0x7875: + { + /* Info-Zip Unix Extra Field (type 3) "ux". */ + int uidsize = 0, gidsize = 0; - skip = __archive_read_consume(a, bytes); - if (skip > 0) - zip->offset += skip; - return (skip); + /* TODO: support arbitrary uidsize/gidsize. */ + if (datasize >= 1 && p[offset] == 1) {/* version=1 */ + if (datasize >= 4) { + /* get a uid size. */ + uidsize = p[offset+1]; + if (uidsize == 2) + zip_entry->uid = + archive_le16dec( + p + offset + 2); + else if (uidsize == 4 && datasize >= 6) + zip_entry->uid = + archive_le32dec( + p + offset + 2); + } + if (datasize >= (2 + uidsize + 3)) { + /* get a gid size. */ + gidsize = p[offset+2+uidsize]; + if (gidsize == 2) + zip_entry->gid = + archive_le16dec( + p+offset+2+uidsize+1); + else if (gidsize == 4 && + datasize >= (2 + uidsize + 5)) + zip_entry->gid = + archive_le32dec( + p+offset+2+uidsize+1); + } + } + break; + } + default: + break; + } + offset += datasize; + } +#ifdef DEBUG + if (offset != extra_length) + { + fprintf(stderr, + "Extra data field contents do not match reported size!\n"); + } +#endif } +/* + * Assumes file pointer is at beginning of local file header. + */ static int -zip_read_mac_metadata(struct archive_read *a, struct archive_entry *entry, - struct zip_entry *rsrc) +zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry, + struct zip *zip) { - struct zip *zip = (struct zip *)a->format->data; - unsigned char *metadata, *mp; - int64_t offset = zip->offset; - size_t remaining_bytes, metadata_bytes; - ssize_t hsize; - int ret = ARCHIVE_OK, eof; + const char *p; + const void *h; + const wchar_t *wp; + const char *cp; + size_t len, filename_length, extra_length; + struct archive_string_conv *sconv; + struct zip_entry *zip_entry = zip->entry; + struct zip_entry zip_entry_central_dir; + int ret = ARCHIVE_OK; + char version; - switch(rsrc->compression) { - case 0: /* No compression. */ -#ifdef HAVE_ZLIB_H - case 8: /* Deflate compression. */ -#endif - break; - default: /* Unsupported compression. */ - /* Return a warning. */ - archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, - "Unsupported ZIP compression method (%s)", - compression_name(rsrc->compression)); - /* We can't decompress this entry, but we will - * be able to skip() it and try the next entry. */ - return (ARCHIVE_WARN); - } + /* Save a copy of the original for consistency checks. */ + zip_entry_central_dir = *zip_entry; - if (rsrc->uncompressed_size > (128 * 1024)) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, - "Mac metadata is too large: %jd > 128K bytes", - (intmax_t)rsrc->uncompressed_size); - return (ARCHIVE_WARN); + zip->decompress_init = 0; + zip->end_of_entry = 0; + zip->entry_uncompressed_bytes_read = 0; + zip->entry_compressed_bytes_read = 0; + zip->entry_crc32 = zip->crc32func(0, NULL, 0); + + /* Setup default conversion. */ + if (zip->sconv == NULL && !zip->init_default_conversion) { + zip->sconv_default = + archive_string_default_conversion_for_read(&(a->archive)); + zip->init_default_conversion = 1; } - metadata = malloc((size_t)rsrc->uncompressed_size); - if (metadata == NULL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate memory for Mac metadata"); + if ((p = __archive_read_ahead(a, 30, NULL)) == NULL) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "Truncated ZIP file header"); return (ARCHIVE_FATAL); } - if (zip->offset < rsrc->local_header_offset) - zip_read_consume(a, rsrc->local_header_offset - zip->offset); - else if (zip->offset != rsrc->local_header_offset) { - __archive_read_seek(a, rsrc->local_header_offset, SEEK_SET); - zip->offset = zip->entry->local_header_offset; + if (memcmp(p, "PK\003\004", 4) != 0) { + archive_set_error(&a->archive, -1, "Damaged Zip archive"); + return ARCHIVE_FATAL; } + version = p[4]; + zip_entry->system = p[5]; + zip_entry->zip_flags = archive_le16dec(p + 6); + if (zip_entry->zip_flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)) { + zip->has_encrypted_entries = 1; + archive_entry_set_is_data_encrypted(entry, 1); + if (zip_entry->zip_flags & ZIP_CENTRAL_DIRECTORY_ENCRYPTED && + zip_entry->zip_flags & ZIP_ENCRYPTED && + zip_entry->zip_flags & ZIP_STRONG_ENCRYPTED) { + archive_entry_set_is_metadata_encrypted(entry, 1); + return ARCHIVE_FATAL; + } + } + zip_entry->compression = (char)archive_le16dec(p + 8); + zip_entry->mtime = zip_time(p + 10); + zip_entry->crc32 = archive_le32dec(p + 14); + zip_entry->compressed_size = archive_le32dec(p + 18); + zip_entry->uncompressed_size = archive_le32dec(p + 22); + filename_length = archive_le16dec(p + 26); + extra_length = archive_le16dec(p + 28); - hsize = zip_get_local_file_header_size(a, 0); - zip_read_consume(a, hsize); - - remaining_bytes = (size_t)rsrc->compressed_size; - metadata_bytes = (size_t)rsrc->uncompressed_size; - mp = metadata; - eof = 0; - while (!eof && remaining_bytes) { - const unsigned char *p; - ssize_t bytes_avail; - size_t bytes_used; + __archive_read_consume(a, 30); - p = __archive_read_ahead(a, 1, &bytes_avail); - if (p == NULL) { - archive_set_error(&a->archive, - ARCHIVE_ERRNO_FILE_FORMAT, - "Truncated ZIP file header"); - ret = ARCHIVE_WARN; - goto exit_mac_metadata; + /* Read the filename. */ + if ((h = __archive_read_ahead(a, filename_length, NULL)) == NULL) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "Truncated ZIP file header"); + return (ARCHIVE_FATAL); + } + if (zip_entry->zip_flags & ZIP_UTF8_NAME) { + /* The filename is stored to be UTF-8. */ + if (zip->sconv_utf8 == NULL) { + zip->sconv_utf8 = + archive_string_conversion_from_charset( + &a->archive, "UTF-8", 1); + if (zip->sconv_utf8 == NULL) + return (ARCHIVE_FATAL); } - if ((size_t)bytes_avail > remaining_bytes) - bytes_avail = remaining_bytes; - switch(rsrc->compression) { - case 0: /* No compression. */ - memcpy(mp, p, bytes_avail); - bytes_used = (size_t)bytes_avail; - metadata_bytes -= bytes_used; - mp += bytes_used; - if (metadata_bytes == 0) - eof = 1; - break; -#ifdef HAVE_ZLIB_H - case 8: /* Deflate compression. */ - { - int r; - - ret = zip_deflate_init(a, zip); - if (ret != ARCHIVE_OK) - goto exit_mac_metadata; - zip->stream.next_in = - (Bytef *)(uintptr_t)(const void *)p; - zip->stream.avail_in = (uInt)bytes_avail; - zip->stream.total_in = 0; - zip->stream.next_out = mp; - zip->stream.avail_out = (uInt)metadata_bytes; - zip->stream.total_out = 0; + sconv = zip->sconv_utf8; + } else if (zip->sconv != NULL) + sconv = zip->sconv; + else + sconv = zip->sconv_default; - r = inflate(&zip->stream, 0); - switch (r) { - case Z_OK: - break; - case Z_STREAM_END: - eof = 1; - break; - case Z_MEM_ERROR: - archive_set_error(&a->archive, ENOMEM, - "Out of memory for ZIP decompression"); - ret = ARCHIVE_FATAL; - goto exit_mac_metadata; - default: - archive_set_error(&a->archive, - ARCHIVE_ERRNO_MISC, - "ZIP decompression failed (%d)", r); - ret = ARCHIVE_FATAL; - goto exit_mac_metadata; - } - bytes_used = zip->stream.total_in; - metadata_bytes -= zip->stream.total_out; - mp += zip->stream.total_out; - break; - } -#endif - default: - bytes_used = 0; - break; + if (archive_entry_copy_pathname_l(entry, + h, filename_length, sconv) != 0) { + if (errno == ENOMEM) { + archive_set_error(&a->archive, ENOMEM, + "Can't allocate memory for Pathname"); + return (ARCHIVE_FATAL); } - zip_read_consume(a, bytes_used); - remaining_bytes -= bytes_used; + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Pathname cannot be converted " + "from %s to current locale.", + archive_string_conversion_charset_name(sconv)); + ret = ARCHIVE_WARN; } - archive_entry_copy_mac_metadata(entry, metadata, - (size_t)rsrc->uncompressed_size - metadata_bytes); - - __archive_read_seek(a, offset, SEEK_SET); - zip->offset = offset; -exit_mac_metadata: - zip->decompress_init = 0; - free(metadata); - return (ret); -} + __archive_read_consume(a, filename_length); -static int -archive_read_format_zip_seekable_read_header(struct archive_read *a, - struct archive_entry *entry) -{ - struct zip *zip = (struct zip *)a->format->data; - struct zip_entry *rsrc; - int r, ret = ARCHIVE_OK; + /* Work around a bug in Info-Zip: When reading from a pipe, it + * stats the pipe instead of synthesizing a file entry. */ + if ((zip_entry->mode & AE_IFMT) == AE_IFIFO) { + zip_entry->mode &= ~ AE_IFMT; + zip_entry->mode |= AE_IFREG; + } - a->archive.archive_format = ARCHIVE_FORMAT_ZIP; - if (a->archive.archive_format_name == NULL) - a->archive.archive_format_name = "ZIP"; + if ((zip_entry->mode & AE_IFMT) == 0) { + /* Especially in streaming mode, we can end up + here without having seen proper mode information. + Guess from the filename. */ + wp = archive_entry_pathname_w(entry); + if (wp != NULL) { + len = wcslen(wp); + if (len > 0 && wp[len - 1] == L'/') + zip_entry->mode |= AE_IFDIR; + else + zip_entry->mode |= AE_IFREG; + } else { + cp = archive_entry_pathname(entry); + len = (cp != NULL)?strlen(cp):0; + if (len > 0 && cp[len - 1] == '/') + zip_entry->mode |= AE_IFDIR; + else + zip_entry->mode |= AE_IFREG; + } + if (zip_entry->mode == AE_IFDIR) { + zip_entry->mode |= 0775; + } else if (zip_entry->mode == AE_IFREG) { + zip_entry->mode |= 0664; + } + } - if (zip->zip_entries == NULL) { - r = slurp_central_directory(a, zip); - zip->entries_remaining = zip->central_directory_entries; - if (r != ARCHIVE_OK) - return r; - /* Get first entry whose local header offset is lower than - * other entries in the archive file. */ - zip->entry = - (struct zip_entry *)ARCHIVE_RB_TREE_MIN(&zip->tree); - } else if (zip->entry != NULL) { - /* Get next entry in local header offset order. */ - zip->entry = (struct zip_entry *)__archive_rb_tree_iterate( - &zip->tree, &zip->entry->node, ARCHIVE_RB_DIR_RIGHT); + /* Read the extra data. */ + if ((h = __archive_read_ahead(a, extra_length, NULL)) == NULL) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "Truncated ZIP file header"); + return (ARCHIVE_FATAL); } - if (zip->entries_remaining <= 0 || zip->entry == NULL) - return ARCHIVE_EOF; - --zip->entries_remaining; + process_extra(h, extra_length, zip_entry); + __archive_read_consume(a, extra_length); + + if (zip_entry->flags & LA_FROM_CENTRAL_DIRECTORY) { + /* If this came from the central dir, it's size info + * is definitive, so ignore the length-at-end flag. */ + zip_entry->zip_flags &= ~ZIP_LENGTH_AT_END; + /* If local header is missing a value, use the one from + the central directory. If both have it, warn about + mismatches. */ + if (zip_entry->crc32 == 0) { + zip_entry->crc32 = zip_entry_central_dir.crc32; + } else if (!zip->ignore_crc32 + && zip_entry->crc32 != zip_entry_central_dir.crc32) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Inconsistent CRC32 values"); + ret = ARCHIVE_WARN; + } + if (zip_entry->compressed_size == 0) { + zip_entry->compressed_size + = zip_entry_central_dir.compressed_size; + } else if (zip_entry->compressed_size + != zip_entry_central_dir.compressed_size) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Inconsistent compressed size: " + "%jd in central directory, %jd in local header", + (intmax_t)zip_entry_central_dir.compressed_size, + (intmax_t)zip_entry->compressed_size); + ret = ARCHIVE_WARN; + } + if (zip_entry->uncompressed_size == 0) { + zip_entry->uncompressed_size + = zip_entry_central_dir.uncompressed_size; + } else if (zip_entry->uncompressed_size + != zip_entry_central_dir.uncompressed_size) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Inconsistent uncompressed size: " + "%jd in central directory, %jd in local header", + (intmax_t)zip_entry_central_dir.uncompressed_size, + (intmax_t)zip_entry->uncompressed_size); + ret = ARCHIVE_WARN; + } + } - if (zip->entry->rsrcname.s) - rsrc = (struct zip_entry *)__archive_rb_tree_find_node( - &zip->tree_rsrc, zip->entry->rsrcname.s); - else - rsrc = NULL; + /* Populate some additional entry fields: */ + archive_entry_set_mode(entry, zip_entry->mode); + archive_entry_set_uid(entry, zip_entry->uid); + archive_entry_set_gid(entry, zip_entry->gid); + archive_entry_set_mtime(entry, zip_entry->mtime, 0); + archive_entry_set_ctime(entry, zip_entry->ctime, 0); + archive_entry_set_atime(entry, zip_entry->atime, 0); - /* File entries are sorted by the header offset, we should mostly - * use zip_read_consume to advance a read point to avoid redundant - * data reading. */ - if (zip->offset < zip->entry->local_header_offset) - zip_read_consume(a, - zip->entry->local_header_offset - zip->offset); - else if (zip->offset != zip->entry->local_header_offset) { - __archive_read_seek(a, zip->entry->local_header_offset, - SEEK_SET); - zip->offset = zip->entry->local_header_offset; - } - zip->unconsumed = 0; - r = zip_read_local_file_header(a, entry, zip); - if (r != ARCHIVE_OK) - return r; if ((zip->entry->mode & AE_IFMT) == AE_IFLNK) { - const void *p; - struct archive_string_conv *sconv; - size_t linkname_length = (size_t)archive_entry_size(entry); + size_t linkname_length = zip_entry->compressed_size; archive_entry_set_size(entry, 0); p = __archive_read_ahead(a, linkname_length, NULL); @@ -749,16 +691,21 @@ archive_read_format_zip_seekable_read_header(struct archive_read *a, "Truncated Zip file"); return ARCHIVE_FATAL; } + if (__archive_read_consume(a, linkname_length) < 0) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "Read error skipping symlink target name"); + return ARCHIVE_FATAL; + } sconv = zip->sconv; - if (sconv == NULL && (zip->entry->flags & ZIP_UTF8_NAME)) + if (sconv == NULL && (zip->entry->zip_flags & ZIP_UTF8_NAME)) sconv = zip->sconv_utf8; if (sconv == NULL) sconv = zip->sconv_default; if (archive_entry_copy_symlink_l(entry, p, linkname_length, sconv) != 0) { if (errno != ENOMEM && sconv == zip->sconv_utf8 && - (zip->entry->flags & ZIP_UTF8_NAME)) + (zip->entry->zip_flags & ZIP_UTF8_NAME)) archive_entry_copy_symlink_l(entry, p, linkname_length, NULL); if (errno == ENOMEM) { @@ -772,7 +719,7 @@ archive_read_format_zip_seekable_read_header(struct archive_read *a, * in an automatic conversion. */ if (sconv != zip->sconv_utf8 || - (zip->entry->flags & ZIP_UTF8_NAME) == 0) { + (zip->entry->zip_flags & ZIP_UTF8_NAME) == 0) { archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Symlink cannot be converted " @@ -782,401 +729,296 @@ archive_read_format_zip_seekable_read_header(struct archive_read *a, ret = ARCHIVE_WARN; } } + zip_entry->uncompressed_size = zip_entry->compressed_size = 0; + } else if (0 == (zip_entry->zip_flags & ZIP_LENGTH_AT_END) + || zip_entry->uncompressed_size > 0) { + /* Set the size only if it's meaningful. */ + archive_entry_set_size(entry, zip_entry->uncompressed_size); } - if (rsrc) { - int ret2 = zip_read_mac_metadata(a, entry, rsrc); - if (ret2 < ret) - ret = ret2; - } - return (ret); -} - -static int -archive_read_format_zip_streamable_bid(struct archive_read *a, int best_bid) -{ - const char *p; - - (void)best_bid; /* UNUSED */ - - if ((p = __archive_read_ahead(a, 4, NULL)) == NULL) - return (-1); + zip->entry_bytes_remaining = zip_entry->compressed_size; - /* - * Bid of 30 here is: 16 bits for "PK", - * next 16-bit field has four options (-2 bits). - * 16 + 16-2 = 30. - */ - if (p[0] == 'P' && p[1] == 'K') { - if ((p[2] == '\001' && p[3] == '\002') - || (p[2] == '\003' && p[3] == '\004') - || (p[2] == '\005' && p[3] == '\006') - || (p[2] == '\007' && p[3] == '\010') - || (p[2] == '0' && p[3] == '0')) - return (30); - } + /* If there's no body, force read_data() to return EOF immediately. */ + if (0 == (zip_entry->zip_flags & ZIP_LENGTH_AT_END) + && zip->entry_bytes_remaining < 1) + zip->end_of_entry = 1; - /* TODO: It's worth looking ahead a little bit for a valid - * PK signature. In particular, that would make it possible - * to read some UUEncoded SFX files or SFX files coming from - * a network socket. */ + /* Set up a more descriptive format name. */ + sprintf(zip->format_name, "ZIP %d.%d (%s)", + version / 10, version % 10, + compression_name(zip->entry->compression)); + a->archive.archive_format_name = zip->format_name; - return (0); + return (ret); } +/* + * Read "uncompressed" data. There are three cases: + * 1) We know the size of the data. This is always true for the + * seeking reader (we've examined the Central Directory already). + * 2) ZIP_LENGTH_AT_END was set, but only the CRC was deferred. + * Info-ZIP seems to do this; we know the size but have to grab + * the CRC from the data descriptor afterwards. + * 3) We're streaming and ZIP_LENGTH_AT_END was specified and + * we have no size information. In this case, we can do pretty + * well by watching for the data descriptor record. The data + * descriptor is 16 bytes and includes a computed CRC that should + * provide a strong check. + * + * TODO: Technically, the PK\007\010 signature is optional. + * In the original spec, the data descriptor contained CRC + * and size fields but had no leading signature. In practice, + * newer writers seem to provide the signature pretty consistently. + * + * For uncompressed data, the PK\007\010 marker seems essential + * to be sure we've actually seen the end of the entry. + * + * Returns ARCHIVE_OK if successful, ARCHIVE_FATAL otherwise, sets + * zip->end_of_entry if it consumes all of the data. + */ static int -archive_read_format_zip_options(struct archive_read *a, - const char *key, const char *val) +zip_read_data_none(struct archive_read *a, const void **_buff, + size_t *size, int64_t *offset) { struct zip *zip; - int ret = ARCHIVE_FAILED; + const char *buff; + ssize_t bytes_avail; + + (void)offset; /* UNUSED */ zip = (struct zip *)(a->format->data); - if (strcmp(key, "compat-2x") == 0) { - /* Handle filnames as libarchive 2.x */ - zip->init_default_conversion = (val != NULL) ? 1 : 0; - return (ARCHIVE_OK); - } else if (strcmp(key, "hdrcharset") == 0) { - if (val == NULL || val[0] == 0) - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "zip: hdrcharset option needs a character-set name" - ); - else { - zip->sconv = archive_string_conversion_from_charset( - &a->archive, val, 0); - if (zip->sconv != NULL) { - if (strcmp(val, "UTF-8") == 0) - zip->sconv_utf8 = zip->sconv; - ret = ARCHIVE_OK; - } else - ret = ARCHIVE_FATAL; + + if (zip->entry->zip_flags & ZIP_LENGTH_AT_END) { + const char *p; + + /* Grab at least 24 bytes. */ + buff = __archive_read_ahead(a, 24, &bytes_avail); + if (bytes_avail < 24) { + /* Zip archives have end-of-archive markers + that are longer than this, so a failure to get at + least 24 bytes really does indicate a truncated + file. */ + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Truncated ZIP file data"); + return (ARCHIVE_FATAL); } - return (ret); + /* Check for a complete PK\007\010 signature, followed + * by the correct 4-byte CRC. */ + p = buff; + if (p[0] == 'P' && p[1] == 'K' + && p[2] == '\007' && p[3] == '\010' + && (archive_le32dec(p + 4) == zip->entry_crc32 + || zip->ignore_crc32)) { + if (zip->entry->flags & LA_USED_ZIP64) { + zip->entry->crc32 = archive_le32dec(p + 4); + zip->entry->compressed_size = archive_le64dec(p + 8); + zip->entry->uncompressed_size = archive_le64dec(p + 16); + zip->unconsumed = 24; + } else { + zip->entry->crc32 = archive_le32dec(p + 4); + zip->entry->compressed_size = archive_le32dec(p + 8); + zip->entry->uncompressed_size = archive_le32dec(p + 12); + zip->unconsumed = 16; + } + zip->end_of_entry = 1; + return (ARCHIVE_OK); + } + /* If not at EOF, ensure we consume at least one byte. */ + ++p; + + /* Scan forward until we see where a PK\007\010 signature + * might be. */ + /* Return bytes up until that point. On the next call, + * the code above will verify the data descriptor. */ + while (p < buff + bytes_avail - 4) { + if (p[3] == 'P') { p += 3; } + else if (p[3] == 'K') { p += 2; } + else if (p[3] == '\007') { p += 1; } + else if (p[3] == '\010' && p[2] == '\007' + && p[1] == 'K' && p[0] == 'P') { + break; + } else { p += 4; } + } + bytes_avail = p - buff; + } else { + if (zip->entry_bytes_remaining == 0) { + zip->end_of_entry = 1; + return (ARCHIVE_OK); + } + /* Grab a bunch of bytes. */ + buff = __archive_read_ahead(a, 1, &bytes_avail); + if (bytes_avail <= 0) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Truncated ZIP file data"); + return (ARCHIVE_FATAL); + } + if (bytes_avail > zip->entry_bytes_remaining) + bytes_avail = (ssize_t)zip->entry_bytes_remaining; } + *size = bytes_avail; + zip->entry_bytes_remaining -= bytes_avail; + zip->entry_uncompressed_bytes_read += bytes_avail; + zip->entry_compressed_bytes_read += bytes_avail; + zip->unconsumed += bytes_avail; + *_buff = buff; + return (ARCHIVE_OK); +} - /* Note: The "warn" return is just to inform the options - * supervisor that we didn't handle it. It will generate - * a suitable error if no one used this option. */ - return (ARCHIVE_WARN); +#ifdef HAVE_ZLIB_H +static int +zip_deflate_init(struct archive_read *a, struct zip *zip) +{ + int r; + + /* If we haven't yet read any data, initialize the decompressor. */ + if (!zip->decompress_init) { + if (zip->stream_valid) + r = inflateReset(&zip->stream); + else + r = inflateInit2(&zip->stream, + -15 /* Don't check for zlib header */); + if (r != Z_OK) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "Can't initialize ZIP decompression."); + return (ARCHIVE_FATAL); + } + /* Stream structure has been set up. */ + zip->stream_valid = 1; + /* We've initialized decompression for this stream. */ + zip->decompress_init = 1; + } + return (ARCHIVE_OK); } static int -archive_read_format_zip_streamable_read_header(struct archive_read *a, - struct archive_entry *entry) +zip_read_data_deflate(struct archive_read *a, const void **buff, + size_t *size, int64_t *offset) { struct zip *zip; + ssize_t bytes_avail; + const void *compressed_buff; + int r; - a->archive.archive_format = ARCHIVE_FORMAT_ZIP; - if (a->archive.archive_format_name == NULL) - a->archive.archive_format_name = "ZIP"; + (void)offset; /* UNUSED */ zip = (struct zip *)(a->format->data); - /* Make sure we have a zip_entry structure to use. */ - if (zip->zip_entries == NULL) { - zip->zip_entries = malloc(sizeof(struct zip_entry)); - if (zip->zip_entries == NULL) { + /* If the buffer hasn't been allocated, allocate it now. */ + if (zip->uncompressed_buffer == NULL) { + zip->uncompressed_buffer_size = 256 * 1024; + zip->uncompressed_buffer + = (unsigned char *)malloc(zip->uncompressed_buffer_size); + if (zip->uncompressed_buffer == NULL) { archive_set_error(&a->archive, ENOMEM, - "Out of memory"); - return ARCHIVE_FATAL; + "No memory for ZIP decompression"); + return (ARCHIVE_FATAL); } } - zip->entry = zip->zip_entries; - memset(zip->entry, 0, sizeof(struct zip_entry)); - - /* Search ahead for the next local file header. */ - zip_read_consume(a, zip->unconsumed); - zip->unconsumed = 0; - for (;;) { - int64_t skipped = 0; - const char *p, *end; - ssize_t bytes; - p = __archive_read_ahead(a, 4, &bytes); - if (p == NULL) - return (ARCHIVE_FATAL); - end = p + bytes; + r = zip_deflate_init(a, zip); + if (r != ARCHIVE_OK) + return (r); - while (p + 4 <= end) { - if (p[0] == 'P' && p[1] == 'K') { - if (p[2] == '\001' && p[3] == '\002') - /* Beginning of central directory. */ - return (ARCHIVE_EOF); + /* + * Note: '1' here is a performance optimization. + * Recall that the decompression layer returns a count of + * available bytes; asking for more than that forces the + * decompressor to combine reads by copying data. + */ + compressed_buff = __archive_read_ahead(a, 1, &bytes_avail); + if (0 == (zip->entry->zip_flags & ZIP_LENGTH_AT_END) + && bytes_avail > zip->entry_bytes_remaining) { + bytes_avail = (ssize_t)zip->entry_bytes_remaining; + } + if (bytes_avail <= 0) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "Truncated ZIP file body"); + return (ARCHIVE_FATAL); + } - if (p[2] == '\003' && p[3] == '\004') { - /* Regular file entry. */ - zip_read_consume(a, skipped); - return zip_read_local_file_header(a, - entry, zip); - } + /* + * A bug in zlib.h: stream.next_in should be marked 'const' + * but isn't (the library never alters data through the + * next_in pointer, only reads it). The result: this ugly + * cast to remove 'const'. + */ + zip->stream.next_in = (Bytef *)(uintptr_t)(const void *)compressed_buff; + zip->stream.avail_in = (uInt)bytes_avail; + zip->stream.total_in = 0; + zip->stream.next_out = zip->uncompressed_buffer; + zip->stream.avail_out = (uInt)zip->uncompressed_buffer_size; + zip->stream.total_out = 0; - if (p[2] == '\005' && p[3] == '\006') - /* End of central directory. */ - return (ARCHIVE_EOF); - } - ++p; - ++skipped; - } - zip_read_consume(a, skipped); + r = inflate(&zip->stream, 0); + switch (r) { + case Z_OK: + break; + case Z_STREAM_END: + zip->end_of_entry = 1; + break; + case Z_MEM_ERROR: + archive_set_error(&a->archive, ENOMEM, + "Out of memory for ZIP decompression"); + return (ARCHIVE_FATAL); + default: + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "ZIP decompression failed (%d)", r); + return (ARCHIVE_FATAL); } -} -static ssize_t -zip_get_local_file_header_size(struct archive_read *a, size_t extra) -{ - const char *p; - ssize_t filename_length, extra_length; + /* Consume as much as the compressor actually used. */ + bytes_avail = zip->stream.total_in; + __archive_read_consume(a, bytes_avail); + zip->entry_bytes_remaining -= bytes_avail; + zip->entry_compressed_bytes_read += bytes_avail; - if ((p = __archive_read_ahead(a, extra + 30, NULL)) == NULL) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, - "Truncated ZIP file header"); - return (ARCHIVE_WARN); - } - p += extra; + *size = zip->stream.total_out; + zip->entry_uncompressed_bytes_read += zip->stream.total_out; + *buff = zip->uncompressed_buffer; - if (memcmp(p, "PK\003\004", 4) != 0) { - archive_set_error(&a->archive, -1, "Damaged Zip archive"); - return ARCHIVE_WARN; + if (zip->end_of_entry && (zip->entry->zip_flags & ZIP_LENGTH_AT_END)) { + const char *p; + + if (NULL == (p = __archive_read_ahead(a, 24, NULL))) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Truncated ZIP end-of-file record"); + return (ARCHIVE_FATAL); + } + /* Consume the optional PK\007\010 marker. */ + if (p[0] == 'P' && p[1] == 'K' && + p[2] == '\007' && p[3] == '\010') { + p += 4; + zip->unconsumed = 4; + } + if (zip->entry->flags & LA_USED_ZIP64) { + zip->entry->crc32 = archive_le32dec(p); + zip->entry->compressed_size = archive_le64dec(p + 4); + zip->entry->uncompressed_size = archive_le64dec(p + 12); + zip->unconsumed += 20; + } else { + zip->entry->crc32 = archive_le32dec(p); + zip->entry->compressed_size = archive_le32dec(p + 4); + zip->entry->uncompressed_size = archive_le32dec(p + 8); + zip->unconsumed += 12; + } } - filename_length = archive_le16dec(p + 26); - extra_length = archive_le16dec(p + 28); - return (30 + filename_length + extra_length); + return (ARCHIVE_OK); } +#endif -/* - * Assumes file pointer is at beginning of local file header. - */ static int -zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry, - struct zip *zip) +archive_read_format_zip_read_data(struct archive_read *a, + const void **buff, size_t *size, int64_t *offset) { - const char *p; - const void *h; - const wchar_t *wp; - const char *cp; - size_t len, filename_length, extra_length; - struct archive_string_conv *sconv; - struct zip_entry *zip_entry = zip->entry; - uint32_t local_crc32; - int64_t compressed_size, uncompressed_size; - int ret = ARCHIVE_OK; - char version; + int r; + struct zip *zip = (struct zip *)(a->format->data); - zip->decompress_init = 0; - zip->end_of_entry = 0; - zip->entry_uncompressed_bytes_read = 0; - zip->entry_compressed_bytes_read = 0; - zip->entry_crc32 = crc32(0, NULL, 0); - - /* Setup default conversion. */ - if (zip->sconv == NULL && !zip->init_default_conversion) { - zip->sconv_default = - archive_string_default_conversion_for_read(&(a->archive)); - zip->init_default_conversion = 1; - } - - if ((p = __archive_read_ahead(a, 30, NULL)) == NULL) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, - "Truncated ZIP file header"); - return (ARCHIVE_FATAL); - } - - if (memcmp(p, "PK\003\004", 4) != 0) { - archive_set_error(&a->archive, -1, "Damaged Zip archive"); - return ARCHIVE_FATAL; - } - version = p[4]; - zip_entry->system = p[5]; - zip_entry->flags = archive_le16dec(p + 6); - zip_entry->compression = (char)archive_le16dec(p + 8); - zip_entry->mtime = zip_time(p + 10); - local_crc32 = archive_le32dec(p + 14); - compressed_size = archive_le32dec(p + 18); - uncompressed_size = archive_le32dec(p + 22); - filename_length = archive_le16dec(p + 26); - extra_length = archive_le16dec(p + 28); - - zip_read_consume(a, 30); - - if (zip->have_central_directory) { - /* If we read the central dir entry, we must have size - * information as well, so ignore the length-at-end flag. */ - zip_entry->flags &= ~ZIP_LENGTH_AT_END; - /* If we have values from both the local file header - and the central directory, warn about mismatches - which might indicate a damaged file. But some - writers always put zero in the local header; don't - bother warning about that. */ - if (local_crc32 != 0 && local_crc32 != zip_entry->crc32) { - archive_set_error(&a->archive, - ARCHIVE_ERRNO_FILE_FORMAT, - "Inconsistent CRC32 values"); - ret = ARCHIVE_WARN; - } - if (compressed_size != 0 - && compressed_size != zip_entry->compressed_size) { - archive_set_error(&a->archive, - ARCHIVE_ERRNO_FILE_FORMAT, - "Inconsistent compressed size"); - ret = ARCHIVE_WARN; - } - if (uncompressed_size != 0 - && uncompressed_size != zip_entry->uncompressed_size) { - archive_set_error(&a->archive, - ARCHIVE_ERRNO_FILE_FORMAT, - "Inconsistent uncompressed size"); - ret = ARCHIVE_WARN; - } - } else { - /* If we don't have the CD info, use whatever we do have. */ - zip_entry->crc32 = local_crc32; - zip_entry->compressed_size = compressed_size; - zip_entry->uncompressed_size = uncompressed_size; - } - - /* Read the filename. */ - if ((h = __archive_read_ahead(a, filename_length, NULL)) == NULL) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, - "Truncated ZIP file header"); - return (ARCHIVE_FATAL); - } - if (zip_entry->flags & ZIP_UTF8_NAME) { - /* The filename is stored to be UTF-8. */ - if (zip->sconv_utf8 == NULL) { - zip->sconv_utf8 = - archive_string_conversion_from_charset( - &a->archive, "UTF-8", 1); - if (zip->sconv_utf8 == NULL) - return (ARCHIVE_FATAL); - } - sconv = zip->sconv_utf8; - } else if (zip->sconv != NULL) - sconv = zip->sconv; - else - sconv = zip->sconv_default; - - if (archive_entry_copy_pathname_l(entry, - h, filename_length, sconv) != 0) { - if (errno == ENOMEM) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate memory for Pathname"); - return (ARCHIVE_FATAL); - } - archive_set_error(&a->archive, - ARCHIVE_ERRNO_FILE_FORMAT, - "Pathname cannot be converted " - "from %s to current locale.", - archive_string_conversion_charset_name(sconv)); - ret = ARCHIVE_WARN; - } - zip_read_consume(a, filename_length); - - if (zip_entry->mode == 0) { - /* Especially in streaming mode, we can end up - here without having seen any mode information. - Guess from the filename. */ - wp = archive_entry_pathname_w(entry); - if (wp != NULL) { - len = wcslen(wp); - if (len > 0 && wp[len - 1] == L'/') - zip_entry->mode = AE_IFDIR | 0777; - else - zip_entry->mode = AE_IFREG | 0666; - } else { - cp = archive_entry_pathname(entry); - len = (cp != NULL)?strlen(cp):0; - if (len > 0 && cp[len - 1] == '/') - zip_entry->mode = AE_IFDIR | 0777; - else - zip_entry->mode = AE_IFREG | 0666; - } - } - - /* Read the extra data. */ - if ((h = __archive_read_ahead(a, extra_length, NULL)) == NULL) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, - "Truncated ZIP file header"); - return (ARCHIVE_FATAL); - } - process_extra(h, extra_length, zip_entry); - zip_read_consume(a, extra_length); - - /* Populate some additional entry fields: */ - archive_entry_set_mode(entry, zip_entry->mode); - archive_entry_set_uid(entry, zip_entry->uid); - archive_entry_set_gid(entry, zip_entry->gid); - archive_entry_set_mtime(entry, zip_entry->mtime, 0); - archive_entry_set_ctime(entry, zip_entry->ctime, 0); - archive_entry_set_atime(entry, zip_entry->atime, 0); - /* Set the size only if it's meaningful. */ - if (0 == (zip_entry->flags & ZIP_LENGTH_AT_END)) - archive_entry_set_size(entry, zip_entry->uncompressed_size); - - zip->entry_bytes_remaining = zip_entry->compressed_size; - - /* If there's no body, force read_data() to return EOF immediately. */ - if (0 == (zip_entry->flags & ZIP_LENGTH_AT_END) - && zip->entry_bytes_remaining < 1) - zip->end_of_entry = 1; - - /* Set up a more descriptive format name. */ - sprintf(zip->format_name, "ZIP %d.%d (%s)", - version / 10, version % 10, - compression_name(zip->entry->compression)); - a->archive.archive_format_name = zip->format_name; - - return (ret); -} - -static const char * -compression_name(int compression) -{ - static const char *compression_names[] = { - "uncompressed", - "shrinking", - "reduced-1", - "reduced-2", - "reduced-3", - "reduced-4", - "imploded", - "reserved", - "deflation" - }; - - if (0 <= compression && compression < - (int)(sizeof(compression_names)/sizeof(compression_names[0]))) - return compression_names[compression]; - else - return "??"; -} - -/* Convert an MSDOS-style date/time into Unix-style time. */ -static time_t -zip_time(const char *p) -{ - int msTime, msDate; - struct tm ts; - - msTime = (0xff & (unsigned)p[0]) + 256 * (0xff & (unsigned)p[1]); - msDate = (0xff & (unsigned)p[2]) + 256 * (0xff & (unsigned)p[3]); - - memset(&ts, 0, sizeof(ts)); - ts.tm_year = ((msDate >> 9) & 0x7f) + 80; /* Years since 1900. */ - ts.tm_mon = ((msDate >> 5) & 0x0f) - 1; /* Month number. */ - ts.tm_mday = msDate & 0x1f; /* Day of month. */ - ts.tm_hour = (msTime >> 11) & 0x1f; - ts.tm_min = (msTime >> 5) & 0x3f; - ts.tm_sec = (msTime << 1) & 0x3e; - ts.tm_isdst = -1; - return mktime(&ts); -} - -static int -archive_read_format_zip_read_data(struct archive_read *a, - const void **buff, size_t *size, int64_t *offset) -{ - int r; - struct zip *zip = (struct zip *)(a->format->data); + if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) { + zip->has_encrypted_entries = 0; + } *offset = zip->entry_uncompressed_bytes_read; *size = 0; @@ -1190,13 +1032,14 @@ archive_read_format_zip_read_data(struct archive_read *a, if (AE_IFREG != (zip->entry->mode & AE_IFMT)) return (ARCHIVE_EOF); - if (zip->entry->flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)) { + if (zip->entry->zip_flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)) { + zip->has_encrypted_entries = 1; archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Encrypted file is unsupported"); return (ARCHIVE_FAILED); } - zip_read_consume(a, zip->unconsumed); + __archive_read_consume(a, zip->unconsumed); zip->unconsumed = 0; switch(zip->entry->compression) { @@ -1222,7 +1065,7 @@ archive_read_format_zip_read_data(struct archive_read *a, return (r); /* Update checksum */ if (*size) - zip->entry_crc32 = crc32(zip->entry_crc32, *buff, + zip->entry_crc32 = zip->crc32func(zip->entry_crc32, *buff, (unsigned)*size); /* If we hit the end, swallow any end-of-data marker. */ if (zip->end_of_entry) { @@ -1242,13 +1085,14 @@ archive_read_format_zip_read_data(struct archive_read *a, != (zip->entry_uncompressed_bytes_read & UINT32_MAX)) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "ZIP uncompressed data is wrong size " - "(read %jd, expected %jd)", + "(read %jd, expected %jd)\n", (intmax_t)zip->entry_uncompressed_bytes_read, (intmax_t)zip->entry->uncompressed_size); return (ARCHIVE_WARN); } /* Check computed CRC against header */ - if (zip->entry->crc32 != zip->entry_crc32) { + if (zip->entry->crc32 != zip->entry_crc32 + && !zip->ignore_crc32) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "ZIP bad CRC: 0x%lx should be 0x%lx", (unsigned long)zip->entry_crc32, @@ -1260,268 +1104,263 @@ archive_read_format_zip_read_data(struct archive_read *a, return (ARCHIVE_OK); } -/* - * Read "uncompressed" data. There are three cases: - * 1) We know the size of the data. This is always true for the - * seeking reader (we've examined the Central Directory already). - * 2) ZIP_LENGTH_AT_END was set, but only the CRC was deferred. - * Info-ZIP seems to do this; we know the size but have to grab - * the CRC from the data descriptor afterwards. - * 3) We're streaming and ZIP_LENGTH_AT_END was specified and - * we have no size information. In this case, we can do pretty - * well by watching for the data descriptor record. The data - * descriptor is 16 bytes and includes a computed CRC that should - * provide a strong check. - * - * TODO: Technically, the PK\007\010 signature is optional. - * In the original spec, the data descriptor contained CRC - * and size fields but had no leading signature. In practice, - * newer writers seem to provide the signature pretty consistently, - * but we might need to do something more complex here if - * we want to handle older archives that lack that signature. - * - * Returns ARCHIVE_OK if successful, ARCHIVE_FATAL otherwise, sets - * zip->end_of_entry if it consumes all of the data. - */ static int -zip_read_data_none(struct archive_read *a, const void **_buff, - size_t *size, int64_t *offset) +archive_read_format_zip_cleanup(struct archive_read *a) { struct zip *zip; - const char *buff; - ssize_t bytes_avail; - - (void)offset; /* UNUSED */ + struct zip_entry *zip_entry, *next_zip_entry; zip = (struct zip *)(a->format->data); - - if (zip->entry->flags & ZIP_LENGTH_AT_END) { - const char *p; - - /* Grab at least 16 bytes. */ - buff = __archive_read_ahead(a, 16, &bytes_avail); - if (bytes_avail < 16) { - /* Zip archives have end-of-archive markers - that are longer than this, so a failure to get at - least 16 bytes really does indicate a truncated - file. */ - archive_set_error(&a->archive, - ARCHIVE_ERRNO_FILE_FORMAT, - "Truncated ZIP file data"); - return (ARCHIVE_FATAL); - } - /* Check for a complete PK\007\010 signature. */ - p = buff; - if (p[0] == 'P' && p[1] == 'K' - && p[2] == '\007' && p[3] == '\010' - && archive_le32dec(p + 4) == zip->entry_crc32 - && archive_le32dec(p + 8) == - zip->entry_compressed_bytes_read - && archive_le32dec(p + 12) == - zip->entry_uncompressed_bytes_read) { - zip->entry->crc32 = archive_le32dec(p + 4); - zip->entry->compressed_size = archive_le32dec(p + 8); - zip->entry->uncompressed_size = archive_le32dec(p + 12); - zip->end_of_entry = 1; - zip->unconsumed = 16; - return (ARCHIVE_OK); +#ifdef HAVE_ZLIB_H + if (zip->stream_valid) + inflateEnd(&zip->stream); + free(zip->uncompressed_buffer); +#endif + if (zip->zip_entries) { + zip_entry = zip->zip_entries; + while (zip_entry != NULL) { + next_zip_entry = zip_entry->next; + archive_string_free(&zip_entry->rsrcname); + free(zip_entry); + zip_entry = next_zip_entry; } - /* If not at EOF, ensure we consume at least one byte. */ - ++p; + } + free(zip); + (a->format->data) = NULL; + return (ARCHIVE_OK); +} - /* Scan forward until we see where a PK\007\010 signature - * might be. */ - /* Return bytes up until that point. On the next call, - * the code above will verify the data descriptor. */ - while (p < buff + bytes_avail - 4) { - if (p[3] == 'P') { p += 3; } - else if (p[3] == 'K') { p += 2; } - else if (p[3] == '\007') { p += 1; } - else if (p[3] == '\010' && p[2] == '\007' - && p[1] == 'K' && p[0] == 'P') { - break; - } else { p += 4; } - } - bytes_avail = p - buff; - } else { - if (zip->entry_bytes_remaining == 0) { - zip->end_of_entry = 1; - return (ARCHIVE_OK); - } - /* Grab a bunch of bytes. */ - buff = __archive_read_ahead(a, 1, &bytes_avail); - if (bytes_avail <= 0) { - archive_set_error(&a->archive, - ARCHIVE_ERRNO_FILE_FORMAT, - "Truncated ZIP file data"); - return (ARCHIVE_FATAL); +static int +archive_read_format_zip_has_encrypted_entries(struct archive_read *_a) +{ + if (_a && _a->format) { + struct zip * zip = (struct zip *)_a->format->data; + if (zip) { + return zip->has_encrypted_entries; } - if (bytes_avail > zip->entry_bytes_remaining) - bytes_avail = (ssize_t)zip->entry_bytes_remaining; } - *size = bytes_avail; - zip->entry_bytes_remaining -= bytes_avail; - zip->entry_uncompressed_bytes_read += bytes_avail; - zip->entry_compressed_bytes_read += bytes_avail; - zip->unconsumed += bytes_avail; - *_buff = buff; - return (ARCHIVE_OK); + return ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW; } -#ifdef HAVE_ZLIB_H static int -zip_deflate_init(struct archive_read *a, struct zip *zip) +archive_read_format_zip_options(struct archive_read *a, + const char *key, const char *val) { - int r; + struct zip *zip; + int ret = ARCHIVE_FAILED; - /* If we haven't yet read any data, initialize the decompressor. */ - if (!zip->decompress_init) { - if (zip->stream_valid) - r = inflateReset(&zip->stream); - else - r = inflateInit2(&zip->stream, - -15 /* Don't check for zlib header */); - if (r != Z_OK) { + zip = (struct zip *)(a->format->data); + if (strcmp(key, "compat-2x") == 0) { + /* Handle filenames as libarchive 2.x */ + zip->init_default_conversion = (val != NULL) ? 1 : 0; + return (ARCHIVE_OK); + } else if (strcmp(key, "hdrcharset") == 0) { + if (val == NULL || val[0] == 0) archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "Can't initialize ZIP decompression."); - return (ARCHIVE_FATAL); + "zip: hdrcharset option needs a character-set name" + ); + else { + zip->sconv = archive_string_conversion_from_charset( + &a->archive, val, 0); + if (zip->sconv != NULL) { + if (strcmp(val, "UTF-8") == 0) + zip->sconv_utf8 = zip->sconv; + ret = ARCHIVE_OK; + } else + ret = ARCHIVE_FATAL; } - /* Stream structure has been set up. */ - zip->stream_valid = 1; - /* We've initialized decompression for this stream. */ - zip->decompress_init = 1; + return (ret); + } else if (strcmp(key, "ignorecrc32") == 0) { + /* Mostly useful for testing. */ + if (val == NULL || val[0] == 0) { + zip->crc32func = real_crc32; + zip->ignore_crc32 = 0; + } else { + zip->crc32func = fake_crc32; + zip->ignore_crc32 = 1; + } + return (ARCHIVE_OK); + } else if (strcmp(key, "mac-ext") == 0) { + zip->process_mac_extensions = (val != NULL && val[0] != 0); + return (ARCHIVE_OK); } - return (ARCHIVE_OK); + + /* Note: The "warn" return is just to inform the options + * supervisor that we didn't handle it. It will generate + * a suitable error if no one used this option. */ + return (ARCHIVE_WARN); } -static int -zip_read_data_deflate(struct archive_read *a, const void **buff, - size_t *size, int64_t *offset) +int +archive_read_support_format_zip(struct archive *a) { - struct zip *zip; - ssize_t bytes_avail; - const void *compressed_buff; int r; + r = archive_read_support_format_zip_streamable(a); + if (r != ARCHIVE_OK) + return r; + return (archive_read_support_format_zip_seekable(a)); +} - (void)offset; /* UNUSED */ +/* ------------------------------------------------------------------------ */ - zip = (struct zip *)(a->format->data); +/* + * Streaming-mode support + */ - /* If the buffer hasn't been allocated, allocate it now. */ - if (zip->uncompressed_buffer == NULL) { - zip->uncompressed_buffer_size = 256 * 1024; - zip->uncompressed_buffer - = (unsigned char *)malloc(zip->uncompressed_buffer_size); - if (zip->uncompressed_buffer == NULL) { - archive_set_error(&a->archive, ENOMEM, - "No memory for ZIP decompression"); - return (ARCHIVE_FATAL); - } - } - r = zip_deflate_init(a, zip); - if (r != ARCHIVE_OK) - return (r); +static int +archive_read_support_format_zip_capabilities_streamable(struct archive_read * a) +{ + (void)a; /* UNUSED */ + return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA); +} + +static int +archive_read_format_zip_streamable_bid(struct archive_read *a, int best_bid) +{ + const char *p; + + (void)best_bid; /* UNUSED */ + + if ((p = __archive_read_ahead(a, 4, NULL)) == NULL) + return (-1); /* - * Note: '1' here is a performance optimization. - * Recall that the decompression layer returns a count of - * available bytes; asking for more than that forces the - * decompressor to combine reads by copying data. + * Bid of 29 here comes from: + * + 16 bits for "PK", + * + next 16-bit field has 6 options so contributes + * about 16 - log_2(6) ~= 16 - 2.6 ~= 13 bits + * + * So we've effectively verified ~29 total bits of check data. */ - compressed_buff = __archive_read_ahead(a, 1, &bytes_avail); - if (0 == (zip->entry->flags & ZIP_LENGTH_AT_END) - && bytes_avail > zip->entry_bytes_remaining) { - bytes_avail = (ssize_t)zip->entry_bytes_remaining; - } - if (bytes_avail <= 0) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, - "Truncated ZIP file body"); - return (ARCHIVE_FATAL); + if (p[0] == 'P' && p[1] == 'K') { + if ((p[2] == '\001' && p[3] == '\002') + || (p[2] == '\003' && p[3] == '\004') + || (p[2] == '\005' && p[3] == '\006') + || (p[2] == '\006' && p[3] == '\006') + || (p[2] == '\007' && p[3] == '\010') + || (p[2] == '0' && p[3] == '0')) + return (29); } + /* TODO: It's worth looking ahead a little bit for a valid + * PK signature. In particular, that would make it possible + * to read some UUEncoded SFX files or SFX files coming from + * a network socket. */ + + return (0); +} + +static int +archive_read_format_zip_streamable_read_header(struct archive_read *a, + struct archive_entry *entry) +{ + struct zip *zip; + + a->archive.archive_format = ARCHIVE_FORMAT_ZIP; + if (a->archive.archive_format_name == NULL) + a->archive.archive_format_name = "ZIP"; + + zip = (struct zip *)(a->format->data); + /* - * A bug in zlib.h: stream.next_in should be marked 'const' - * but isn't (the library never alters data through the - * next_in pointer, only reads it). The result: this ugly - * cast to remove 'const'. + * It should be sufficient to call archive_read_next_header() for + * a reader to determine if an entry is encrypted or not. If the + * encryption of an entry is only detectable when calling + * archive_read_data(), so be it. We'll do the same check there + * as well. */ - zip->stream.next_in = (Bytef *)(uintptr_t)(const void *)compressed_buff; - zip->stream.avail_in = (uInt)bytes_avail; - zip->stream.total_in = 0; - zip->stream.next_out = zip->uncompressed_buffer; - zip->stream.avail_out = (uInt)zip->uncompressed_buffer_size; - zip->stream.total_out = 0; + if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) { + zip->has_encrypted_entries = 0; + } - r = inflate(&zip->stream, 0); - switch (r) { - case Z_OK: - break; - case Z_STREAM_END: - zip->end_of_entry = 1; - break; - case Z_MEM_ERROR: - archive_set_error(&a->archive, ENOMEM, - "Out of memory for ZIP decompression"); - return (ARCHIVE_FATAL); - default: - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "ZIP decompression failed (%d)", r); - return (ARCHIVE_FATAL); + /* Make sure we have a zip_entry structure to use. */ + if (zip->zip_entries == NULL) { + zip->zip_entries = malloc(sizeof(struct zip_entry)); + if (zip->zip_entries == NULL) { + archive_set_error(&a->archive, ENOMEM, + "Out of memory"); + return ARCHIVE_FATAL; + } } + zip->entry = zip->zip_entries; + memset(zip->entry, 0, sizeof(struct zip_entry)); - /* Consume as much as the compressor actually used. */ - bytes_avail = zip->stream.total_in; - zip_read_consume(a, bytes_avail); - zip->entry_bytes_remaining -= bytes_avail; - zip->entry_compressed_bytes_read += bytes_avail; + /* Search ahead for the next local file header. */ + __archive_read_consume(a, zip->unconsumed); + zip->unconsumed = 0; + for (;;) { + int64_t skipped = 0; + const char *p, *end; + ssize_t bytes; - *size = zip->stream.total_out; - zip->entry_uncompressed_bytes_read += zip->stream.total_out; - *buff = zip->uncompressed_buffer; + p = __archive_read_ahead(a, 4, &bytes); + if (p == NULL) + return (ARCHIVE_FATAL); + end = p + bytes; - if (zip->end_of_entry && (zip->entry->flags & ZIP_LENGTH_AT_END)) { - const char *p; + while (p + 4 <= end) { + if (p[0] == 'P' && p[1] == 'K') { + if (p[2] == '\003' && p[3] == '\004') { + /* Regular file entry. */ + __archive_read_consume(a, skipped); + return zip_read_local_file_header(a, + entry, zip); + } - if (NULL == (p = __archive_read_ahead(a, 16, NULL))) { - archive_set_error(&a->archive, - ARCHIVE_ERRNO_FILE_FORMAT, - "Truncated ZIP end-of-file record"); - return (ARCHIVE_FATAL); - } - /* Consume the optional PK\007\010 marker. */ - if (p[0] == 'P' && p[1] == 'K' && - p[2] == '\007' && p[3] == '\010') { - zip->entry->crc32 = archive_le32dec(p + 4); - zip->entry->compressed_size = archive_le32dec(p + 8); - zip->entry->uncompressed_size = archive_le32dec(p + 12); - zip->unconsumed = 16; + /* + * TODO: We cannot restore permissions + * based only on the local file headers. + * Consider scanning the central + * directory and returning additional + * entries for at least directories. + * This would allow us to properly set + * directory permissions. + * + * This won't help us fix symlinks + * and may not help with regular file + * permissions, either. + */ + if (p[2] == '\001' && p[3] == '\002') { + return (ARCHIVE_EOF); + } + + /* End of central directory? Must be an + * empty archive. */ + if ((p[2] == '\005' && p[3] == '\006') + || (p[2] == '\006' && p[3] == '\006')) + return (ARCHIVE_EOF); + } + ++p; + ++skipped; } + __archive_read_consume(a, skipped); } - - return (ARCHIVE_OK); } -#endif static int -archive_read_format_zip_read_data_skip(struct archive_read *a) +archive_read_format_zip_read_data_skip_streamable(struct archive_read *a) { struct zip *zip; + int64_t bytes_skipped; zip = (struct zip *)(a->format->data); + bytes_skipped = __archive_read_consume(a, zip->unconsumed); + zip->unconsumed = 0; + if (bytes_skipped < 0) + return (ARCHIVE_FATAL); /* If we've already read to end of data, we're done. */ if (zip->end_of_entry) return (ARCHIVE_OK); /* So we know we're streaming... */ - if (0 == (zip->entry->flags & ZIP_LENGTH_AT_END)) { + if (0 == (zip->entry->zip_flags & ZIP_LENGTH_AT_END) + || zip->entry->compressed_size > 0) { /* We know the compressed length, so we can just skip. */ - int64_t bytes_skipped = zip_read_consume(a, - zip->entry_bytes_remaining + zip->unconsumed); + bytes_skipped = __archive_read_consume(a, zip->entry_bytes_remaining); if (bytes_skipped < 0) return (ARCHIVE_FATAL); - zip->unconsumed = 0; return (ARCHIVE_OK); } @@ -1544,8 +1383,6 @@ archive_read_format_zip_read_data_skip(struct archive_read *a) #endif default: /* Uncompressed or unknown. */ /* Scan for a PK\007\010 signature. */ - zip_read_consume(a, zip->unconsumed); - zip->unconsumed = 0; for (;;) { const char *p, *buff; ssize_t bytes_avail; @@ -1563,180 +1400,772 @@ archive_read_format_zip_read_data_skip(struct archive_read *a) else if (p[3] == '\007') { p += 1; } else if (p[3] == '\010' && p[2] == '\007' && p[1] == 'K' && p[0] == 'P') { - zip_read_consume(a, p - buff + 16); + if (zip->entry->flags & LA_USED_ZIP64) + __archive_read_consume(a, p - buff + 24); + else + __archive_read_consume(a, p - buff + 16); return ARCHIVE_OK; } else { p += 4; } } - zip_read_consume(a, p - buff); + __archive_read_consume(a, p - buff); } } } -static int -archive_read_format_zip_cleanup(struct archive_read *a) +int +archive_read_support_format_zip_streamable(struct archive *_a) { + struct archive_read *a = (struct archive_read *)_a; struct zip *zip; + int r; - zip = (struct zip *)(a->format->data); -#ifdef HAVE_ZLIB_H - if (zip->stream_valid) - inflateEnd(&zip->stream); -#endif - if (zip->zip_entries && zip->central_directory_entries) { - unsigned i; - for (i = 0; i < zip->central_directory_entries; i++) - archive_string_free(&(zip->zip_entries[i].rsrcname)); + archive_check_magic(_a, ARCHIVE_READ_MAGIC, + ARCHIVE_STATE_NEW, "archive_read_support_format_zip"); + + zip = (struct zip *)malloc(sizeof(*zip)); + if (zip == NULL) { + archive_set_error(&a->archive, ENOMEM, + "Can't allocate zip data"); + return (ARCHIVE_FATAL); } - free(zip->zip_entries); - free(zip->uncompressed_buffer); - archive_string_free(&(zip->extra)); - free(zip); - (a->format->data) = NULL; + memset(zip, 0, sizeof(*zip)); + + /* Streamable reader doesn't support mac extensions. */ + zip->process_mac_extensions = 0; + + /* + * Until enough data has been read, we cannot tell about + * any encrypted entries yet. + */ + zip->has_encrypted_entries = ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW; + zip->crc32func = real_crc32; + + r = __archive_read_register_format(a, + zip, + "zip", + archive_read_format_zip_streamable_bid, + archive_read_format_zip_options, + archive_read_format_zip_streamable_read_header, + archive_read_format_zip_read_data, + archive_read_format_zip_read_data_skip_streamable, + NULL, + archive_read_format_zip_cleanup, + archive_read_support_format_zip_capabilities_streamable, + archive_read_format_zip_has_encrypted_entries); + + if (r != ARCHIVE_OK) + free(zip); return (ARCHIVE_OK); } +/* ------------------------------------------------------------------------ */ + /* - * The extra data is stored as a list of - * id1+size1+data1 + id2+size2+data2 ... - * triplets. id and size are 2 bytes each. + * Seeking-mode support */ -static void -process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry) + +static int +archive_read_support_format_zip_capabilities_seekable(struct archive_read * a) { - unsigned offset = 0; + (void)a; /* UNUSED */ + return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA); +} - while (offset < extra_length - 4) - { - unsigned short headerid = archive_le16dec(p + offset); - unsigned short datasize = archive_le16dec(p + offset + 2); - offset += 4; - if (offset + datasize > extra_length) - break; -#ifdef DEBUG - fprintf(stderr, "Header id 0x%x, length %d\n", - headerid, datasize); -#endif - switch (headerid) { - case 0x0001: - /* Zip64 extended information extra field. */ - if (datasize >= 8) - zip_entry->uncompressed_size = - archive_le64dec(p + offset); - if (datasize >= 16) - zip_entry->compressed_size = - archive_le64dec(p + offset + 8); - break; - case 0x5455: - { - /* Extended time field "UT". */ - int flags = p[offset]; - offset++; - datasize--; - /* Flag bits indicate which dates are present. */ - if (flags & 0x01) - { -#ifdef DEBUG - fprintf(stderr, "mtime: %lld -> %d\n", - (long long)zip_entry->mtime, - archive_le32dec(p + offset)); -#endif - if (datasize < 4) - break; - zip_entry->mtime = archive_le32dec(p + offset); - offset += 4; - datasize -= 4; - } - if (flags & 0x02) - { - if (datasize < 4) - break; - zip_entry->atime = archive_le32dec(p + offset); - offset += 4; - datasize -= 4; +/* + * TODO: This is a performance sink because it forces the read core to + * drop buffered data from the start of file, which will then have to + * be re-read again if this bidder loses. + * + * We workaround this a little by passing in the best bid so far so + * that later bidders can do nothing if they know they'll never + * outbid. But we can certainly do better... + */ +static int +read_eocd(struct zip *zip, const char *p, int64_t current_offset) +{ + /* Sanity-check the EOCD we've found. */ + + /* This must be the first volume. */ + if (archive_le16dec(p + 4) != 0) + return 0; + /* Central directory must be on this volume. */ + if (archive_le16dec(p + 4) != archive_le16dec(p + 6)) + return 0; + /* All central directory entries must be on this volume. */ + if (archive_le16dec(p + 10) != archive_le16dec(p + 8)) + return 0; + /* Central directory can't extend beyond start of EOCD record. */ + if (archive_le32dec(p + 16) + archive_le32dec(p + 12) + > current_offset) + return 0; + + /* Save the central directory location for later use. */ + zip->central_directory_offset = archive_le32dec(p + 16); + + /* This is just a tiny bit higher than the maximum + returned by the streaming Zip bidder. This ensures + that the more accurate seeking Zip parser wins + whenever seek is available. */ + return 32; +} + +static int +read_zip64_eocd(struct archive_read *a, struct zip *zip, const char *p) +{ + int64_t eocd64_offset; + int64_t eocd64_size; + + /* Sanity-check the locator record. */ + + /* Central dir must be on first volume. */ + if (archive_le32dec(p + 4) != 0) + return 0; + /* Must be only a single volume. */ + if (archive_le32dec(p + 16) != 1) + return 0; + + /* Find the Zip64 EOCD record. */ + eocd64_offset = archive_le64dec(p + 8); + if (__archive_read_seek(a, eocd64_offset, SEEK_SET) < 0) + return 0; + if ((p = __archive_read_ahead(a, 56, NULL)) == NULL) + return 0; + /* Make sure we can read all of it. */ + eocd64_size = archive_le64dec(p + 4) + 12; + if (eocd64_size < 56 || eocd64_size > 16384) + return 0; + if ((p = __archive_read_ahead(a, eocd64_size, NULL)) == NULL) + return 0; + + /* Sanity-check the EOCD64 */ + if (archive_le32dec(p + 16) != 0) /* Must be disk #0 */ + return 0; + if (archive_le32dec(p + 20) != 0) /* CD must be on disk #0 */ + return 0; + /* CD can't be split. */ + if (archive_le64dec(p + 24) != archive_le64dec(p + 32)) + return 0; + + /* Save the central directory offset for later use. */ + zip->central_directory_offset = archive_le64dec(p + 48); + + return 32; +} + +static int +archive_read_format_zip_seekable_bid(struct archive_read *a, int best_bid) +{ + struct zip *zip = (struct zip *)a->format->data; + int64_t file_size, current_offset; + const char *p; + int i, tail; + + /* If someone has already bid more than 32, then avoid + trashing the look-ahead buffers with a seek. */ + if (best_bid > 32) + return (-1); + + file_size = __archive_read_seek(a, 0, SEEK_END); + if (file_size <= 0) + return 0; + + /* Search last 16k of file for end-of-central-directory + * record (which starts with PK\005\006) or Zip64 locator + * record (which begins with PK\006\007) */ + tail = zipmin(1024 * 16, file_size); + current_offset = __archive_read_seek(a, -tail, SEEK_END); + if (current_offset < 0) + return 0; + if ((p = __archive_read_ahead(a, (size_t)tail, NULL)) == NULL) + return 0; + /* TODO: Rework this to search backwards from the end. We + * normally expect the EOCD record to be at the very end, so + * that should be significantly faster. Tricky part: Make + * sure we still prefer the Zip64 locator if it's present. */ + for (i = 0; i <= tail - 22;) { + switch (p[i + 3]) { + case 'P': i += 3; break; + case 'K': i += 2; break; + case 005: i += 1; break; + case 006: + if (memcmp(p + i, "PK\005\006", 4) == 0) { + int ret = read_eocd(zip, p + i, current_offset + i); + if (ret > 0) + return (ret); } - if (flags & 0x04) - { - if (datasize < 4) - break; - zip_entry->ctime = archive_le32dec(p + offset); - offset += 4; - datasize -= 4; + i += 1; /* Look for PK\006\007 next */ + break; + case 007: + if (memcmp(p + i, "PK\006\007", 4) == 0) { + int ret = read_zip64_eocd(a, zip, p + i); + if (ret > 0) + return (ret); } + i += 4; break; + default: i += 4; break; } - case 0x5855: - { - /* Info-ZIP Unix Extra Field (old version) "UX". */ - if (datasize >= 8) { - zip_entry->atime = archive_le32dec(p + offset); - zip_entry->mtime = - archive_le32dec(p + offset + 4); - } - if (datasize >= 12) { - zip_entry->uid = - archive_le16dec(p + offset + 8); - zip_entry->gid = - archive_le16dec(p + offset + 10); + } + return 0; +} + +/* The red-black trees are only used in seeking mode to manage + * the in-memory copy of the central directory. */ + +static int +cmp_node(const struct archive_rb_node *n1, const struct archive_rb_node *n2) +{ + const struct zip_entry *e1 = (const struct zip_entry *)n1; + const struct zip_entry *e2 = (const struct zip_entry *)n2; + + if (e1->local_header_offset > e2->local_header_offset) + return -1; + if (e1->local_header_offset < e2->local_header_offset) + return 1; + return 0; +} + +static int +cmp_key(const struct archive_rb_node *n, const void *key) +{ + /* This function won't be called */ + (void)n; /* UNUSED */ + (void)key; /* UNUSED */ + return 1; +} + +static const struct archive_rb_tree_ops rb_ops = { + &cmp_node, &cmp_key +}; + +static int +rsrc_cmp_node(const struct archive_rb_node *n1, + const struct archive_rb_node *n2) +{ + const struct zip_entry *e1 = (const struct zip_entry *)n1; + const struct zip_entry *e2 = (const struct zip_entry *)n2; + + return (strcmp(e2->rsrcname.s, e1->rsrcname.s)); +} + +static int +rsrc_cmp_key(const struct archive_rb_node *n, const void *key) +{ + const struct zip_entry *e = (const struct zip_entry *)n; + return (strcmp((const char *)key, e->rsrcname.s)); +} + +static const struct archive_rb_tree_ops rb_rsrc_ops = { + &rsrc_cmp_node, &rsrc_cmp_key +}; + +static const char * +rsrc_basename(const char *name, size_t name_length) +{ + const char *s, *r; + + r = s = name; + for (;;) { + s = memchr(s, '/', name_length - (s - name)); + if (s == NULL) + break; + r = ++s; + } + return (r); +} + +static void +expose_parent_dirs(struct zip *zip, const char *name, size_t name_length) +{ + struct archive_string str; + struct zip_entry *dir; + char *s; + + archive_string_init(&str); + archive_strncpy(&str, name, name_length); + for (;;) { + s = strrchr(str.s, '/'); + if (s == NULL) + break; + *s = '\0'; + /* Transfer the parent directory from zip->tree_rsrc RB + * tree to zip->tree RB tree to expose. */ + dir = (struct zip_entry *) + __archive_rb_tree_find_node(&zip->tree_rsrc, str.s); + if (dir == NULL) + break; + __archive_rb_tree_remove_node(&zip->tree_rsrc, &dir->node); + archive_string_free(&dir->rsrcname); + __archive_rb_tree_insert_node(&zip->tree, &dir->node); + } + archive_string_free(&str); +} + +static int +slurp_central_directory(struct archive_read *a, struct zip *zip) +{ + ssize_t i; + unsigned found; + int64_t correction; + ssize_t bytes_avail; + const char *p; + + /* + * Find the start of the central directory. The end-of-CD + * record has our starting point, but there are lots of + * Zip archives which have had other data prepended to the + * file, which makes the recorded offsets all too small. + * So we search forward from the specified offset until we + * find the real start of the central directory. Then we + * know the correction we need to apply to account for leading + * padding. + */ + if (__archive_read_seek(a, zip->central_directory_offset, SEEK_SET) < 0) + return ARCHIVE_FATAL; + + found = 0; + while (!found) { + if ((p = __archive_read_ahead(a, 20, &bytes_avail)) == NULL) + return ARCHIVE_FATAL; + for (found = 0, i = 0; !found && i < bytes_avail - 4;) { + switch (p[i + 3]) { + case 'P': i += 3; break; + case 'K': i += 2; break; + case 001: i += 1; break; + case 002: + if (memcmp(p + i, "PK\001\002", 4) == 0) { + p += i; + found = 1; + } else + i += 4; + break; + case 005: i += 1; break; + case 006: + if (memcmp(p + i, "PK\005\006", 4) == 0) { + p += i; + found = 1; + } else if (memcmp(p + i, "PK\006\006", 4) == 0) { + p += i; + found = 1; + } else + i += 1; + break; + default: i += 4; break; } + } + __archive_read_consume(a, i); + } + correction = archive_filter_bytes(&a->archive, 0) - zip->central_directory_offset; + + __archive_rb_tree_init(&zip->tree, &rb_ops); + __archive_rb_tree_init(&zip->tree_rsrc, &rb_rsrc_ops); + + zip->central_directory_entries_total = 0; + while (1) { + struct zip_entry *zip_entry; + size_t filename_length, extra_length, comment_length; + uint32_t external_attributes; + const char *name, *r; + + if ((p = __archive_read_ahead(a, 4, NULL)) == NULL) + return ARCHIVE_FATAL; + if (memcmp(p, "PK\006\006", 4) == 0 + || memcmp(p, "PK\005\006", 4) == 0) { break; + } else if (memcmp(p, "PK\001\002", 4) != 0) { + archive_set_error(&a->archive, + -1, "Invalid central directory signature"); + return ARCHIVE_FATAL; } - case 0x7855: - /* Info-ZIP Unix Extra Field (type 2) "Ux". */ -#ifdef DEBUG - fprintf(stderr, "uid %d gid %d\n", - archive_le16dec(p + offset), - archive_le16dec(p + offset + 2)); + if ((p = __archive_read_ahead(a, 46, NULL)) == NULL) + return ARCHIVE_FATAL; + + zip_entry = calloc(1, sizeof(struct zip_entry)); + zip_entry->next = zip->zip_entries; + zip_entry->flags |= LA_FROM_CENTRAL_DIRECTORY; + zip->zip_entries = zip_entry; + zip->central_directory_entries_total++; + + /* version = p[4]; */ + zip_entry->system = p[5]; + /* version_required = archive_le16dec(p + 6); */ + zip_entry->zip_flags = archive_le16dec(p + 8); + if (zip_entry->zip_flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)){ + zip->has_encrypted_entries = 1; + } + zip_entry->compression = (char)archive_le16dec(p + 10); + zip_entry->mtime = zip_time(p + 12); + zip_entry->crc32 = archive_le32dec(p + 16); + zip_entry->compressed_size = archive_le32dec(p + 20); + zip_entry->uncompressed_size = archive_le32dec(p + 24); + filename_length = archive_le16dec(p + 28); + extra_length = archive_le16dec(p + 30); + comment_length = archive_le16dec(p + 32); + /* disk_start = archive_le16dec(p + 34); */ /* Better be zero. */ + /* internal_attributes = archive_le16dec(p + 36); */ /* text bit */ + external_attributes = archive_le32dec(p + 38); + zip_entry->local_header_offset = + archive_le32dec(p + 42) + correction; + + /* If we can't guess the mode, leave it zero here; + when we read the local file header we might get + more information. */ + zip_entry->mode = 0; + if (zip_entry->system == 3) { + zip_entry->mode = external_attributes >> 16; + } + + /* We're done with the regular data; get the filename and + * extra data. */ + __archive_read_consume(a, 46); + if ((p = __archive_read_ahead(a, filename_length + extra_length, NULL)) + == NULL) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "Truncated ZIP file header"); + return ARCHIVE_FATAL; + } + process_extra(p + filename_length, extra_length, zip_entry); + + /* + * Mac resource fork files are stored under the + * "__MACOSX/" directory, so we should check if + * it is. + */ + if (!zip->process_mac_extensions) { + /* Treat every entry as a regular entry. */ + __archive_rb_tree_insert_node(&zip->tree, + &zip_entry->node); + } else { + name = p; + r = rsrc_basename(name, filename_length); + if (filename_length >= 9 && + strncmp("__MACOSX/", name, 9) == 0) { + /* If this file is not a resource fork nor + * a directory. We should treat it as a non + * resource fork file to expose it. */ + if (name[filename_length-1] != '/' && + (r - name < 3 || r[0] != '.' || r[1] != '_')) { + __archive_rb_tree_insert_node(&zip->tree, + &zip_entry->node); + /* Expose its parent directories. */ + expose_parent_dirs(zip, name, filename_length); + } else { + /* This file is a resource fork file or + * a directory. */ + archive_strncpy(&(zip_entry->rsrcname), name, + filename_length); + __archive_rb_tree_insert_node(&zip->tree_rsrc, + &zip_entry->node); + } + } else { + /* Generate resource fork name to find its resource + * file at zip->tree_rsrc. */ + archive_strcpy(&(zip_entry->rsrcname), "__MACOSX/"); + archive_strncat(&(zip_entry->rsrcname), name, r - name); + archive_strcat(&(zip_entry->rsrcname), "._"); + archive_strncat(&(zip_entry->rsrcname), + name + (r - name), filename_length - (r - name)); + /* Register an entry to RB tree to sort it by + * file offset. */ + __archive_rb_tree_insert_node(&zip->tree, + &zip_entry->node); + } + } + + /* Skip the comment too ... */ + __archive_read_consume(a, + filename_length + extra_length + comment_length); + } + + return ARCHIVE_OK; +} + +static ssize_t +zip_get_local_file_header_size(struct archive_read *a, size_t extra) +{ + const char *p; + ssize_t filename_length, extra_length; + + if ((p = __archive_read_ahead(a, extra + 30, NULL)) == NULL) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "Truncated ZIP file header"); + return (ARCHIVE_WARN); + } + p += extra; + + if (memcmp(p, "PK\003\004", 4) != 0) { + archive_set_error(&a->archive, -1, "Damaged Zip archive"); + return ARCHIVE_WARN; + } + filename_length = archive_le16dec(p + 26); + extra_length = archive_le16dec(p + 28); + + return (30 + filename_length + extra_length); +} + +static int +zip_read_mac_metadata(struct archive_read *a, struct archive_entry *entry, + struct zip_entry *rsrc) +{ + struct zip *zip = (struct zip *)a->format->data; + unsigned char *metadata, *mp; + int64_t offset = archive_filter_bytes(&a->archive, 0); + size_t remaining_bytes, metadata_bytes; + ssize_t hsize; + int ret = ARCHIVE_OK, eof; + + switch(rsrc->compression) { + case 0: /* No compression. */ +#ifdef HAVE_ZLIB_H + case 8: /* Deflate compression. */ #endif - if (datasize >= 2) - zip_entry->uid = archive_le16dec(p + offset); - if (datasize >= 4) - zip_entry->gid = - archive_le16dec(p + offset + 2); + break; + default: /* Unsupported compression. */ + /* Return a warning. */ + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "Unsupported ZIP compression method (%s)", + compression_name(rsrc->compression)); + /* We can't decompress this entry, but we will + * be able to skip() it and try the next entry. */ + return (ARCHIVE_WARN); + } + + if (rsrc->uncompressed_size > (4 * 1024 * 1024)) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "Mac metadata is too large: %jd > 4M bytes", + (intmax_t)rsrc->uncompressed_size); + return (ARCHIVE_WARN); + } + + metadata = malloc((size_t)rsrc->uncompressed_size); + if (metadata == NULL) { + archive_set_error(&a->archive, ENOMEM, + "Can't allocate memory for Mac metadata"); + return (ARCHIVE_FATAL); + } + + if (offset < rsrc->local_header_offset) + __archive_read_consume(a, rsrc->local_header_offset - offset); + else if (offset != rsrc->local_header_offset) { + __archive_read_seek(a, rsrc->local_header_offset, SEEK_SET); + } + + hsize = zip_get_local_file_header_size(a, 0); + __archive_read_consume(a, hsize); + + remaining_bytes = (size_t)rsrc->compressed_size; + metadata_bytes = (size_t)rsrc->uncompressed_size; + mp = metadata; + eof = 0; + while (!eof && remaining_bytes) { + const unsigned char *p; + ssize_t bytes_avail; + size_t bytes_used; + + p = __archive_read_ahead(a, 1, &bytes_avail); + if (p == NULL) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Truncated ZIP file header"); + ret = ARCHIVE_WARN; + goto exit_mac_metadata; + } + if ((size_t)bytes_avail > remaining_bytes) + bytes_avail = remaining_bytes; + switch(rsrc->compression) { + case 0: /* No compression. */ + memcpy(mp, p, bytes_avail); + bytes_used = (size_t)bytes_avail; + metadata_bytes -= bytes_used; + mp += bytes_used; + if (metadata_bytes == 0) + eof = 1; break; - case 0x7875: +#ifdef HAVE_ZLIB_H + case 8: /* Deflate compression. */ { - /* Info-Zip Unix Extra Field (type 3) "ux". */ - int uidsize = 0, gidsize = 0; + int r; - if (datasize >= 1 && p[offset] == 1) {/* version=1 */ - if (datasize >= 4) { - /* get a uid size. */ - uidsize = p[offset+1]; - if (uidsize == 2) - zip_entry->uid = - archive_le16dec( - p + offset + 2); - else if (uidsize == 4 && datasize >= 6) - zip_entry->uid = - archive_le32dec( - p + offset + 2); - } - if (datasize >= (2 + uidsize + 3)) { - /* get a gid size. */ - gidsize = p[offset+2+uidsize]; - if (gidsize == 2) - zip_entry->gid = - archive_le16dec( - p+offset+2+uidsize+1); - else if (gidsize == 4 && - datasize >= (2 + uidsize + 5)) - zip_entry->gid = - archive_le32dec( - p+offset+2+uidsize+1); - } + ret = zip_deflate_init(a, zip); + if (ret != ARCHIVE_OK) + goto exit_mac_metadata; + zip->stream.next_in = + (Bytef *)(uintptr_t)(const void *)p; + zip->stream.avail_in = (uInt)bytes_avail; + zip->stream.total_in = 0; + zip->stream.next_out = mp; + zip->stream.avail_out = (uInt)metadata_bytes; + zip->stream.total_out = 0; + + r = inflate(&zip->stream, 0); + switch (r) { + case Z_OK: + break; + case Z_STREAM_END: + eof = 1; + break; + case Z_MEM_ERROR: + archive_set_error(&a->archive, ENOMEM, + "Out of memory for ZIP decompression"); + ret = ARCHIVE_FATAL; + goto exit_mac_metadata; + default: + archive_set_error(&a->archive, + ARCHIVE_ERRNO_MISC, + "ZIP decompression failed (%d)", r); + ret = ARCHIVE_FATAL; + goto exit_mac_metadata; } + bytes_used = zip->stream.total_in; + metadata_bytes -= zip->stream.total_out; + mp += zip->stream.total_out; break; } +#endif default: + bytes_used = 0; break; } - offset += datasize; + __archive_read_consume(a, bytes_used); + remaining_bytes -= bytes_used; } -#ifdef DEBUG - if (offset != extra_length) - { - fprintf(stderr, - "Extra data field contents do not match reported size!\n"); + archive_entry_copy_mac_metadata(entry, metadata, + (size_t)rsrc->uncompressed_size - metadata_bytes); + +exit_mac_metadata: + __archive_read_seek(a, offset, SEEK_SET); + zip->decompress_init = 0; + free(metadata); + return (ret); +} + +static int +archive_read_format_zip_seekable_read_header(struct archive_read *a, + struct archive_entry *entry) +{ + struct zip *zip = (struct zip *)a->format->data; + struct zip_entry *rsrc; + int64_t offset; + int r, ret = ARCHIVE_OK; + + /* + * It should be sufficient to call archive_read_next_header() for + * a reader to determine if an entry is encrypted or not. If the + * encryption of an entry is only detectable when calling + * archive_read_data(), so be it. We'll do the same check there + * as well. + */ + if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) { + zip->has_encrypted_entries = 0; + } + + a->archive.archive_format = ARCHIVE_FORMAT_ZIP; + if (a->archive.archive_format_name == NULL) + a->archive.archive_format_name = "ZIP"; + + if (zip->zip_entries == NULL) { + r = slurp_central_directory(a, zip); + if (r != ARCHIVE_OK) + return r; + /* Get first entry whose local header offset is lower than + * other entries in the archive file. */ + zip->entry = + (struct zip_entry *)ARCHIVE_RB_TREE_MIN(&zip->tree); + } else if (zip->entry != NULL) { + /* Get next entry in local header offset order. */ + zip->entry = (struct zip_entry *)__archive_rb_tree_iterate( + &zip->tree, &zip->entry->node, ARCHIVE_RB_DIR_RIGHT); + } + + if (zip->entry == NULL) + return ARCHIVE_EOF; + + if (zip->entry->rsrcname.s) + rsrc = (struct zip_entry *)__archive_rb_tree_find_node( + &zip->tree_rsrc, zip->entry->rsrcname.s); + else + rsrc = NULL; + + /* File entries are sorted by the header offset, we should mostly + * use __archive_read_consume to advance a read point to avoid redundant + * data reading. */ + offset = archive_filter_bytes(&a->archive, 0); + if (offset < zip->entry->local_header_offset) + __archive_read_consume(a, + zip->entry->local_header_offset - offset); + else if (offset != zip->entry->local_header_offset) { + __archive_read_seek(a, zip->entry->local_header_offset, SEEK_SET); + } + zip->unconsumed = 0; + r = zip_read_local_file_header(a, entry, zip); + if (r != ARCHIVE_OK) + return r; + if (rsrc) { + int ret2 = zip_read_mac_metadata(a, entry, rsrc); + if (ret2 < ret) + ret = ret2; + } + return (ret); +} + +/* + * We're going to seek for the next header anyway, so we don't + * need to bother doing anything here. + */ +static int +archive_read_format_zip_read_data_skip_seekable(struct archive_read *a) +{ + struct zip *zip; + zip = (struct zip *)(a->format->data); + + zip->unconsumed = 0; + return (ARCHIVE_OK); +} + +int +archive_read_support_format_zip_seekable(struct archive *_a) +{ + struct archive_read *a = (struct archive_read *)_a; + struct zip *zip; + int r; + + archive_check_magic(_a, ARCHIVE_READ_MAGIC, + ARCHIVE_STATE_NEW, "archive_read_support_format_zip_seekable"); + + zip = (struct zip *)malloc(sizeof(*zip)); + if (zip == NULL) { + archive_set_error(&a->archive, ENOMEM, + "Can't allocate zip data"); + return (ARCHIVE_FATAL); } + memset(zip, 0, sizeof(*zip)); + +#ifdef HAVE_COPYFILE_H + /* Set this by default on Mac OS. */ + zip->process_mac_extensions = 1; #endif + + /* + * Until enough data has been read, we cannot tell about + * any encrypted entries yet. + */ + zip->has_encrypted_entries = ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW; + zip->crc32func = real_crc32; + + r = __archive_read_register_format(a, + zip, + "zip", + archive_read_format_zip_seekable_bid, + archive_read_format_zip_options, + archive_read_format_zip_seekable_read_header, + archive_read_format_zip_read_data, + archive_read_format_zip_read_data_skip_seekable, + NULL, + archive_read_format_zip_cleanup, + archive_read_support_format_zip_capabilities_seekable, + archive_read_format_zip_has_encrypted_entries); + + if (r != ARCHIVE_OK) + free(zip); + return (ARCHIVE_OK); } diff --git a/libarchive/archive_util.c b/libarchive/archive_util.c index 34d8081..3d92566 100644 --- a/libarchive/archive_util.c +++ b/libarchive/archive_util.c @@ -45,6 +45,15 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_util.c 201098 2009-12-28 02:58:1 #if defined(HAVE_WINCRYPT_H) && !defined(__CYGWIN__) #include #endif +#ifdef HAVE_ZLIB_H +#include +#endif +#ifdef HAVE_LZMA_H +#include +#endif +#ifdef HAVE_BZLIB_H +#include +#endif #include "archive.h" #include "archive_private.h" @@ -54,6 +63,8 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_util.c 201098 2009-12-28 02:58:1 #define O_CLOEXEC 0 #endif +static int archive_utility_string_sort_helper(char **, unsigned int); + /* Generic initialization of 'struct archive' objects. */ int __archive_clean(struct archive *a) @@ -74,6 +85,38 @@ archive_version_string(void) return (ARCHIVE_VERSION_STRING); } +const char * +archive_version_details(void) +{ + static struct archive_string str; + static int init = 0; + + if (!init) { + archive_string_init(&str); + + archive_strcat(&str, ARCHIVE_VERSION_STRING); +#ifdef HAVE_ZLIB_H + archive_strcat(&str, " zlib/"); + archive_strcat(&str, ZLIB_VERSION); +#endif +#ifdef HAVE_LZMA_H + archive_strcat(&str, " liblzma/"); + archive_strcat(&str, LZMA_VERSION_STRING); +#endif +#ifdef HAVE_BZLIB_H + { + const char *p = BZ2_bzlibVersion(); + const char *sep = strchr(p, ','); + if (sep == NULL) + sep = p + strlen(p); + archive_strcat(&str, " bz2lib/"); + archive_strncat(&str, p, sep - p); + } +#endif + } + return str.s; +} + int archive_errno(struct archive *a) { @@ -499,3 +542,69 @@ __archive_ensure_cloexec_flag(int fd) } #endif } + +/* + * Utility function to sort a group of strings using quicksort. + */ +static int +archive_utility_string_sort_helper(char **strings, unsigned int n) +{ + unsigned int i, lesser_count, greater_count; + char **lesser, **greater, **tmp, *pivot; + int retval1, retval2; + + /* A list of 0 or 1 elements is already sorted */ + if (n <= 1) + return (ARCHIVE_OK); + + lesser_count = greater_count = 0; + lesser = greater = NULL; + pivot = strings[0]; + for (i = 1; i < n; i++) + { + if (strcmp(strings[i], pivot) < 0) + { + lesser_count++; + tmp = (char **)realloc(lesser, lesser_count * sizeof(char *)); + if (!tmp) + return (ARCHIVE_FATAL); + lesser = tmp; + lesser[lesser_count - 1] = strings[i]; + } + else + { + greater_count++; + tmp = (char **)realloc(greater, greater_count * sizeof(char *)); + if (!tmp) + return (ARCHIVE_FATAL); + greater = tmp; + greater[greater_count - 1] = strings[i]; + } + } + + /* quicksort(lesser) */ + retval1 = archive_utility_string_sort_helper(lesser, lesser_count); + for (i = 0; i < lesser_count; i++) + strings[i] = lesser[i]; + free(lesser); + + /* pivot */ + strings[lesser_count] = pivot; + + /* quicksort(greater) */ + retval2 = archive_utility_string_sort_helper(greater, greater_count); + for (i = 0; i < greater_count; i++) + strings[lesser_count + 1 + i] = greater[i]; + free(greater); + + return (retval1 < retval2) ? retval1 : retval2; +} + +int +archive_utility_string_sort(char **strings) +{ + unsigned int size = 0; + while (strings[size] != NULL) + size++; + return archive_utility_string_sort_helper(strings, size); +} diff --git a/libarchive/archive_virtual.c b/libarchive/archive_virtual.c index 0c4155f..de2595a 100644 --- a/libarchive/archive_virtual.c +++ b/libarchive/archive_virtual.c @@ -55,6 +55,14 @@ archive_filter_bytes(struct archive *a, int n) } int +archive_free(struct archive *a) +{ + if (a == NULL) + return (ARCHIVE_OK); + return ((a->vtable->archive_free)(a)); +} + +int archive_write_close(struct archive *a) { return ((a->vtable->archive_close)(a)); @@ -76,9 +84,7 @@ archive_write_fail(struct archive *a) int archive_write_free(struct archive *a) { - if (a == NULL) - return (ARCHIVE_OK); - return ((a->vtable->archive_free)(a)); + return archive_free(a); } #if ARCHIVE_VERSION_NUMBER < 4000000 @@ -93,9 +99,7 @@ archive_write_finish(struct archive *a) int archive_read_free(struct archive *a) { - if (a == NULL) - return (ARCHIVE_OK); - return ((a->vtable->archive_free)(a)); + return archive_free(a); } #if ARCHIVE_VERSION_NUMBER < 4000000 diff --git a/libarchive/archive_windows.c b/libarchive/archive_windows.c index d3bf758..d4e93fe 100644 --- a/libarchive/archive_windows.c +++ b/libarchive/archive_windows.c @@ -301,7 +301,7 @@ __la_open(const char *path, int flags, ...) ws = NULL; if ((flags & ~O_BINARY) == O_RDONLY) { /* - * When we open a directory, _open function returns + * When we open a directory, _open function returns * "Permission denied" error. */ attr = GetFileAttributesA(path); @@ -515,9 +515,9 @@ __hstat(HANDLE handle, struct ustat *st) else mode |= S_IFREG; st->st_mode = mode; - + fileTimeToUTC(&info.ftLastAccessTime, &t, &ns); - st->st_atime = t; + st->st_atime = t; st->st_atime_nsec = ns; fileTimeToUTC(&info.ftLastWriteTime, &t, &ns); st->st_mtime = t; @@ -525,7 +525,7 @@ __hstat(HANDLE handle, struct ustat *st) fileTimeToUTC(&info.ftCreationTime, &t, &ns); st->st_ctime = t; st->st_ctime_nsec = ns; - st->st_size = + st->st_size = ((int64_t)(info.nFileSizeHigh) * ((int64_t)MAXDWORD + 1)) + (int64_t)(info.nFileSizeLow); #ifdef SIMULATE_WIN_STAT @@ -599,7 +599,7 @@ __la_stat(const char *path, struct stat *st) struct ustat u; int ret; - handle = la_CreateFile(path, 0, 0, NULL, OPEN_EXISTING, + handle = la_CreateFile(path, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); if (handle == INVALID_HANDLE_VALUE) { diff --git a/libarchive/archive_windows.h b/libarchive/archive_windows.h index c6f5bc5..63947c8 100644 --- a/libarchive/archive_windows.h +++ b/libarchive/archive_windows.h @@ -89,7 +89,7 @@ /* Alias the Windows _function to the POSIX equivalent. */ #define close _close -#define fcntl(fd, cmd, flg) /* No operation. */ +#define fcntl(fd, cmd, flg) /* No operation. */ #ifndef fileno #define fileno _fileno #endif @@ -109,13 +109,14 @@ #define lstat __la_stat #define open __la_open #define read __la_read -#if !defined(__BORLANDC__) +#if !defined(__BORLANDC__) && !defined(__WATCOMC__) #define setmode _setmode #endif #ifdef stat #undef stat #endif #define stat(path,stref) __la_stat(path,stref) +#if !defined(__WATCOMC__) #if !defined(__BORLANDC__) #define strdup _strdup #endif @@ -123,9 +124,12 @@ #if !defined(__BORLANDC__) #define umask _umask #endif +#endif #define waitpid __la_waitpid #define write __la_write +#if !defined(__WATCOMC__) + #ifndef O_RDONLY #define O_RDONLY _O_RDONLY #define O_WRONLY _O_WRONLY @@ -203,7 +207,7 @@ #define _S_IXGRP (_S_IXUSR >> 3) /* read permission, group */ #define _S_IWGRP (_S_IWUSR >> 3) /* write permission, group */ #define _S_IRGRP (_S_IRUSR >> 3) /* execute/search permission, group */ -#define _S_IRWXO (_S_IRWXG >> 3) +#define _S_IRWXO (_S_IRWXG >> 3) #define _S_IXOTH (_S_IXGRP >> 3) /* read permission, other */ #define _S_IWOTH (_S_IWGRP >> 3) /* write permission, other */ #define _S_IROTH (_S_IRGRP >> 3) /* execute/search permission, other */ @@ -223,6 +227,8 @@ #define S_IWOTH _S_IWOTH #define S_IROTH _S_IROTH +#endif + #define F_DUPFD 0 /* Duplicate file descriptor. */ #define F_GETFD 1 /* Get file descriptor flags. */ #define F_SETFD 2 /* Set file descriptor flags. */ diff --git a/libarchive/archive_write.c b/libarchive/archive_write.c index a3d1a33..90212bc 100644 --- a/libarchive/archive_write.c +++ b/libarchive/archive_write.c @@ -503,8 +503,9 @@ _archive_write_close(struct archive *_a) archive_clear_error(&a->archive); - /* Finish the last entry. */ - if (a->archive.state == ARCHIVE_STATE_DATA) + /* Finish the last entry if a finish callback is specified */ + if (a->archive.state == ARCHIVE_STATE_DATA + && a->format_finish_entry != NULL) r = ((a->format_finish_entry)(a)); /* Finish off the archive. */ @@ -638,6 +639,9 @@ _archive_write_header(struct archive *_a, struct archive_entry *entry) /* Format and write header. */ r2 = ((a->format_write_header)(a, entry)); + if (r2 == ARCHIVE_FAILED) { + return (ARCHIVE_FAILED); + } if (r2 == ARCHIVE_FATAL) { a->archive.state = ARCHIVE_STATE_FATAL; return (ARCHIVE_FATAL); @@ -658,7 +662,8 @@ _archive_write_finish_entry(struct archive *_a) archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC, ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA, "archive_write_finish_entry"); - if (a->archive.state & ARCHIVE_STATE_DATA) + if (a->archive.state & ARCHIVE_STATE_DATA + && a->format_finish_entry != NULL) ret = (a->format_finish_entry)(a); a->archive.state = ARCHIVE_STATE_HEADER; return (ret); @@ -671,8 +676,13 @@ static ssize_t _archive_write_data(struct archive *_a, const void *buff, size_t s) { struct archive_write *a = (struct archive_write *)_a; + const size_t max_write = INT_MAX; + archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC, ARCHIVE_STATE_DATA, "archive_write_data"); + /* In particular, this catches attempts to pass negative values. */ + if (s > max_write) + s = max_write; archive_clear_error(&a->archive); return ((a->format_write_data)(a, buff, s)); } diff --git a/libarchive/archive_write_add_filter_lrzip.c b/libarchive/archive_write_add_filter_lrzip.c index 85fdf6a..da1cf5e 100644 --- a/libarchive/archive_write_add_filter_lrzip.c +++ b/libarchive/archive_write_add_filter_lrzip.c @@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$"); struct write_lrzip { struct archive_write_program_data *pdata; int compression_level; - enum { lzma = 0, bzip2, gzip, lzo, zpaq } compression; + enum { lzma = 0, bzip2, gzip, lzo, none, zpaq } compression; }; static int archive_write_lrzip_open(struct archive_write_filter *); @@ -107,6 +107,8 @@ archive_write_lrzip_options(struct archive_write_filter *f, const char *key, data->compression = gzip; else if (strcmp(value, "lzo") == 0) data->compression = lzo; + else if (strcmp(value, "none") == 0) + data->compression = none; else if (strcmp(value, "zpaq") == 0) data->compression = zpaq; else @@ -148,6 +150,9 @@ archive_write_lrzip_open(struct archive_write_filter *f) case lzo: archive_strcat(&as, " -l"); break; + case none: + archive_strcat(&as, " -n"); + break; case zpaq: archive_strcat(&as, " -z"); break; diff --git a/libarchive/archive_write_disk_acl.c b/libarchive/archive_write_disk_acl.c index 9797203..5cbba54 100644 --- a/libarchive/archive_write_disk_acl.c +++ b/libarchive/archive_write_disk_acl.c @@ -43,7 +43,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_disk.c 201159 2009-12-29 0 #include "archive_acl_private.h" #include "archive_write_disk_private.h" -#if !defined(HAVE_POSIX_ACL) || !defined(ACL_TYPE_NFS4) +#ifndef HAVE_POSIX_ACL /* Default empty function body to satisfy mainline code. */ int archive_write_disk_set_acls(struct archive *a, int fd, const char *name, @@ -79,10 +79,12 @@ archive_write_disk_set_acls(struct archive *a, int fd, const char *name, ret = set_acl(a, fd, name, abstract_acl, ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, "default"); return (ret); +#ifdef ACL_TYPE_NFS4 } else if (archive_acl_count(abstract_acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4) > 0) { ret = set_acl(a, fd, name, abstract_acl, ACL_TYPE_NFS4, ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4"); return (ret); +#endif } else return ARCHIVE_OK; } @@ -94,6 +96,7 @@ static struct { {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE}, {ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE}, {ARCHIVE_ENTRY_ACL_READ, ACL_READ}, +#ifdef ACL_TYPE_NFS4 {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA}, {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY}, {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA}, @@ -110,8 +113,10 @@ static struct { {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_ACL}, {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_WRITE_OWNER}, {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE} +#endif }; +#ifdef ACL_TYPE_NFS4 static struct { int archive_inherit; int platform_inherit; @@ -121,6 +126,7 @@ static struct { {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_NO_PROPAGATE_INHERIT}, {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY} }; +#endif static int set_acl(struct archive *a, int fd, const char *name, @@ -130,7 +136,9 @@ set_acl(struct archive *a, int fd, const char *name, acl_t acl; acl_entry_t acl_entry; acl_permset_t acl_permset; +#ifdef ACL_TYPE_NFS4 acl_flagset_t acl_flagset; +#endif int ret; int ae_type, ae_permset, ae_tag, ae_id; uid_t ae_uid; @@ -171,14 +179,17 @@ set_acl(struct archive *a, int fd, const char *name, case ARCHIVE_ENTRY_ACL_OTHER: acl_set_tag_type(acl_entry, ACL_OTHER); break; +#ifdef ACL_TYPE_NFS4 case ARCHIVE_ENTRY_ACL_EVERYONE: acl_set_tag_type(acl_entry, ACL_EVERYONE); break; +#endif default: /* XXX */ break; } +#ifdef ACL_TYPE_NFS4 switch (ae_type) { case ARCHIVE_ENTRY_ACL_TYPE_ALLOW: acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALLOW); @@ -200,6 +211,7 @@ set_acl(struct archive *a, int fd, const char *name, // XXX error handling here. break; } +#endif acl_get_permset(acl_entry, &acl_permset); acl_clear_perms(acl_permset); @@ -210,6 +222,7 @@ set_acl(struct archive *a, int fd, const char *name, acl_perm_map[i].platform_perm); } +#ifdef ACL_TYPE_NFS4 acl_get_flagset_np(acl_entry, &acl_flagset); acl_clear_flags_np(acl_flagset); for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) { @@ -217,6 +230,7 @@ set_acl(struct archive *a, int fd, const char *name, acl_add_flag_np(acl_flagset, acl_inherit_map[i].platform_inherit); } +#endif } /* Try restoring the ACL through 'fd' if we can. */ diff --git a/libarchive/archive_write_disk_windows.c b/libarchive/archive_write_disk_windows.c index 0f0780a..ed62009 100644 --- a/libarchive/archive_write_disk_windows.c +++ b/libarchive/archive_write_disk_windows.c @@ -525,7 +525,7 @@ la_GetFunctionKernel32(const char *name) static int set; if (!set) { set = 1; - lib = LoadLibrary("kernel32.dll"); + lib = LoadLibrary(TEXT("kernel32.dll")); } if (lib == NULL) { fprintf(stderr, "Can't load kernel32.dll?!\n"); diff --git a/libarchive/archive_write_format.3 b/libarchive/archive_write_format.3 index dad2f7d..39d3006 100644 --- a/libarchive/archive_write_format.3 +++ b/libarchive/archive_write_format.3 @@ -24,13 +24,14 @@ .\" .\" $FreeBSD$ .\" -.Dd February 2, 2012 +.Dd February 14, 2013 .Dt ARCHIVE_WRITE_FORMAT 3 .Os .Sh NAME .Nm archive_write_set_format_cpio , .Nm archive_write_set_format_pax , .Nm archive_write_set_format_pax_restricted , +.Nm archive_write_set_format_raw , .Nm archive_write_set_format_shar , .Nm archive_write_set_format_shar_dump , .Nm archive_write_set_format_ustar @@ -46,6 +47,8 @@ Streaming Archive Library (libarchive, -larchive) .Ft int .Fn archive_write_set_format_pax_restricted "struct archive *" .Ft int +.Fn archive_write_set_format_raw "struct archive *" +.Ft int .Fn archive_write_set_format_shar "struct archive *" .Ft int .Fn archive_write_set_format_shar_dump "struct archive *" diff --git a/libarchive/archive_write_set_format.c b/libarchive/archive_write_set_format.c index 641d56f..9055753 100644 --- a/libarchive/archive_write_set_format.c +++ b/libarchive/archive_write_set_format.c @@ -47,6 +47,7 @@ struct { int code; int (*setter)(struct archive *); } codes[] = { ARCHIVE_FORMAT_CPIO_SVR4_NOCRC, archive_write_set_format_cpio_newc }, { ARCHIVE_FORMAT_ISO9660, archive_write_set_format_iso9660 }, { ARCHIVE_FORMAT_MTREE, archive_write_set_format_mtree }, + { ARCHIVE_FORMAT_RAW, archive_write_set_format_raw }, { ARCHIVE_FORMAT_SHAR, archive_write_set_format_shar }, { ARCHIVE_FORMAT_SHAR_BASE, archive_write_set_format_shar }, { ARCHIVE_FORMAT_SHAR_DUMP, archive_write_set_format_shar_dump }, @@ -57,7 +58,7 @@ struct { int code; int (*setter)(struct archive *); } codes[] = archive_write_set_format_pax_restricted }, { ARCHIVE_FORMAT_TAR_USTAR, archive_write_set_format_ustar }, { ARCHIVE_FORMAT_XAR, archive_write_set_format_xar }, - { ARCHIVE_FORMAT_ZIP, archive_write_set_format_zip }, + { ARCHIVE_FORMAT_ZIP, archive_write_set_format_zip }, { 0, NULL } }; diff --git a/libarchive/archive_write_set_format_by_name.c b/libarchive/archive_write_set_format_by_name.c index af3105e..4f3ce7d 100644 --- a/libarchive/archive_write_set_format_by_name.c +++ b/libarchive/archive_write_set_format_by_name.c @@ -63,6 +63,7 @@ struct { const char *name; int (*setter)(struct archive *); } names[] = { "pax", archive_write_set_format_pax }, { "paxr", archive_write_set_format_pax_restricted }, { "posix", archive_write_set_format_pax }, + { "raw", archive_write_set_format_raw }, { "rpax", archive_write_set_format_pax_restricted }, { "shar", archive_write_set_format_shar }, { "shardump", archive_write_set_format_shar_dump }, diff --git a/libarchive/archive_write_set_format_mtree.c b/libarchive/archive_write_set_format_mtree.c index 9c0613c..4d343ea 100644 --- a/libarchive/archive_write_set_format_mtree.c +++ b/libarchive/archive_write_set_format_mtree.c @@ -128,6 +128,9 @@ struct mtree_entry { unsigned long fflags_clear; dev_t rdevmajor; dev_t rdevminor; + dev_t devmajor; + dev_t devminor; + int64_t ino; }; struct mtree_writer { @@ -210,6 +213,9 @@ struct mtree_writer { #define F_SHA256 0x00800000 /* SHA-256 digest */ #define F_SHA384 0x01000000 /* SHA-384 digest */ #define F_SHA512 0x02000000 /* SHA-512 digest */ +#define F_INO 0x04000000 /* inode number */ +#define F_RESDEV 0x08000000 /* device ID on which the + * entry resides */ /* Options */ int dironly; /* If it is set, ignore all files except @@ -823,8 +829,11 @@ mtree_entry_new(struct archive_write *a, struct archive_entry *entry, archive_entry_fflags(entry, &me->fflags_set, &me->fflags_clear); me->mtime = archive_entry_mtime(entry); me->mtime_nsec = archive_entry_mtime_nsec(entry); - me->rdevmajor = archive_entry_rdevmajor(entry); + me->rdevmajor = archive_entry_rdevmajor(entry); me->rdevminor = archive_entry_rdevminor(entry); + me->devmajor = archive_entry_devmajor(entry); + me->devminor = archive_entry_devminor(entry); + me->ino = archive_entry_ino(entry); me->size = archive_entry_size(entry); if (me->filetype == AE_IFDIR) { me->dir_info = calloc(1, sizeof(*me->dir_info)); @@ -882,7 +891,7 @@ archive_write_mtree_header(struct archive_write *a, mtree->first = 0; archive_strcat(&mtree->buf, "#mtree\n"); if ((mtree->keys & SET_KEYS) == 0) - mtree->output_global_set = 0;/* Disalbed. */ + mtree->output_global_set = 0;/* Disabled. */ } mtree->entry_bytes_remaining = archive_entry_size(entry); @@ -983,6 +992,15 @@ write_mtree_entry(struct archive_write *a, struct mtree_entry *me) if ((keys & F_UID) != 0) archive_string_sprintf(str, " uid=%jd", (intmax_t)me->uid); + if ((keys & F_INO) != 0) + archive_string_sprintf(str, " inode=%jd", (intmax_t)me->ino); + if ((keys & F_RESDEV) != 0) { + archive_string_sprintf(str, + " resdevice=native,%ju,%ju", + (uintmax_t)me->devmajor, + (uintmax_t)me->devminor); + } + switch (me->filetype) { case AE_IFLNK: if ((keys & F_TYPE) != 0) @@ -1117,7 +1135,7 @@ write_mtree_entry_tree(struct archive_write *a) } else { /* Whenever output_global_set is enabled * output global value(/set keywords) - * even if the directory entry is not allowd + * even if the directory entry is not allowed * to be written because the global values * can be used for the children. */ if (mtree->output_global_set) @@ -1296,6 +1314,8 @@ archive_write_mtree_options(struct archive_write *a, const char *key, if (strcmp(key, "indent") == 0) { mtree->indent = (value != NULL)? 1: 0; return (ARCHIVE_OK); + } else if (strcmp(key, "inode") == 0) { + keybit = F_INO; } break; case 'l': @@ -1314,7 +1334,9 @@ archive_write_mtree_options(struct archive_write *a, const char *key, keybit = F_NLINK; break; case 'r': - if (strcmp(key, "ripemd160digest") == 0 || + if (strcmp(key, "resdevice") == 0) { + keybit = F_RESDEV; + } else if (strcmp(key, "ripemd160digest") == 0 || strcmp(key, "rmd160") == 0 || strcmp(key, "rmd160digest") == 0) keybit = F_RMD160; @@ -1855,9 +1877,9 @@ mtree_entry_setup_filenames(struct archive_write *a, struct mtree_entry *file, return (ret); } - /* Make a basename from dirname and slash */ + /* Make a basename from file->parentdir.s and slash */ *slash = '\0'; - file->parentdir.length = slash - dirname; + file->parentdir.length = slash - file->parentdir.s; archive_strcpy(&(file->basename), slash + 1); return (ret); } @@ -2198,6 +2220,9 @@ mtree_entry_exchange_same_entry(struct archive_write *a, struct mtree_entry *np, np->mtime_nsec = file->mtime_nsec; np->rdevmajor = file->rdevmajor; np->rdevminor = file->rdevminor; + np->devmajor = file->devmajor; + np->devminor = file->devminor; + np->ino = file->ino; return (ARCHIVE_WARN); } diff --git a/libarchive/archive_write_set_format_raw.c b/libarchive/archive_write_set_format_raw.c new file mode 100644 index 0000000..feff936 --- /dev/null +++ b/libarchive/archive_write_set_format_raw.c @@ -0,0 +1,125 @@ +/*- + * Copyright (c) 2013 Marek Kubica + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "archive_platform.h" + +#ifdef HAVE_ERRNO_H +#include +#endif + +#include "archive_entry.h" +#include "archive_write_private.h" + +static ssize_t archive_write_raw_data(struct archive_write *, + const void *buff, size_t s); +static int archive_write_raw_free(struct archive_write *); +static int archive_write_raw_header(struct archive_write *, + struct archive_entry *); + +struct raw { + int entries_written; +}; + +/* + * Set output format to 'raw' format. + */ +int +archive_write_set_format_raw(struct archive *_a) +{ + struct archive_write *a = (struct archive_write *)_a; + struct raw *raw; + + archive_check_magic(_a, ARCHIVE_WRITE_MAGIC, + ARCHIVE_STATE_NEW, "archive_write_set_format_raw"); + + /* If someone else was already registered, unregister them. */ + if (a->format_free != NULL) + (a->format_free)(a); + + raw = (struct raw *)calloc(1, sizeof(*raw)); + if (raw == NULL) { + archive_set_error(&a->archive, ENOMEM, "Can't allocate raw data"); + return (ARCHIVE_FATAL); + } + raw->entries_written = 0; + a->format_data = raw; + a->format_name = "raw"; + /* no options exist for this format */ + a->format_options = NULL; + a->format_write_header = archive_write_raw_header; + a->format_write_data = archive_write_raw_data; + a->format_finish_entry = NULL; + /* nothing needs to be done on closing */ + a->format_close = NULL; + a->format_free = archive_write_raw_free; + a->archive.archive_format = ARCHIVE_FORMAT_RAW; + a->archive.archive_format_name = "RAW"; + return (ARCHIVE_OK); +} + +static int +archive_write_raw_header(struct archive_write *a, struct archive_entry *entry) +{ + struct raw *raw = (struct raw *)a->format_data; + + if (archive_entry_filetype(entry) != AE_IFREG) { + archive_set_error(&a->archive, ERANGE, + "Raw format only supports filetype AE_IFREG"); + return (ARCHIVE_FATAL); + } + + + if (raw->entries_written > 0) { + archive_set_error(&a->archive, ERANGE, + "Raw format only supports one entry per archive"); + return (ARCHIVE_FATAL); + } + raw->entries_written++; + + return (ARCHIVE_OK); +} + +static ssize_t +archive_write_raw_data(struct archive_write *a, const void *buff, size_t s) +{ + int ret; + + ret = __archive_write_output(a, buff, s); + if (ret >= 0) + return (s); + else + return (ret); +} + +static int +archive_write_raw_free(struct archive_write *a) +{ + struct raw *raw; + + raw = (struct raw *)a->format_data; + free(raw); + a->format_data = NULL; + return (ARCHIVE_OK); +} diff --git a/libarchive/archive_write_set_format_shar.c b/libarchive/archive_write_set_format_shar.c index 9ec15f9..c033fb3 100644 --- a/libarchive/archive_write_set_format_shar.c +++ b/libarchive/archive_write_set_format_shar.c @@ -548,6 +548,7 @@ archive_write_shar_finish_entry(struct archive_write *a) archive_strcat(&shar->work, ":"); shar_quote(&shar->work, g, 1); } + archive_strcat(&shar->work, " "); shar_quote(&shar->work, archive_entry_pathname(shar->entry), 1); archive_strcat(&shar->work, "\n"); diff --git a/libarchive/archive_write_set_format_zip.c b/libarchive/archive_write_set_format_zip.c index 3d8b3b5..ccd50ea 100644 --- a/libarchive/archive_write_set_format_zip.c +++ b/libarchive/archive_write_set_format_zip.c @@ -29,24 +29,6 @@ * Development supported by Google Summer of Code 2008. */ -/* - * The current implementation is very limited: - * - * - No encryption support. - * - No ZIP64 support. - * - No support for splitting and spanning. - * - Only supports regular file and folder entries. - * - * Note that generally data in ZIP files is little-endian encoded, - * with some exceptions. - * - * TODO: Since Libarchive is generally 64bit oriented, but this implementation - * does not yet support sizes exceeding 32bit, it is highly fragile for - * big archives. This should change when ZIP64 is finally implemented, otherwise - * some serious checking has to be done. - * - */ - #include "archive_platform.h" __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_zip.c 201168 2009-12-29 06:15:32Z kientzle $"); @@ -77,25 +59,80 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_zip.c 201168 20 #include "archive_crc32.h" #endif -#define ZIP_SIGNATURE_LOCAL_FILE_HEADER 0x04034b50 -#define ZIP_SIGNATURE_DATA_DESCRIPTOR 0x08074b50 -#define ZIP_SIGNATURE_FILE_HEADER 0x02014b50 -#define ZIP_SIGNATURE_CENTRAL_DIRECTORY_END 0x06054b50 -#define ZIP_SIGNATURE_EXTRA_TIMESTAMP 0x5455 -#define ZIP_SIGNATURE_EXTRA_NEW_UNIX 0x7875 -#define ZIP_VERSION_EXTRACT 0x0014 /* ZIP version 2.0 is needed. */ -#define ZIP_VERSION_BY 0x0314 /* Made by UNIX, using ZIP version 2.0. */ -#define ZIP_FLAGS 0x08 /* Flagging bit 3 (count from 0) for using data descriptor. */ -#define ZIP_FLAGS_UTF8_NAME (1 << 11) +#define ZIP_ENTRY_FLAG_LENGTH_AT_END (1<<3) +#define ZIP_ENTRY_FLAG_UTF8_NAME (1 << 11) + enum compression { - COMPRESSION_STORE = 0 -#ifdef HAVE_ZLIB_H - , + COMPRESSION_UNSPECIFIED = -1, + COMPRESSION_STORE = 0, COMPRESSION_DEFLATE = 8 +}; + +#ifdef HAVE_ZLIB_H +#define COMPRESSION_DEFAULT COMPRESSION_DEFLATE +#else +#define COMPRESSION_DEFAULT COMPRESSION_STORE +#endif + +struct cd_segment { + struct cd_segment *next; + size_t buff_size; + unsigned char *buff; + unsigned char *p; +}; + +/* Bits used to enable/disable certain experimental features. */ +#define EXPERIMENT_LA 1 +#define EXPERIMENTS_ALL 0xffff + +struct zip { + + int64_t entry_offset; + int64_t entry_compressed_size; + int64_t entry_uncompressed_size; + int64_t entry_compressed_written; + int64_t entry_uncompressed_written; + int64_t entry_uncompressed_limit; + struct archive_entry *entry; + uint32_t entry_crc32; + enum compression entry_compression; + int entry_flags; + int entry_uses_zip64; + int experiments; + + unsigned char *file_header; + size_t file_header_extra_offset; + unsigned long (*crc32func)(unsigned long crc, const void *buff, size_t len); + + struct cd_segment *central_directory; + struct cd_segment *central_directory_last; + size_t central_directory_bytes; + size_t central_directory_entries; + + int64_t written_bytes; /* Overall position in file. */ + + struct archive_string_conv *opt_sconv; + struct archive_string_conv *sconv_default; + enum compression requested_compression; + int init_default_conversion; + +#define ZIP_FLAG_AVOID_ZIP64 1 +#define ZIP_FLAG_FORCE_ZIP64 2 +#define ZIP_FLAG_EXPERIMENT_EL 4 + int flags; + +#ifdef HAVE_ZLIB_H + z_stream stream; + size_t len_buf; + unsigned char *buf; #endif }; +/* Don't call this min or MIN, since those are already defined + on lots of platforms (but not all). */ +#define zipmin(a, b) ((a) > (b) ? (b) : (a)) + static ssize_t archive_write_zip_data(struct archive_write *, const void *buff, size_t s); static int archive_write_zip_close(struct archive_write *); @@ -108,106 +145,58 @@ static int archive_write_zip_options(struct archive_write *, static unsigned int dos_time(const time_t); static size_t path_length(struct archive_entry *); static int write_path(struct archive_entry *, struct archive_write *); +static void copy_path(struct archive_entry *, unsigned char *); +static struct archive_string_conv *get_sconv(struct archive_write *, struct zip *); -#define LOCAL_FILE_HEADER_SIGNATURE 0 -#define LOCAL_FILE_HEADER_VERSION 4 -#define LOCAL_FILE_HEADER_FLAGS 6 -#define LOCAL_FILE_HEADER_COMPRESSION 8 -#define LOCAL_FILE_HEADER_TIMEDATE 10 -#define LOCAL_FILE_HEADER_CRC32 14 -#define LOCAL_FILE_HEADER_COMPRESSED_SIZE 18 -#define LOCAL_FILE_HEADER_UNCOMPRESSED_SIZE 22 -#define LOCAL_FILE_HEADER_FILENAME_LENGTH 26 -#define LOCAL_FILE_HEADER_EXTRA_LENGTH 28 -#define SIZE_LOCAL_FILE_HEADER 30 - -#define FILE_HEADER_SIGNATURE 0 -#define FILE_HEADER_VERSION_BY 4 -#define FILE_HEADER_VERSION_EXTRACT 6 -#define FILE_HEADER_FLAGS 8 -#define FILE_HEADER_COMPRESSION 10 -#define FILE_HEADER_TIMEDATE 12 -#define FILE_HEADER_CRC32 16 -#define FILE_HEADER_COMPRESSED_SIZE 20 -#define FILE_HEADER_UNCOMPRESSED_SIZE 24 -#define FILE_HEADER_FILENAME_LENGTH 28 -#define FILE_HEADER_EXTRA_LENGTH 30 -#define FILE_HEADER_COMMENT_LENGTH 32 -#define FILE_HEADER_DISK_NUMBER 34 -#define FILE_HEADER_ATTRIBUTES_INTERNAL 36 -#define FILE_HEADER_ATTRIBUTES_EXTERNAL 38 -#define FILE_HEADER_OFFSET 42 -#define SIZE_FILE_HEADER 46 - - /* Not mandatory, but recommended by specification. */ -#define DATA_DESCRIPTOR_SIGNATURE 0 -#define DATA_DESCRIPTOR_CRC32 4 -#define DATA_DESCRIPTOR_COMPRESSED_SIZE 8 -#define DATA_DESCRIPTOR_UNCOMPRESSED_SIZE 12 -#define SIZE_DATA_DESCRIPTOR 16 - -#define EXTRA_DATA_LOCAL_TIME_ID 0 -#define EXTRA_DATA_LOCAL_TIME_SIZE 2 -#define EXTRA_DATA_LOCAL_TIME_FLAG 4 -#define EXTRA_DATA_LOCAL_MTIME 5 -#define EXTRA_DATA_LOCAL_ATIME 9 -#define EXTRA_DATA_LOCAL_CTIME 13 -#define EXTRA_DATA_LOCAL_UNIX_ID 17 -#define EXTRA_DATA_LOCAL_UNIX_SIZE 19 -#define EXTRA_DATA_LOCAL_UNIX_VERSION 21 -#define EXTRA_DATA_LOCAL_UNIX_UID_SIZE 22 -#define EXTRA_DATA_LOCAL_UNIX_UID 23 -#define EXTRA_DATA_LOCAL_UNIX_GID_SIZE 27 -#define EXTRA_DATA_LOCAL_UNIX_GID 28 -#define SIZE_EXTRA_DATA_LOCAL 32 - -#define EXTRA_DATA_CENTRAL_TIME_ID 0 -#define EXTRA_DATA_CENTRAL_TIME_SIZE 2 -#define EXTRA_DATA_CENTRAL_TIME_FLAG 4 -#define EXTRA_DATA_CENTRAL_MTIME 5 -#define EXTRA_DATA_CENTRAL_UNIX_ID 9 -#define EXTRA_DATA_CENTRAL_UNIX_SIZE 11 -#define SIZE_EXTRA_DATA_CENTRAL 13 - -#define CENTRAL_DIRECTORY_END_SIGNATURE 0 -#define CENTRAL_DIRECTORY_END_DISK 4 -#define CENTRAL_DIRECTORY_END_START_DISK 6 -#define CENTRAL_DIRECTORY_END_ENTRIES_DISK 8 -#define CENTRAL_DIRECTORY_END_ENTRIES 10 -#define CENTRAL_DIRECTORY_END_SIZE 12 -#define CENTRAL_DIRECTORY_END_OFFSET 16 -#define CENTRAL_DIRECTORY_END_COMMENT_LENGTH 20 -#define SIZE_CENTRAL_DIRECTORY_END 22 - -struct zip_file_header_link { - struct zip_file_header_link *next; - struct archive_entry *entry; - int64_t offset; - unsigned long crc32; - int64_t compressed_size; - enum compression compression; - int flags; -}; +static unsigned char * +cd_alloc(struct zip *zip, size_t length) +{ + unsigned char *p; + + if (zip->central_directory == NULL + || (zip->central_directory_last->p + length + > zip->central_directory_last->buff + zip->central_directory_last->buff_size)) { + struct cd_segment *segment = calloc(1, sizeof(*segment)); + if (segment == NULL) + return NULL; + segment->buff_size = 64 * 1024; + segment->buff = malloc(segment->buff_size); + if (segment->buff == NULL) { + free(segment); + return NULL; + } + segment->p = segment->buff; -struct zip { - uint8_t data_descriptor[SIZE_DATA_DESCRIPTOR]; - struct zip_file_header_link *central_directory; - struct zip_file_header_link *central_directory_end; - int64_t offset; - int64_t written_bytes; - int64_t remaining_data_bytes; - enum compression compression; - int flags; - struct archive_string_conv *opt_sconv; - struct archive_string_conv *sconv_default; - int init_default_conversion; + if (zip->central_directory == NULL) { + zip->central_directory + = zip->central_directory_last + = segment; + } else { + zip->central_directory_last->next = segment; + zip->central_directory_last = segment; + } + } -#ifdef HAVE_ZLIB_H - z_stream stream; - size_t len_buf; - unsigned char *buf; -#endif -}; + p = zip->central_directory_last->p; + zip->central_directory_last->p += length; + zip->central_directory_bytes += length; + return (p); +} + +static unsigned long +real_crc32(unsigned long crc, const void *buff, size_t len) +{ + return crc32(crc, buff, len); +} + +static unsigned long +fake_crc32(unsigned long crc, const void *buff, size_t len) +{ + (void)crc; /* UNUSED */ + (void)buff; /* UNUSED */ + (void)len; /* UNUSED */ + return 0; +} static int archive_write_zip_options(struct archive_write *a, const char *key, @@ -217,24 +206,49 @@ archive_write_zip_options(struct archive_write *a, const char *key, int ret = ARCHIVE_FAILED; if (strcmp(key, "compression") == 0) { + /* + * Set compression to use on all future entries. + * This only affects regular files. + */ if (val == NULL || val[0] == 0) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "%s: compression option needs a compression name", a->format_name); } else if (strcmp(val, "deflate") == 0) { #ifdef HAVE_ZLIB_H - zip->compression = COMPRESSION_DEFLATE; + zip->requested_compression = COMPRESSION_DEFLATE; ret = ARCHIVE_OK; #else archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "deflate compression not supported"); #endif } else if (strcmp(val, "store") == 0) { - zip->compression = COMPRESSION_STORE; + zip->requested_compression = COMPRESSION_STORE; ret = ARCHIVE_OK; } return (ret); + } else if (strcmp(key, "experimental") == 0) { + if (val == NULL || val[0] == 0) { + zip->flags &= ~ ZIP_FLAG_EXPERIMENT_EL; + } else { + zip->flags |= ZIP_FLAG_EXPERIMENT_EL; + } + return (ARCHIVE_OK); + } else if (strcmp(key, "fakecrc32") == 0) { + /* + * FOR TESTING ONLY: disable CRC calculation to speed up + * certain complex tests. + */ + if (val == NULL || val[0] == 0) { + zip->crc32func = real_crc32; + } else { + zip->crc32func = fake_crc32; + } + return (ARCHIVE_OK); } else if (strcmp(key, "hdrcharset") == 0) { + /* + * Set the character set used in translating filenames. + */ if (val == NULL || val[0] == 0) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "%s: hdrcharset option needs a character-set name", @@ -248,6 +262,21 @@ archive_write_zip_options(struct archive_write *a, const char *key, ret = ARCHIVE_FATAL; } return (ret); + } else if (strcmp(key, "zip64") == 0) { + /* + * Bias decisions about Zip64: force them to be + * generated in certain cases where they are not + * forbidden or avoid them in certain cases where they + * are not strictly required. + */ + if (val != NULL && *val != '\0') { + zip->flags |= ZIP_FLAG_FORCE_ZIP64; + zip->flags &= ~ZIP_FLAG_AVOID_ZIP64; + } else { + zip->flags &= ~ZIP_FLAG_FORCE_ZIP64; + zip->flags |= ZIP_FLAG_AVOID_ZIP64; + } + return (ARCHIVE_OK); } /* Note: The "warn" return is just to inform the options @@ -261,9 +290,9 @@ archive_write_zip_set_compression_deflate(struct archive *_a) { struct archive_write *a = (struct archive_write *)_a; int ret = ARCHIVE_FAILED; - + archive_check_magic(_a, ARCHIVE_WRITE_MAGIC, - ARCHIVE_STATE_NEW | ARCHIVE_STATE_HEADER, + ARCHIVE_STATE_NEW | ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA, "archive_write_zip_set_compression_deflate"); if (a->archive.archive_format != ARCHIVE_FORMAT_ZIP) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, @@ -273,11 +302,12 @@ archive_write_zip_set_compression_deflate(struct archive *_a) } else { #ifdef HAVE_ZLIB_H struct zip *zip = a->format_data; - zip->compression = COMPRESSION_DEFLATE; + zip->requested_compression = COMPRESSION_DEFLATE; ret = ARCHIVE_OK; #else archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "deflate compression not supported"); + ret = ARCHIVE_FAILED; #endif } return (ret); @@ -289,9 +319,9 @@ archive_write_zip_set_compression_store(struct archive *_a) struct archive_write *a = (struct archive_write *)_a; struct zip *zip = a->format_data; int ret = ARCHIVE_FAILED; - + archive_check_magic(_a, ARCHIVE_WRITE_MAGIC, - ARCHIVE_STATE_NEW | ARCHIVE_STATE_HEADER, + ARCHIVE_STATE_NEW | ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA, "archive_write_zip_set_compression_deflate"); if (a->archive.archive_format != ARCHIVE_FORMAT_ZIP) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, @@ -299,7 +329,7 @@ archive_write_zip_set_compression_store(struct archive *_a) " with zip format"); ret = ARCHIVE_FATAL; } else { - zip->compression = COMPRESSION_STORE; + zip->requested_compression = COMPRESSION_STORE; ret = ARCHIVE_OK; } return (ret); @@ -324,14 +354,12 @@ archive_write_set_format_zip(struct archive *_a) "Can't allocate zip data"); return (ARCHIVE_FATAL); } - zip->central_directory = NULL; - zip->central_directory_end = NULL; - zip->offset = 0; - zip->written_bytes = 0; - zip->remaining_data_bytes = 0; + + /* "Unspecified" lets us choose the appropriate compression. */ + zip->requested_compression = COMPRESSION_UNSPECIFIED; + zip->crc32func = real_crc32; #ifdef HAVE_ZLIB_H - zip->compression = COMPRESSION_DEFLATE; zip->len_buf = 65536; zip->buf = malloc(zip->len_buf); if (zip->buf == NULL) { @@ -340,8 +368,6 @@ archive_write_set_format_zip(struct archive *_a) "Can't allocate compression buffer"); return (ARCHIVE_FATAL); } -#else - zip->compression = COMPRESSION_STORE; #endif a->format_data = zip; @@ -355,9 +381,6 @@ archive_write_set_format_zip(struct archive *_a) a->archive.archive_format = ARCHIVE_FORMAT_ZIP; a->archive.archive_format_name = "ZIP"; - archive_le32enc(&zip->data_descriptor[DATA_DESCRIPTOR_SIGNATURE], - ZIP_SIGNATURE_DATA_DESCRIPTOR); - return (ARCHIVE_OK); } @@ -376,17 +399,21 @@ is_all_ascii(const char *p) static int archive_write_zip_header(struct archive_write *a, struct archive_entry *entry) { - struct zip *zip; - uint8_t h[SIZE_LOCAL_FILE_HEADER]; - uint8_t e[SIZE_EXTRA_DATA_LOCAL]; - uint8_t *d; - struct zip_file_header_link *l; - struct archive_string_conv *sconv; + unsigned char local_header[32]; + unsigned char local_extra[128]; + struct zip *zip = a->format_data; + unsigned char *e; + unsigned char *cd_extra; + size_t filename_length; + const char *symlink = NULL; + size_t symlink_size = 0; + struct archive_string_conv *sconv = get_sconv(a, zip); int ret, ret2 = ARCHIVE_OK; int64_t size; mode_t type; + int version_needed = 10; - /* Entries other than a regular file or a folder are skipped. */ + /* Ignore types of entries that we don't support. */ type = archive_entry_filetype(entry); if (type != AE_IFREG && type != AE_IFDIR && type != AE_IFLNK) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, @@ -394,70 +421,64 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry) return ARCHIVE_FAILED; }; - /* Directory entries should have a size of 0. */ - if (type == AE_IFDIR) + /* If we're not using Zip64, reject large files. */ + if (zip->flags & ZIP_FLAG_AVOID_ZIP64) { + /* Reject entries over 4GB. */ + if (archive_entry_size_is_set(entry) + && (archive_entry_size(entry) > 0xffffffff)) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "Files > 4GB require Zip64 extensions"); + return ARCHIVE_FAILED; + } + /* Reject entries if archive is > 4GB. */ + if (zip->written_bytes > 0xffffffff) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "Archives > 4GB require Zip64 extensions"); + return ARCHIVE_FAILED; + } + } + + /* Only regular files can have size > 0. */ + if (type != AE_IFREG) archive_entry_set_size(entry, 0); - zip = a->format_data; - /* Setup default conversion. */ - if (zip->opt_sconv == NULL && !zip->init_default_conversion) { - zip->sconv_default = - archive_string_default_conversion_for_write(&(a->archive)); - zip->init_default_conversion = 1; - } - if (zip->flags == 0) { - /* Initialize the general purpose flags. */ - zip->flags = ZIP_FLAGS; - if (zip->opt_sconv != NULL) { - if (strcmp(archive_string_conversion_charset_name( - zip->opt_sconv), "UTF-8") == 0) - zip->flags |= ZIP_FLAGS_UTF8_NAME; -#if HAVE_NL_LANGINFO - } else if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0) { - zip->flags |= ZIP_FLAGS_UTF8_NAME; -#endif - } + /* Reset information from last entry. */ + zip->entry_offset = zip->written_bytes; + zip->entry_uncompressed_limit = INT64_MAX; + zip->entry_compressed_size = 0; + zip->entry_uncompressed_size = 0; + zip->entry_compressed_written = 0; + zip->entry_uncompressed_written = 0; + zip->entry_flags = 0; + zip->entry_uses_zip64 = 0; + zip->entry_crc32 = zip->crc32func(0, NULL, 0); + if (zip->entry != NULL) { + archive_entry_free(zip->entry); + zip->entry = NULL; } - d = zip->data_descriptor; - size = archive_entry_size(entry); - zip->remaining_data_bytes = size; - /* Append archive entry to the central directory data. */ - l = (struct zip_file_header_link *) malloc(sizeof(*l)); - if (l == NULL) { - archive_set_error(&a->archive, ENOMEM, - "Can't allocate zip header data"); - return (ARCHIVE_FATAL); - } #if defined(_WIN32) && !defined(__CYGWIN__) /* Make sure the path separators in pahtname, hardlink and symlink * are all slash '/', not the Windows path separator '\'. */ - l->entry = __la_win_entry_in_posix_pathseparator(entry); - if (l->entry == entry) - l->entry = archive_entry_clone(entry); + zip->entry = __la_win_entry_in_posix_pathseparator(entry); + if (zip->entry == entry) + zip->entry = archive_entry_clone(entry); #else - l->entry = archive_entry_clone(entry); + zip->entry = archive_entry_clone(entry); #endif - if (l->entry == NULL) { + if (zip->entry == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate zip header data"); - free(l); return (ARCHIVE_FATAL); } - l->flags = zip->flags; - if (zip->opt_sconv != NULL) - sconv = zip->opt_sconv; - else - sconv = zip->sconv_default; + if (sconv != NULL) { const char *p; size_t len; if (archive_entry_pathname_l(entry, &p, &len, sconv) != 0) { if (errno == ENOMEM) { - archive_entry_free(l->entry); - free(l); archive_set_error(&a->archive, ENOMEM, "Can't allocate memory for Pathname"); return (ARCHIVE_FATAL); @@ -470,163 +491,283 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry) ret2 = ARCHIVE_WARN; } if (len > 0) - archive_entry_set_pathname(l->entry, p); + archive_entry_set_pathname(zip->entry, p); /* - * Although there is no character-set regulation for Symlink, - * it is suitable to convert a character-set of Symlinke to - * what those of the Pathname has been converted to. + * There is no standard for symlink handling; we convert + * it using the same character-set translation that we use + * for filename. */ if (type == AE_IFLNK) { if (archive_entry_symlink_l(entry, &p, &len, sconv)) { if (errno == ENOMEM) { - archive_entry_free(l->entry); - free(l); archive_set_error(&a->archive, ENOMEM, "Can't allocate memory " " for Symlink"); return (ARCHIVE_FATAL); } - /* - * Even if the strng conversion failed, - * we should not report the error since - * thre is no regulation for. - */ + /* No error if we can't convert. */ } else if (len > 0) - archive_entry_set_symlink(l->entry, p); + archive_entry_set_symlink(zip->entry, p); + } + } + + /* If filename isn't ASCII and we can use UTF-8, set the UTF-8 flag. */ + if (!is_all_ascii(archive_entry_pathname(zip->entry))) { + if (zip->opt_sconv != NULL) { + if (strcmp(archive_string_conversion_charset_name( + zip->opt_sconv), "UTF-8") == 0) + zip->entry_flags |= ZIP_ENTRY_FLAG_UTF8_NAME; +#if HAVE_NL_LANGINFO + } else if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0) { + zip->entry_flags |= ZIP_ENTRY_FLAG_UTF8_NAME; +#endif } } - /* If all characters in a filename are ASCII, Reset UTF-8 Name flag. */ - if ((l->flags & ZIP_FLAGS_UTF8_NAME) != 0 && - is_all_ascii(archive_entry_pathname(l->entry))) - l->flags &= ~ZIP_FLAGS_UTF8_NAME; + filename_length = path_length(zip->entry); - /* Initialize the CRC variable and potentially the local crc32(). */ - l->crc32 = crc32(0, NULL, 0); + /* Determine appropriate compression and size for this entry. */ if (type == AE_IFLNK) { - const char *p = archive_entry_symlink(l->entry); - if (p != NULL) - size = strlen(p); + symlink = archive_entry_symlink(zip->entry); + if (symlink != NULL) + symlink_size = strlen(symlink); else - size = 0; - zip->remaining_data_bytes = 0; - archive_entry_set_size(l->entry, size); - l->compression = COMPRESSION_STORE; - l->compressed_size = size; + symlink_size = 0; + zip->entry_uncompressed_limit = symlink_size; + zip->entry_compressed_size = symlink_size; + zip->entry_uncompressed_size = symlink_size; + zip->entry_crc32 = zip->crc32func(zip->entry_crc32, + (const unsigned char *)symlink, symlink_size); + zip->entry_compression = COMPRESSION_STORE; + version_needed = 20; + } else if (type != AE_IFREG) { + zip->entry_compression = COMPRESSION_STORE; + zip->entry_uncompressed_limit = 0; + size = 0; + version_needed = 20; + } else if (archive_entry_size_is_set(zip->entry)) { + size = archive_entry_size(zip->entry); + zip->entry_uncompressed_limit = size; + zip->entry_compression = zip->requested_compression; + if (zip->entry_compression == COMPRESSION_UNSPECIFIED) { + zip->entry_compression = COMPRESSION_DEFAULT; + } + if (zip->entry_compression == COMPRESSION_STORE) { + zip->entry_compressed_size = size; + zip->entry_uncompressed_size = size; + version_needed = 10; + } else { + zip->entry_uncompressed_size = size; + version_needed = 20; + } + if ((zip->flags & ZIP_FLAG_FORCE_ZIP64) /* User asked. */ + || (zip->entry_uncompressed_size > 0xffffffffLL)) { /* Large entry. */ + zip->entry_uses_zip64 = 1; + version_needed = 45; + } + + /* We may know the size, but never the CRC. */ + zip->entry_flags |= ZIP_ENTRY_FLAG_LENGTH_AT_END; } else { - l->compression = zip->compression; - l->compressed_size = 0; + /* Prefer deflate if it's available, because deflate + * has a clear end-of-data marker that makes + * length-at-end more reliable. */ + zip->entry_compression = COMPRESSION_DEFAULT; + zip->entry_flags |= ZIP_ENTRY_FLAG_LENGTH_AT_END; + if ((zip->flags & ZIP_FLAG_AVOID_ZIP64) == 0) { + zip->entry_uses_zip64 = 1; + version_needed = 45; + } else if (zip->entry_compression == COMPRESSION_STORE) { + version_needed = 10; + } else { + version_needed = 20; + } } - l->next = NULL; - if (zip->central_directory == NULL) { - zip->central_directory = l; + + /* Format the local header. */ + memset(local_header, 0, sizeof(local_header)); + memcpy(local_header, "PK\003\004", 4); + archive_le16enc(local_header + 4, version_needed); + archive_le16enc(local_header + 6, zip->entry_flags); + archive_le16enc(local_header + 8, zip->entry_compression); + archive_le32enc(local_header + 10, dos_time(archive_entry_mtime(zip->entry))); + archive_le32enc(local_header + 14, zip->entry_crc32); + if (zip->entry_uses_zip64) { + /* Zip64 data in the local header "must" include both + * compressed and uncompressed sizes AND those fields + * are included only if these are 0xffffffff; + * THEREFORE these must be set this way, even if we + * know one of them is smaller. */ + archive_le32enc(local_header + 18, 0xffffffffLL); + archive_le32enc(local_header + 22, 0xffffffffLL); } else { - zip->central_directory_end->next = l; - } - zip->central_directory_end = l; - - /* Store the offset of this header for later use in central - * directory. */ - l->offset = zip->written_bytes; - - memset(h, 0, sizeof(h)); - archive_le32enc(&h[LOCAL_FILE_HEADER_SIGNATURE], - ZIP_SIGNATURE_LOCAL_FILE_HEADER); - archive_le16enc(&h[LOCAL_FILE_HEADER_VERSION], ZIP_VERSION_EXTRACT); - archive_le16enc(&h[LOCAL_FILE_HEADER_FLAGS], l->flags); - archive_le16enc(&h[LOCAL_FILE_HEADER_COMPRESSION], l->compression); - archive_le32enc(&h[LOCAL_FILE_HEADER_TIMEDATE], - dos_time(archive_entry_mtime(entry))); - archive_le16enc(&h[LOCAL_FILE_HEADER_FILENAME_LENGTH], - (uint16_t)path_length(l->entry)); - - switch (l->compression) { - case COMPRESSION_STORE: - /* Setting compressed and uncompressed sizes even when - * specification says to set to zero when using data - * descriptors. Otherwise the end of the data for an - * entry is rather difficult to find. */ - archive_le32enc(&h[LOCAL_FILE_HEADER_COMPRESSED_SIZE], - (uint32_t)size); - archive_le32enc(&h[LOCAL_FILE_HEADER_UNCOMPRESSED_SIZE], - (uint32_t)size); - break; -#ifdef HAVE_ZLIB_H - case COMPRESSION_DEFLATE: - archive_le32enc(&h[LOCAL_FILE_HEADER_UNCOMPRESSED_SIZE], - (uint32_t)size); + archive_le32enc(local_header + 18, zip->entry_compressed_size); + archive_le32enc(local_header + 22, zip->entry_uncompressed_size); + } + archive_le16enc(local_header + 26, filename_length); + + /* Format as much of central directory file header as we can: */ + zip->file_header = cd_alloc(zip, 46); + /* If (zip->file_header == NULL) XXXX */ + ++zip->central_directory_entries; + memset(zip->file_header, 0, 46); + memcpy(zip->file_header, "PK\001\002", 4); + /* "Made by PKZip 2.0 on Unix." */ + archive_le16enc(zip->file_header + 4, 3 * 256 + version_needed); + archive_le16enc(zip->file_header + 6, version_needed); + archive_le16enc(zip->file_header + 8, zip->entry_flags); + archive_le16enc(zip->file_header + 10, zip->entry_compression); + archive_le32enc(zip->file_header + 12, dos_time(archive_entry_mtime(zip->entry))); + archive_le16enc(zip->file_header + 28, filename_length); + /* Following Info-Zip, store mode in the "external attributes" field. */ + archive_le32enc(zip->file_header + 38, + archive_entry_mode(zip->entry) << 16); + e = cd_alloc(zip, filename_length); + /* If (e == NULL) XXXX */ + copy_path(zip->entry, e); + + /* Format extra data. */ + memset(local_extra, 0, sizeof(local_extra)); + e = local_extra; + + /* First, extra blocks that are the same between + * the local file header and the central directory. + * We format them once and then duplicate them. */ + + /* UT timestamp, length depends on what timestamps are set. */ + memcpy(e, "UT", 2); + archive_le16enc(e + 2, + 1 + + (archive_entry_mtime_is_set(entry) ? 4 : 0) + + (archive_entry_atime_is_set(entry) ? 4 : 0) + + (archive_entry_ctime_is_set(entry) ? 4 : 0)); + e += 4; + *e++ = + (archive_entry_mtime_is_set(entry) ? 1 : 0) + | (archive_entry_atime_is_set(entry) ? 2 : 0) + | (archive_entry_ctime_is_set(entry) ? 4 : 0); + if (archive_entry_mtime_is_set(entry)) { + archive_le32enc(e, (uint32_t)archive_entry_mtime(entry)); + e += 4; + } + if (archive_entry_atime_is_set(entry)) { + archive_le32enc(e, (uint32_t)archive_entry_atime(entry)); + e += 4; + } + if (archive_entry_ctime_is_set(entry)) { + archive_le32enc(e, (uint32_t)archive_entry_ctime(entry)); + e += 4; + } - zip->stream.zalloc = Z_NULL; - zip->stream.zfree = Z_NULL; - zip->stream.opaque = Z_NULL; - zip->stream.next_out = zip->buf; - zip->stream.avail_out = (uInt)zip->len_buf; - if (deflateInit2(&zip->stream, Z_DEFAULT_COMPRESSION, - Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) { - archive_set_error(&a->archive, ENOMEM, - "Can't init deflate compressor"); - return (ARCHIVE_FATAL); + /* ux Unix extra data, length 11, version 1 */ + /* TODO: If uid < 64k, use 2 bytes, ditto for gid. */ + memcpy(e, "ux\013\000\001", 5); + e += 5; + *e++ = 4; /* Length of following UID */ + archive_le32enc(e, (uint32_t)archive_entry_uid(entry)); + e += 4; + *e++ = 4; /* Length of following GID */ + archive_le32enc(e, (uint32_t)archive_entry_gid(entry)); + e += 4; + + /* Copy UT and ux into central directory as well. */ + zip->file_header_extra_offset = zip->central_directory_bytes; + cd_extra = cd_alloc(zip, e - local_extra); + memcpy(cd_extra, local_extra, e - local_extra); + + /* + * Following extra blocks vary between local header and + * central directory. These are the local header versions. + * Central directory versions get formatted in + * archive_write_zip_finish_entry() below. + */ + + /* "[Zip64 entry] in the local header MUST include BOTH + * original [uncompressed] and compressed size fields." */ + if (zip->entry_uses_zip64) { + unsigned char *zip64_start = e; + memcpy(e, "\001\000\020\000", 4); + e += 4; + archive_le64enc(e, zip->entry_uncompressed_size); + e += 8; + archive_le64enc(e, zip->entry_compressed_size); + e += 8; + archive_le16enc(zip64_start + 2, e - (zip64_start + 4)); + } + + if (zip->flags & ZIP_FLAG_EXPERIMENT_EL) { + /* Experimental 'el' extension to improve streaming. */ + unsigned char *external_info = e; + int included = 7; + memcpy(e, "el\000\000", 4); // 0x6c65 + 2-byte length + e += 4; + e[0] = included; /* bitmap of included fields */ + e += 1; + if (included & 1) { + archive_le16enc(e, /* "Version created by" */ + 3 * 256 + version_needed); + e += 2; } - break; -#endif + if (included & 2) { + archive_le16enc(e, 0); /* internal file attributes */ + e += 2; + } + if (included & 4) { + archive_le32enc(e, /* external file attributes */ + archive_entry_mode(zip->entry) << 16); + e += 4; + } + if (included & 8) { + // Libarchive does not currently support file comments. + } + archive_le16enc(external_info + 2, e - (external_info + 4)); } - /* Formatting extra data. */ - archive_le16enc(&h[LOCAL_FILE_HEADER_EXTRA_LENGTH], sizeof(e)); - archive_le16enc(&e[EXTRA_DATA_LOCAL_TIME_ID], - ZIP_SIGNATURE_EXTRA_TIMESTAMP); - archive_le16enc(&e[EXTRA_DATA_LOCAL_TIME_SIZE], 1 + 4 * 3); - e[EXTRA_DATA_LOCAL_TIME_FLAG] = 0x07; - archive_le32enc(&e[EXTRA_DATA_LOCAL_MTIME], - (uint32_t)archive_entry_mtime(entry)); - archive_le32enc(&e[EXTRA_DATA_LOCAL_ATIME], - (uint32_t)archive_entry_atime(entry)); - archive_le32enc(&e[EXTRA_DATA_LOCAL_CTIME], - (uint32_t)archive_entry_ctime(entry)); - - archive_le16enc(&e[EXTRA_DATA_LOCAL_UNIX_ID], - ZIP_SIGNATURE_EXTRA_NEW_UNIX); - archive_le16enc(&e[EXTRA_DATA_LOCAL_UNIX_SIZE], 1 + (1 + 4) * 2); - e[EXTRA_DATA_LOCAL_UNIX_VERSION] = 1; - e[EXTRA_DATA_LOCAL_UNIX_UID_SIZE] = 4; - archive_le32enc(&e[EXTRA_DATA_LOCAL_UNIX_UID], - (uint32_t)archive_entry_uid(entry)); - e[EXTRA_DATA_LOCAL_UNIX_GID_SIZE] = 4; - archive_le32enc(&e[EXTRA_DATA_LOCAL_UNIX_GID], - (uint32_t)archive_entry_gid(entry)); - - archive_le32enc(&d[DATA_DESCRIPTOR_UNCOMPRESSED_SIZE], - (uint32_t)size); - - ret = __archive_write_output(a, h, sizeof(h)); + /* Update local header with size of extra data and write it all out: */ + archive_le16enc(local_header + 28, e - local_extra); + + ret = __archive_write_output(a, local_header, 30); if (ret != ARCHIVE_OK) return (ARCHIVE_FATAL); - zip->written_bytes += sizeof(h); + zip->written_bytes += 30; - ret = write_path(l->entry, a); + ret = write_path(zip->entry, a); if (ret <= ARCHIVE_OK) return (ARCHIVE_FATAL); zip->written_bytes += ret; - ret = __archive_write_output(a, e, sizeof(e)); + ret = __archive_write_output(a, local_extra, e - local_extra); if (ret != ARCHIVE_OK) return (ARCHIVE_FATAL); - zip->written_bytes += sizeof(e); - - if (type == AE_IFLNK) { - const unsigned char *p; + zip->written_bytes += e - local_extra; - p = (const unsigned char *)archive_entry_symlink(l->entry); - ret = __archive_write_output(a, p, (size_t)size); + /* For symlinks, write the body now. */ + if (symlink != NULL) { + ret = __archive_write_output(a, symlink, (size_t)symlink_size); if (ret != ARCHIVE_OK) return (ARCHIVE_FATAL); - zip->written_bytes += size; - l->crc32 = crc32(l->crc32, p, (unsigned)size); + zip->entry_compressed_written += symlink_size; + zip->entry_uncompressed_written += symlink_size; + zip->written_bytes += symlink_size; } - if (ret2 != ARCHIVE_OK) - return (ret2); - return (ARCHIVE_OK); +#ifdef HAVE_ZLIB_H + if (zip->entry_compression == COMPRESSION_DEFLATE) { + zip->stream.zalloc = Z_NULL; + zip->stream.zfree = Z_NULL; + zip->stream.opaque = Z_NULL; + zip->stream.next_out = zip->buf; + zip->stream.avail_out = (uInt)zip->len_buf; + if (deflateInit2(&zip->stream, Z_DEFAULT_COMPRESSION, + Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) { + archive_set_error(&a->archive, ENOMEM, + "Can't init deflate compressor"); + return (ARCHIVE_FATAL); + } + } +#endif + + return (ret2); } static ssize_t @@ -634,22 +775,21 @@ archive_write_zip_data(struct archive_write *a, const void *buff, size_t s) { int ret; struct zip *zip = a->format_data; - struct zip_file_header_link *l = zip->central_directory_end; - if ((int64_t)s > zip->remaining_data_bytes) - s = (size_t)zip->remaining_data_bytes; + if ((int64_t)s > zip->entry_uncompressed_limit) + s = (size_t)zip->entry_uncompressed_limit; + zip->entry_uncompressed_written += s; if (s == 0) return 0; - switch (l->compression) { + switch (zip->entry_compression) { case COMPRESSION_STORE: ret = __archive_write_output(a, buff, s); - if (ret != ARCHIVE_OK) return (ret); + if (ret != ARCHIVE_OK) + return (ret); zip->written_bytes += s; - zip->remaining_data_bytes -= s; - l->compressed_size += s; - l->crc32 = crc32(l->crc32, buff, (unsigned)s); - return (s); + zip->entry_compressed_written += s; + break; #if HAVE_ZLIB_H case COMPRESSION_DEFLATE: zip->stream.next_in = (unsigned char*)(uintptr_t)buff; @@ -663,16 +803,13 @@ archive_write_zip_data(struct archive_write *a, const void *buff, size_t s) zip->len_buf); if (ret != ARCHIVE_OK) return (ret); - l->compressed_size += zip->len_buf; + zip->entry_compressed_written += zip->len_buf; zip->written_bytes += zip->len_buf; zip->stream.next_out = zip->buf; zip->stream.avail_out = (uInt)zip->len_buf; } } while (zip->stream.avail_in != 0); - zip->remaining_data_bytes -= s; - /* If we have it, use zlib's fast crc32() */ - l->crc32 = crc32(l->crc32, buff, (uInt)s); - return (s); + break; #endif default: @@ -680,153 +817,174 @@ archive_write_zip_data(struct archive_write *a, const void *buff, size_t s) "Invalid ZIP compression type"); return ARCHIVE_FATAL; } + + zip->entry_uncompressed_limit -= s; + zip->entry_crc32 = zip->crc32func(zip->entry_crc32, buff, (unsigned)s); + return (s); + } static int archive_write_zip_finish_entry(struct archive_write *a) { - /* Write the data descripter after file data has been written. */ - int ret; struct zip *zip = a->format_data; - uint8_t *d = zip->data_descriptor; - struct zip_file_header_link *l = zip->central_directory_end; -#if HAVE_ZLIB_H - size_t reminder; -#endif + int ret; - switch(l->compression) { - case COMPRESSION_STORE: - break; #if HAVE_ZLIB_H - case COMPRESSION_DEFLATE: + if (zip->entry_compression == COMPRESSION_DEFLATE) { for (;;) { + size_t remainder; ret = deflate(&zip->stream, Z_FINISH); if (ret == Z_STREAM_ERROR) return (ARCHIVE_FATAL); - reminder = zip->len_buf - zip->stream.avail_out; - ret = __archive_write_output(a, zip->buf, reminder); + remainder = zip->len_buf - zip->stream.avail_out; + ret = __archive_write_output(a, zip->buf, remainder); if (ret != ARCHIVE_OK) return (ret); - l->compressed_size += reminder; - zip->written_bytes += reminder; + zip->entry_compressed_written += remainder; + zip->written_bytes += remainder; zip->stream.next_out = zip->buf; if (zip->stream.avail_out != 0) break; zip->stream.avail_out = (uInt)zip->len_buf; } deflateEnd(&zip->stream); - break; + } #endif + + /* Write trailing data descriptor. */ + if ((zip->entry_flags & ZIP_ENTRY_FLAG_LENGTH_AT_END) != 0) { + char d[24]; + memcpy(d, "PK\007\010", 4); + archive_le32enc(d + 4, zip->entry_crc32); + if (zip->entry_uses_zip64) { + archive_le64enc(d + 8, (uint64_t)zip->entry_compressed_written); + archive_le64enc(d + 16, (uint64_t)zip->entry_uncompressed_written); + ret = __archive_write_output(a, d, 24); + zip->written_bytes += 24; + } else { + archive_le32enc(d + 8, (uint32_t)zip->entry_compressed_written); + archive_le32enc(d + 12, (uint32_t)zip->entry_uncompressed_written); + ret = __archive_write_output(a, d, 16); + zip->written_bytes += 16; + } + if (ret != ARCHIVE_OK) + return (ARCHIVE_FATAL); } - archive_le32enc(&d[DATA_DESCRIPTOR_CRC32], l->crc32); - archive_le32enc(&d[DATA_DESCRIPTOR_COMPRESSED_SIZE], - (uint32_t)l->compressed_size); - ret = __archive_write_output(a, d, SIZE_DATA_DESCRIPTOR); - if (ret != ARCHIVE_OK) - return (ARCHIVE_FATAL); - zip->written_bytes += SIZE_DATA_DESCRIPTOR; + /* Append Zip64 extra data to central directory information. */ + if (zip->entry_compressed_written > 0xffffffffLL + || zip->entry_uncompressed_written > 0xffffffffLL + || zip->entry_offset > 0xffffffffLL) { + unsigned char zip64[32]; + unsigned char *z = zip64, *zd; + memcpy(z, "\001\000\000\000", 4); + z += 4; + if (zip->entry_uncompressed_written >= 0xffffffffLL) { + archive_le64enc(z, zip->entry_uncompressed_written); + z += 8; + } + if (zip->entry_compressed_written >= 0xffffffffLL) { + archive_le64enc(z, zip->entry_compressed_written); + z += 8; + } + if (zip->entry_offset >= 0xffffffffLL) { + archive_le64enc(z, zip->entry_offset); + z += 8; + } + archive_le16enc(zip64 + 2, z - (zip64 + 4)); + zd = cd_alloc(zip, z - zip64); + if (zd == NULL) { + archive_set_error(&a->archive, ENOMEM, + "Can't allocate zip data"); + return (ARCHIVE_FATAL); + } + memcpy(zd, zip64, z - zip64); + /* Zip64 means version needs to be set to at least 4.5 */ + if (archive_le16dec(zip->file_header + 6) < 45) + archive_le16enc(zip->file_header + 6, 45); + } + + /* Fix up central directory file header. */ + archive_le32enc(zip->file_header + 16, zip->entry_crc32); + archive_le32enc(zip->file_header + 20, + zipmin(zip->entry_compressed_written, 0xffffffffLL)); + archive_le32enc(zip->file_header + 24, + zipmin(zip->entry_uncompressed_written, 0xffffffffLL)); + archive_le16enc(zip->file_header + 30, + zip->central_directory_bytes - zip->file_header_extra_offset); + archive_le32enc(zip->file_header + 42, + zipmin(zip->entry_offset, 0xffffffffLL)); + return (ARCHIVE_OK); } static int archive_write_zip_close(struct archive_write *a) { - struct zip *zip; - struct zip_file_header_link *l; - uint8_t h[SIZE_FILE_HEADER]; - uint8_t end[SIZE_CENTRAL_DIRECTORY_END]; - uint8_t e[SIZE_EXTRA_DATA_CENTRAL]; + uint8_t buff[64]; int64_t offset_start, offset_end; - int entries; + struct zip *zip = a->format_data; + struct cd_segment *segment; int ret; - zip = a->format_data; - l = zip->central_directory; - - /* - * Formatting central directory file header fields that are - * fixed for all entries. - * Fields not used (and therefor 0) are: - * - * - comment_length - * - disk_number - * - attributes_internal - */ - memset(h, 0, sizeof(h)); - archive_le32enc(&h[FILE_HEADER_SIGNATURE], ZIP_SIGNATURE_FILE_HEADER); - archive_le16enc(&h[FILE_HEADER_VERSION_BY], ZIP_VERSION_BY); - archive_le16enc(&h[FILE_HEADER_VERSION_EXTRACT], ZIP_VERSION_EXTRACT); - - entries = 0; offset_start = zip->written_bytes; - - /* Formatting individual header fields per entry and - * writing each entry. */ - while (l != NULL) { - archive_le16enc(&h[FILE_HEADER_FLAGS], l->flags); - archive_le16enc(&h[FILE_HEADER_COMPRESSION], l->compression); - archive_le32enc(&h[FILE_HEADER_TIMEDATE], - dos_time(archive_entry_mtime(l->entry))); - archive_le32enc(&h[FILE_HEADER_CRC32], l->crc32); - archive_le32enc(&h[FILE_HEADER_COMPRESSED_SIZE], - (uint32_t)l->compressed_size); - archive_le32enc(&h[FILE_HEADER_UNCOMPRESSED_SIZE], - (uint32_t)archive_entry_size(l->entry)); - archive_le16enc(&h[FILE_HEADER_FILENAME_LENGTH], - (uint16_t)path_length(l->entry)); - archive_le16enc(&h[FILE_HEADER_EXTRA_LENGTH], sizeof(e)); - archive_le16enc(&h[FILE_HEADER_ATTRIBUTES_EXTERNAL+2], - archive_entry_mode(l->entry)); - archive_le32enc(&h[FILE_HEADER_OFFSET], (uint32_t)l->offset); - - /* Formatting extra data. */ - archive_le16enc(&e[EXTRA_DATA_CENTRAL_TIME_ID], - ZIP_SIGNATURE_EXTRA_TIMESTAMP); - archive_le16enc(&e[EXTRA_DATA_CENTRAL_TIME_SIZE], 1 + 4); - e[EXTRA_DATA_CENTRAL_TIME_FLAG] = 0x07; - archive_le32enc(&e[EXTRA_DATA_CENTRAL_MTIME], - (uint32_t)archive_entry_mtime(l->entry)); - archive_le16enc(&e[EXTRA_DATA_CENTRAL_UNIX_ID], - ZIP_SIGNATURE_EXTRA_NEW_UNIX); - archive_le16enc(&e[EXTRA_DATA_CENTRAL_UNIX_SIZE], 0x0000); - - ret = __archive_write_output(a, h, sizeof(h)); + segment = zip->central_directory; + while (segment != NULL) { + ret = __archive_write_output(a, + segment->buff, segment->p - segment->buff); if (ret != ARCHIVE_OK) return (ARCHIVE_FATAL); - zip->written_bytes += sizeof(h); - - ret = write_path(l->entry, a); - if (ret <= ARCHIVE_OK) - return (ARCHIVE_FATAL); - zip->written_bytes += ret; + zip->written_bytes += segment->p - segment->buff; + segment = segment->next; + } + offset_end = zip->written_bytes; - ret = __archive_write_output(a, e, sizeof(e)); - if (ret != ARCHIVE_OK) - return (ARCHIVE_FATAL); - zip->written_bytes += sizeof(e); + /* If central dir info is too large, write Zip64 end-of-cd */ + if (offset_end - offset_start > 0xffffffffLL + || offset_start > 0xffffffffLL + || zip->central_directory_entries > 0xffffUL + || (zip->flags & ZIP_FLAG_FORCE_ZIP64)) { + /* Zip64 end-of-cd record */ + memset(buff, 0, 56); + memcpy(buff, "PK\006\006", 4); + archive_le64enc(buff + 4, 44); + archive_le16enc(buff + 12, 45); + archive_le16enc(buff + 14, 45); + /* This is disk 0 of 0. */ + archive_le64enc(buff + 24, zip->central_directory_entries); + archive_le64enc(buff + 32, zip->central_directory_entries); + archive_le64enc(buff + 40, offset_end - offset_start); + archive_le64enc(buff + 48, offset_start); + ret = __archive_write_output(a, buff, 56); + if (ret != ARCHIVE_OK) + return (ARCHIVE_FATAL); + zip->written_bytes += 56; + + /* Zip64 end-of-cd locator record. */ + memset(buff, 0, 20); + memcpy(buff, "PK\006\007", 4); + archive_le32enc(buff + 4, 0); + archive_le64enc(buff + 8, offset_end); + archive_le32enc(buff + 16, 1); + ret = __archive_write_output(a, buff, 20); + if (ret != ARCHIVE_OK) + return (ARCHIVE_FATAL); + zip->written_bytes += 20; - l = l->next; - entries++; } - offset_end = zip->written_bytes; - /* Formatting end of central directory. */ - memset(end, 0, sizeof(end)); - archive_le32enc(&end[CENTRAL_DIRECTORY_END_SIGNATURE], - ZIP_SIGNATURE_CENTRAL_DIRECTORY_END); - archive_le16enc(&end[CENTRAL_DIRECTORY_END_ENTRIES_DISK], entries); - archive_le16enc(&end[CENTRAL_DIRECTORY_END_ENTRIES], entries); - archive_le32enc(&end[CENTRAL_DIRECTORY_END_SIZE], - (uint32_t)(offset_end - offset_start)); - archive_le32enc(&end[CENTRAL_DIRECTORY_END_OFFSET], - (uint32_t)offset_start); - - /* Writing end of central directory. */ - ret = __archive_write_output(a, end, sizeof(end)); + /* Format and write end of central directory. */ + memset(buff, 0, sizeof(buff)); + memcpy(buff, "PK\005\006", 4); + archive_le16enc(buff + 8, zipmin(0xffffU, zip->central_directory_entries)); + archive_le16enc(buff + 10, zipmin(0xffffU, zip->central_directory_entries)); + archive_le32enc(buff + 12, (uint32_t)zipmin(0xffffffffLL, (offset_end - offset_start))); + archive_le32enc(buff + 16, (uint32_t)zipmin(0xffffffffLL, offset_start)); + ret = __archive_write_output(a, buff, 22); if (ret != ARCHIVE_OK) return (ARCHIVE_FATAL); - zip->written_bytes += sizeof(end); + zip->written_bytes += 22; return (ARCHIVE_OK); } @@ -834,18 +992,21 @@ static int archive_write_zip_free(struct archive_write *a) { struct zip *zip; - struct zip_file_header_link *l; + struct cd_segment *segment; zip = a->format_data; while (zip->central_directory != NULL) { - l = zip->central_directory; - zip->central_directory = l->next; - archive_entry_free(l->entry); - free(l); + segment = zip->central_directory; + zip->central_directory = segment->next; + free(segment->buff); + free(segment); } #ifdef HAVE_ZLIB_H free(zip->buf); #endif + archive_entry_free(zip->entry); + /* TODO: Free opt_sconv, sconv_default */ + free(zip); a->format_data = NULL; return (ARCHIVE_OK); @@ -918,7 +1079,7 @@ write_path(struct archive_entry *entry, struct archive_write *archive) return (ARCHIVE_FATAL); written_bytes += strlen(path); - /* Folders are recognized by a traling slash. */ + /* Folders are recognized by a trailing slash. */ if ((type == AE_IFDIR) & (path[strlen(path) - 1] != '/')) { ret = __archive_write_output(archive, "/", 1); if (ret != ARCHIVE_OK) @@ -928,3 +1089,38 @@ write_path(struct archive_entry *entry, struct archive_write *archive) return ((int)written_bytes); } + +static void +copy_path(struct archive_entry *entry, unsigned char *p) +{ + const char *path; + size_t pathlen; + mode_t type; + + path = archive_entry_pathname(entry); + pathlen = strlen(path); + type = archive_entry_filetype(entry); + + memcpy(p, path, pathlen); + + /* Folders are recognized by a trailing slash. */ + if ((type == AE_IFDIR) & (path[pathlen - 1] != '/')) { + p[pathlen] = '/'; + p[pathlen + 1] = '\0'; + } +} + + +static struct archive_string_conv * +get_sconv(struct archive_write *a, struct zip *zip) +{ + if (zip->opt_sconv != NULL) + return (zip->opt_sconv); + + if (!zip->init_default_conversion) { + zip->sconv_default = + archive_string_default_conversion_for_write(&(a->archive)); + zip->init_default_conversion = 1; + } + return (zip->sconv_default); +} diff --git a/libarchive/filter_fork_windows.c b/libarchive/filter_fork_windows.c index fa59cc9..ad271fe 100644 --- a/libarchive/filter_fork_windows.c +++ b/libarchive/filter_fork_windows.c @@ -36,7 +36,7 @@ __archive_create_child(const char *cmd, int *child_stdin, int *child_stdout) { HANDLE childStdout[2], childStdin[2],childStderr; SECURITY_ATTRIBUTES secAtts; - STARTUPINFO staInfo; + STARTUPINFOA staInfo; PROCESS_INFORMATION childInfo; struct archive_string cmdline; struct archive_string fullpath; diff --git a/libarchive/mtree.5 b/libarchive/mtree.5 index 983fff7..8c45a7d 100644 --- a/libarchive/mtree.5 +++ b/libarchive/mtree.5 @@ -28,7 +28,7 @@ .\" From: @(#)mtree.8 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd May 6, 2008 +.Dd September 4, 2013 .Dt MTREE 5 .Os .Sh NAME @@ -134,6 +134,52 @@ The checksum of the file using the default algorithm specified by the .Xr cksum 1 utility. +.It Cm device +The device number for +.Sy block +or +.Sy char +file types. +The value must be one of the following forms: +.Pp +.Bl -tag -width 4n +.It Ar format , Ns Ar major , Ns Ar minor Ns Bo , Ns Ar subunit Bc +A device with +.Ar major , minor +and optional +.Ar subunit +fields. +Their meaning is specified by the operating's system +.Ar format . +See below for valid formats. +.It Ar number +Opaque number (as stored on the file system). +.El +.Pp +The following values for +.Ar format +are recognized: +.Sy native , +.Sy 386bsd , +.Sy 4bsd , +.Sy bsdos , +.Sy freebsd , +.Sy hpux , +.Sy isc , +.Sy linux , +.Sy netbsd , +.Sy osf1 , +.Sy sco , +.Sy solaris , +.Sy sunos , +.Sy svr3 , +.Sy svr4 , +and +.Sy ultrix . +.Pp +See +.Xr mknod 8 +for more details. .It Cm contents The full pathname of a file that holds the contents of this file. .It Cm flags @@ -150,6 +196,8 @@ The file group as a numeric value. The file group as a symbolic name. .It Cm ignore Ignore any file hierarchy below this file. +.It Cm inode +The inode number. .It Cm link The target of the symbolic link when type=link. .It Cm md5 @@ -164,6 +212,16 @@ value. The number of hard links the file is expected to have. .It Cm nochange Make sure this file or directory exists but otherwise ignore all attributes. +.It Cm optional +The file is optional; do not complain about the file if it is not in +the file hierarchy. +.It Cm resdevice +The +.Dq resident +device number of the file, e.g. the ID of the device that +contains the file. +Its format is the same as the one for +.Cm device . .It Cm ripemd160digest The .Tn RIPEMD160 @@ -192,6 +250,24 @@ message digest of the file. .It Cm sha256digest A synonym for .Cm sha256 . +.It Cm sha384 +The +.Tn FIPS +180-2 +.Pq Dq Tn SHA-384 +message digest of the file. +.It Cm sha384digest +A synonym for +.Cm sha384 . +.It Cm sha512 +The +.Tn FIPS +180-2 +.Pq Dq Tn SHA-512 +message digest of the file. +.It Cm sha512digest +A synonym for +.Cm sha512 . .It Cm size The size, in bytes, of the file. .It Cm time -- cgit v0.12 From 23e4666cf57c31c719472debba83a43f54d351d8 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Apr 2014 14:37:13 -0400 Subject: libarchive: Disable more whitespace checks in third-party code --- Utilities/cmlibarchive/.gitattributes | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Utilities/cmlibarchive/.gitattributes b/Utilities/cmlibarchive/.gitattributes index be7062b..a87f192 100644 --- a/Utilities/cmlibarchive/.gitattributes +++ b/Utilities/cmlibarchive/.gitattributes @@ -1,2 +1 @@ -*.h whitespace=indent-with-non-tab,-blank-at-eol -*.c whitespace=indent-with-non-tab,-blank-at-eol +* whitespace=-indent-with-non-tab,-tab-in-indent,-blank-at-eol,-blank-at-eof -- cgit v0.12 From 8092e759ea24bd2e1af8ac360ed43675776b82c9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Apr 2014 14:42:45 -0400 Subject: libarchive: Update README-CMake.txt for new snapshot --- Utilities/cmlibarchive/README-CMake.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Utilities/cmlibarchive/README-CMake.txt b/Utilities/cmlibarchive/README-CMake.txt index ab105f0..7cbee4c 100644 --- a/Utilities/cmlibarchive/README-CMake.txt +++ b/Utilities/cmlibarchive/README-CMake.txt @@ -11,7 +11,7 @@ branch, but it is merged into our history. Update libarchive from upstream as follows. Create a local branch to explicitly reference the upstream snapshot branch head: - git branch libarchive-upstream 35df7c8b + git branch libarchive-upstream 64713ae3 Use a temporary directory to checkout the branch: @@ -24,7 +24,7 @@ Use a temporary directory to checkout the branch: Now place the (reduced) libarchive content in this directory. See instructions shown by - git log 35df7c8b + git log 64713ae3 for help extracting the content from the upstream svn repo. Then run the following commands to commit the new version. Substitute the @@ -34,8 +34,8 @@ appropriate date and version number: GIT_AUTHOR_NAME='LibArchive Upstream' \ GIT_AUTHOR_EMAIL='libarchive-discuss@googlegroups.com' \ - GIT_AUTHOR_DATE='2013-02-09 12:17:57 -0500' \ - git commit -m 'libarchive 3.1.2 (reduced)' && + GIT_AUTHOR_DATE='Mon Mar 17 20:43:07 2014 -0700' \ + git commit -m 'libarchive 3.1.2-218-g00f4bd83 (reduced)' && git commit --amend Edit the commit message to describe the procedure used to obtain the -- cgit v0.12 From 66b0c4fa198baa283e33a779d5d794d6cff8a277 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Apr 2014 14:44:50 -0400 Subject: libarchive: Do not generate a pkg-config file CMake does not install the headers or libraries so skip the .pc file too. --- Utilities/cmlibarchive/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt index 75a4fd5..24e5ba7 100644 --- a/Utilities/cmlibarchive/CMakeLists.txt +++ b/Utilities/cmlibarchive/CMakeLists.txt @@ -1296,9 +1296,6 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.h.in INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) ADD_DEFINITIONS(-DHAVE_CONFIG_H) -# Handle generation of the libarchive.pc file for pkg-config -INCLUDE(CreatePkgConfigFile) - # # Register installation of PDF documents. # -- cgit v0.12 From debe4decced43000fbb00391eaad1d01a56b0179 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Apr 2014 14:53:16 -0400 Subject: libarchive: Drop options not present in reduced version Drop ENABLE_TAR and ENABLE_CPIO related options because we do not build these command-line tools. Drop ENABLE_TEST and ENABLE_COVERAGE options because we do not build the tests. --- Utilities/cmlibarchive/CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt index 24e5ba7..e493966 100644 --- a/Utilities/cmlibarchive/CMakeLists.txt +++ b/Utilities/cmlibarchive/CMakeLists.txt @@ -76,15 +76,9 @@ OPTION(ENABLE_EXPAT "Enable the use of the system found EXPAT library if found" OPTION(ENABLE_PCREPOSIX "Enable the use of the system found PCREPOSIX library if found" ON) OPTION(ENABLE_LibGCC "Enable the use of the system found LibGCC library if found" ON) -OPTION(ENABLE_TAR "Enable tar building" ON) -OPTION(ENABLE_TAR_SHARED "Enable dynamic build of tar" FALSE) -OPTION(ENABLE_CPIO "Enable cpio building" ON) -OPTION(ENABLE_CPIO_SHARED "Enable dynamic build of cpio" FALSE) OPTION(ENABLE_XATTR "Enable extended attribute support" ON) OPTION(ENABLE_ACL "Enable ACL support" ON) OPTION(ENABLE_ICONV "Enable iconv support" ON) -OPTION(ENABLE_TEST "Enable unit and regression tests" ON) -OPTION(ENABLE_COVERAGE "Enable code coverage (GCC only, automatically sets ENABLE_TEST to ON)" FALSE) IF(WIN32) IF(MSVC60) -- cgit v0.12 From b0a9807f39c8e4220848d6ce9f4fdc874f9ebadc Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Apr 2014 15:06:49 -0400 Subject: libarchive: Update archive_util.c to use CMake zlib and bzip2 headers --- Utilities/cmlibarchive/libarchive/archive_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Utilities/cmlibarchive/libarchive/archive_util.c b/Utilities/cmlibarchive/libarchive/archive_util.c index 3d92566..b53beca 100644 --- a/Utilities/cmlibarchive/libarchive/archive_util.c +++ b/Utilities/cmlibarchive/libarchive/archive_util.c @@ -46,13 +46,13 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_util.c 201098 2009-12-28 02:58:1 #include #endif #ifdef HAVE_ZLIB_H -#include +#include #endif #ifdef HAVE_LZMA_H #include #endif #ifdef HAVE_BZLIB_H -#include +#include #endif #include "archive.h" -- cgit v0.12 From dfb0458e5bb3444db506c0891d6c78ac678e4017 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Apr 2014 15:09:28 -0400 Subject: libarchive: Convert literal LL suffix to ARCHIVE_LITERAL_LL --- .../libarchive/archive_write_set_format_zip.c | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c index 026bee2..d856b2a 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c @@ -561,7 +561,7 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry) version_needed = 20; } if ((zip->flags & ZIP_FLAG_FORCE_ZIP64) /* User asked. */ - || (zip->entry_uncompressed_size > 0xffffffffLL)) { /* Large entry. */ + || (zip->entry_uncompressed_size > ARCHIVE_LITERAL_LL(0xffffffff))) { /* Large entry. */ zip->entry_uses_zip64 = 1; version_needed = 45; } @@ -598,8 +598,8 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry) * are included only if these are 0xffffffff; * THEREFORE these must be set this way, even if we * know one of them is smaller. */ - archive_le32enc(local_header + 18, 0xffffffffLL); - archive_le32enc(local_header + 22, 0xffffffffLL); + archive_le32enc(local_header + 18, ARCHIVE_LITERAL_LL(0xffffffff)); + archive_le32enc(local_header + 22, ARCHIVE_LITERAL_LL(0xffffffff)); } else { archive_le32enc(local_header + 18, zip->entry_compressed_size); archive_le32enc(local_header + 22, zip->entry_uncompressed_size); @@ -873,22 +873,22 @@ archive_write_zip_finish_entry(struct archive_write *a) } /* Append Zip64 extra data to central directory information. */ - if (zip->entry_compressed_written > 0xffffffffLL - || zip->entry_uncompressed_written > 0xffffffffLL - || zip->entry_offset > 0xffffffffLL) { + if (zip->entry_compressed_written > ARCHIVE_LITERAL_LL(0xffffffff) + || zip->entry_uncompressed_written > ARCHIVE_LITERAL_LL(0xffffffff) + || zip->entry_offset > ARCHIVE_LITERAL_LL(0xffffffff)) { unsigned char zip64[32]; unsigned char *z = zip64, *zd; memcpy(z, "\001\000\000\000", 4); z += 4; - if (zip->entry_uncompressed_written >= 0xffffffffLL) { + if (zip->entry_uncompressed_written >= ARCHIVE_LITERAL_LL(0xffffffff)) { archive_le64enc(z, zip->entry_uncompressed_written); z += 8; } - if (zip->entry_compressed_written >= 0xffffffffLL) { + if (zip->entry_compressed_written >= ARCHIVE_LITERAL_LL(0xffffffff)) { archive_le64enc(z, zip->entry_compressed_written); z += 8; } - if (zip->entry_offset >= 0xffffffffLL) { + if (zip->entry_offset >= ARCHIVE_LITERAL_LL(0xffffffff)) { archive_le64enc(z, zip->entry_offset); z += 8; } @@ -908,13 +908,13 @@ archive_write_zip_finish_entry(struct archive_write *a) /* Fix up central directory file header. */ archive_le32enc(zip->file_header + 16, zip->entry_crc32); archive_le32enc(zip->file_header + 20, - zipmin(zip->entry_compressed_written, 0xffffffffLL)); + zipmin(zip->entry_compressed_written, ARCHIVE_LITERAL_LL(0xffffffff))); archive_le32enc(zip->file_header + 24, - zipmin(zip->entry_uncompressed_written, 0xffffffffLL)); + zipmin(zip->entry_uncompressed_written, ARCHIVE_LITERAL_LL(0xffffffff))); archive_le16enc(zip->file_header + 30, zip->central_directory_bytes - zip->file_header_extra_offset); archive_le32enc(zip->file_header + 42, - zipmin(zip->entry_offset, 0xffffffffLL)); + zipmin(zip->entry_offset, ARCHIVE_LITERAL_LL(0xffffffff))); return (ARCHIVE_OK); } @@ -941,8 +941,8 @@ archive_write_zip_close(struct archive_write *a) offset_end = zip->written_bytes; /* If central dir info is too large, write Zip64 end-of-cd */ - if (offset_end - offset_start > 0xffffffffLL - || offset_start > 0xffffffffLL + if (offset_end - offset_start > ARCHIVE_LITERAL_LL(0xffffffff) + || offset_start > ARCHIVE_LITERAL_LL(0xffffffff) || zip->central_directory_entries > 0xffffUL || (zip->flags & ZIP_FLAG_FORCE_ZIP64)) { /* Zip64 end-of-cd record */ @@ -979,8 +979,8 @@ archive_write_zip_close(struct archive_write *a) memcpy(buff, "PK\005\006", 4); archive_le16enc(buff + 8, zipmin(0xffffU, zip->central_directory_entries)); archive_le16enc(buff + 10, zipmin(0xffffU, zip->central_directory_entries)); - archive_le32enc(buff + 12, (uint32_t)zipmin(0xffffffffLL, (offset_end - offset_start))); - archive_le32enc(buff + 16, (uint32_t)zipmin(0xffffffffLL, offset_start)); + archive_le32enc(buff + 12, (uint32_t)zipmin(ARCHIVE_LITERAL_LL(0xffffffff), (offset_end - offset_start))); + archive_le32enc(buff + 16, (uint32_t)zipmin(ARCHIVE_LITERAL_LL(0xffffffff), offset_start)); ret = __archive_write_output(a, buff, 22); if (ret != ARCHIVE_OK) return (ARCHIVE_FATAL); -- cgit v0.12 From 8088332178a9fb082dd387beae9b1f262615a228 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Apr 2014 15:18:28 -0400 Subject: libarchive: Do not require includers to have windows.h In archive_entry.h refer to "BY_HANDLE_FILE_INFORMATION *" using "struct _BY_HANDLE_FILE_INFORMATION *" to avoid requiring the includer to already have . --- Utilities/cmlibarchive/libarchive/archive_entry.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/cmlibarchive/libarchive/archive_entry.h b/Utilities/cmlibarchive/libarchive/archive_entry.h index 20d709b..efc4d73 100644 --- a/Utilities/cmlibarchive/libarchive/archive_entry.h +++ b/Utilities/cmlibarchive/libarchive/archive_entry.h @@ -247,7 +247,7 @@ __LA_DECL int archive_entry_is_encrypted(struct archive_entry *); __LA_DECL void archive_entry_set_atime(struct archive_entry *, time_t, long); __LA_DECL void archive_entry_unset_atime(struct archive_entry *); #if defined(_WIN32) && !defined(__CYGWIN__) -__LA_DECL void archive_entry_copy_bhfi(struct archive_entry *, BY_HANDLE_FILE_INFORMATION *); +__LA_DECL void archive_entry_copy_bhfi(struct archive_entry *, struct _BY_HANDLE_FILE_INFORMATION *); #endif __LA_DECL void archive_entry_set_birthtime(struct archive_entry *, time_t, long); __LA_DECL void archive_entry_unset_birthtime(struct archive_entry *); -- cgit v0.12 From e2b02823e7986e7df59907b307480acad5ec6562 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Apr 2014 15:20:58 -0400 Subject: Update libarchive configuration within CMake Hard-code libarchive build options to the way CMake needs them. Set them as internal cache entries so users do not see them when building CMake. --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0793d0..5e4cd15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -321,6 +321,12 @@ macro (CMAKE_BUILD_UTILITIES) add_definitions(-DLIBARCHIVE_STATIC) set(ENABLE_NETTLE OFF CACHE INTERNAL "Enable use of Nettle") set(ENABLE_OPENSSL ${CMAKE_USE_OPENSSL} CACHE INTERNAL "Enable use of OpenSSL") + set(ENABLE_LZMA OFF CACHE INTERNAL "Enable the use of the system found LZMA library if found") + set(ENABLE_ZLIB ON CACHE INTERNAL "Enable the use of the system found ZLIB library if found") + set(ENABLE_BZip2 ON CACHE INTERNAL "Enable the use of the system found BZip2 library if found") + set(ENABLE_EXPAT OFF CACHE INTERNAL "Enable the use of the system found EXPAT library if found") + set(ENABLE_PCREPOSIX OFF CACHE INTERNAL "Enable the use of the system found PCREPOSIX library if found") + set(ENABLE_LibGCC OFF CACHE INTERNAL "Enable the use of the system found LibGCC library if found") set(ENABLE_XATTR OFF CACHE INTERNAL "Enable extended attribute support") set(ENABLE_ACL OFF CACHE INTERNAL "Enable ACL support") set(ENABLE_ICONV OFF CACHE INTERNAL "Enable iconv support") -- cgit v0.12 From ff710539ab31ba4b6f3b376621dd9fbd56e1b558 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 1 Apr 2014 23:53:05 +0200 Subject: Remove default labels from fully covered switch statements. Allow compilers to warn when new enum values are added, making switches no-longer fully-covered. --- Source/cmCTest.cxx | 2 -- Source/cmLocalGenerator.cxx | 1 - Source/cmMakefile.cxx | 1 - Source/cmNewLineStyle.cxx | 2 -- Source/cmTargetLinkLibrariesCommand.cxx | 1 - 5 files changed, 7 deletions(-) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 9f711b7..d797d3b 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -217,8 +217,6 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method, url += "?" + fields; } break; - default: - break; } ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index dcf9f97..1e65a02 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2283,7 +2283,6 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared, case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::NEW: - default: return false; } } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index b1d6fe2..1328974 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3365,7 +3365,6 @@ std::string cmMakefile::GetModulesFile(const char* filename) const case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::NEW: - default: result = moduleInCMakeRoot; break; } diff --git a/Source/cmNewLineStyle.cxx b/Source/cmNewLineStyle.cxx index a7d7429..08f0b5b 100644 --- a/Source/cmNewLineStyle.cxx +++ b/Source/cmNewLineStyle.cxx @@ -76,8 +76,6 @@ const std::string cmNewLineStyle::GetCharacters() const return "\n"; case CRLF: return "\r\n"; - default: - ; } return ""; } diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 1c2e625..56e1338 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -70,7 +70,6 @@ bool cmTargetLinkLibrariesCommand GetRequiredPolicyError(cmPolicies::CMP0016); break; case cmPolicies::NEW: // NEW behavior prints the error. - default: break; } } -- cgit v0.12 From 4bef02e7aa60c48df923d778ae33438e573ec7bc Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 3 Apr 2014 21:28:10 +0200 Subject: cmTypeMacro: Add a class to eat the semicolon following the macro use. Apply the same workaround to the cmCPackTypeMacro. Additionally change that macro to not use 'class' as a macro parameter. --- Source/CPack/cmCPackGenerator.h | 7 ++++--- Source/cmStandardIncludes.h | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index efd3bef..e780f0e 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -22,9 +22,10 @@ // Forward declarations are insufficient since we use them in // std::map data members below... -#define cmCPackTypeMacro(class, superclass) \ - cmTypeMacro(class, superclass); \ - static cmCPackGenerator* CreateGenerator() { return new class; } +#define cmCPackTypeMacro(klass, superclass) \ + cmTypeMacro(klass, superclass); \ + static cmCPackGenerator* CreateGenerator() { return new klass; } \ + class cmCPackTypeMacro_UseTrailingSemicolon #define cmCPackLogger(logType, msg) \ do { \ diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index ed8efcc..a544894 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -378,7 +378,8 @@ static thisClass* SafeDownCast(cmObject *c) \ return static_cast(c); \ } \ return 0;\ -} +} \ +class cmTypeMacro_UseTrailingSemicolon inline bool cmHasLiteralPrefixImpl(const std::string &str1, const char *str2, -- cgit v0.12 From 6c190245703b2115e8cdf62ccdea090583d14299 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 3 Apr 2014 21:35:22 +0200 Subject: Remove extra semicolons from C++ code. Clang based tools running over the code complain about these, but clang has a fixit for removing them. --- Source/cmCTest.h | 6 +++--- Source/cmCommand.h | 2 +- Source/cmDepends.h | 2 +- Source/cmDynamicLoader.h | 4 ++-- Source/cmExecutionStatus.h | 2 +- Source/cmFunctionCommand.cxx | 4 ++-- Source/cmGlobalGenerator.h | 2 +- Source/cmIfCommand.h | 2 +- Source/cmLocalGenerator.h | 10 +++++----- Source/cmMacroCommand.cxx | 4 ++-- Source/cmMakefile.h | 2 +- Source/cmProperty.h | 2 +- Source/cmPropertyDefinition.h | 10 +++++----- Source/cmPropertyMap.h | 4 ++-- Source/cmSourceFile.h | 2 +- Source/cmStandardIncludes.h | 6 +++--- Source/cmStringCommand.h | 2 +- Source/cmTarget.h | 4 ++-- Source/cmTest.h | 4 ++-- Source/cmake.h | 8 ++++---- 20 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 836e41d..246294f 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -134,7 +134,7 @@ public: /* * Is the tomorrow tag set? */ - bool GetTomorrowTag() { return this->TomorrowTag; }; + bool GetTomorrowTag() { return this->TomorrowTag; } /** * Try to run tests of the project @@ -167,7 +167,7 @@ public: * Set the cmake test mode (experimental, nightly, continuous). */ void SetTestModel(int mode); - int GetTestModel() { return this->TestModel; }; + int GetTestModel() { return this->TestModel; } std::string GetTestModelString(); static int GetTestModelFromString(const char* str); @@ -392,7 +392,7 @@ public: int ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf); std::vector &GetInitialCommandLineArguments() - { return this->InitialCommandLineArguments; }; + { return this->InitialCommandLineArguments; } //! Set the track to submit to void SetSpecificTrack(const char* track); diff --git a/Source/cmCommand.h b/Source/cmCommand.h index b15869a..a34ea71 100644 --- a/Source/cmCommand.h +++ b/Source/cmCommand.h @@ -81,7 +81,7 @@ public: * not implement this method. At this point, reading and * writing to the cache can be done. */ - virtual void FinalPass() {}; + virtual void FinalPass() {} /** * Does this command have a final pass? Query after InitialPass. diff --git a/Source/cmDepends.h b/Source/cmDepends.h index b293c5b..4f6517e 100644 --- a/Source/cmDepends.h +++ b/Source/cmDepends.h @@ -32,7 +32,7 @@ public: cmDepends(cmLocalGenerator* lg=0, const char* targetDir=""); /** at what level will the compile be done from */ - void SetCompileDirectory(const char *dir) {this->CompileDirectory = dir;}; + void SetCompileDirectory(const char *dir) {this->CompileDirectory = dir;} /** Set the local generator for the directory in which we are scanning dependencies. This is not a full local generator; it diff --git a/Source/cmDynamicLoader.h b/Source/cmDynamicLoader.h index acf8011..d038b5c 100644 --- a/Source/cmDynamicLoader.h +++ b/Source/cmDynamicLoader.h @@ -36,8 +36,8 @@ public: static void FlushCache(); protected: - cmDynamicLoader() {}; - ~cmDynamicLoader() {}; + cmDynamicLoader() {} + ~cmDynamicLoader() {} private: cmDynamicLoader(const cmDynamicLoader&); // Not implemented. diff --git a/Source/cmExecutionStatus.h b/Source/cmExecutionStatus.h index 1488924..5c94a97 100644 --- a/Source/cmExecutionStatus.h +++ b/Source/cmExecutionStatus.h @@ -24,7 +24,7 @@ class cmExecutionStatus : public cmObject public: cmTypeMacro(cmExecutionStatus, cmObject); - cmExecutionStatus() { this->Clear();}; + cmExecutionStatus() { this->Clear();} virtual void SetReturnInvoked(bool val) { this->ReturnInvoked = val; } diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 3ff527d..3580374 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -20,7 +20,7 @@ public: cmFunctionHelperCommand() {} ///! clean up any memory allocated by the function - ~cmFunctionHelperCommand() {}; + ~cmFunctionHelperCommand() {} /** * This is used to avoid including this command @@ -59,7 +59,7 @@ public: cmExecutionStatus &); virtual bool InitialPass(std::vector const&, - cmExecutionStatus &) { return false; }; + cmExecutionStatus &) { return false; } /** * The name of the command as specified in CMakeList.txt. diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 54f5f3b..82fb1e5 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -51,7 +51,7 @@ public: virtual cmLocalGenerator *CreateLocalGenerator(); ///! Get the name for this generator - virtual std::string GetName() const { return "Generic"; }; + virtual std::string GetName() const { return "Generic"; } /** Check whether the given name matches the current generator. */ virtual bool MatchesGeneratorName(const std::string& name) const diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h index b9de845..814c052 100644 --- a/Source/cmIfCommand.h +++ b/Source/cmIfCommand.h @@ -58,7 +58,7 @@ public: * the CMakeLists.txt file. */ virtual bool InitialPass(std::vector const&, - cmExecutionStatus &) { return false;}; + cmExecutionStatus &) { return false;} /** * The name of the command as specified in CMakeList.txt. diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 61488fe..8f30149 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -76,17 +76,17 @@ public: ///! Get the makefile for this generator cmMakefile *GetMakefile() { - return this->Makefile; }; + return this->Makefile; } ///! Get the makefile for this generator, const version const cmMakefile *GetMakefile() const { - return this->Makefile; }; + return this->Makefile; } ///! Get the GlobalGenerator this is associated with cmGlobalGenerator *GetGlobalGenerator() { - return this->GlobalGenerator; }; + return this->GlobalGenerator; } const cmGlobalGenerator *GetGlobalGenerator() const { - return this->GlobalGenerator; }; + return this->GlobalGenerator; } ///! Set the Global Generator, done on creation by the GlobalGenerator void SetGlobalGenerator(cmGlobalGenerator *gg); @@ -135,7 +135,7 @@ public: ///! set/get the children void AddChild(cmLocalGenerator* g) { this->Children.push_back(g); } - std::vector& GetChildren() { return this->Children; }; + std::vector& GetChildren() { return this->Children; } void AddArchitectureFlags(std::string& flags, cmGeneratorTarget* target, diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 9f569e1..ae81c58 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -20,7 +20,7 @@ public: cmMacroHelperCommand() {} ///! clean up any memory allocated by the macro - ~cmMacroHelperCommand() {}; + ~cmMacroHelperCommand() {} /** * This is used to avoid including this command @@ -60,7 +60,7 @@ public: cmExecutionStatus &); virtual bool InitialPass(std::vector const&, - cmExecutionStatus &) { return false; }; + cmExecutionStatus &) { return false; } /** * The name of the command as specified in CMakeList.txt. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 8ff6daa..1288f45 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -815,7 +815,7 @@ public: const std::string& config); // Get the properties - cmPropertyMap &GetProperties() { return this->Properties; }; + cmPropertyMap &GetProperties() { return this->Properties; } ///! Initialize a makefile from its parent void InitializeFromParent(); diff --git a/Source/cmProperty.h b/Source/cmProperty.h index 789be1d..34897e8 100644 --- a/Source/cmProperty.h +++ b/Source/cmProperty.h @@ -31,7 +31,7 @@ public: const char *GetValue() const; // construct with the value not set - cmProperty() { this->ValueHasBeenSet = false; }; + cmProperty() { this->ValueHasBeenSet = false; } protected: std::string Name; diff --git a/Source/cmPropertyDefinition.h b/Source/cmPropertyDefinition.h index 9ca8222..098fadb 100644 --- a/Source/cmPropertyDefinition.h +++ b/Source/cmPropertyDefinition.h @@ -33,22 +33,22 @@ public: bool chained); /// Default constructor - cmPropertyDefinition() { this->Chained = false; }; + cmPropertyDefinition() { this->Chained = false; } /// Is the property chained? - bool IsChained() const { return this->Chained; }; + bool IsChained() const { return this->Chained; } /// Get the scope cmProperty::ScopeType GetScope() const { - return this->Scope; }; + return this->Scope; } /// Get the documentation (short version) const std::string &GetShortDescription() const { - return this->ShortDescription; }; + return this->ShortDescription; } /// Get the documentation (full version) const std::string &GetFullDescription() const { - return this->FullDescription; }; + return this->FullDescription; } protected: std::string Name; diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index fa33848..02d4235 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -31,9 +31,9 @@ public: cmProperty::ScopeType scope, bool &chain) const; - void SetCMakeInstance(cmake *cm) { this->CMakeInstance = cm; }; + void SetCMakeInstance(cmake *cm) { this->CMakeInstance = cm; } - cmPropertyMap() { this->CMakeInstance = 0;}; + cmPropertyMap() { this->CMakeInstance = 0;} private: cmake *CMakeInstance; diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 755a2cf..a1d9de1 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -89,7 +89,7 @@ public: void AddDepend(const char* d) { this->Depends.push_back(d); } // Get the properties - cmPropertyMap &GetProperties() { return this->Properties; }; + cmPropertyMap &GetProperties() { return this->Properties; } /** * Check whether the given source file location could refer to this diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index a544894..3731502 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -324,12 +324,12 @@ struct cmDocumentationEntry { std::string Name; std::string Brief; - cmDocumentationEntry(){}; + cmDocumentationEntry(){} cmDocumentationEntry(const char *doc[2]) { if (doc[0]) this->Name = doc[0]; - if (doc[1]) this->Brief = doc[1];}; + if (doc[1]) this->Brief = doc[1];} cmDocumentationEntry(const char *n, const char *b) - { if (n) this->Name = n; if (b) this->Brief = b; }; + { if (n) this->Name = n; if (b) this->Brief = b; } }; /** Data structure to represent a single command line. */ diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h index 5b7412d..51069e7 100644 --- a/Source/cmStringCommand.h +++ b/Source/cmStringCommand.h @@ -83,7 +83,7 @@ protected: RegexReplacement(const char* s): number(-1), value(s) {} RegexReplacement(const std::string& s): number(-1), value(s) {} RegexReplacement(int n): number(n), value() {} - RegexReplacement() {}; + RegexReplacement() {} int number; std::string value; }; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 055e029..da032a5 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -106,7 +106,7 @@ public: ///! Set the cmMakefile that owns this target void SetMakefile(cmMakefile *mf); - cmMakefile *GetMakefile() const { return this->Makefile;}; + cmMakefile *GetMakefile() const { return this->Makefile;} #define DECLARE_TARGET_POLICY(POLICY) \ cmPolicies::PolicyStatus GetPolicyStatus ## POLICY () const \ @@ -448,7 +448,7 @@ public: cmTarget const* head = 0) const; // Get the properties - cmPropertyMap &GetProperties() const { return this->Properties; }; + cmPropertyMap &GetProperties() const { return this->Properties; } bool GetMappedConfig(std::string const& desired_config, const char** loc, diff --git a/Source/cmTest.h b/Source/cmTest.h index b3785f6..a93eff5 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -51,10 +51,10 @@ public: const char* value,bool asString=false); const char *GetProperty(const std::string& prop) const; bool GetPropertyAsBool(const std::string& prop) const; - cmPropertyMap &GetProperties() { return this->Properties; }; + cmPropertyMap &GetProperties() { return this->Properties; } /** Get the cmMakefile instance that owns this test. */ - cmMakefile *GetMakefile() { return this->Makefile;}; + cmMakefile *GetMakefile() { return this->Makefile;} /** Get the backtrace of the command that created this test. */ cmListFileBacktrace const& GetBacktrace() const; diff --git a/Source/cmake.h b/Source/cmake.h index 6772740..76a3179 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -98,9 +98,9 @@ class cmake /// Destructor ~cmake(); - static const char *GetCMakeFilesDirectory() {return "/CMakeFiles";}; + static const char *GetCMakeFilesDirectory() {return "/CMakeFiles";} static const char *GetCMakeFilesDirectoryPostSlash() { - return "CMakeFiles/";}; + return "CMakeFiles/";} //@{ /** @@ -261,7 +261,7 @@ class cmake void UpdateProgress(const char *msg, float prog); ///! get the cmake policies instance - cmPolicies *GetPolicies() {return this->Policies;} ; + cmPolicies *GetPolicies() {return this->Policies;} ///! Get the variable watch object cmVariableWatch* GetVariableWatch() { return this->VariableWatch; } @@ -278,7 +278,7 @@ class cmake bool GetPropertyAsBool(const std::string& prop); // Get the properties - cmPropertyMap &GetProperties() { return this->Properties; }; + cmPropertyMap &GetProperties() { return this->Properties; } ///! Do all the checks before running configure int DoPreConfigureChecks(); -- cgit v0.12 From 63d864a02664d1a2cbd201b327ced1345d62d14a Mon Sep 17 00:00:00 2001 From: Alex Ciobanu Date: Thu, 3 Apr 2014 16:26:41 -0400 Subject: Tests: Fix CTestTestFailedSubmit-ftp with OS X system libcurl On OS X 10.9 the system libcurl has a different error message when failing to connect: Failed connect to :21; Connection refused Match this message to pass the test. --- Tests/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 1c474ab..0e60ed1 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2440,6 +2440,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release set(regex "${regex}|Error message was: ") set(regex "${regex}([Cc]ould *n.t resolve host") set(regex "${regex}|[Cc]ould *n.t connect to host") + set(regex "${regex}|Failed connect to") set(regex "${regex}|Empty reply from server") set(regex "${regex}|The requested URL returned error") set(regex "${regex}|libcurl was built with SSL disabled. https: not supported)") -- cgit v0.12 From ce0aae7039c96f7c2532a38348b97d73acc52b37 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 4 Apr 2014 00:01:07 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 7b9db16..c6de66e 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 0) -set(CMake_VERSION_PATCH 20140403) +set(CMake_VERSION_PATCH 20140404) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 2dad1c143cfee60eadcf1bee5faa47efed89a31a Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Mon, 18 Nov 2013 12:24:24 +0100 Subject: ExternalProject: Find VCS packages quietly This keeps the VCS packages out from FeatureSummary output, unless the INCLUDE_QUIET_PACKAGES is used. --- Modules/ExternalProject.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 0f651e9..3ba91de 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -1352,7 +1352,7 @@ function(_ep_add_download_command name) if(cmd_set) set(work_dir ${download_dir}) elseif(cvs_repository) - find_package(CVS) + find_package(CVS QUIET) if(NOT CVS_EXECUTABLE) message(FATAL_ERROR "error: could not find cvs for checkout of ${name}") endif() @@ -1379,7 +1379,7 @@ function(_ep_add_download_command name) set(cmd ${CVS_EXECUTABLE} -d ${cvs_repository} -q co ${cvs_tag} -d ${src_name} ${cvs_module}) list(APPEND depends ${stamp_dir}/${name}-cvsinfo.txt) elseif(svn_repository) - find_package(Subversion) + find_package(Subversion QUIET) if(NOT Subversion_SVN_EXECUTABLE) message(FATAL_ERROR "error: could not find svn for checkout of ${name}") endif() @@ -1415,7 +1415,7 @@ function(_ep_add_download_command name) --non-interactive ${svn_trust_cert_args} ${svn_user_pw_args} ${src_name}) list(APPEND depends ${stamp_dir}/${name}-svninfo.txt) elseif(git_repository) - find_package(Git) + find_package(Git QUIET) if(NOT GIT_EXECUTABLE) message(FATAL_ERROR "error: could not find git for clone of ${name}") endif() @@ -1463,7 +1463,7 @@ function(_ep_add_download_command name) set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitclone.cmake) list(APPEND depends ${stamp_dir}/${name}-gitinfo.txt) elseif(hg_repository) - find_package(Hg) + find_package(Hg QUIET) if(NOT HG_EXECUTABLE) message(FATAL_ERROR "error: could not find hg for clone of ${name}") endif() -- cgit v0.12 From a40f57e485079fdfc5146dfd294d975fd851a227 Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Thu, 3 Apr 2014 10:19:46 +0200 Subject: cmMakefile: Revise comment describing IsOn() --- Source/cmMakefile.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 460a85c..ea4d34c 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -601,8 +601,11 @@ public: */ std::vector GetDefinitions(int cacheonly=0) const; - /** Test a boolean cache entry to see if it is true or false, - * returns false if no entry defined. + /** + * Test a boolean variable to see if it is true or false. + * If the variable is not found in this makefile instance, the + * cache is then queried. + * Returns false if no entry defined. */ bool IsOn(const std::string& name) const; bool IsSet(const std::string& name) const; -- cgit v0.12 From f4b9c6bbebb0757db2b87efd2239a8eb44d24092 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Thu, 3 Apr 2014 19:02:01 +0200 Subject: CompileFlags: Test for C++ features after selecting flags Some flags we select may affect availability of C++ features. --- CompileFlags.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CompileFlags.cmake b/CompileFlags.cmake index 24ac58d..332d742 100644 --- a/CompileFlags.cmake +++ b/CompileFlags.cmake @@ -19,7 +19,6 @@ endif() if(CMAKE_GENERATOR MATCHES "Visual Studio 6") set(CMAKE_SKIP_COMPATIBILITY_TESTS 1) endif() -include (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityCXX.cmake) if(WIN32 AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$") set(_INTEL_WINDOWS 1) @@ -68,3 +67,5 @@ endif () if (CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL parisc) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--unique=.text._*") endif () + +include (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityCXX.cmake) -- cgit v0.12 From be53734d3c3d5e74ea2d119e4c15c66121283bca Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Thu, 27 Mar 2014 22:30:23 +0100 Subject: CompileFlags: Add -AA +hpxstd98 on HP-UX 11.11 with aCC These flags are needed to enable support for C++98. Also teach the 'bootstrap' script to add them if necessary. --- CompileFlags.cmake | 8 ++++++++ bootstrap | 25 ++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/CompileFlags.cmake b/CompileFlags.cmake index 332d742..873af8f 100644 --- a/CompileFlags.cmake +++ b/CompileFlags.cmake @@ -53,6 +53,14 @@ if(CMAKE_SYSTEM MATCHES "OSF1-V.*") endif() endif() +if(CMAKE_SYSTEM_NAME MATCHES "HP-UX" AND CMAKE_CXX_COMPILER_ID MATCHES "HP") + # it is known that version 3.85 fails and 6.25 works without these flags + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4) + # use new C++ library and improved template support + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA +hpxstd98") + endif() +endif() + # use the ansi CXX compile flag for building cmake if (CMAKE_ANSI_CXXFLAGS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}") diff --git a/bootstrap b/bootstrap index 4e61f3e..233806c 100755 --- a/bootstrap +++ b/bootstrap @@ -1086,8 +1086,8 @@ if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then cmake_test_flags= # If we are on HP-UX, check for -Ae for the C compiler. - cmake_test_flags="-Ae" if [ "x${cmake_system}" = "xHP-UX" ]; then + cmake_test_flags="-Ae" TMPFILE=`cmake_tmp_file` echo ' int main(int argc, char** argv) { (void)argc; (void)argv; return 0; } @@ -1108,6 +1108,29 @@ if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then echo "${cmake_c_compiler} does not need ${cmake_test_flags}" fi rm -f "${TMPFILE}.c" + echo ' + #include + int main(int argc, char** argv) { + for(int i=0; i < 1; ++i); + for(int i=0; i < 1; ++i); + (void)argc; (void)argv; return 0; } +' > ${TMPFILE}.cxx + cmake_need_AAstd98=0 + cmake_test_flags="-AA +hpxstd98" + if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then + : + else + if cmake_try_run "${cmake_cxx_compiler}" \ + "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then + cmake_need_AAstd98=1 + fi + fi + if [ "x${cmake_need_AAstd98}" = "x1" ]; then + cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}" + echo "${cmake_cxx_compiler} needs ${cmake_test_flags}" + else + echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}" + fi fi cmake_test_flags= fi -- cgit v0.12 From 539b6c58f5d9fa9487f8d831f11320517e4dae47 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 4 Apr 2014 23:25:33 +0200 Subject: Fix build on AIX failing because of access to string elements The compilation failed with this error message: .../Source/cmCryptoHash.cxx: In method `string cmCryptoHash::HashString (const string &)': .../Source/cmCryptoHash.cxx:41: non-lvalue in unary `&' This was introduced in 77f60392d93f41a8828d3db1d7b76d45f1535d07 (stringapi: Accept strings when MD5 hashing data). --- Source/cmCryptoHash.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index 0d3c6bb..74e17b6 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -38,7 +38,7 @@ cmsys::auto_ptr cmCryptoHash::New(const char* algo) std::string cmCryptoHash::HashString(const std::string& input) { this->Initialize(); - this->Append(reinterpret_cast(&input[0]), + this->Append(reinterpret_cast(input.c_str()), static_cast(input.size())); return this->Finalize(); } -- cgit v0.12 From d5a32737cfb77b87efca3d9f0b97a36d6c853d6b Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 5 Apr 2014 00:01:06 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c6de66e..9b44508 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 0) -set(CMake_VERSION_PATCH 20140404) +set(CMake_VERSION_PATCH 20140405) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 19b7c22d020a3b1bf26065beb33b0f2f499cd1ad Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 17:09:56 +0200 Subject: Ninja: Query custom commands once per target, not once per file. Computing the source files is now more expensive, so the Ninja generator became very slow with a large number of files. --- Source/cmNinjaTargetGenerator.cxx | 14 +++++++------- Source/cmNinjaTargetGenerator.h | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 56155ef..cb6eb90 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -494,6 +494,9 @@ cmNinjaTargetGenerator { cmCustomCommand const* cc = (*si)->GetCustomCommand(); this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget()); + // Record the custom commands for this target. The container is used + // in WriteObjectBuildStatement when called in a loop below. + this->CustomCommands.push_back((*si)->GetCustomCommand()); } std::vector headerSources; this->GeneratorTarget->GetHeaderSources(headerSources, config); @@ -565,14 +568,11 @@ cmNinjaTargetGenerator } // Add order-only dependencies on custom command outputs. - std::vector customCommands; - std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - this->GeneratorTarget->GetCustomCommands(customCommands, config); - for(std::vector::const_iterator - si = customCommands.begin(); - si != customCommands.end(); ++si) + for(std::vector::const_iterator + cci = this->CustomCommands.begin(); + cci != this->CustomCommands.end(); ++cci) { - cmCustomCommand const* cc = (*si)->GetCustomCommand(); + cmCustomCommand const* cc = *cci; cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->GetMakefile()); const std::vector& ccoutputs = ccg.GetOutputs(); diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 8669e6e..8073af2 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -153,6 +153,7 @@ private: cmLocalNinjaGenerator* LocalGenerator; /// List of object files for this target. cmNinjaDeps Objects; + std::vector CustomCommands; typedef std::map LanguageFlagMap; LanguageFlagMap LanguageFlags; -- cgit v0.12 From e6aace96eb1893a0f9f43bbf1596d527428e2e70 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 6 Apr 2014 00:01:08 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 9b44508..4c015e7 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 0) -set(CMake_VERSION_PATCH 20140405) +set(CMake_VERSION_PATCH 20140406) #set(CMake_VERSION_RC 1) -- cgit v0.12 From eb163f37d449af27fe8446c5d8d632aa295b6428 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 17:45:28 +0200 Subject: cmTarget: Extract a ProcessSourceItemCMP0049 method. Avoid calling AddSource for each src filename. That involves checking each entry for uniqueness and creating a separate generator expression for each one. Instead, add a single entry for the list of sources. The source files are passed through a uniqueness filter at generate-time, so duplicates don't matter so much. --- Source/cmTarget.cxx | 48 +++++++++++++++++++++++++++++++++++++++--------- Source/cmTarget.h | 2 ++ 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b6bb2d3..22be57f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -812,23 +812,41 @@ void cmTarget::GetSourceFiles(std::vector &files, //---------------------------------------------------------------------------- void cmTarget::AddSources(std::vector const& srcs) { + std::string srcFiles; + const char* sep = ""; for(std::vector::const_iterator i = srcs.begin(); i != srcs.end(); ++i) { - const char* src = i->c_str(); - if(src[0] == '$' && src[1] == '<') - { - this->AddSource(src); - } - else + std::string filename = *i; + const char* src = filename.c_str(); + + if(!(src[0] == '$' && src[1] == '<')) { - this->AddSourceCMP0049(src); + filename = this->ProcessSourceItemCMP0049(filename); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + this->Makefile->GetOrCreateSource(filename); } + srcFiles += sep; + srcFiles += filename; + sep = ";"; + } + if (!srcFiles.empty()) + { + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr cge = ge.Parse(srcFiles); + cge->SetEvaluateForBuildsystem(true); + this->Internal->SourceEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); } } //---------------------------------------------------------------------------- -cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s) +std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s) { std::string src = s; @@ -863,10 +881,22 @@ cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s) this->Makefile->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { - return 0; + return ""; } } } + return src; +} + +//---------------------------------------------------------------------------- +cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s) +{ + std::string src = this->ProcessSourceItemCMP0049(s); + + if (cmSystemTools::GetErrorOccuredFlag()) + { + return 0; + } return this->AddSource(src); } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index da032a5..a8ac57f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -752,6 +752,8 @@ private: void ComputeLinkClosure(const std::string& config, LinkClosure& lc, cmTarget const* head) const; + std::string ProcessSourceItemCMP0049(const std::string& s); + void ClearLinkMaps(); void MaybeInvalidatePropertyCache(const std::string& prop); -- cgit v0.12 From c5b26f3bec0e6e18255802da53886eae30a74021 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 5 Apr 2014 11:40:38 +0200 Subject: cmTarget: Cache the cmSourceFiles in GetSourceFiles. Avoid calling GetSourceFiles with the same result container multiple times when tracing target dependencies. The result from the previous configuration is cached and used later otherwise. --- Source/cmGeneratorTarget.cxx | 18 +++++++++--------- Source/cmTarget.cxx | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 01fad26..69a2977 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -636,26 +636,26 @@ cmTargetTraceDependencies // Queue all the source files already specified for the target. if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) { - std::vector sources; std::vector configs; this->Makefile->GetConfigurations(configs); if (configs.empty()) { configs.push_back(""); } + std::set emitted; for(std::vector::const_iterator ci = configs.begin(); ci != configs.end(); ++ci) { + std::vector sources; this->Target->GetSourceFiles(sources, *ci); - } - std::set emitted; - for(std::vector::const_iterator si = sources.begin(); - si != sources.end(); ++si) - { - if(emitted.insert(*si).second && this->SourcesQueued.insert(*si).second) + for(std::vector::const_iterator si = sources.begin(); + si != sources.end(); ++si) { - this->SourceQueue.push(*si); - this->Makefile->GetOrCreateSource(*si); + if(emitted.insert(*si).second && this->SourcesQueued.insert(*si).second) + { + this->SourceQueue.push(*si); + this->Makefile->GetOrCreateSource(*si); + } } } } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 22be57f..d28ac3f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -138,6 +138,10 @@ public: LinkClosureMapType; LinkClosureMapType LinkClosureMap; + typedef std::map > + SourceFilesMapType; + SourceFilesMapType SourceFilesMap; + struct TargetPropertyEntry { TargetPropertyEntry(cmsys::auto_ptr cge, const std::string &targetName = std::string()) @@ -793,19 +797,33 @@ void cmTarget::GetSourceFiles(std::vector &files, const std::string& config, cmTarget const* head) const { - std::vector srcs; - this->GetSourceFiles(srcs, config, head); - std::set emitted; + // Lookup any existing link implementation for this configuration. + TargetConfigPair key(head, cmSystemTools::UpperCase(config)); - for(std::vector::const_iterator i = srcs.begin(); - i != srcs.end(); ++i) + cmTargetInternals::SourceFilesMapType::iterator + it = this->Internal->SourceFilesMap.find(key); + if(it != this->Internal->SourceFilesMap.end()) + { + files = it->second; + } + else { - cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i); - if (emitted.insert(sf).second) + std::vector srcs; + this->GetSourceFiles(srcs, config, head); + + std::set emitted; + + for(std::vector::const_iterator i = srcs.begin(); + i != srcs.end(); ++i) { - files.push_back(sf); + cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i); + if (emitted.insert(sf).second) + { + files.push_back(sf); + } } + this->Internal->SourceFilesMap[key] = files; } } @@ -835,6 +853,7 @@ void cmTarget::AddSources(std::vector const& srcs) } if (!srcFiles.empty()) { + this->Internal->SourceFilesMap.clear(); cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); cmGeneratorExpression ge(lfbt); @@ -969,6 +988,7 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) TargetPropertyEntryFinder(sfl)) == this->Internal->SourceEntries.end()) { + this->Internal->SourceFilesMap.clear(); cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); cmGeneratorExpression ge(lfbt); @@ -1738,6 +1758,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } + this->Internal->SourceFilesMap.clear(); cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); cmGeneratorExpression ge(lfbt); @@ -1824,7 +1845,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - + this->Internal->SourceFilesMap.clear(); cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); cmGeneratorExpression ge(lfbt); -- cgit v0.12 From 92e2fbe103c6ffc3af1189d0450493488c65baaa Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 5 Apr 2014 11:41:58 +0200 Subject: cmGeneratorTarget: Trace cmSourceFile objects instead of strings. This reverses the decision in commit d38423ec (cmTarget: Add a method to obtain list of filenames for sources., 2014-03-17). The cmSourceFile based API is preferred because that avoids creation of many cmSourceFileLocation objects for matching strings, and the result is cached by cmTarget. --- Source/cmGeneratorTarget.cxx | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 69a2977..0d25a00 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -606,12 +606,12 @@ private: cmGlobalGenerator const* GlobalGenerator; typedef cmGeneratorTarget::SourceEntry SourceEntry; SourceEntry* CurrentEntry; - std::queue SourceQueue; - std::set SourcesQueued; + std::queue SourceQueue; + std::set SourcesQueued; typedef std::map NameMapType; NameMapType NameMap; - void QueueSource(std::string const& name); + void QueueSource(cmSourceFile* sf); void FollowName(std::string const& name); void FollowNames(std::vector const& names); bool IsUtility(std::string const& dep); @@ -642,19 +642,19 @@ cmTargetTraceDependencies { configs.push_back(""); } - std::set emitted; + std::set emitted; for(std::vector::const_iterator ci = configs.begin(); ci != configs.end(); ++ci) { - std::vector sources; + std::vector sources; this->Target->GetSourceFiles(sources, *ci); - for(std::vector::const_iterator si = sources.begin(); + for(std::vector::const_iterator si = sources.begin(); si != sources.end(); ++si) { - if(emitted.insert(*si).second && this->SourcesQueued.insert(*si).second) + cmSourceFile* sf = *si; + if(emitted.insert(sf).second && this->SourcesQueued.insert(sf).second) { - this->SourceQueue.push(*si); - this->Makefile->GetOrCreateSource(*si); + this->SourceQueue.push(sf); } } } @@ -673,8 +673,7 @@ void cmTargetTraceDependencies::Trace() while(!this->SourceQueue.empty()) { // Get the next source from the queue. - std::string src = this->SourceQueue.front(); - cmSourceFile* sf = this->Makefile->GetSource(src); + cmSourceFile* sf = this->SourceQueue.front(); this->SourceQueue.pop(); this->CurrentEntry = &this->GeneratorTarget->SourceEntries[sf]; @@ -702,14 +701,14 @@ void cmTargetTraceDependencies::Trace() } //---------------------------------------------------------------------------- -void cmTargetTraceDependencies::QueueSource(std::string const& name) +void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf) { - if(this->SourcesQueued.insert(name).second) + if(this->SourcesQueued.insert(sf).second) { - this->SourceQueue.push(name); + this->SourceQueue.push(sf); // Make sure this file is in the target. - this->Target->AddSource(name); + this->Target->AddSource(sf->GetFullPath()); } } @@ -731,7 +730,7 @@ void cmTargetTraceDependencies::FollowName(std::string const& name) { this->CurrentEntry->Depends.push_back(sf); } - this->QueueSource(sf->GetFullPath()); + this->QueueSource(sf); } } -- cgit v0.12 From a4e6bf8e36e6fa38bb40dc6df2345922de86bad4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 5 Apr 2014 12:35:43 +0200 Subject: cmTarget: Make GetSourceFiles string overload private. Consumers should use the cmSourceFile overload, which is now always the case. --- Source/cmTarget.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a8ac57f..da9d0a1 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -135,9 +135,6 @@ public: /** * Get the list of the source files used by this target */ - void GetSourceFiles(std::vector &files, - const std::string& config, - cmTarget const* head = 0) const; void GetSourceFiles(std::vector &files, const std::string& config, cmTarget const* head = 0) const; @@ -683,6 +680,9 @@ private: const std::string& config, bool contentOnly) const; + void GetSourceFiles(std::vector &files, + const std::string& config, + cmTarget const* head = 0) const; private: std::string Name; std::vector PreBuildCommands; -- cgit v0.12 From c869984ea013f99c3104abaf17d553b08c4b17c2 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Apr 2014 23:53:52 +0200 Subject: RunCMake: Allow specifying the source dir and file to test. This will allow decoupling the name of the test from the name and location of the source file under test, which means one source file can be used for multiple tests. Rename the PARENT_SCOPE test in RunCMake.set to not use a keyword of the if() command as a file name. As the filename is now used with an if condition, this causes a conflict. --- Tests/RunCMake/RunCMake.cmake | 9 ++++++-- Tests/RunCMake/set/PARENT_SCOPE-result.txt | 1 - Tests/RunCMake/set/PARENT_SCOPE.cmake | 33 ------------------------------ Tests/RunCMake/set/ParentScope-result.txt | 1 + Tests/RunCMake/set/ParentScope.cmake | 33 ++++++++++++++++++++++++++++++ Tests/RunCMake/set/RunCMakeTest.cmake | 2 +- 6 files changed, 42 insertions(+), 37 deletions(-) delete mode 100644 Tests/RunCMake/set/PARENT_SCOPE-result.txt delete mode 100644 Tests/RunCMake/set/PARENT_SCOPE.cmake create mode 100644 Tests/RunCMake/set/ParentScope-result.txt create mode 100644 Tests/RunCMake/set/ParentScope.cmake diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index ed3afc5..4ed2f43 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -25,7 +25,9 @@ function(run_cmake test) unset(expect_std${o}) endif() endforeach() - set(RunCMake_TEST_SOURCE_DIR "${top_src}") + if (NOT RunCMake_TEST_SOURCE_DIR) + set(RunCMake_TEST_SOURCE_DIR "${top_src}") + endif() if(NOT RunCMake_TEST_BINARY_DIR) set(RunCMake_TEST_BINARY_DIR "${top_bin}/${test}-build") endif() @@ -36,6 +38,9 @@ function(run_cmake test) if(NOT DEFINED RunCMake_TEST_OPTIONS) set(RunCMake_TEST_OPTIONS "") endif() + if (NOT RunCMake_TEST_FILE) + set(RunCMake_TEST_FILE "${test}") + endif() if(APPLE) list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0025=NEW) endif() @@ -52,7 +57,7 @@ function(run_cmake test) COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}" -G "${RunCMake_GENERATOR}" -T "${RunCMake_GENERATOR_TOOLSET}" - -DRunCMake_TEST=${test} + -DRunCMake_TEST=${RunCMake_TEST_FILE} --no-warn-unused-cli ${RunCMake_TEST_OPTIONS} WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/set/PARENT_SCOPE-result.txt deleted file mode 100644 index 573541a..0000000 --- a/Tests/RunCMake/set/PARENT_SCOPE-result.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tests/RunCMake/set/PARENT_SCOPE.cmake b/Tests/RunCMake/set/PARENT_SCOPE.cmake deleted file mode 100644 index 9bd6bca..0000000 --- a/Tests/RunCMake/set/PARENT_SCOPE.cmake +++ /dev/null @@ -1,33 +0,0 @@ -set(FOO ) -set(BAR "bar") -set(BAZ "baz") -set(BOO "boo") - -function(_parent_scope) - set(FOO "foo" PARENT_SCOPE) - set(BAR "" PARENT_SCOPE) - set(BAZ PARENT_SCOPE) - unset(BOO PARENT_SCOPE) -endfunction() - -_parent_scope() - -if(NOT DEFINED FOO) - message(FATAL_ERROR "FOO not defined") -elseif(NOT "${FOO}" STREQUAL "foo") - message(FATAL_ERROR "FOO should be \"foo\", not \"${FOO}\"") -endif() - -if(NOT DEFINED BAR) - message(FATAL_ERROR "BAR not defined") -elseif(NOT "${BAR}" STREQUAL "") - message(FATAL_ERROR "BAR should be an empty string, not \"${BAR}\"") -endif() - -if(DEFINED BAZ) - message(FATAL_ERROR "BAZ defined") -endif() - -if(DEFINED BOO) - message(FATAL_ERROR "BOO defined") -endif() diff --git a/Tests/RunCMake/set/ParentScope-result.txt b/Tests/RunCMake/set/ParentScope-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/set/ParentScope-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/set/ParentScope.cmake b/Tests/RunCMake/set/ParentScope.cmake new file mode 100644 index 0000000..9bd6bca --- /dev/null +++ b/Tests/RunCMake/set/ParentScope.cmake @@ -0,0 +1,33 @@ +set(FOO ) +set(BAR "bar") +set(BAZ "baz") +set(BOO "boo") + +function(_parent_scope) + set(FOO "foo" PARENT_SCOPE) + set(BAR "" PARENT_SCOPE) + set(BAZ PARENT_SCOPE) + unset(BOO PARENT_SCOPE) +endfunction() + +_parent_scope() + +if(NOT DEFINED FOO) + message(FATAL_ERROR "FOO not defined") +elseif(NOT "${FOO}" STREQUAL "foo") + message(FATAL_ERROR "FOO should be \"foo\", not \"${FOO}\"") +endif() + +if(NOT DEFINED BAR) + message(FATAL_ERROR "BAR not defined") +elseif(NOT "${BAR}" STREQUAL "") + message(FATAL_ERROR "BAR should be an empty string, not \"${BAR}\"") +endif() + +if(DEFINED BAZ) + message(FATAL_ERROR "BAZ defined") +endif() + +if(DEFINED BOO) + message(FATAL_ERROR "BOO defined") +endif() diff --git a/Tests/RunCMake/set/RunCMakeTest.cmake b/Tests/RunCMake/set/RunCMakeTest.cmake index 5d036e3..1b51ea2 100644 --- a/Tests/RunCMake/set/RunCMakeTest.cmake +++ b/Tests/RunCMake/set/RunCMakeTest.cmake @@ -1,3 +1,3 @@ include(RunCMake) -run_cmake(PARENT_SCOPE) +run_cmake(ParentScope) -- cgit v0.12 From 4023bd7b115fb9df6836dacea55e8cb3b1218c9c Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 7 Apr 2014 00:01:06 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 4c015e7..49e2cf3 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 0) -set(CMake_VERSION_PATCH 20140406) +set(CMake_VERSION_PATCH 20140407) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 72e137ea7d4912099b469f6a3b0f8913a1ac5a65 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 4 Apr 2014 11:47:04 -0400 Subject: Re-word comment on unreachable return statements Do not use the word "warning" in the comment because CTest launchers match it and CTestCustom.cmake.in does not suppress it. --- Source/cmCommandArgumentLexer.cxx | 2 +- Source/cmDependsJavaLexer.cxx | 2 +- Source/cmExprLexer.cxx | 2 +- Source/cmSystemTools.cxx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmCommandArgumentLexer.cxx b/Source/cmCommandArgumentLexer.cxx index e62e53e..e23ef8a 100644 --- a/Source/cmCommandArgumentLexer.cxx +++ b/Source/cmCommandArgumentLexer.cxx @@ -1069,7 +1069,7 @@ case YY_STATE_EOF(NOESCAPES): "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ -return 0; /* this should not happend but it should silence a warning */ +return 0; /* this should not happen but it quiets some compilers */ } /* end of cmCommandArgument_yylex */ /* yy_get_next_buffer - try to read in a new buffer diff --git a/Source/cmDependsJavaLexer.cxx b/Source/cmDependsJavaLexer.cxx index 1e505a5..f7676d9 100644 --- a/Source/cmDependsJavaLexer.cxx +++ b/Source/cmDependsJavaLexer.cxx @@ -1591,7 +1591,7 @@ case YY_STATE_EOF(string): "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ -return 0; /* this should not happen but it silences a warning*/ +return 0; /* this should not happen but it quiets some compilers */ } /* end of cmDependsJava_yylex */ /* yy_get_next_buffer - try to read in a new buffer diff --git a/Source/cmExprLexer.cxx b/Source/cmExprLexer.cxx index aa384cd..4704f03 100644 --- a/Source/cmExprLexer.cxx +++ b/Source/cmExprLexer.cxx @@ -976,7 +976,7 @@ case YY_STATE_EOF(INITIAL): "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ -return 0; /* this should not happen but it silences a warning*/ +return 0; /* this should not happen but it quiets some compilers */ } /* end of cmExpr_yylex */ /* yy_get_next_buffer - try to read in a new buffer diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index c1c33f2..635e31c 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1617,7 +1617,7 @@ long copy_data(struct archive *ar, struct archive *aw) } } #if !defined(__clang__) - return r; /* this should not happen but it silences a warning */ + return r; /* this should not happen but it quiets some compilers */ #endif } -- cgit v0.12 From 59b5fdd37c87dd27205e3756d17a186e02e0d326 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 11 Nov 2013 20:35:52 +0100 Subject: Don't load Clang-CXX from AppleClang-CXX. The Clang-CXX module is going to get version-specific checks, and the version system for AppleClang is not the same as Clang. --- Modules/Compiler/AppleClang-CXX.cmake | 7 ++++++- Modules/Compiler/Clang-CXX.cmake | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake index 680f720..0372e18 100644 --- a/Modules/Compiler/AppleClang-CXX.cmake +++ b/Modules/Compiler/AppleClang-CXX.cmake @@ -1 +1,6 @@ -include(Compiler/Clang-CXX) +include(Compiler/Clang) +__compiler_clang(CXX) + +if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") + set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") +endif() diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index 0372e18..ab1b766 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -4,3 +4,8 @@ __compiler_clang(CXX) if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") endif() + +cmake_policy(GET CMP0025 appleClangPolicy) +if(NOT appleClangPolicy STREQUAL NEW) + return() +endif() -- cgit v0.12 From 892243fc3bbc2bbd859cf6c6aaa7b1e1c19d59c9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 2 Apr 2014 14:18:32 +0200 Subject: Tests: Require CMake 3.0 for the SystemInformation test. Correctly identify AppleClang. --- Tests/SystemInformation/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/SystemInformation/CMakeLists.txt b/Tests/SystemInformation/CMakeLists.txt index c33380f..db54612 100644 --- a/Tests/SystemInformation/CMakeLists.txt +++ b/Tests/SystemInformation/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 3.0) project(SystemInformation) include_directories("This does not exists") -- cgit v0.12 From 8238a6cd5d2867e709e87a752e0a24c7c2bf28f0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 13 Oct 2013 01:26:16 +0200 Subject: Add some COMPILE_OPTIONS for specifying C++ dialect. These are compiler-specific, compiler version specific, extension specific and standard version specific. --- Modules/Compiler/Clang-CXX.cmake | 13 +++++++++++++ Modules/Compiler/GNU-CXX.cmake | 13 +++++++++++++ Tests/SystemInformation/SystemInformation.in | 4 ++++ 3 files changed, 30 insertions(+) diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index ab1b766..a1b3a10 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -9,3 +9,16 @@ cmake_policy(GET CMP0025 appleClangPolicy) if(NOT appleClangPolicy STREQUAL NEW) return() endif() + +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1) + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") +endif() + +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") +elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x") +endif() diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index 33d6093..3ee8639 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -10,3 +10,16 @@ else() set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") endif() endif() + +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3) + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") +endif() + +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") +elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x") +endif() diff --git a/Tests/SystemInformation/SystemInformation.in b/Tests/SystemInformation/SystemInformation.in index df3bf49..92b24e2 100644 --- a/Tests/SystemInformation/SystemInformation.in +++ b/Tests/SystemInformation/SystemInformation.in @@ -21,6 +21,10 @@ CMAKE_C_COMPILER_ID == "${CMAKE_C_COMPILER_ID}" CMAKE_C_COMPILER_VERSION == "${CMAKE_C_COMPILER_VERSION}" CMAKE_CXX_COMPILER_ID == "${CMAKE_CXX_COMPILER_ID}" CMAKE_CXX_COMPILER_VERSION == "${CMAKE_CXX_COMPILER_VERSION}" +CMAKE_CXX98_STANDARD_COMPILE_OPTION == "${CMAKE_CXX98_STANDARD_COMPILE_OPTION}" +CMAKE_CXX11_STANDARD_COMPILE_OPTION == "${CMAKE_CXX11_STANDARD_COMPILE_OPTION}" +CMAKE_CXX98_EXTENSION_COMPILE_OPTION == "${CMAKE_CXX98_EXTENSION_COMPILE_OPTION}" +CMAKE_CXX11_EXTENSION_COMPILE_OPTION == "${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}" // C shared library flag CMAKE_SHARED_LIBRARY_C_FLAGS == "${CMAKE_SHARED_LIBRARY_C_FLAGS}" -- cgit v0.12 From 913394af249d6b1892a6e609d2abfed001fa1dc4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 13 Oct 2013 02:00:24 +0200 Subject: cmTarget: Add CXX_STANDARD and CXX_EXTENSION target properties. These are used to determine whether to add -std=c++11, -std=gnu++11 etc flags on the compile line. --- Help/manual/cmake-properties.7.rst | 2 ++ Help/manual/cmake-variables.7.rst | 2 ++ Help/prop_tgt/CXX_EXTENSIONS.rst | 8 +++++++ Help/prop_tgt/CXX_STANDARD.rst | 14 +++++++++++++ Help/release/dev/compile-language-features.rst | 8 +++++++ Help/variable/CMAKE_CXX_EXTENSIONS.rst | 8 +++++++ Help/variable/CMAKE_CXX_STANDARD.rst | 8 +++++++ Source/cmLocalGenerator.cxx | 29 ++++++++++++++++++++++++++ Source/cmLocalGenerator.h | 2 ++ Source/cmTarget.cxx | 2 ++ Tests/CMakeLists.txt | 13 ++++++++++++ Tests/CxxDialect/CMakeLists.txt | 14 +++++++++++++ Tests/CxxDialect/use_constexpr.cxx | 10 +++++++++ Tests/CxxDialect/use_constexpr_and_typeof.cxx | 11 ++++++++++ Tests/CxxDialect/use_typeof.cxx | 6 ++++++ 15 files changed, 137 insertions(+) create mode 100644 Help/prop_tgt/CXX_EXTENSIONS.rst create mode 100644 Help/prop_tgt/CXX_STANDARD.rst create mode 100644 Help/release/dev/compile-language-features.rst create mode 100644 Help/variable/CMAKE_CXX_EXTENSIONS.rst create mode 100644 Help/variable/CMAKE_CXX_STANDARD.rst create mode 100644 Tests/CxxDialect/CMakeLists.txt create mode 100644 Tests/CxxDialect/use_constexpr.cxx create mode 100644 Tests/CxxDialect/use_constexpr_and_typeof.cxx create mode 100644 Tests/CxxDialect/use_typeof.cxx diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index fd16eb9..9ea50de 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -106,6 +106,8 @@ Properties on Targets /prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG /prop_tgt/CONFIG_OUTPUT_NAME /prop_tgt/CONFIG_POSTFIX + /prop_tgt/CXX_STANDARD + /prop_tgt/CXX_EXTENSIONS /prop_tgt/DEBUG_POSTFIX /prop_tgt/DEFINE_SYMBOL /prop_tgt/EchoString diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 4fac6a5..62a7cce 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -257,6 +257,8 @@ Variables for Languages :maxdepth: 1 /variable/CMAKE_COMPILER_IS_GNULANG + /variable/CMAKE_CXX_STANDARD + /variable/CMAKE_CXX_EXTENSIONS /variable/CMAKE_Fortran_MODDIR_DEFAULT /variable/CMAKE_Fortran_MODDIR_FLAG /variable/CMAKE_Fortran_MODOUT_FLAG diff --git a/Help/prop_tgt/CXX_EXTENSIONS.rst b/Help/prop_tgt/CXX_EXTENSIONS.rst new file mode 100644 index 0000000..b9c9931 --- /dev/null +++ b/Help/prop_tgt/CXX_EXTENSIONS.rst @@ -0,0 +1,8 @@ +CXX_EXTENSIONS +-------------- + +Boolean specifying whether compiler specific extensions are requested. + +This property specifies whether compiler specific extensions should be +used. For some compilers, this results in adding a flag such +as ``-std=gnu++11`` instead of ``-std=c++11`` to the compile line. diff --git a/Help/prop_tgt/CXX_STANDARD.rst b/Help/prop_tgt/CXX_STANDARD.rst new file mode 100644 index 0000000..e1b6e78 --- /dev/null +++ b/Help/prop_tgt/CXX_STANDARD.rst @@ -0,0 +1,14 @@ +CXX_STANDARD +------------ + +The C++ standard whose features are required to build this target. + +This property specifies the C++ standard whose features are required +to build this target. For some compilers, this results in adding a +flag such as ``-std=c++11`` to the compile line. + +Supported values are ``98`` and ``11``. + +This property is initialized by the value of +the :variable:`CMAKE_CXX_STANDARD` variable if it is set when a target +is created. diff --git a/Help/release/dev/compile-language-features.rst b/Help/release/dev/compile-language-features.rst new file mode 100644 index 0000000..f03e1a3 --- /dev/null +++ b/Help/release/dev/compile-language-features.rst @@ -0,0 +1,8 @@ +target-language-features +------------------------ + +* New :prop_tgt:`CXX_STANDARD` and :prop_tgt:`CXX_EXTENSIONS` target + properties may specify values which CMake uses to compute required + compile options such as ``-std=c++11`` or ``-std=gnu++11``. The + :variable:`CMAKE_CXX_STANDARD` and :variable:`CMAKE_CXX_EXTENSIONS` + variables may be set to initialize the target properties. diff --git a/Help/variable/CMAKE_CXX_EXTENSIONS.rst b/Help/variable/CMAKE_CXX_EXTENSIONS.rst new file mode 100644 index 0000000..734d508 --- /dev/null +++ b/Help/variable/CMAKE_CXX_EXTENSIONS.rst @@ -0,0 +1,8 @@ +CMAKE_CXX_EXTENSIONS +-------------------- + +Default value for ``CXX_EXTENSIONS`` property of targets. + +This variable is used to initialize the :prop_tgt:`CXX_EXTENSIONS` +property on all targets. See that target property for additional +information. diff --git a/Help/variable/CMAKE_CXX_STANDARD.rst b/Help/variable/CMAKE_CXX_STANDARD.rst new file mode 100644 index 0000000..5fd4138 --- /dev/null +++ b/Help/variable/CMAKE_CXX_STANDARD.rst @@ -0,0 +1,8 @@ +CMAKE_CXX_STANDARD +------------------ + +Default value for ``CXX_STANDARD`` property of targets. + +This variable is used to initialize the :prop_tgt:`CXX_STANDARD` +property on all targets. See that target property for additional +information. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 1e65a02..779a2b8 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1459,6 +1459,7 @@ void cmLocalGenerator::AddCompileOptions( this->AppendFlagEscape(flags, *i); } } + this->AddCompilerRequirementFlag(flags, target, lang); } //---------------------------------------------------------------------------- @@ -2128,6 +2129,34 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags, } } +//---------------------------------------------------------------------------- +void cmLocalGenerator:: +AddCompilerRequirementFlag(std::string &flags, cmTarget* target, + const std::string& lang) +{ + if (lang.empty()) + { + return; + } + std::string stdProp = lang + "_STANDARD"; + const char *standard = target->GetProperty(stdProp); + if (!standard) + { + return; + } + std::string extProp = lang + "_EXTENSIONS"; + bool ext = target->GetPropertyAsBool(extProp); + std::string type = ext ? "EXTENSION" : "STANDARD"; + + std::string compile_option = + "CMAKE_" + lang + std::string(standard) + + "_" + type + "_COMPILE_OPTION"; + if (const char *opt = target->GetMakefile()->GetDefinition(compile_option)) + { + this->AppendFlags(flags, opt); + } +} + static void AddVisibilityCompileOption(std::string &flags, cmTarget* target, cmLocalGenerator *lg, const std::string& lang) diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 8f30149..12a94e4 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -149,6 +149,8 @@ public: const std::string& lang); void AddConfigVariableFlags(std::string& flags, const std::string& var, const std::string& config); + void AddCompilerRequirementFlag(std::string &flags, cmTarget* target, + const std::string& lang); ///! Append flags to a string. virtual void AppendFlags(std::string& flags, const char* newFlags); virtual void AppendFlagEscape(std::string& flags, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d28ac3f..53c0205 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -307,6 +307,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("MACOSX_BUNDLE", 0); this->SetPropertyDefault("MACOSX_RPATH", 0); this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", 0); + this->SetPropertyDefault("CXX_STANDARD", 0); + this->SetPropertyDefault("CXX_EXTENSIONS", 0); } // Collect the set of configuration types. diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 0e60ed1..aaa24c7 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -283,6 +283,19 @@ if(BUILD_TESTING) ADD_TEST_MACRO(ConfigSources ConfigSources) endif() ADD_TEST_MACRO(SourcesProperty SourcesProperty) + if(CMAKE_CXX_COMPILER_ID STREQUAL GNU + AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) + set(runCxxDialectTest 1) + endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL Clang + AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.9) + if(NOT APPLE OR POLICY CMP0025) + set(runCxxDialectTest 1) + endif() + endif() + if(runCxxDialectTest) + ADD_TEST_MACRO(CxxDialect CxxDialect) + endif() set_tests_properties(EmptyLibrary PROPERTIES PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test") ADD_TEST_MACRO(CrossCompile CrossCompile) diff --git a/Tests/CxxDialect/CMakeLists.txt b/Tests/CxxDialect/CMakeLists.txt new file mode 100644 index 0000000..0eb6f8f --- /dev/null +++ b/Tests/CxxDialect/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 2.8.12) +cmake_policy(SET CMP0025 NEW) +project(CxxDialect) + +add_executable(use_typeof use_typeof.cxx) +set_property(TARGET use_typeof PROPERTY CXX_STANDARD 98) +set_property(TARGET use_typeof PROPERTY CXX_EXTENSIONS ON) + +add_executable(use_constexpr use_constexpr.cxx) +set_property(TARGET use_constexpr PROPERTY CXX_STANDARD 11) + +add_executable(CxxDialect use_constexpr_and_typeof.cxx) +set_property(TARGET CxxDialect PROPERTY CXX_STANDARD 11) +set_property(TARGET CxxDialect PROPERTY CXX_EXTENSIONS ON) diff --git a/Tests/CxxDialect/use_constexpr.cxx b/Tests/CxxDialect/use_constexpr.cxx new file mode 100644 index 0000000..30ccc4c --- /dev/null +++ b/Tests/CxxDialect/use_constexpr.cxx @@ -0,0 +1,10 @@ + +constexpr int foo() +{ + return 0; +} + +int main(int argc, char**) +{ + return foo(); +} diff --git a/Tests/CxxDialect/use_constexpr_and_typeof.cxx b/Tests/CxxDialect/use_constexpr_and_typeof.cxx new file mode 100644 index 0000000..af217b6 --- /dev/null +++ b/Tests/CxxDialect/use_constexpr_and_typeof.cxx @@ -0,0 +1,11 @@ + +constexpr int foo() +{ + return 0; +} + +int main(int argc, char**) +{ + typeof(argc) ret = foo(); + return ret; +} diff --git a/Tests/CxxDialect/use_typeof.cxx b/Tests/CxxDialect/use_typeof.cxx new file mode 100644 index 0000000..dabb61f --- /dev/null +++ b/Tests/CxxDialect/use_typeof.cxx @@ -0,0 +1,6 @@ + +int main(int argc, char**) +{ + typeof(argc) ret = 0; + return ret; +} -- cgit v0.12 From faeddf64f21b592a5663803ca8accdf9f4b73c29 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 17 Oct 2013 11:47:29 +0200 Subject: project: Add infrastructure for recording CXX compiler features Add a feature test using the compiler macros and the preprocessor to determine available features. Add a CMAKE_CXX_COMPILE_FEATURES variable which contains all features known to the loaded compiler, and a CMAKE_CXX_KNOWN_FEATURES variable containing all features known to CMake. Add language standard specific variables for internal use to determine the standard-specific compile flags to use. This will be extended to other languages in the future. Follow-up commits will add features which will be recorded by the feature test. --- Help/manual/cmake-variables.7.rst | 2 + Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst | 8 ++++ Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 8 ++++ Modules/CMakeCXXCompiler.cmake.in | 3 ++ Modules/CMakeDetermineCompileFeatures.cmake | 43 +++++++++++++++++++++ Modules/CMakeTestCXXCompiler.cmake | 3 ++ Modules/Internal/FeatureTesting.cmake | 57 ++++++++++++++++++++++++++++ 7 files changed, 124 insertions(+) create mode 100644 Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst create mode 100644 Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst create mode 100644 Modules/CMakeDetermineCompileFeatures.cmake create mode 100644 Modules/Internal/FeatureTesting.cmake diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 62a7cce..dfdd09b 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -257,6 +257,8 @@ Variables for Languages :maxdepth: 1 /variable/CMAKE_COMPILER_IS_GNULANG + /variable/CMAKE_CXX_COMPILE_FEATURES + /variable/CMAKE_CXX_KNOWN_FEATURES /variable/CMAKE_CXX_STANDARD /variable/CMAKE_CXX_EXTENSIONS /variable/CMAKE_Fortran_MODDIR_DEFAULT diff --git a/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst b/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst new file mode 100644 index 0000000..6be0124 --- /dev/null +++ b/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst @@ -0,0 +1,8 @@ +CMAKE_CXX_COMPILE_FEATURES +-------------------------- + +List of features known to the C++ compiler + +These features are known to be available for use with the C++ compiler. This +list is a subset of the features listed in the :variable:`CMAKE_CXX_KNOWN_FEATURES` +variable. diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst new file mode 100644 index 0000000..7466d44 --- /dev/null +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -0,0 +1,8 @@ +CMAKE_CXX_KNOWN_FEATURES +------------------------ + +List of C++ features known to this version of CMake. + +The features listed in this variable may be known to be available to the +C++ compiler. If the feature is available with the C++ compiler, it will +be listed in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable. diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index c75611a..fdee336 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -2,6 +2,9 @@ set(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@") set(CMAKE_CXX_COMPILER_ARG1 "@CMAKE_CXX_COMPILER_ARG1@") set(CMAKE_CXX_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@") set(CMAKE_CXX_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@") +set(CMAKE_CXX_COMPILE_FEATURES "@CMAKE_CXX_COMPILE_FEATURES@") +set(CMAKE_CXX11_COMPILE_FEATURES "@CMAKE_CXX11_COMPILE_FEATURES@") + set(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@") set(CMAKE_CXX_SIMULATE_ID "@CMAKE_CXX_SIMULATE_ID@") set(CMAKE_CXX_SIMULATE_VERSION "@CMAKE_CXX_SIMULATE_VERSION@") diff --git a/Modules/CMakeDetermineCompileFeatures.cmake b/Modules/CMakeDetermineCompileFeatures.cmake new file mode 100644 index 0000000..40aa9d6 --- /dev/null +++ b/Modules/CMakeDetermineCompileFeatures.cmake @@ -0,0 +1,43 @@ + +#============================================================================= +# Copyright 2013 Stephen Kelly +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +function(cmake_determine_compile_features lang) + + if(lang STREQUAL CXX AND COMMAND cmake_record_cxx_compile_features) + message(STATUS "Detecting ${lang} compile features") + + set(CMAKE_CXX11_COMPILE_FEATURES) + + include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake") + + cmake_record_cxx_compile_features() + + if(NOT _result EQUAL 0) + message(STATUS "Detecting ${lang} compile features - failed") + return() + endif() + + if(NOT CMAKE_CXX_COMPILE_FEATURES) + set(CMAKE_CXX_COMPILE_FEATURES + ${CMAKE_CXX11_COMPILE_FEATURES} + ) + endif() + + set(CMAKE_CXX_COMPILE_FEATURES ${CMAKE_CXX_COMPILE_FEATURES} PARENT_SCOPE) + set(CMAKE_CXX11_COMPILE_FEATURES ${CMAKE_CXX11_COMPILE_FEATURES} PARENT_SCOPE) + + message(STATUS "Detecting ${lang} compile features - done") + endif() + +endfunction() diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake index a06c92a..81561b2 100644 --- a/Modules/CMakeTestCXXCompiler.cmake +++ b/Modules/CMakeTestCXXCompiler.cmake @@ -66,6 +66,9 @@ else() # Try to identify the ABI and configure it into CMakeCXXCompiler.cmake include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) CMAKE_DETERMINE_COMPILER_ABI(CXX ${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp) + # Try to identify the compiler features + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) + CMAKE_DETERMINE_COMPILE_FEATURES(CXX) # Re-configure to save learned information. configure_file( diff --git a/Modules/Internal/FeatureTesting.cmake b/Modules/Internal/FeatureTesting.cmake new file mode 100644 index 0000000..92d262c --- /dev/null +++ b/Modules/Internal/FeatureTesting.cmake @@ -0,0 +1,57 @@ + +macro(record_compiler_features lang compile_flags feature_list) + include("${CMAKE_ROOT}/Modules/Compiler/${CMAKE_${lang}_COMPILER_ID}-${lang}-FeatureTests.cmake" OPTIONAL) + + string(TOLOWER ${lang} lang_lc) + file(REMOVE "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.bin") + file(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" " + extern const char features[] = {\"\"\n") + foreach(feature ${CMAKE_${lang}_KNOWN_FEATURES}) + if (_cmake_feature_test_${feature}) + if (${_cmake_feature_test_${feature}} STREQUAL 1) + set(_feature_condition "\"1\" ") + else() + set(_feature_condition "#if ${_cmake_feature_test_${feature}}\n\"1\"\n#else\n\"0\"\n#endif\n") + endif() + file(APPEND "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" "\"${lang}_FEATURE:\"\n${_feature_condition}\"${feature}\\n\"\n") + endif() + endforeach() + file(APPEND "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" + "\n};\n\nint main(int, char **) { return 0; }\n") + + try_compile(CMAKE_${lang}_FEATURE_TEST + ${CMAKE_BINARY_DIR} "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" + COMPILE_DEFINITIONS "${compile_flags}" + OUTPUT_VARIABLE _output + COPY_FILE "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.bin" + COPY_FILE_ERROR _copy_error + ) + if(CMAKE_${lang}_FEATURE_TEST AND NOT _copy_error) + set(_result 0) + else() + set(_result 255) + endif() + unset(CMAKE_${lang}_FEATURE_TEST CACHE) + + if (_result EQUAL 0) + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "\n\nDetecting ${lang} [${compile_flags}] compiler features compiled with the following output:\n${_output}\n\n") + if(EXISTS "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.bin") + file(STRINGS "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.bin" + features REGEX "${lang}_FEATURE:.*") + foreach(info ${features}) + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + " Feature record: ${info}\n") + string(REPLACE "${lang}_FEATURE:" "" info ${info}) + string(SUBSTRING ${info} 0 1 has_feature) + if(has_feature) + string(REGEX REPLACE "^1" "" feature ${info}) + list(APPEND ${feature_list} ${feature}) + endif() + endforeach() + endif() + else() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Detecting ${lang} [${compile_flags}] compiler features failed to compile with the following output:\n${_output}\n${_copy_error}\n\n") + endif() +endmacro() -- cgit v0.12 From 03355d6b5b382020e7dafb28605e6d8d2f20de3c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 2 Apr 2014 15:57:15 +0200 Subject: cmTarget: Add COMPILE_FEATURES target property. Use the contents of it to upgrade the CXX_STANDARD target property, if appropriate. This will have the effect of adding the -std=c++11 compile flag or other language specification on GNU when that is needed for the feature. --- Help/manual/cmake-properties.7.rst | 1 + Help/prop_tgt/COMPILE_FEATURES.rst | 7 ++ Help/release/dev/compile-language-features.rst | 6 ++ Source/cmLocalGenerator.cxx | 13 +++ Source/cmMakefile.cxx | 113 +++++++++++++++++++++++++ Source/cmMakefile.h | 4 + Source/cmTarget.cxx | 40 +++++++++ 7 files changed, 184 insertions(+) create mode 100644 Help/prop_tgt/COMPILE_FEATURES.rst diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 9ea50de..30413ae 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -98,6 +98,7 @@ Properties on Targets /prop_tgt/COMPATIBLE_INTERFACE_STRING /prop_tgt/COMPILE_DEFINITIONS_CONFIG /prop_tgt/COMPILE_DEFINITIONS + /prop_tgt/COMPILE_FEATURES /prop_tgt/COMPILE_FLAGS /prop_tgt/COMPILE_OPTIONS /prop_tgt/COMPILE_PDB_NAME diff --git a/Help/prop_tgt/COMPILE_FEATURES.rst b/Help/prop_tgt/COMPILE_FEATURES.rst new file mode 100644 index 0000000..b2c6145 --- /dev/null +++ b/Help/prop_tgt/COMPILE_FEATURES.rst @@ -0,0 +1,7 @@ +COMPILE_FEATURES +---------------- + +Compiler features enabled for this target. + +The list of features in this property are a subset of the features listed +in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable. diff --git a/Help/release/dev/compile-language-features.rst b/Help/release/dev/compile-language-features.rst index f03e1a3..74fe209 100644 --- a/Help/release/dev/compile-language-features.rst +++ b/Help/release/dev/compile-language-features.rst @@ -6,3 +6,9 @@ target-language-features compile options such as ``-std=c++11`` or ``-std=gnu++11``. The :variable:`CMAKE_CXX_STANDARD` and :variable:`CMAKE_CXX_EXTENSIONS` variables may be set to initialize the target properties. + +* New :prop_tgt:`COMPILE_FEATURES` target property may contain a list + of features required to compile a target. CMake uses this + information to ensure that the compiler in use is capable of building + the target, and to add any necessary compile flags to support language + features. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 779a2b8..0f8e7dc 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1459,6 +1459,19 @@ void cmLocalGenerator::AddCompileOptions( this->AppendFlagEscape(flags, *i); } } + if (const char* featureProp = target->GetProperty("COMPILE_FEATURES")) + { + std::vector features; + cmSystemTools::ExpandListArgument(featureProp, features); + for(std::vector::const_iterator it = features.begin(); + it != features.end(); ++it) + { + if (!this->Makefile->AddRequiredTargetFeature(target, *it)) + { + return; + } + } + } this->AddCompilerRequirementFlag(flags, target, lang); } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 1328974..64163de 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -41,6 +41,8 @@ #include // for isspace #include +#define FOR_EACH_CXX_FEATURE(F) + class cmMakefile::Internals { public: @@ -4494,3 +4496,114 @@ void cmMakefile::RecordPolicies(cmPolicies::PolicyMap& pm) pm[pid] = this->GetPolicyStatus(pid); } } + +#define FEATURE_STRING(F) , #F + +static const char * const CXX_FEATURES[] = { + 0 + FOR_EACH_CXX_FEATURE(FEATURE_STRING) +}; + +static const char * const CXX_STANDARDS[] = { + "98" + , "11" +}; + +//---------------------------------------------------------------------------- +bool cmMakefile:: +AddRequiredTargetFeature(cmTarget *target, const std::string& feature, + std::string *error) const +{ + bool isCxxFeature = std::find_if(cmArrayBegin(CXX_FEATURES) + 1, + cmArrayEnd(CXX_FEATURES), cmStrCmp(feature)) + != cmArrayEnd(CXX_FEATURES); + if (!isCxxFeature) + { + cmOStringStream e; + e << "specified unknown feature \"" << feature << "\" specified for " + "target \"" << target->GetName() << "\"."; + if (error) + { + *error = e.str(); + } + else + { + this->IssueMessage(cmake::FATAL_ERROR, e.str()); + } + return false; + } + + std::string lang = "CXX"; + + const char* featuresKnown = + this->GetDefinition("CMAKE_" + lang + "_COMPILE_FEATURES"); + + if (!featuresKnown || !*featuresKnown) + { + // We know of no features for the compiler at all. + return true; + } + + std::vector availableFeatures; + cmSystemTools::ExpandListArgument(featuresKnown, availableFeatures); + if (std::find(availableFeatures.begin(), + availableFeatures.end(), + feature) == availableFeatures.end()) + { + cmOStringStream e; + e << "The compiler feature \"" << feature + << "\" is not known to compiler\n\"" + << this->GetDefinition("CMAKE_" + lang + "_COMPILER_ID") + << "\"\nversion " + << this->GetDefinition("CMAKE_" + lang + "_COMPILER_VERSION") << "."; + this->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + + target->AppendProperty("COMPILE_FEATURES", feature.c_str()); + + bool needCxx11 = false; + + if (const char *propCxx11 = + this->GetDefinition("CMAKE_CXX11_COMPILE_FEATURES")) + { + std::vector props; + cmSystemTools::ExpandListArgument(propCxx11, props); + needCxx11 = std::find(props.begin(), props.end(), feature) != props.end(); + } + + const char *existingCxxStandard = target->GetProperty("CXX_STANDARD"); + if (existingCxxStandard) + { + if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS), + cmStrCmp(existingCxxStandard)) == cmArrayEnd(CXX_STANDARDS)) + { + cmOStringStream e; + e << "The CXX_STANDARD property on target \"" << target->GetName() + << "\" contained an invalid value: \"" << existingCxxStandard << "\"."; + this->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + } + const char * const *existingCxxIt = existingCxxStandard + ? std::find_if(cmArrayBegin(CXX_STANDARDS), + cmArrayEnd(CXX_STANDARDS), + cmStrCmp(existingCxxStandard)) + : cmArrayEnd(CXX_STANDARDS); + + bool setCxx11 = needCxx11 && !existingCxxStandard; + + if (needCxx11 && existingCxxStandard && existingCxxIt < + std::find_if(cmArrayBegin(CXX_STANDARDS), + cmArrayEnd(CXX_STANDARDS), + cmStrCmp("11"))) + { + setCxx11 = true; + } + + if (setCxx11) + { + target->SetProperty("CXX_STANDARD", "11"); + } + return true; +} diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 7695d6e..3bccb63 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -885,6 +885,10 @@ public: bool PolicyOptionalWarningEnabled(std::string const& var); + bool AddRequiredTargetFeature(cmTarget *target, + const std::string& feature, + std::string *error = 0) const; + protected: // add link libraries and directories to the target void AddGlobalLinkInformation(const std::string& name, cmTarget& target); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 53c0205..6f53009 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -153,6 +153,7 @@ public: }; std::vector IncludeDirectoriesEntries; std::vector CompileOptionsEntries; + std::vector CompileFeaturesEntries; std::vector CompileDefinitionsEntries; std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; @@ -1722,6 +1723,17 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) new cmTargetInternals::TargetPropertyEntry(cge)); return; } + if(prop == "COMPILE_FEATURES") + { + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + deleteAndClear(this->Internal->CompileFeaturesEntries); + cmsys::auto_ptr cge = ge.Parse(value); + this->Internal->CompileFeaturesEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); + return; + } if(prop == "COMPILE_DEFINITIONS") { cmListFileBacktrace lfbt; @@ -1812,6 +1824,15 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); return; } + if(prop == "COMPILE_FEATURES") + { + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + this->Internal->CompileFeaturesEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + return; + } if(prop == "COMPILE_DEFINITIONS") { cmListFileBacktrace lfbt; @@ -3109,6 +3130,24 @@ const char *cmTarget::GetProperty(const std::string& prop, } return output.c_str(); } + if(prop == "COMPILE_FEATURES") + { + static std::string output; + output = ""; + std::string sep; + typedef cmTargetInternals::TargetPropertyEntry + TargetPropertyEntry; + for (std::vector::const_iterator + it = this->Internal->CompileFeaturesEntries.begin(), + end = this->Internal->CompileFeaturesEntries.end(); + it != end; ++it) + { + output += sep; + output += (*it)->ge->GetInput(); + sep = ";"; + } + return output.c_str(); + } if(prop == "COMPILE_DEFINITIONS") { static std::string output; @@ -6886,6 +6925,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() { deleteAndClear(this->Pointer->IncludeDirectoriesEntries); deleteAndClear(this->Pointer->CompileOptionsEntries); + deleteAndClear(this->Pointer->CompileFeaturesEntries); deleteAndClear(this->Pointer->CompileDefinitionsEntries); deleteAndClear(this->Pointer->SourceEntries); delete this->Pointer; -- cgit v0.12 From f97bf4370c283432c4e14fe54ed481d5d9b7ceef Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 2 Apr 2014 15:34:16 +0200 Subject: Features: Add cxx_auto_type. Record the availability of this feature for GNU 4.8 on (UNIX AND NOT APPLE) only. In the future, availability can be recorded for earlier GNU, for other platforms and for other compilers. Initially the affected configurations are as restricted as possible to allow for easy testing while extending the features vector in only one dimension. The error message when using the set_property API directly is not very good, but follow up commits will provide origin debugging of the property and a target_compile_features command which will provide a configure-time backtrace when possible. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 7 +++++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 8 ++++++++ Modules/Compiler/GNU-CXX.cmake | 12 +++++++++++ Source/cmMakefile.cxx | 19 +++++++++++++++-- Tests/CMakeLists.txt | 4 ++++ Tests/CompileFeatures/CMakeLists.txt | 24 ++++++++++++++++++++++ Tests/CompileFeatures/cxx_auto_type.cpp | 5 +++++ Tests/CompileFeatures/main.cpp | 6 ++++++ Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/CompileFeatures/CMakeLists.txt | 3 +++ .../CompileFeatures/NotAFeature-result.txt | 1 + .../CompileFeatures/NotAFeature-stderr.txt | 2 ++ Tests/RunCMake/CompileFeatures/NotAFeature.cmake | 3 +++ Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake | 3 +++ Tests/RunCMake/CompileFeatures/empty.cpp | 7 +++++++ Tests/SystemInformation/SystemInformation.in | 2 ++ 16 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 Modules/Compiler/GNU-CXX-FeatureTests.cmake create mode 100644 Tests/CompileFeatures/CMakeLists.txt create mode 100644 Tests/CompileFeatures/cxx_auto_type.cpp create mode 100644 Tests/CompileFeatures/main.cpp create mode 100644 Tests/RunCMake/CompileFeatures/CMakeLists.txt create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeature-result.txt create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeature-stderr.txt create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeature.cmake create mode 100644 Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/CompileFeatures/empty.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 7466d44..d49bb68 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -6,3 +6,10 @@ List of C++ features known to this version of CMake. The features listed in this variable may be known to be available to the C++ compiler. If the feature is available with the C++ compiler, it will be listed in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable. + +The features known to this version of CMake are: + +``cxx_auto_type`` + Automatic type deduction, as defined in N1984_. + + .. _N1984: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1984.pdf diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake new file mode 100644 index 0000000..b36315f --- /dev/null +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -0,0 +1,8 @@ + +# Reference: http://gcc.gnu.org/projects/cxx0x.html + +set(_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408") +# TODO: Should be supported by GNU 4.4 +set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}") +set(_oldestSupported) diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index 3ee8639..7acad52 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -23,3 +23,15 @@ elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x") endif() + +macro(cmake_record_cxx_compile_features) + macro(_get_gcc_features std_version list) + record_compiler_features(CXX "-std=${std_version}" ${list}) + endmacro() + + if (UNIX AND NOT APPLE AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) + _get_gcc_features(c++11 CMAKE_CXX11_COMPILE_FEATURES) + else() + set(_result 0) + endif() +endmacro() diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 64163de..0b3c43e 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -41,7 +41,8 @@ #include // for isspace #include -#define FOR_EACH_CXX_FEATURE(F) +#define FOR_EACH_CXX_FEATURE(F) \ + F(cxx_auto_type) class cmMakefile::Internals { @@ -2453,6 +2454,12 @@ const char* cmMakefile::GetDefinition(const std::string& name) const { this->Internal->VarUsageStack.top().insert(name); } + if (name == "CMAKE_CXX_KNOWN_FEATURES") + { +#define STRING_LIST_ELEMENT(F) ";" #F + return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1; +#undef STRING_LIST_ELEMENT + } const char* def = this->Internal->VarStack.top().Get(name); if(!def) { @@ -4520,7 +4527,15 @@ AddRequiredTargetFeature(cmTarget *target, const std::string& feature, if (!isCxxFeature) { cmOStringStream e; - e << "specified unknown feature \"" << feature << "\" specified for " + if (error) + { + e << "specified"; + } + else + { + e << "Specified"; + } + e << " unknown feature \"" << feature << "\" for " "target \"" << target->GetName() << "\"."; if (error) { diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index aaa24c7..fc58f1e 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -197,6 +197,10 @@ if(BUILD_TESTING) ADD_TEST_MACRO(TarTest TarTest) ADD_TEST_MACRO(SystemInformation SystemInformation) ADD_TEST_MACRO(MathTest MathTest) + if(CMAKE_CXX_COMPILER_ID STREQUAL GNU + AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) + ADD_TEST_MACRO(CompileFeatures CompileFeatures) + endif() # assume no resources building to test set(TEST_RESOURCES FALSE) # for windows and cygwin assume we have resources diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt new file mode 100644 index 0000000..471b560 --- /dev/null +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -0,0 +1,24 @@ + +cmake_minimum_required(VERSION 3.0) + +project(CompileFeatures) + +macro(run_test feature) + if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ${feature}) + add_library(test_${feature} OBJECT ${feature}.cpp) + set_property(TARGET test_${feature} + PROPERTY COMPILE_FEATURES "${feature}" + ) + else() + message("Not supported: ${feature}") + endif() +endmacro() + +foreach(feature ${CMAKE_CXX_KNOWN_FEATURES}) + run_test(${feature}) +endforeach() + +add_executable(CompileFeatures main.cpp) +set_property(TARGET CompileFeatures + PROPERTY COMPILE_FEATURES "cxx_auto_type" +) diff --git a/Tests/CompileFeatures/cxx_auto_type.cpp b/Tests/CompileFeatures/cxx_auto_type.cpp new file mode 100644 index 0000000..7dbf04f --- /dev/null +++ b/Tests/CompileFeatures/cxx_auto_type.cpp @@ -0,0 +1,5 @@ + +void someFunc() +{ + auto x = 3.14; +} diff --git a/Tests/CompileFeatures/main.cpp b/Tests/CompileFeatures/main.cpp new file mode 100644 index 0000000..3a8e0fc --- /dev/null +++ b/Tests/CompileFeatures/main.cpp @@ -0,0 +1,6 @@ + +int main(int,char**) +{ + auto value = 0; + return value; +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 851de42..dd769ac 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -53,6 +53,7 @@ add_RunCMake_test(ObjectLibrary) add_RunCMake_test(TargetObjects) add_RunCMake_test(TargetSources) add_RunCMake_test(find_dependency) +add_RunCMake_test(CompileFeatures) if(NOT WIN32) add_RunCMake_test(PositionIndependentCode) set(SKIP_VISIBILITY 0) diff --git a/Tests/RunCMake/CompileFeatures/CMakeLists.txt b/Tests/RunCMake/CompileFeatures/CMakeLists.txt new file mode 100644 index 0000000..3482e6b --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.0) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeature-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeature-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeature-stderr.txt new file mode 100644 index 0000000..ff60e50 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeature-stderr.txt @@ -0,0 +1,2 @@ +CMake Error in CMakeLists.txt: + Specified unknown feature "not_a_feature" for target "somelib". diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature.cmake b/Tests/RunCMake/CompileFeatures/NotAFeature.cmake new file mode 100644 index 0000000..35246c8 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeature.cmake @@ -0,0 +1,3 @@ + +add_library(somelib STATIC empty.cpp) +set_property(TARGET somelib PROPERTY COMPILE_FEATURES "not_a_feature") diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake new file mode 100644 index 0000000..3c999e6 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(NotAFeature) diff --git a/Tests/RunCMake/CompileFeatures/empty.cpp b/Tests/RunCMake/CompileFeatures/empty.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/SystemInformation/SystemInformation.in b/Tests/SystemInformation/SystemInformation.in index 92b24e2..954a2fe 100644 --- a/Tests/SystemInformation/SystemInformation.in +++ b/Tests/SystemInformation/SystemInformation.in @@ -25,6 +25,8 @@ CMAKE_CXX98_STANDARD_COMPILE_OPTION == "${CMAKE_CXX98_STANDARD_COMPILE_OPTION}" CMAKE_CXX11_STANDARD_COMPILE_OPTION == "${CMAKE_CXX11_STANDARD_COMPILE_OPTION}" CMAKE_CXX98_EXTENSION_COMPILE_OPTION == "${CMAKE_CXX98_EXTENSION_COMPILE_OPTION}" CMAKE_CXX11_EXTENSION_COMPILE_OPTION == "${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}" +CMAKE_CXX_COMPILE_FEATURES == "${CMAKE_CXX_COMPILE_FEATURES}" +CMAKE_CXX11_COMPILE_FEATURES == "${CMAKE_CXX11_COMPILE_FEATURES}" // C shared library flag CMAKE_SHARED_LIBRARY_C_FLAGS == "${CMAKE_SHARED_LIBRARY_C_FLAGS}" -- cgit v0.12 From baff44345cff8e635766e020d316da514616c16e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 22 Oct 2013 15:05:49 +0200 Subject: cmTarget: Allow populating COMPILE_FEATURES using generator expressions. Delay validation of the content as a feature if it contains a generator expression. It will be checked again at generate-time after evaluation. --- Help/prop_tgt/COMPILE_FEATURES.rst | 4 ++++ Source/cmLocalGenerator.cxx | 15 ++++++--------- Source/cmMakefile.cxx | 5 +++++ Source/cmTarget.cxx | 16 ++++++++++++++++ Source/cmTarget.h | 1 + Tests/CompileFeatures/CMakeLists.txt | 5 +++++ .../RunCMake/CompileFeatures/NotAFeatureGenex-result.txt | 1 + .../RunCMake/CompileFeatures/NotAFeatureGenex-stderr.txt | 2 ++ Tests/RunCMake/CompileFeatures/NotAFeatureGenex.cmake | 3 +++ Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake | 1 + 10 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeatureGenex-result.txt create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeatureGenex-stderr.txt create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeatureGenex.cmake diff --git a/Help/prop_tgt/COMPILE_FEATURES.rst b/Help/prop_tgt/COMPILE_FEATURES.rst index b2c6145..dc32825 100644 --- a/Help/prop_tgt/COMPILE_FEATURES.rst +++ b/Help/prop_tgt/COMPILE_FEATURES.rst @@ -5,3 +5,7 @@ Compiler features enabled for this target. The list of features in this property are a subset of the features listed in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable. + +Contents of ``COMPILE_FEATURES`` may use "generator expressions" with the +syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for +available expressions. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 0f8e7dc..f581806 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1459,17 +1459,14 @@ void cmLocalGenerator::AddCompileOptions( this->AppendFlagEscape(flags, *i); } } - if (const char* featureProp = target->GetProperty("COMPILE_FEATURES")) + std::vector features; + target->GetCompileFeatures(features); + for(std::vector::const_iterator it = features.begin(); + it != features.end(); ++it) { - std::vector features; - cmSystemTools::ExpandListArgument(featureProp, features); - for(std::vector::const_iterator it = features.begin(); - it != features.end(); ++it) + if (!this->Makefile->AddRequiredTargetFeature(target, *it)) { - if (!this->Makefile->AddRequiredTargetFeature(target, *it)) - { - return; - } + return; } } this->AddCompilerRequirementFlag(flags, target, lang); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 0b3c43e..5004a08 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4521,6 +4521,11 @@ bool cmMakefile:: AddRequiredTargetFeature(cmTarget *target, const std::string& feature, std::string *error) const { + if (cmGeneratorExpression::Find(feature) != std::string::npos) + { + target->AppendProperty("COMPILE_FEATURES", feature.c_str()); + return true; + } bool isCxxFeature = std::find_if(cmArrayBegin(CXX_FEATURES) + 1, cmArrayEnd(CXX_FEATURES), cmStrCmp(feature)) != cmArrayEnd(CXX_FEATURES); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 6f53009..09e3339 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2617,6 +2617,22 @@ void cmTarget::GetCompileDefinitions(std::vector &list, } //---------------------------------------------------------------------------- +void cmTarget::GetCompileFeatures(std::vector &features) const +{ + assert(this->GetType() != INTERFACE_LIBRARY); + for(std::vector::const_iterator + si = this->Internal->CompileFeaturesEntries.begin(); + si != this->Internal->CompileFeaturesEntries.end(); ++si) + { + cmSystemTools::ExpandListArgument((*si)->ge->Evaluate(this->Makefile, + "", + false, + this), + features); + } +} + +//---------------------------------------------------------------------------- void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop) { // Wipe out maps caching information affected by this property. diff --git a/Source/cmTarget.h b/Source/cmTarget.h index da9d0a1..fe3ea2b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -545,6 +545,7 @@ public: const std::string& config) const; void GetAutoUicOptions(std::vector &result, const std::string& config) const; + void GetCompileFeatures(std::vector &features) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; bool IsLinkInterfaceDependentBoolProperty(const std::string &p, diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index 471b560..2114f94 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -22,3 +22,8 @@ add_executable(CompileFeatures main.cpp) set_property(TARGET CompileFeatures PROPERTY COMPILE_FEATURES "cxx_auto_type" ) + +add_executable(GenexCompileFeatures main.cpp) +set_property(TARGET GenexCompileFeatures + PROPERTY COMPILE_FEATURES "$<1:cxx_auto_type>;$<0:not_a_feature>" +) diff --git a/Tests/RunCMake/CompileFeatures/NotAFeatureGenex-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeatureGenex-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeatureGenex-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompileFeatures/NotAFeatureGenex-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeatureGenex-stderr.txt new file mode 100644 index 0000000..ff60e50 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeatureGenex-stderr.txt @@ -0,0 +1,2 @@ +CMake Error in CMakeLists.txt: + Specified unknown feature "not_a_feature" for target "somelib". diff --git a/Tests/RunCMake/CompileFeatures/NotAFeatureGenex.cmake b/Tests/RunCMake/CompileFeatures/NotAFeatureGenex.cmake new file mode 100644 index 0000000..ad2bd37 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeatureGenex.cmake @@ -0,0 +1,3 @@ + +add_library(somelib STATIC empty.cpp) +set_property(TARGET somelib PROPERTY COMPILE_FEATURES "$<1:not_a_feature>") diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index 3c999e6..da9477d 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -1,3 +1,4 @@ include(RunCMake) run_cmake(NotAFeature) +run_cmake(NotAFeatureGenex) -- cgit v0.12 From 5412deded1073e9a217c771ae24e8c5a8a581a96 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 22 Oct 2013 01:40:47 +0200 Subject: cmTarget: Transitively evaluate compiler features. Extend the interface of the target_compile_features command with PUBLIC and INTERFACE keywords. Populate the INTERFACE_COMPILER_FEATURES target property if they are set. Consume the INTERFACE_COMPILER_FEATURES target property from linked dependent targets to determine the final required compiler features and the compile flag, if needed. Use the same pattern of origin-debugging which is used for other build properties. --- Help/manual/cmake-properties.7.rst | 1 + Help/prop_tgt/INTERFACE_COMPILE_FEATURES.rst | 14 +++ Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst | 2 +- Source/cmGeneratorExpressionDAGChecker.h | 3 +- Source/cmLocalGenerator.cxx | 2 +- Source/cmTarget.cxx | 121 +++++++++++++++++++-- Source/cmTarget.h | 4 +- Tests/CompileFeatures/CMakeLists.txt | 7 ++ .../NotAFeatureTransitive-result.txt | 1 + .../NotAFeatureTransitive-stderr.txt | 2 + .../CompileFeatures/NotAFeatureTransitive.cmake | 6 + .../NotAFeature_OriginDebug-result.txt | 1 + .../NotAFeature_OriginDebug-stderr.txt | 11 ++ .../CompileFeatures/NotAFeature_OriginDebug.cmake | 4 + .../NotAFeature_OriginDebugGenex-result.txt | 1 + .../NotAFeature_OriginDebugGenex-stderr.txt | 11 ++ .../NotAFeature_OriginDebugGenex.cmake | 4 + .../NotAFeature_OriginDebugTransitive-result.txt | 1 + .../NotAFeature_OriginDebugTransitive-stderr.txt | 11 ++ .../NotAFeature_OriginDebugTransitive.cmake | 6 + Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake | 4 + 21 files changed, 203 insertions(+), 14 deletions(-) create mode 100644 Help/prop_tgt/INTERFACE_COMPILE_FEATURES.rst create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-result.txt create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-stderr.txt create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeatureTransitive.cmake create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-result.txt create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-stderr.txt create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug.cmake create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-result.txt create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-stderr.txt create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex.cmake create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-result.txt create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-stderr.txt create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive.cmake diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 30413ae..a82522d 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -151,6 +151,7 @@ Properties on Targets /prop_tgt/INSTALL_RPATH_USE_LINK_PATH /prop_tgt/INTERFACE_AUTOUIC_OPTIONS /prop_tgt/INTERFACE_COMPILE_DEFINITIONS + /prop_tgt/INTERFACE_COMPILE_FEATURES /prop_tgt/INTERFACE_COMPILE_OPTIONS /prop_tgt/INTERFACE_INCLUDE_DIRECTORIES /prop_tgt/INTERFACE_LINK_LIBRARIES diff --git a/Help/prop_tgt/INTERFACE_COMPILE_FEATURES.rst b/Help/prop_tgt/INTERFACE_COMPILE_FEATURES.rst new file mode 100644 index 0000000..a98e362 --- /dev/null +++ b/Help/prop_tgt/INTERFACE_COMPILE_FEATURES.rst @@ -0,0 +1,14 @@ +INTERFACE_COMPILE_FEATURES +-------------------------- + +List of public compile requirements for a library. + +Targets may populate this property to publish the compiler features +required to compile against the headers for the target. Consuming +targets can add entries to their own :prop_tgt:`COMPILE_FEATURES` +property such as ``$`` +to require the features specified in the interface of ``foo``. + +Contents of ``INTERFACE_COMPILE_FEATURES`` may use "generator expressions" +with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` +manual for available expressions. diff --git a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst index edd8fa1..e200b86 100644 --- a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst +++ b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst @@ -7,7 +7,7 @@ This variable can be populated with a list of properties to generate debug output for when evaluating target properties. Currently it can only be used when evaluating the :prop_tgt:`INCLUDE_DIRECTORIES`, :prop_tgt:`COMPILE_DEFINITIONS`, :prop_tgt:`COMPILE_OPTIONS`, -:prop_tgt:`AUTOUIC_OPTIONS`, :prop_tgt:`SOURCES`, +:prop_tgt:`AUTOUIC_OPTIONS`, :prop_tgt:`SOURCES`, :prop_tgt:`COMPILE_FEATURES`, :prop_tgt:`POSITION_INDEPENDENT_CODE` target properties and any other property listed in :prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other ``COMPATIBLE_INTERFACE_`` properties. It outputs an origin for each entry in the target property. diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index b3147f7..7217a56 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -26,7 +26,8 @@ SELECT(F, EvaluatingCompileDefinitions, COMPILE_DEFINITIONS) \ SELECT(F, EvaluatingCompileOptions, COMPILE_OPTIONS) \ SELECT(F, EvaluatingAutoUicOptions, AUTOUIC_OPTIONS) \ - SELECT(F, EvaluatingSources, SOURCES) + SELECT(F, EvaluatingSources, SOURCES) \ + SELECT(F, EvaluatingCompileFeatures, COMPILE_FEATURES) #define CM_FOR_EACH_TRANSITIVE_PROPERTY(F) \ CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_BOTH) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index f581806..528b1dc 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1460,7 +1460,7 @@ void cmLocalGenerator::AddCompileOptions( } } std::vector features; - target->GetCompileFeatures(features); + target->GetCompileFeatures(features, config); for(std::vector::const_iterator it = features.begin(); it != features.end(); ++it) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 09e3339..1d4d84c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -166,11 +166,14 @@ public: CachedLinkInterfaceCompileDefinitionsEntries; mutable std::map > CachedLinkInterfaceSourcesEntries; + mutable std::map > + CachedLinkInterfaceCompileFeaturesEntries; mutable std::map CacheLinkInterfaceIncludeDirectoriesDone; mutable std::map CacheLinkInterfaceCompileDefinitionsDone; mutable std::map CacheLinkInterfaceCompileOptionsDone; mutable std::map CacheLinkInterfaceSourcesDone; + mutable std::map CacheLinkInterfaceCompileFeaturesDone; }; //---------------------------------------------------------------------------- @@ -205,6 +208,7 @@ cmTargetInternals::~cmTargetInternals() { deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries); deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries); + deleteAndClear(this->CachedLinkInterfaceCompileFeaturesEntries); deleteAndClear(this->CachedLinkInterfaceCompileDefinitionsEntries); deleteAndClear(this->CachedLinkInterfaceSourcesEntries); } @@ -228,6 +232,7 @@ cmTarget::cmTarget() this->BuildInterfaceIncludesAppended = false; this->DebugIncludesDone = false; this->DebugCompileOptionsDone = false; + this->DebugCompileFeaturesDone = false; this->DebugCompileDefinitionsDone = false; this->DebugSourcesDone = false; } @@ -2617,18 +2622,114 @@ void cmTarget::GetCompileDefinitions(std::vector &list, } //---------------------------------------------------------------------------- -void cmTarget::GetCompileFeatures(std::vector &features) const +static void processCompileFeatures(cmTarget const* tgt, + const std::vector &entries, + std::vector &options, + std::set &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions) { - assert(this->GetType() != INTERFACE_LIBRARY); - for(std::vector::const_iterator - si = this->Internal->CompileFeaturesEntries.begin(); - si != this->Internal->CompileFeaturesEntries.end(); ++si) + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, "features"); +} + +//---------------------------------------------------------------------------- +void cmTarget::GetCompileFeatures(std::vector &result, + const std::string& config) const +{ + std::set uniqueFeatures; + cmListFileBacktrace lfbt; + + cmGeneratorExpressionDAGChecker dagChecker(lfbt, + this->GetName(), + "COMPILE_FEATURES", + 0, 0); + + std::vector debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) { - cmSystemTools::ExpandListArgument((*si)->ge->Evaluate(this->Makefile, - "", - false, - this), - features); + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugFeatures = !this->DebugCompileFeaturesDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_FEATURES") + != debugProperties.end(); + + if (this->Makefile->IsGeneratingBuildSystem()) + { + this->DebugCompileFeaturesDone = true; + } + + processCompileFeatures(this, + this->Internal->CompileFeaturesEntries, + result, + uniqueFeatures, + &dagChecker, + config, + debugFeatures); + + if (!this->Internal->CacheLinkInterfaceCompileFeaturesDone[config]) + { + for (std::vector::const_iterator + it = this->Internal->LinkImplementationPropertyEntries.begin(), + end = this->Internal->LinkImplementationPropertyEntries.end(); + it != end; ++it) + { + if (!cmGeneratorExpression::IsValidTargetName(it->Value) + && cmGeneratorExpression::Find(it->Value) == std::string::npos) + { + continue; + } + { + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr cge = + ge.Parse(it->Value); + std::string targetResult = cge->Evaluate(this->Makefile, config, + false, this, 0, 0); + if (!this->Makefile->FindTargetToUse(targetResult)) + { + continue; + } + } + std::string featureGenex = "$Value + ",INTERFACE_COMPILE_FEATURES>"; + if (cmGeneratorExpression::Find(it->Value) != std::string::npos) + { + // Because it->Value is a generator expression, ensure that it + // evaluates to the non-empty string before being used in the + // TARGET_PROPERTY expression. + featureGenex = "$<$Value + ">:" + featureGenex + ">"; + } + cmGeneratorExpression ge(it->Backtrace); + cmsys::auto_ptr cge = ge.Parse( + featureGenex); + + this->Internal + ->CachedLinkInterfaceCompileFeaturesEntries[config].push_back( + new cmTargetInternals::TargetPropertyEntry(cge, + it->Value)); + } + } + + processCompileFeatures(this, + this->Internal->CachedLinkInterfaceCompileFeaturesEntries[config], + result, + uniqueFeatures, + &dagChecker, + config, + debugFeatures); + + if (!this->Makefile->IsGeneratingBuildSystem()) + { + deleteAndClear(this->Internal->CachedLinkInterfaceCompileFeaturesEntries); + } + else + { + this->Internal->CacheLinkInterfaceCompileFeaturesDone[config] = true; } } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index fe3ea2b..8984649 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -545,7 +545,8 @@ public: const std::string& config) const; void GetAutoUicOptions(std::vector &result, const std::string& config) const; - void GetCompileFeatures(std::vector &features) const; + void GetCompileFeatures(std::vector &features, + const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; bool IsLinkInterfaceDependentBoolProperty(const std::string &p, @@ -712,6 +713,7 @@ private: mutable bool DebugCompileOptionsDone; mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; + mutable bool DebugCompileFeaturesDone; mutable std::set LinkImplicitNullProperties; bool BuildInterfaceIncludesAppended; diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index 2114f94..bceb6bb 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -27,3 +27,10 @@ add_executable(GenexCompileFeatures main.cpp) set_property(TARGET GenexCompileFeatures PROPERTY COMPILE_FEATURES "$<1:cxx_auto_type>;$<0:not_a_feature>" ) + +add_library(iface INTERFACE) +set_property(TARGET iface + PROPERTY INTERFACE_COMPILE_FEATURES "cxx_auto_type" +) +add_executable(IfaceCompileFeatures main.cpp) +target_link_libraries(IfaceCompileFeatures iface) diff --git a/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-stderr.txt new file mode 100644 index 0000000..ff60e50 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-stderr.txt @@ -0,0 +1,2 @@ +CMake Error in CMakeLists.txt: + Specified unknown feature "not_a_feature" for target "somelib". diff --git a/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive.cmake b/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive.cmake new file mode 100644 index 0000000..7311aec --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive.cmake @@ -0,0 +1,6 @@ + +add_library(iface INTERFACE) +set_property(TARGET iface PROPERTY INTERFACE_COMPILE_FEATURES "not_a_feature") + +add_library(somelib STATIC empty.cpp) +target_link_libraries(somelib iface) diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-stderr.txt new file mode 100644 index 0000000..60a8e51 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-stderr.txt @@ -0,0 +1,11 @@ +CMake Debug Log at NotAFeature_OriginDebug.cmake:4 \(set_property\): + Used compile features for target somelib: + + \* not_a_feature + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error in CMakeLists.txt: + Specified unknown feature "not_a_feature" for target "somelib". diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug.cmake b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug.cmake new file mode 100644 index 0000000..350c2ea --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug.cmake @@ -0,0 +1,4 @@ + +set(CMAKE_DEBUG_TARGET_PROPERTIES COMPILE_FEATURES) +add_library(somelib STATIC empty.cpp) +set_property(TARGET somelib PROPERTY COMPILE_FEATURES "not_a_feature") diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-stderr.txt new file mode 100644 index 0000000..08e20a8 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-stderr.txt @@ -0,0 +1,11 @@ +CMake Debug Log at NotAFeature_OriginDebugGenex.cmake:4 \(set_property\): + Used compile features for target somelib: + + \* not_a_feature + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error in CMakeLists.txt: + Specified unknown feature "not_a_feature" for target "somelib". diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex.cmake b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex.cmake new file mode 100644 index 0000000..2122981 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex.cmake @@ -0,0 +1,4 @@ + +set(CMAKE_DEBUG_TARGET_PROPERTIES COMPILE_FEATURES) +add_library(somelib STATIC empty.cpp) +set_property(TARGET somelib PROPERTY COMPILE_FEATURES "$<1:not_a_feature>") diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-stderr.txt new file mode 100644 index 0000000..23c3305 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-stderr.txt @@ -0,0 +1,11 @@ +CMake Debug Log at NotAFeature_OriginDebugTransitive.cmake:6 \(target_link_libraries\): + Used compile features for target somelib: + + \* not_a_feature + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error in CMakeLists.txt: + Specified unknown feature "not_a_feature" for target "somelib". diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive.cmake b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive.cmake new file mode 100644 index 0000000..05d0073 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive.cmake @@ -0,0 +1,6 @@ + +set(CMAKE_DEBUG_TARGET_PROPERTIES COMPILE_FEATURES) +add_library(iface INTERFACE) +set_property(TARGET iface PROPERTY INTERFACE_COMPILE_FEATURES "not_a_feature") +add_library(somelib STATIC empty.cpp) +target_link_libraries(somelib iface) diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index da9477d..a059900 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -2,3 +2,7 @@ include(RunCMake) run_cmake(NotAFeature) run_cmake(NotAFeatureGenex) +run_cmake(NotAFeatureTransitive) +run_cmake(NotAFeature_OriginDebug) +run_cmake(NotAFeature_OriginDebugGenex) +run_cmake(NotAFeature_OriginDebugTransitive) -- cgit v0.12 From 4e6ca504459640ff39eac48eb62fcae95c8fc8d2 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 9 Nov 2013 00:18:35 +0100 Subject: cmTargetPropCommandBase: Change the interface to return bool. This is needed for the target_compile_features command, which may fail at configure time if an invalid feature is specified. --- Source/cmTargetCompileDefinitionsCommand.cxx | 3 ++- Source/cmTargetCompileDefinitionsCommand.h | 2 +- Source/cmTargetCompileOptionsCommand.cxx | 3 ++- Source/cmTargetCompileOptionsCommand.h | 2 +- Source/cmTargetIncludeDirectoriesCommand.cxx | 3 ++- Source/cmTargetIncludeDirectoriesCommand.h | 2 +- Source/cmTargetPropCommandBase.cxx | 14 ++++++++------ Source/cmTargetPropCommandBase.h | 4 ++-- Source/cmTargetSourcesCommand.cxx | 3 ++- Source/cmTargetSourcesCommand.h | 2 +- 10 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx index b567252..66d8ad3 100644 --- a/Source/cmTargetCompileDefinitionsCommand.cxx +++ b/Source/cmTargetCompileDefinitionsCommand.cxx @@ -58,9 +58,10 @@ std::string cmTargetCompileDefinitionsCommand } //---------------------------------------------------------------------------- -void cmTargetCompileDefinitionsCommand +bool cmTargetCompileDefinitionsCommand ::HandleDirectContent(cmTarget *tgt, const std::vector &content, bool, bool) { tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content).c_str()); + return true; } diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index 5ba9e03..b548c70 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -44,7 +44,7 @@ private: virtual void HandleImportedTarget(const std::string &tgt); virtual void HandleMissingTarget(const std::string &name); - virtual void HandleDirectContent(cmTarget *tgt, + virtual bool HandleDirectContent(cmTarget *tgt, const std::vector &content, bool prepend, bool system); virtual std::string Join(const std::vector &content); diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx index 254acc7..18499fd 100644 --- a/Source/cmTargetCompileOptionsCommand.cxx +++ b/Source/cmTargetCompileOptionsCommand.cxx @@ -51,7 +51,7 @@ std::string cmTargetCompileOptionsCommand } //---------------------------------------------------------------------------- -void cmTargetCompileOptionsCommand +bool cmTargetCompileOptionsCommand ::HandleDirectContent(cmTarget *tgt, const std::vector &content, bool, bool) { @@ -59,4 +59,5 @@ void cmTargetCompileOptionsCommand this->Makefile->GetBacktrace(lfbt); cmValueWithOrigin entry(this->Join(content), lfbt); tgt->InsertCompileOption(entry); + return true; } diff --git a/Source/cmTargetCompileOptionsCommand.h b/Source/cmTargetCompileOptionsCommand.h index d58dc07..d43534d 100644 --- a/Source/cmTargetCompileOptionsCommand.h +++ b/Source/cmTargetCompileOptionsCommand.h @@ -44,7 +44,7 @@ private: virtual void HandleImportedTarget(const std::string &tgt); virtual void HandleMissingTarget(const std::string &name); - virtual void HandleDirectContent(cmTarget *tgt, + virtual bool HandleDirectContent(cmTarget *tgt, const std::vector &content, bool prepend, bool system); virtual std::string Join(const std::vector &content); diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index f8e1188..caec7eb 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -66,7 +66,7 @@ std::string cmTargetIncludeDirectoriesCommand } //---------------------------------------------------------------------------- -void cmTargetIncludeDirectoriesCommand +bool cmTargetIncludeDirectoriesCommand ::HandleDirectContent(cmTarget *tgt, const std::vector &content, bool prepend, bool system) { @@ -78,6 +78,7 @@ void cmTargetIncludeDirectoriesCommand { tgt->AddSystemIncludeDirectories(content); } + return true; } //---------------------------------------------------------------------------- diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index c8b22fb..2a7814e 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -45,7 +45,7 @@ private: virtual void HandleImportedTarget(const std::string &tgt); virtual void HandleMissingTarget(const std::string &name); - virtual void HandleDirectContent(cmTarget *tgt, + virtual bool HandleDirectContent(cmTarget *tgt, const std::vector &content, bool prepend, bool system); virtual void HandleInterfaceContent(cmTarget *tgt, diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index d356611..4696de4 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -132,29 +132,31 @@ bool cmTargetPropCommandBase || args[i] == "PRIVATE" || args[i] == "INTERFACE" ) { - this->PopulateTargetProperies(scope, content, prepend, system); - return true; + return this->PopulateTargetProperies(scope, content, prepend, system); } content.push_back(args[i]); } - this->PopulateTargetProperies(scope, content, prepend, system); - return true; + return this->PopulateTargetProperies(scope, content, prepend, system); } //---------------------------------------------------------------------------- -void cmTargetPropCommandBase +bool cmTargetPropCommandBase ::PopulateTargetProperies(const std::string &scope, const std::vector &content, bool prepend, bool system) { if (scope == "PRIVATE" || scope == "PUBLIC") { - this->HandleDirectContent(this->Target, content, prepend, system); + if (!this->HandleDirectContent(this->Target, content, prepend, system)) + { + return false; + } } if (scope == "INTERFACE" || scope == "PUBLIC") { this->HandleInterfaceContent(this->Target, content, prepend, system); } + return true; } //---------------------------------------------------------------------------- diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index 555a08a..d42b588 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -44,7 +44,7 @@ private: virtual void HandleImportedTarget(const std::string &tgt) = 0; virtual void HandleMissingTarget(const std::string &name) = 0; - virtual void HandleDirectContent(cmTarget *tgt, + virtual bool HandleDirectContent(cmTarget *tgt, const std::vector &content, bool prepend, bool system) = 0; @@ -52,7 +52,7 @@ private: bool ProcessContentArgs(std::vector const& args, unsigned int &argIndex, bool prepend, bool system); - void PopulateTargetProperies(const std::string &scope, + bool PopulateTargetProperies(const std::string &scope, const std::vector &content, bool prepend, bool system); }; diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx index e82b36d..ce3b11e 100644 --- a/Source/cmTargetSourcesCommand.cxx +++ b/Source/cmTargetSourcesCommand.cxx @@ -56,9 +56,10 @@ std::string cmTargetSourcesCommand } //---------------------------------------------------------------------------- -void cmTargetSourcesCommand +bool cmTargetSourcesCommand ::HandleDirectContent(cmTarget *tgt, const std::vector &content, bool, bool) { tgt->AppendProperty("SOURCES", this->Join(content).c_str()); + return true; } diff --git a/Source/cmTargetSourcesCommand.h b/Source/cmTargetSourcesCommand.h index dae78c4..a170e36 100644 --- a/Source/cmTargetSourcesCommand.h +++ b/Source/cmTargetSourcesCommand.h @@ -45,7 +45,7 @@ private: virtual void HandleImportedTarget(const std::string &tgt); virtual void HandleMissingTarget(const std::string &name); - virtual void HandleDirectContent(cmTarget *tgt, + virtual bool HandleDirectContent(cmTarget *tgt, const std::vector &content, bool prepend, bool system); -- cgit v0.12 From 8ed59fc207fd028d5b2b1f8cb8a323291ef04ffc Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 13 Oct 2013 14:25:08 +0200 Subject: Add target_compile_features command. This can be used to set the compiler features required by particular targets. An error is issued at CMake time if the compiler does not support the required feature. If a language dialect flag is required by the features used, that will be added automatically. Base the target_compile_features command on cmTargetPropCommandBase. This gives us 'free' handling of IMPORTED, ALIAS, INTERFACE, non-compilable and missing targets. --- Help/command/target_compile_features.rst | 30 ++++++++++ Help/manual/cmake-commands.7.rst | 1 + Help/release/dev/compile-language-features.rst | 4 ++ Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 3 + Source/CMakeLists.txt | 1 + Source/cmTargetCompileFeaturesCommand.cxx | 70 ++++++++++++++++++++++ Source/cmTargetCompileFeaturesCommand.h | 41 +++++++++++++ .../target_compile_features/CMakeLists.txt | 17 ++++++ .../target_compile_features/dummy.cpp | 5 ++ .../target_compile_features/lib_auto_type.cpp | 6 ++ .../target_compile_features/lib_auto_type.h | 8 +++ .../target_compile_features/lib_user.cpp | 7 +++ .../CMakeCommands/target_compile_features/main.cpp | 6 ++ Tests/CMakeLists.txt | 1 + Tests/RunCMake/CMakeLists.txt | 4 ++ ..._OriginDebug_target_compile_features-result.txt | 1 + ..._OriginDebug_target_compile_features-stderr.txt | 5 ++ ...ature_OriginDebug_target_compile_features.cmake | 4 ++ Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake | 1 + .../target_compile_features/CMakeLists.txt | 3 + .../target_compile_features/RunCMakeTest.cmake | 11 ++++ .../alias_target-result.txt | 1 + .../alias_target-stderr.txt | 4 ++ .../target_compile_features/alias_target.cmake | 4 ++ Tests/RunCMake/target_compile_features/empty.cpp | 7 +++ .../imported_target-result.txt | 1 + .../imported_target-stderr.txt | 4 ++ .../target_compile_features/imported_target.cmake | 3 + .../invalid_args-result.txt | 1 + .../invalid_args-stderr.txt | 4 ++ .../target_compile_features/invalid_args.cmake | 3 + .../invalid_args_on_interface-result.txt | 1 + .../invalid_args_on_interface-stderr.txt | 5 ++ .../invalid_args_on_interface.cmake | 3 + .../no_matching_cxx_feature-result.txt | 1 + .../no_matching_cxx_feature-stderr.txt | 8 +++ .../no_matching_cxx_feature.cmake | 26 ++++++++ .../target_compile_features/no_target-result.txt | 1 + .../target_compile_features/no_target-stderr.txt | 5 ++ .../target_compile_features/no_target.cmake | 2 + .../not_a_cxx_feature-result.txt | 1 + .../not_a_cxx_feature-stderr.txt | 5 ++ .../not_a_cxx_feature.cmake | 6 ++ .../not_enough_args-result.txt | 1 + .../not_enough_args-stderr.txt | 4 ++ .../target_compile_features/not_enough_args.cmake | 3 + .../utility_target-result.txt | 1 + .../utility_target-stderr.txt | 4 ++ .../target_compile_features/utility_target.cmake | 4 ++ 49 files changed, 342 insertions(+) create mode 100644 Help/command/target_compile_features.rst create mode 100644 Source/cmTargetCompileFeaturesCommand.cxx create mode 100644 Source/cmTargetCompileFeaturesCommand.h create mode 100644 Tests/CMakeCommands/target_compile_features/CMakeLists.txt create mode 100644 Tests/CMakeCommands/target_compile_features/dummy.cpp create mode 100644 Tests/CMakeCommands/target_compile_features/lib_auto_type.cpp create mode 100644 Tests/CMakeCommands/target_compile_features/lib_auto_type.h create mode 100644 Tests/CMakeCommands/target_compile_features/lib_user.cpp create mode 100644 Tests/CMakeCommands/target_compile_features/main.cpp create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-result.txt create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-stderr.txt create mode 100644 Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features.cmake create mode 100644 Tests/RunCMake/target_compile_features/CMakeLists.txt create mode 100644 Tests/RunCMake/target_compile_features/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/target_compile_features/alias_target-result.txt create mode 100644 Tests/RunCMake/target_compile_features/alias_target-stderr.txt create mode 100644 Tests/RunCMake/target_compile_features/alias_target.cmake create mode 100644 Tests/RunCMake/target_compile_features/empty.cpp create mode 100644 Tests/RunCMake/target_compile_features/imported_target-result.txt create mode 100644 Tests/RunCMake/target_compile_features/imported_target-stderr.txt create mode 100644 Tests/RunCMake/target_compile_features/imported_target.cmake create mode 100644 Tests/RunCMake/target_compile_features/invalid_args-result.txt create mode 100644 Tests/RunCMake/target_compile_features/invalid_args-stderr.txt create mode 100644 Tests/RunCMake/target_compile_features/invalid_args.cmake create mode 100644 Tests/RunCMake/target_compile_features/invalid_args_on_interface-result.txt create mode 100644 Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt create mode 100644 Tests/RunCMake/target_compile_features/invalid_args_on_interface.cmake create mode 100644 Tests/RunCMake/target_compile_features/no_matching_cxx_feature-result.txt create mode 100644 Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt create mode 100644 Tests/RunCMake/target_compile_features/no_matching_cxx_feature.cmake create mode 100644 Tests/RunCMake/target_compile_features/no_target-result.txt create mode 100644 Tests/RunCMake/target_compile_features/no_target-stderr.txt create mode 100644 Tests/RunCMake/target_compile_features/no_target.cmake create mode 100644 Tests/RunCMake/target_compile_features/not_a_cxx_feature-result.txt create mode 100644 Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt create mode 100644 Tests/RunCMake/target_compile_features/not_a_cxx_feature.cmake create mode 100644 Tests/RunCMake/target_compile_features/not_enough_args-result.txt create mode 100644 Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt create mode 100644 Tests/RunCMake/target_compile_features/not_enough_args.cmake create mode 100644 Tests/RunCMake/target_compile_features/utility_target-result.txt create mode 100644 Tests/RunCMake/target_compile_features/utility_target-stderr.txt create mode 100644 Tests/RunCMake/target_compile_features/utility_target.cmake diff --git a/Help/command/target_compile_features.rst b/Help/command/target_compile_features.rst new file mode 100644 index 0000000..f8e5c54 --- /dev/null +++ b/Help/command/target_compile_features.rst @@ -0,0 +1,30 @@ +target_compile_features +----------------------- + +Add expected compiler features to a target. + +:: + + target_compile_features( [...]) + +Specify compiler features required when compiling a given target. If the +feature is not listed in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable, +then an error will be reported by CMake. If the use of the feature requires +an additional compiler flag, such as ``-std=c++11``, the flag will be added +automatically. + +The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to +specify the scope of the features. ``PRIVATE`` and ``PUBLIC`` items will +populate the :prop_tgt:`COMPILE_FEATURES` property of ````. +``PUBLIC`` and ``INTERFACE`` items will populate the +:prop_tgt:`INTERFACE_COMPILE_FEATURES` property of ````. Repeated +calls for the same ```` append items. + +The named ```` must have been created by a command such as +:command:`add_executable` or :command:`add_library` and must not be +an ``IMPORTED`` target. + +Arguments to ``target_compile_features`` may use "generator expressions" +with the syntax ``$<...>``. +See the :manual:`cmake-generator-expressions(7)` manual for available +expressions. diff --git a/Help/manual/cmake-commands.7.rst b/Help/manual/cmake-commands.7.rst index 4b1dbed..17c3236 100644 --- a/Help/manual/cmake-commands.7.rst +++ b/Help/manual/cmake-commands.7.rst @@ -91,6 +91,7 @@ These commands may be used freely in CMake projects. /command/source_group /command/string /command/target_compile_definitions + /command/target_compile_features /command/target_compile_options /command/target_include_directories /command/target_link_libraries diff --git a/Help/release/dev/compile-language-features.rst b/Help/release/dev/compile-language-features.rst index 74fe209..3c5d7ca 100644 --- a/Help/release/dev/compile-language-features.rst +++ b/Help/release/dev/compile-language-features.rst @@ -12,3 +12,7 @@ target-language-features information to ensure that the compiler in use is capable of building the target, and to add any necessary compile flags to support language features. + +* New :command:`target_compile_features` command allows populating the + :prop_tgt:`COMPILE_FEATURES` target property, just like any other + build variable. diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index d49bb68..3278b2e 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -7,6 +7,9 @@ The features listed in this variable may be known to be available to the C++ compiler. If the feature is available with the C++ compiler, it will be listed in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable. +The features listed here may be used with the :command:`target_compile_features` +command. + The features known to this version of CMake are: ``cxx_auto_type`` diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 4c678d8..660c0c5 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -346,6 +346,7 @@ foreach(command_file cmSourceGroupCommand cmSubdirDependsCommand cmTargetCompileDefinitionsCommand + cmTargetCompileFeaturesCommand cmTargetCompileOptionsCommand cmTargetIncludeDirectoriesCommand cmTargetSourcesCommand diff --git a/Source/cmTargetCompileFeaturesCommand.cxx b/Source/cmTargetCompileFeaturesCommand.cxx new file mode 100644 index 0000000..10daad4 --- /dev/null +++ b/Source/cmTargetCompileFeaturesCommand.cxx @@ -0,0 +1,70 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2013 Stephen Kelly + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmTargetCompileFeaturesCommand.h" + +bool cmTargetCompileFeaturesCommand::InitialPass( + std::vector const& args, + cmExecutionStatus &) +{ + return this->HandleArguments(args, "COMPILE_FEATURES", NO_FLAGS); +} + +void cmTargetCompileFeaturesCommand +::HandleImportedTarget(const std::string &tgt) +{ + cmOStringStream e; + e << "Cannot specify compile features for imported target \"" + << tgt << "\"."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); +} + +void cmTargetCompileFeaturesCommand +::HandleMissingTarget(const std::string &name) +{ + cmOStringStream e; + e << "Cannot specify compile features for target \"" << name << "\" " + "which is not built by this project."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); +} + +//---------------------------------------------------------------------------- +std::string cmTargetCompileFeaturesCommand +::Join(const std::vector &content) +{ + std::string defs; + std::string sep; + for(std::vector::const_iterator it = content.begin(); + it != content.end(); ++it) + { + defs += sep + *it; + sep = ";"; + } + return defs; +} + +//---------------------------------------------------------------------------- +bool cmTargetCompileFeaturesCommand +::HandleDirectContent(cmTarget *tgt, const std::vector &content, + bool, bool) +{ + for(std::vector::const_iterator it = content.begin(); + it != content.end(); ++it) + { + std::string error; + if(!this->Makefile->AddRequiredTargetFeature(tgt, *it, &error)) + { + this->SetError(error); + return false; + } + } + return true; +} diff --git a/Source/cmTargetCompileFeaturesCommand.h b/Source/cmTargetCompileFeaturesCommand.h new file mode 100644 index 0000000..fa7ae8d --- /dev/null +++ b/Source/cmTargetCompileFeaturesCommand.h @@ -0,0 +1,41 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2013 Stephen Kelly + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmTargetCompileFeaturesCommand_h +#define cmTargetCompileFeaturesCommand_h + +#include "cmTargetPropCommandBase.h" + +class cmTargetCompileFeaturesCommand : public cmTargetPropCommandBase +{ + virtual cmCommand* Clone() + { + return new cmTargetCompileFeaturesCommand; + } + + virtual bool InitialPass(std::vector const& args, + cmExecutionStatus &status); + + virtual std::string GetName() const { return "target_compile_features";} + + cmTypeMacro(cmTargetCompileFeaturesCommand, cmTargetPropCommandBase); + +private: + virtual void HandleImportedTarget(const std::string &tgt); + virtual void HandleMissingTarget(const std::string &name); + + virtual bool HandleDirectContent(cmTarget *tgt, + const std::vector &content, + bool prepend, bool system); + virtual std::string Join(const std::vector &content); +}; + +#endif diff --git a/Tests/CMakeCommands/target_compile_features/CMakeLists.txt b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt new file mode 100644 index 0000000..ad76411 --- /dev/null +++ b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.0) +project(target_compile_features) + +set(CMAKE_VERBOSE_MAKEFILE ON) + +add_executable(target_compile_features main.cpp) +target_compile_features(target_compile_features + PRIVATE cxx_auto_type +) + +add_library(lib_auto_type lib_auto_type.cpp) +target_compile_features(lib_auto_type + PUBLIC cxx_auto_type +) + +add_executable(lib_user lib_user.cpp) +target_link_libraries(lib_user lib_auto_type) diff --git a/Tests/CMakeCommands/target_compile_features/dummy.cpp b/Tests/CMakeCommands/target_compile_features/dummy.cpp new file mode 100644 index 0000000..341aaaf --- /dev/null +++ b/Tests/CMakeCommands/target_compile_features/dummy.cpp @@ -0,0 +1,5 @@ + +int main(int, char **) +{ + return 0; +} diff --git a/Tests/CMakeCommands/target_compile_features/lib_auto_type.cpp b/Tests/CMakeCommands/target_compile_features/lib_auto_type.cpp new file mode 100644 index 0000000..71b2215 --- /dev/null +++ b/Tests/CMakeCommands/target_compile_features/lib_auto_type.cpp @@ -0,0 +1,6 @@ + +int getAutoTypeImpl() +{ + auto i = 0; + return i; +} diff --git a/Tests/CMakeCommands/target_compile_features/lib_auto_type.h b/Tests/CMakeCommands/target_compile_features/lib_auto_type.h new file mode 100644 index 0000000..c825b10 --- /dev/null +++ b/Tests/CMakeCommands/target_compile_features/lib_auto_type.h @@ -0,0 +1,8 @@ + +int getAutoTypeImpl(); + +int getAutoType() +{ + auto i = getAutoTypeImpl(); + return i; +} diff --git a/Tests/CMakeCommands/target_compile_features/lib_user.cpp b/Tests/CMakeCommands/target_compile_features/lib_user.cpp new file mode 100644 index 0000000..976068a --- /dev/null +++ b/Tests/CMakeCommands/target_compile_features/lib_user.cpp @@ -0,0 +1,7 @@ + +#include "lib_auto_type.h" + +int main(int argc, char **argv) +{ + return getAutoType(); +} diff --git a/Tests/CMakeCommands/target_compile_features/main.cpp b/Tests/CMakeCommands/target_compile_features/main.cpp new file mode 100644 index 0000000..fe29b04 --- /dev/null +++ b/Tests/CMakeCommands/target_compile_features/main.cpp @@ -0,0 +1,6 @@ + +int main(int, char **) +{ + auto i = 0; + return i; +} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index fc58f1e..c1d5cde 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -200,6 +200,7 @@ if(BUILD_TESTING) if(CMAKE_CXX_COMPILER_ID STREQUAL GNU AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) ADD_TEST_MACRO(CompileFeatures CompileFeatures) + ADD_TEST_MACRO(CMakeCommands.target_compile_features target_compile_features) endif() # assume no resources building to test set(TEST_RESOURCES FALSE) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index dd769ac..00e6702 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -125,6 +125,10 @@ endif() add_RunCMake_test(File_Generate) add_RunCMake_test(ExportWithoutLanguage) add_RunCMake_test(target_link_libraries) + +if (CMAKE_CXX_COMPILER_ID STREQUAL GNU AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) + add_RunCMake_test(target_compile_features) +endif() add_RunCMake_test(CheckModules) add_RunCMake_test(CommandLine) diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-stderr.txt new file mode 100644 index 0000000..d819d15 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at NotAFeature_OriginDebug_target_compile_features.cmake:4 \(target_compile_features\): + target_compile_features specified unknown feature "not_a_feature" for + target "somelib". +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features.cmake b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features.cmake new file mode 100644 index 0000000..467d9a1 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features.cmake @@ -0,0 +1,4 @@ + +set(CMAKE_DEBUG_TARGET_PROPERTIES COMPILE_FEATURES) +add_library(somelib STATIC empty.cpp) +target_compile_features(somelib PRIVATE not_a_feature) diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index a059900..a6aeeee 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -6,3 +6,4 @@ run_cmake(NotAFeatureTransitive) run_cmake(NotAFeature_OriginDebug) run_cmake(NotAFeature_OriginDebugGenex) run_cmake(NotAFeature_OriginDebugTransitive) +run_cmake(NotAFeature_OriginDebug_target_compile_features) diff --git a/Tests/RunCMake/target_compile_features/CMakeLists.txt b/Tests/RunCMake/target_compile_features/CMakeLists.txt new file mode 100644 index 0000000..3482e6b --- /dev/null +++ b/Tests/RunCMake/target_compile_features/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.0) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake b/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake new file mode 100644 index 0000000..f2abef7 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake @@ -0,0 +1,11 @@ +include(RunCMake) + +run_cmake(not_enough_args) +run_cmake(alias_target) +run_cmake(utility_target) +run_cmake(invalid_args) +run_cmake(invalid_args_on_interface) +run_cmake(imported_target) +run_cmake(no_target) +run_cmake(not_a_cxx_feature) +run_cmake(no_matching_cxx_feature) diff --git a/Tests/RunCMake/target_compile_features/alias_target-result.txt b/Tests/RunCMake/target_compile_features/alias_target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/alias_target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/alias_target-stderr.txt b/Tests/RunCMake/target_compile_features/alias_target-stderr.txt new file mode 100644 index 0000000..417bf62 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/alias_target-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at alias_target.cmake:4 \(target_compile_features\): + target_compile_features can not be used on an ALIAS target. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_compile_features/alias_target.cmake b/Tests/RunCMake/target_compile_features/alias_target.cmake new file mode 100644 index 0000000..d35ddba --- /dev/null +++ b/Tests/RunCMake/target_compile_features/alias_target.cmake @@ -0,0 +1,4 @@ + +add_executable(main empty.cpp) +add_executable(Alias::Main ALIAS main) +target_compile_features(Alias::Main PRIVATE cxx_delegating_constructors) diff --git a/Tests/RunCMake/target_compile_features/empty.cpp b/Tests/RunCMake/target_compile_features/empty.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/target_compile_features/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/target_compile_features/imported_target-result.txt b/Tests/RunCMake/target_compile_features/imported_target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/imported_target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/imported_target-stderr.txt b/Tests/RunCMake/target_compile_features/imported_target-stderr.txt new file mode 100644 index 0000000..c6ff5ec --- /dev/null +++ b/Tests/RunCMake/target_compile_features/imported_target-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at imported_target.cmake:3 \(target_compile_features\): + Cannot specify compile features for imported target "main". +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_compile_features/imported_target.cmake b/Tests/RunCMake/target_compile_features/imported_target.cmake new file mode 100644 index 0000000..e248c2f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/imported_target.cmake @@ -0,0 +1,3 @@ + +add_library(main INTERFACE IMPORTED) +target_compile_features(main INTERFACE cxx_delegating_constructors) diff --git a/Tests/RunCMake/target_compile_features/invalid_args-result.txt b/Tests/RunCMake/target_compile_features/invalid_args-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/invalid_args-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt b/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt new file mode 100644 index 0000000..bd5b7b9 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at invalid_args.cmake:3 \(target_compile_features\): + target_compile_features called with invalid arguments +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_compile_features/invalid_args.cmake b/Tests/RunCMake/target_compile_features/invalid_args.cmake new file mode 100644 index 0000000..1a7fb37 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/invalid_args.cmake @@ -0,0 +1,3 @@ + +add_executable(main empty.cpp) +target_compile_features(main INVALID cxx_delegating_constructors) diff --git a/Tests/RunCMake/target_compile_features/invalid_args_on_interface-result.txt b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt new file mode 100644 index 0000000..c30209a --- /dev/null +++ b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at invalid_args_on_interface.cmake:3 \(target_compile_features\): + target_compile_features may only be set INTERFACE properties on INTERFACE + targets +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_compile_features/invalid_args_on_interface.cmake b/Tests/RunCMake/target_compile_features/invalid_args_on_interface.cmake new file mode 100644 index 0000000..324d0f3 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/invalid_args_on_interface.cmake @@ -0,0 +1,3 @@ + +add_library(main INTERFACE) +target_compile_features(main PRIVATE cxx_delegating_constructors) diff --git a/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-result.txt b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt new file mode 100644 index 0000000..4c76c7a --- /dev/null +++ b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at no_matching_cxx_feature.cmake:[0-9][0-9]? \((target_compile_features|message)\): + The compiler feature "[^"]+" is not known to compiler + + "[^"]*" + + version *[.0-9]+\. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_compile_features/no_matching_cxx_feature.cmake b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature.cmake new file mode 100644 index 0000000..0452dbf --- /dev/null +++ b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature.cmake @@ -0,0 +1,26 @@ + +if (NOT ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";gnu_cxx_typeof;" + AND NOT ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";msvc_cxx_sealed;" ) + # Simulate passing the test. + message(SEND_ERROR + "The compiler feature \"gnu_cxx_dummy\" is not known to compiler\n\"GNU\"\nversion 4.8.1." + ) + return() +endif() + +if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";gnu_cxx_typeof;") + set(feature msvc_cxx_sealed) + if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";msvc_cxx_sealed;") + # If a compiler supports both extensions, remove one of them. + list(REMOVE_ITEM CMAKE_CXX_COMPILE_FEATURES msvc_cxx_sealed) + endif() +else() + set(feature gnu_cxx_typeof) +endif() + +add_executable(main empty.cpp) + +target_compile_features(main + PRIVATE + ${feature} +) diff --git a/Tests/RunCMake/target_compile_features/no_target-result.txt b/Tests/RunCMake/target_compile_features/no_target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/no_target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/no_target-stderr.txt b/Tests/RunCMake/target_compile_features/no_target-stderr.txt new file mode 100644 index 0000000..323ba7a --- /dev/null +++ b/Tests/RunCMake/target_compile_features/no_target-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at no_target.cmake:2 \(target_compile_features\): + Cannot specify compile features for target "main" which is not built by + this project. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_compile_features/no_target.cmake b/Tests/RunCMake/target_compile_features/no_target.cmake new file mode 100644 index 0000000..3f0afe2 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/no_target.cmake @@ -0,0 +1,2 @@ + +target_compile_features(main INTERFACE cxx_delegating_constructors) diff --git a/Tests/RunCMake/target_compile_features/not_a_cxx_feature-result.txt b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt new file mode 100644 index 0000000..efa2bad --- /dev/null +++ b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at not_a_cxx_feature.cmake:3 \(target_compile_features\): + target_compile_features specified unknown feature "cxx_not_a_feature" for + target "main". +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_compile_features/not_a_cxx_feature.cmake b/Tests/RunCMake/target_compile_features/not_a_cxx_feature.cmake new file mode 100644 index 0000000..0207b72 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/not_a_cxx_feature.cmake @@ -0,0 +1,6 @@ + +add_executable(main empty.cpp) +target_compile_features(main + PRIVATE + cxx_not_a_feature +) diff --git a/Tests/RunCMake/target_compile_features/not_enough_args-result.txt b/Tests/RunCMake/target_compile_features/not_enough_args-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/not_enough_args-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt b/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt new file mode 100644 index 0000000..2f8d812 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at not_enough_args.cmake:3 \(target_compile_features\): + target_compile_features called with incorrect number of arguments +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_compile_features/not_enough_args.cmake b/Tests/RunCMake/target_compile_features/not_enough_args.cmake new file mode 100644 index 0000000..9561230 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/not_enough_args.cmake @@ -0,0 +1,3 @@ + +add_executable(main empty.cpp) +target_compile_features(main) diff --git a/Tests/RunCMake/target_compile_features/utility_target-result.txt b/Tests/RunCMake/target_compile_features/utility_target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/utility_target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/utility_target-stderr.txt b/Tests/RunCMake/target_compile_features/utility_target-stderr.txt new file mode 100644 index 0000000..d239059 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/utility_target-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at utility_target.cmake:4 \(target_compile_features\): + target_compile_features called with non-compilable target type +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_compile_features/utility_target.cmake b/Tests/RunCMake/target_compile_features/utility_target.cmake new file mode 100644 index 0000000..8919056 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/utility_target.cmake @@ -0,0 +1,4 @@ + +add_custom_target(utility) + +target_compile_features(utility PRIVATE cxx_delegating_constructors) -- cgit v0.12 From 9b1abc543e9aee946e093229e1715c4b8a961514 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 8 Apr 2014 00:01:05 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 49e2cf3..641c801 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 0) -set(CMake_VERSION_PATCH 20140407) +set(CMake_VERSION_PATCH 20140408) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 9eaf3755987821080908a289cefbf546773071f9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 17 Dec 2013 19:23:40 +0100 Subject: Export: Populate INTERFACE_COMPILE_FEATURES property. --- Source/cmExportBuildFileGenerator.cxx | 3 +++ Source/cmExportInstallFileGenerator.cxx | 4 ++++ Tests/ExportImport/Export/Interface/CMakeLists.txt | 5 ++++- Tests/ExportImport/Import/CMakeLists.txt | 1 + Tests/ExportImport/Import/Interface/CMakeLists.txt | 17 +++++++++++++++++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index e79206d..6c8ebb6 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -85,6 +85,9 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", te, cmGeneratorExpression::BuildInterface, properties, missingTargets); + this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", te, + cmGeneratorExpression::BuildInterface, + properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); const bool newCMP0022Behavior = diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index a83a228..89071c0 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -149,6 +149,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) te, cmGeneratorExpression::InstallInterface, properties, missingTargets); + this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", + te, + cmGeneratorExpression::InstallInterface, + properties, missingTargets); const bool newCMP0022Behavior = te->GetPolicyStatusCMP0022() != cmPolicies::WARN diff --git a/Tests/ExportImport/Export/Interface/CMakeLists.txt b/Tests/ExportImport/Export/Interface/CMakeLists.txt index 9d4793d..1b653eb 100644 --- a/Tests/ExportImport/Export/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Export/Interface/CMakeLists.txt @@ -23,7 +23,10 @@ set_property(TARGET sharedlib PROPERTY INTERFACE_COMPILE_DEFINITIONS "SHAREDLIB_ add_library(sharediface INTERFACE) target_link_libraries(sharediface INTERFACE sharedlib) -install(TARGETS headeronly sharediface +add_library(use_auto_type INTERFACE) +target_compile_features(use_auto_type INTERFACE cxx_auto_type) + +install(TARGETS headeronly sharediface use_auto_type EXPORT expInterface ) install(TARGETS sharedlib diff --git a/Tests/ExportImport/Import/CMakeLists.txt b/Tests/ExportImport/Import/CMakeLists.txt index 5e809a2..189f7a2 100644 --- a/Tests/ExportImport/Import/CMakeLists.txt +++ b/Tests/ExportImport/Import/CMakeLists.txt @@ -1,4 +1,5 @@ cmake_minimum_required (VERSION 2.7.20090711) +cmake_policy(SET CMP0025 NEW) project(Import C CXX) # Import everything in a subdirectory. diff --git a/Tests/ExportImport/Import/Interface/CMakeLists.txt b/Tests/ExportImport/Import/Interface/CMakeLists.txt index cf7e2bc..1f30c67 100644 --- a/Tests/ExportImport/Import/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Import/Interface/CMakeLists.txt @@ -40,6 +40,23 @@ macro(do_try_compile prefix) if(NOT ${prefix}IFACE_TRY_COMPILE) message(SEND_ERROR "${prefix} try_compile with IMPORTED INTERFACE target failed!\n\n${OUTPUT}") endif() + + if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_auto_type;") + set(CMAKE_REQUIRED_LIBRARIES ${prefix}::use_auto_type) + check_cxx_source_compiles( + " + int main(int,char**) + { + auto value = 0; + return value; + } + " ${prefix}IMPORTED_IFACE_CONSTEXPR) + + if(NOT ${prefix}IMPORTED_IFACE_CONSTEXPR) + message(SEND_ERROR "${prefix} try_compile with IMPORTED INTERFACE target failed!\n\n${OUTPUT}") + endif() + endif() + endmacro() do_try_compile(bld) -- cgit v0.12 From 750dfee29c3f45020e8fcff91499a2542913b649 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 7 Apr 2014 17:28:55 +0200 Subject: Features: Add cxx_delegating_constructors. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 3 +++ Source/cmMakefile.cxx | 3 ++- Tests/CompileFeatures/cxx_delegating_constructors.cpp | 15 +++++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 Tests/CompileFeatures/cxx_delegating_constructors.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 3278b2e..957c763 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -16,3 +16,8 @@ The features known to this version of CMake are: Automatic type deduction, as defined in N1984_. .. _N1984: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1984.pdf + +``cxx_delegating_constructors`` + Delegating constructors, as defined in N1986_. + + .. _N1986: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index b36315f..4f14b17 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -2,6 +2,9 @@ # Reference: http://gcc.gnu.org/projects/cxx0x.html set(_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408") +# TODO: Should be supported by GNU 4.7 +set(GNU47_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}") # TODO: Should be supported by GNU 4.4 set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 5004a08..de6b972 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -42,7 +42,8 @@ #include #define FOR_EACH_CXX_FEATURE(F) \ - F(cxx_auto_type) + F(cxx_auto_type) \ + F(cxx_delegating_constructors) class cmMakefile::Internals { diff --git a/Tests/CompileFeatures/cxx_delegating_constructors.cpp b/Tests/CompileFeatures/cxx_delegating_constructors.cpp new file mode 100644 index 0000000..4b41615 --- /dev/null +++ b/Tests/CompileFeatures/cxx_delegating_constructors.cpp @@ -0,0 +1,15 @@ + +class Foo +{ +public: + Foo(int i); + + Foo(double d) + : Foo(static_cast(d)) + { + + } + +private: + int m_i; +}; -- cgit v0.12 From 10f33eee1dfefa9e5a2ee5cf4946095bf08b19bc Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 2 Apr 2014 15:02:41 +0200 Subject: Features: Add cxx_variadic_templates. Expect cxx_variadic_templates to implement N2555. N2555 is essentially a bugfix and predates most compiler releases which aimed to experimentally support variadic templates. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 ++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 13 +++++ Source/cmMakefile.cxx | 3 +- Tests/CompileFeatures/cxx_variadic_templates.cpp | 65 ++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 Tests/CompileFeatures/cxx_variadic_templates.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 957c763..b6b2b35 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -21,3 +21,8 @@ The features known to this version of CMake are: Delegating constructors, as defined in N1986_. .. _N1986: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf + +``cxx_variadic_templates`` + Variadic templates, as defined in N2242_. + + .. _N2242: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2242.pdf diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 4f14b17..6baa463 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -5,7 +5,20 @@ set(_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408") # TODO: Should be supported by GNU 4.7 set(GNU47_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}") +# NOTE: C++11 was ratified in September 2011. GNU 4.7 is the first minor +# release following that (March 2012), and the first minor release to +# support -std=c++11. Prior to that, support for C++11 features is technically +# experiemental and possibly incomplete (see for example the note below about +# cxx_variadic_template_template_parameters) # TODO: Should be supported by GNU 4.4 set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}") +# TODO: If features are ever recorded for GNU 4.3, there should possibly +# be a new feature added like cxx_variadic_template_template_parameters, +# which is implemented by GNU 4.4, but not 4.3. cxx_variadic_templates is +# actually implemented by GNU 4.3, but variadic template template parameters +# 'completes' it, so that is the version we record as having the variadic +# templates capability in CMake. See +# http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2555.pdf set(_oldestSupported) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index de6b972..52f4fb6 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -43,7 +43,8 @@ #define FOR_EACH_CXX_FEATURE(F) \ F(cxx_auto_type) \ - F(cxx_delegating_constructors) + F(cxx_delegating_constructors) \ + F(cxx_variadic_templates) class cmMakefile::Internals { diff --git a/Tests/CompileFeatures/cxx_variadic_templates.cpp b/Tests/CompileFeatures/cxx_variadic_templates.cpp new file mode 100644 index 0000000..1d5a706 --- /dev/null +++ b/Tests/CompileFeatures/cxx_variadic_templates.cpp @@ -0,0 +1,65 @@ +template +struct Interface; + +template +struct Interface +{ + static int accumulate() + { + return I; + } +}; + +template +struct Interface +{ + static int accumulate() + { + return I + Interface::accumulate(); + } +}; + +// Note: split this into a separate test if a +// cxx_variadic_template_template_parameters feature is added. + +template +struct eval { + enum { + Matched = 0 + }; +}; + +template class T, typename... U> +struct eval > { + enum { + Matched = 1 + }; +}; + +template +struct A { + +}; +template +struct B { + +}; +template +struct C { + +}; +template +struct D { + +}; + +// Note: This test assumes that a compiler supporting this feature +// supports static_assert. Add a workaround if that does not hold. +static_assert(eval >::Matched, "A Matches"); +static_assert(eval >::Matched, "A Matches"); +static_assert(eval >::Matched, "A Matches"); +static_assert(eval >::Matched, "B Matches"); +static_assert(eval >::Matched, "C Matches"); +static_assert(eval >::Matched, "D Matches"); +static_assert(eval >::Matched, "D Matches"); +static_assert(eval >::Matched, "D Matches"); -- cgit v0.12 From 91289312fa9da0807b5c59a78de2c5ad21d6cda1 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 18 Mar 2014 12:53:01 +0100 Subject: Features: Add cxx_constexpr. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 3 +++ Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_constexpr.cpp | 5 +++++ 4 files changed, 14 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_constexpr.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index b6b2b35..aa314cd 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -17,6 +17,11 @@ The features known to this version of CMake are: .. _N1984: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1984.pdf +``cxx_constexpr`` + Constant expressions, as defined in N2235_. + + .. _N2235: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf + ``cxx_delegating_constructors`` Delegating constructors, as defined in N1986_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 6baa463..5321eda 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -10,6 +10,9 @@ set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}") # support -std=c++11. Prior to that, support for C++11 features is technically # experiemental and possibly incomplete (see for example the note below about # cxx_variadic_template_template_parameters) +# TODO: Should be supported by GNU 4.6 +set(GNU46_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}") # TODO: Should be supported by GNU 4.4 set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 52f4fb6..cc1dfa1 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -43,6 +43,7 @@ #define FOR_EACH_CXX_FEATURE(F) \ F(cxx_auto_type) \ + F(cxx_constexpr) \ F(cxx_delegating_constructors) \ F(cxx_variadic_templates) diff --git a/Tests/CompileFeatures/cxx_constexpr.cpp b/Tests/CompileFeatures/cxx_constexpr.cpp new file mode 100644 index 0000000..570c10f --- /dev/null +++ b/Tests/CompileFeatures/cxx_constexpr.cpp @@ -0,0 +1,5 @@ + +constexpr int getNum() +{ + return 42; +} -- cgit v0.12 From 88542a61011d13ed0a92b9a1da49d428846aaf20 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 00:00:28 +0200 Subject: Features: Add cxx_static_assert. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 3 +++ Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_static_assert.cpp | 2 ++ 4 files changed, 11 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_static_assert.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index aa314cd..042cd43 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -27,6 +27,11 @@ The features known to this version of CMake are: .. _N1986: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf +``cxx_static_assert`` + Static assert, as defined in N1720_. + + .. _N1720: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html + ``cxx_variadic_templates`` Variadic templates, as defined in N2242_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 5321eda..5d61656 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -24,4 +24,7 @@ set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}") # 'completes' it, so that is the version we record as having the variadic # templates capability in CMake. See # http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2555.pdf +# TODO: Should be supported by GNU 4.3 +set(GNU43_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_static_assert "${GNU43_CXX11}") set(_oldestSupported) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index cc1dfa1..fa806a7 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -45,6 +45,7 @@ F(cxx_auto_type) \ F(cxx_constexpr) \ F(cxx_delegating_constructors) \ + F(cxx_static_assert) \ F(cxx_variadic_templates) class cmMakefile::Internals diff --git a/Tests/CompileFeatures/cxx_static_assert.cpp b/Tests/CompileFeatures/cxx_static_assert.cpp new file mode 100644 index 0000000..6aa8678 --- /dev/null +++ b/Tests/CompileFeatures/cxx_static_assert.cpp @@ -0,0 +1,2 @@ + +static_assert(true, "static_assert test"); -- cgit v0.12 From 57ac6a905c33211af420aaf1e7fc14b3871a7b16 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 18 Mar 2014 23:42:05 +0100 Subject: Features: Add cxx_final. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_final.cpp | 2 ++ 4 files changed, 9 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_final.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 042cd43..a5ecf5a 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -27,6 +27,11 @@ The features known to this version of CMake are: .. _N1986: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf +``cxx_final`` + Override control ``final`` keyword, as defined in N2928_. + + .. _N2928: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm + ``cxx_static_assert`` Static assert, as defined in N1720_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 5d61656..52f49b8 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -5,6 +5,7 @@ set(_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408") # TODO: Should be supported by GNU 4.7 set(GNU47_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}") +set(_cmake_feature_test_cxx_final "${GNU47_CXX11}") # NOTE: C++11 was ratified in September 2011. GNU 4.7 is the first minor # release following that (March 2012), and the first minor release to # support -std=c++11. Prior to that, support for C++11 features is technically diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index fa806a7..a916141 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -45,6 +45,7 @@ F(cxx_auto_type) \ F(cxx_constexpr) \ F(cxx_delegating_constructors) \ + F(cxx_final) \ F(cxx_static_assert) \ F(cxx_variadic_templates) diff --git a/Tests/CompileFeatures/cxx_final.cpp b/Tests/CompileFeatures/cxx_final.cpp new file mode 100644 index 0000000..598cb94 --- /dev/null +++ b/Tests/CompileFeatures/cxx_final.cpp @@ -0,0 +1,2 @@ + +struct A final {}; -- cgit v0.12 From 0685ac6edc8f9285e7b12d32a182e569a372856c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 19 Mar 2014 13:32:59 +0100 Subject: Features: Add cxx_override. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_override.cpp | 7 +++++++ 4 files changed, 14 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_override.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index a5ecf5a..073b0ca 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -32,6 +32,11 @@ The features known to this version of CMake are: .. _N2928: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm +``cxx_override`` + Override control ``override`` keyword, as defined in N2928_. + + .. _N2928: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm + ``cxx_static_assert`` Static assert, as defined in N1720_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 52f49b8..87ed765 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -6,6 +6,7 @@ set(_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408") set(GNU47_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}") set(_cmake_feature_test_cxx_final "${GNU47_CXX11}") +set(_cmake_feature_test_cxx_override "${GNU47_CXX11}") # NOTE: C++11 was ratified in September 2011. GNU 4.7 is the first minor # release following that (March 2012), and the first minor release to # support -std=c++11. Prior to that, support for C++11 features is technically diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index a916141..8e4ba95 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -46,6 +46,7 @@ F(cxx_constexpr) \ F(cxx_delegating_constructors) \ F(cxx_final) \ + F(cxx_override) \ F(cxx_static_assert) \ F(cxx_variadic_templates) diff --git a/Tests/CompileFeatures/cxx_override.cpp b/Tests/CompileFeatures/cxx_override.cpp new file mode 100644 index 0000000..55bec13 --- /dev/null +++ b/Tests/CompileFeatures/cxx_override.cpp @@ -0,0 +1,7 @@ + +struct A { + virtual void doNothing() {} +}; +struct B : A { + void doNothing() override {} +}; -- cgit v0.12 From 0caf08e43ef405a879393cb3a4bae0b6b87e26b6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 00:02:14 +0200 Subject: Features: Add cxx_auto_function. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_trailing_return_types.cpp | 5 +++++ 4 files changed, 12 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_trailing_return_types.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 073b0ca..0d1329c 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -42,6 +42,11 @@ The features known to this version of CMake are: .. _N1720: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html +``cxx_trailing_return_types`` + Automatic function return type, as defined in N2541_. + + .. _N2541: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2541.htm + ``cxx_variadic_templates`` Variadic templates, as defined in N2242_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 87ed765..3549824 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -18,6 +18,7 @@ set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}") # TODO: Should be supported by GNU 4.4 set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_trailing_return_types "${GNU44_CXX11}") set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}") # TODO: If features are ever recorded for GNU 4.3, there should possibly # be a new feature added like cxx_variadic_template_template_parameters, diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8e4ba95..3c23045 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -48,6 +48,7 @@ F(cxx_final) \ F(cxx_override) \ F(cxx_static_assert) \ + F(cxx_trailing_return_types) \ F(cxx_variadic_templates) class cmMakefile::Internals diff --git a/Tests/CompileFeatures/cxx_trailing_return_types.cpp b/Tests/CompileFeatures/cxx_trailing_return_types.cpp new file mode 100644 index 0000000..01a76cb --- /dev/null +++ b/Tests/CompileFeatures/cxx_trailing_return_types.cpp @@ -0,0 +1,5 @@ + +auto someFunc() -> int +{ + return 42; +} -- cgit v0.12 From 8d3467636c4fad32c25390244a62e58e068c33ad Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 3 Apr 2014 00:02:54 +0200 Subject: Features: Add cxx_strong_enums. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_strong_enums.cpp | 7 +++++++ 4 files changed, 14 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_strong_enums.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 0d1329c..4a68573 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -42,6 +42,11 @@ The features known to this version of CMake are: .. _N1720: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html +``cxx_strong_enums`` + Strongly typed enums, as defined in N2347_. + + .. _N2347: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf + ``cxx_trailing_return_types`` Automatic function return type, as defined in N2541_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 3549824..c451b7e 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -18,6 +18,7 @@ set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}") # TODO: Should be supported by GNU 4.4 set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_strong_enums "${GNU44_CXX11}") set(_cmake_feature_test_cxx_trailing_return_types "${GNU44_CXX11}") set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}") # TODO: If features are ever recorded for GNU 4.3, there should possibly diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3c23045..12d88e4 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -48,6 +48,7 @@ F(cxx_final) \ F(cxx_override) \ F(cxx_static_assert) \ + F(cxx_strong_enums) \ F(cxx_trailing_return_types) \ F(cxx_variadic_templates) diff --git a/Tests/CompileFeatures/cxx_strong_enums.cpp b/Tests/CompileFeatures/cxx_strong_enums.cpp new file mode 100644 index 0000000..6262456 --- /dev/null +++ b/Tests/CompileFeatures/cxx_strong_enums.cpp @@ -0,0 +1,7 @@ + +enum class Colors +{ + RedColor, + GreenColor, + BlueColor +}; -- cgit v0.12 From 7e748417bc8e06caa8eb0b6a6258b7d24cc22bfb Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 3 Apr 2014 00:08:49 +0200 Subject: Features: Add cxx_decltype. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_decltype.cpp | 7 +++++++ 4 files changed, 14 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_decltype.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 4a68573..97689dc 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -22,6 +22,11 @@ The features known to this version of CMake are: .. _N2235: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf +``cxx_decltype`` + Decltype, as defined in N2343_. + + .. _N2343: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf + ``cxx_delegating_constructors`` Delegating constructors, as defined in N1986_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index c451b7e..de328c4 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -30,5 +30,6 @@ set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}") # http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2555.pdf # TODO: Should be supported by GNU 4.3 set(GNU43_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_decltype "${GNU43_CXX11}") set(_cmake_feature_test_cxx_static_assert "${GNU43_CXX11}") set(_oldestSupported) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 12d88e4..6ce3c16 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -44,6 +44,7 @@ #define FOR_EACH_CXX_FEATURE(F) \ F(cxx_auto_type) \ F(cxx_constexpr) \ + F(cxx_decltype) \ F(cxx_delegating_constructors) \ F(cxx_final) \ F(cxx_override) \ diff --git a/Tests/CompileFeatures/cxx_decltype.cpp b/Tests/CompileFeatures/cxx_decltype.cpp new file mode 100644 index 0000000..24ec51e --- /dev/null +++ b/Tests/CompileFeatures/cxx_decltype.cpp @@ -0,0 +1,7 @@ + +int someFunc() +{ + int i = 0; + decltype(i) other = 0; + return other; +} -- cgit v0.12 From 91f3699000084804100a782e93509a3a53adc2a8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 3 Apr 2014 00:12:02 +0200 Subject: Features: Add cxx_defaulted_functions. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_defaulted_functions.cpp | 9 +++++++++ 4 files changed, 16 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_defaulted_functions.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 97689dc..bf91fbc 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -27,6 +27,11 @@ The features known to this version of CMake are: .. _N2343: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf +``cxx_defaulted_functions`` + Defaulted functions, as defined in N2346_. + + .. _N2346: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm + ``cxx_delegating_constructors`` Delegating constructors, as defined in N1986_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index de328c4..7d3c13b 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -18,6 +18,7 @@ set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}") # TODO: Should be supported by GNU 4.4 set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_defaulted_functions "${GNU44_CXX11}") set(_cmake_feature_test_cxx_strong_enums "${GNU44_CXX11}") set(_cmake_feature_test_cxx_trailing_return_types "${GNU44_CXX11}") set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 6ce3c16..c7c98aa 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -45,6 +45,7 @@ F(cxx_auto_type) \ F(cxx_constexpr) \ F(cxx_decltype) \ + F(cxx_defaulted_functions) \ F(cxx_delegating_constructors) \ F(cxx_final) \ F(cxx_override) \ diff --git a/Tests/CompileFeatures/cxx_defaulted_functions.cpp b/Tests/CompileFeatures/cxx_defaulted_functions.cpp new file mode 100644 index 0000000..b679a92 --- /dev/null +++ b/Tests/CompileFeatures/cxx_defaulted_functions.cpp @@ -0,0 +1,9 @@ + +struct A { + A() = default; +}; + +void someFunc() +{ + A a; +} -- cgit v0.12 From ac3a1b14c0235cb21b1cce445269426e84e46ae1 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 3 Apr 2014 00:15:53 +0200 Subject: Features: Add cxx_deleted_functions. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_deleted_functions.cpp | 6 ++++++ 4 files changed, 13 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_deleted_functions.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index bf91fbc..df80abf 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -37,6 +37,11 @@ The features known to this version of CMake are: .. _N1986: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf +``cxx_deleted_functions`` + Deleted functions, as defined in N2346_. + + .. _N2346: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm + ``cxx_final`` Override control ``final`` keyword, as defined in N2928_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 7d3c13b..f01382f 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -19,6 +19,7 @@ set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}") set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}") set(_cmake_feature_test_cxx_defaulted_functions "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_deleted_functions "${GNU44_CXX11}") set(_cmake_feature_test_cxx_strong_enums "${GNU44_CXX11}") set(_cmake_feature_test_cxx_trailing_return_types "${GNU44_CXX11}") set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c7c98aa..192171f 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -47,6 +47,7 @@ F(cxx_decltype) \ F(cxx_defaulted_functions) \ F(cxx_delegating_constructors) \ + F(cxx_deleted_functions) \ F(cxx_final) \ F(cxx_override) \ F(cxx_static_assert) \ diff --git a/Tests/CompileFeatures/cxx_deleted_functions.cpp b/Tests/CompileFeatures/cxx_deleted_functions.cpp new file mode 100644 index 0000000..4ecb1e9 --- /dev/null +++ b/Tests/CompileFeatures/cxx_deleted_functions.cpp @@ -0,0 +1,6 @@ + +struct A +{ + A(const A&) = delete; + A& operator=(const A&) = delete; +}; -- cgit v0.12 From ebab2015f9b9b11f09e19369be7a1c8d3bfe3ae4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 3 Apr 2014 19:12:26 +0200 Subject: Features: Add cxx_explicit_conversions. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 3 +++ Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_explicit_conversions.cpp | 10 ++++++++++ 4 files changed, 19 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_explicit_conversions.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index df80abf..33e95b5 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -42,6 +42,11 @@ The features known to this version of CMake are: .. _N2346: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm +``cxx_explicit_conversions`` + Explicit conversion operators, as defined in N2437_. + + .. _N2437: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf + ``cxx_final`` Override control ``final`` keyword, as defined in N2928_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index f01382f..30bb171 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -15,6 +15,9 @@ set(_cmake_feature_test_cxx_override "${GNU47_CXX11}") # TODO: Should be supported by GNU 4.6 set(GNU46_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}") +# TODO: Should be supported by GNU 4.5 +set(GNU45_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_explicit_conversions "${GNU45_CXX11}") # TODO: Should be supported by GNU 4.4 set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 192171f..5c4f6ff 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -48,6 +48,7 @@ F(cxx_defaulted_functions) \ F(cxx_delegating_constructors) \ F(cxx_deleted_functions) \ + F(cxx_explicit_conversions) \ F(cxx_final) \ F(cxx_override) \ F(cxx_static_assert) \ diff --git a/Tests/CompileFeatures/cxx_explicit_conversions.cpp b/Tests/CompileFeatures/cxx_explicit_conversions.cpp new file mode 100644 index 0000000..0decdcd --- /dev/null +++ b/Tests/CompileFeatures/cxx_explicit_conversions.cpp @@ -0,0 +1,10 @@ + +class A +{ + int m_i; +public: + explicit operator bool() + { + return m_i != 0; + } +}; -- cgit v0.12 From a579a0aab4e55aeb0a71dc7c1b58db3d126e1fd4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 3 Apr 2014 19:18:01 +0200 Subject: Features: Add cxx_inheriting_constructors. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 2 ++ Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_inheriting_constructors.cpp | 18 ++++++++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_inheriting_constructors.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 33e95b5..41820e0 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -52,6 +52,11 @@ The features known to this version of CMake are: .. _N2928: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm +``cxx_inheriting_constructors`` + Inheriting constructors, as defined in N2540_. + + .. _N2540: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2540.htm + ``cxx_override`` Override control ``override`` keyword, as defined in N2928_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 30bb171..6844e28 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -2,6 +2,8 @@ # Reference: http://gcc.gnu.org/projects/cxx0x.html set(_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408") +set(GNU48_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}") # TODO: Should be supported by GNU 4.7 set(GNU47_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 5c4f6ff..25a6fee 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -50,6 +50,7 @@ F(cxx_deleted_functions) \ F(cxx_explicit_conversions) \ F(cxx_final) \ + F(cxx_inheriting_constructors) \ F(cxx_override) \ F(cxx_static_assert) \ F(cxx_strong_enums) \ diff --git a/Tests/CompileFeatures/cxx_inheriting_constructors.cpp b/Tests/CompileFeatures/cxx_inheriting_constructors.cpp new file mode 100644 index 0000000..a83b624 --- /dev/null +++ b/Tests/CompileFeatures/cxx_inheriting_constructors.cpp @@ -0,0 +1,18 @@ + +struct A +{ + int m_i; + + A(int i) : m_i(i) {} +}; + +struct B : public A +{ + using A::A; +}; + +void someFunc() +{ + int i; + B b(i); +} -- cgit v0.12 From 15cdf6f51dde9a394ffc7a398e201e59cc959111 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 3 Apr 2014 19:23:40 +0200 Subject: Features: Add cxx_lambdas. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_lambdas.cpp | 5 +++++ 4 files changed, 12 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_lambdas.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 41820e0..9441e57 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -57,6 +57,11 @@ The features known to this version of CMake are: .. _N2540: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2540.htm +``cxx_lambdas`` + Lambda functions, as defined in N2927_. + + .. _N2927: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2927.pdf + ``cxx_override`` Override control ``override`` keyword, as defined in N2928_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 6844e28..f182cea 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -20,6 +20,7 @@ set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}") # TODO: Should be supported by GNU 4.5 set(GNU45_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_explicit_conversions "${GNU45_CXX11}") +set(_cmake_feature_test_cxx_lambdas "${GNU45_CXX11}") # TODO: Should be supported by GNU 4.4 set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 25a6fee..9352ca5 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -51,6 +51,7 @@ F(cxx_explicit_conversions) \ F(cxx_final) \ F(cxx_inheriting_constructors) \ + F(cxx_lambdas) \ F(cxx_override) \ F(cxx_static_assert) \ F(cxx_strong_enums) \ diff --git a/Tests/CompileFeatures/cxx_lambdas.cpp b/Tests/CompileFeatures/cxx_lambdas.cpp new file mode 100644 index 0000000..eecaa23 --- /dev/null +++ b/Tests/CompileFeatures/cxx_lambdas.cpp @@ -0,0 +1,5 @@ + +void someFunc() +{ + [](){}(); +} -- cgit v0.12 From bd2a025eb0ec26dc32d6eb4c9c3da22f68608b27 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 3 Apr 2014 19:29:17 +0200 Subject: Features: Add cxx_nonstatic_member_init. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_nonstatic_member_init.cpp | 4 ++++ 4 files changed, 11 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_nonstatic_member_init.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 9441e57..373b67f 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -62,6 +62,11 @@ The features known to this version of CMake are: .. _N2927: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2927.pdf +``cxx_nonstatic_member_init`` + Non-static data member initialization, as defined in N2756. + + .. _N2756: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2756.htm + ``cxx_override`` Override control ``override`` keyword, as defined in N2928_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index f182cea..b291524 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -8,6 +8,7 @@ set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}") set(GNU47_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}") set(_cmake_feature_test_cxx_final "${GNU47_CXX11}") +set(_cmake_feature_test_cxx_nonstatic_member_init "${GNU47_CXX11}") set(_cmake_feature_test_cxx_override "${GNU47_CXX11}") # NOTE: C++11 was ratified in September 2011. GNU 4.7 is the first minor # release following that (March 2012), and the first minor release to diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9352ca5..2a55fde 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -52,6 +52,7 @@ F(cxx_final) \ F(cxx_inheriting_constructors) \ F(cxx_lambdas) \ + F(cxx_nonstatic_member_init) \ F(cxx_override) \ F(cxx_static_assert) \ F(cxx_strong_enums) \ diff --git a/Tests/CompileFeatures/cxx_nonstatic_member_init.cpp b/Tests/CompileFeatures/cxx_nonstatic_member_init.cpp new file mode 100644 index 0000000..6b7fa70 --- /dev/null +++ b/Tests/CompileFeatures/cxx_nonstatic_member_init.cpp @@ -0,0 +1,4 @@ +class A +{ + int m_i = 42; +}; -- cgit v0.12 From 8149fc909fb2c26235fea8999ea9396d7b45fba7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 3 Apr 2014 19:32:06 +0200 Subject: Features: Add cxx_noexcept. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_noexcept.cpp | 5 +++++ 4 files changed, 12 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_noexcept.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 373b67f..ee383ef 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -62,6 +62,11 @@ The features known to this version of CMake are: .. _N2927: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2927.pdf +``cxx_noexcept`` + Exception specifications, as defined in N3050_. + + .. _N3050: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3050.html + ``cxx_nonstatic_member_init`` Non-static data member initialization, as defined in N2756. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index b291524..c7de17b 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -8,6 +8,7 @@ set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}") set(GNU47_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}") set(_cmake_feature_test_cxx_final "${GNU47_CXX11}") +set(_cmake_feature_test_cxx_noexcept "${GNU47_CXX11}") set(_cmake_feature_test_cxx_nonstatic_member_init "${GNU47_CXX11}") set(_cmake_feature_test_cxx_override "${GNU47_CXX11}") # NOTE: C++11 was ratified in September 2011. GNU 4.7 is the first minor diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2a55fde..90187fd 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -52,6 +52,7 @@ F(cxx_final) \ F(cxx_inheriting_constructors) \ F(cxx_lambdas) \ + F(cxx_noexcept) \ F(cxx_nonstatic_member_init) \ F(cxx_override) \ F(cxx_static_assert) \ diff --git a/Tests/CompileFeatures/cxx_noexcept.cpp b/Tests/CompileFeatures/cxx_noexcept.cpp new file mode 100644 index 0000000..a3c05b8 --- /dev/null +++ b/Tests/CompileFeatures/cxx_noexcept.cpp @@ -0,0 +1,5 @@ + +void someFunc() noexcept +{ + +} -- cgit v0.12 From 0fa9bbf1fa5278d965cbbb7de82f56ef42789fe8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 3 Apr 2014 19:34:47 +0200 Subject: Features: Add cxx_nullptr. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_nullptr.cpp | 10 ++++++++++ 4 files changed, 17 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_nullptr.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index ee383ef..8924a00 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -72,6 +72,11 @@ The features known to this version of CMake are: .. _N2756: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2756.htm +``cxx_nullptr`` + Null pointer, as defined in N2431_. + + .. _N2431: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf + ``cxx_override`` Override control ``override`` keyword, as defined in N2928_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index c7de17b..4539fd6 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -19,6 +19,7 @@ set(_cmake_feature_test_cxx_override "${GNU47_CXX11}") # TODO: Should be supported by GNU 4.6 set(GNU46_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}") +set(_cmake_feature_test_cxx_nullptr "${GNU46_CXX11}") # TODO: Should be supported by GNU 4.5 set(GNU45_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_explicit_conversions "${GNU45_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 90187fd..c56627f 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -54,6 +54,7 @@ F(cxx_lambdas) \ F(cxx_noexcept) \ F(cxx_nonstatic_member_init) \ + F(cxx_nullptr) \ F(cxx_override) \ F(cxx_static_assert) \ F(cxx_strong_enums) \ diff --git a/Tests/CompileFeatures/cxx_nullptr.cpp b/Tests/CompileFeatures/cxx_nullptr.cpp new file mode 100644 index 0000000..96307df --- /dev/null +++ b/Tests/CompileFeatures/cxx_nullptr.cpp @@ -0,0 +1,10 @@ + +void someFunc(int*) +{ + +} + +void otherFunc() +{ + someFunc(nullptr); +} -- cgit v0.12 From 735adf2c94c1ee0cca710c6eb0bade2b84c461de Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 3 Apr 2014 19:40:06 +0200 Subject: Features: Add cxx_range_for. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_range_for.cpp | 10 ++++++++++ 4 files changed, 17 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_range_for.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 8924a00..b8af28f 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -82,6 +82,11 @@ The features known to this version of CMake are: .. _N2928: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm +``cxx_range_for`` + Range-based for, as defined in N2930_. + + .. _N2930: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2930.html + ``cxx_static_assert`` Static assert, as defined in N1720_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 4539fd6..c48fca8 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -20,6 +20,7 @@ set(_cmake_feature_test_cxx_override "${GNU47_CXX11}") set(GNU46_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}") set(_cmake_feature_test_cxx_nullptr "${GNU46_CXX11}") +set(_cmake_feature_test_cxx_range_for "${GNU46_CXX11}") # TODO: Should be supported by GNU 4.5 set(GNU45_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_explicit_conversions "${GNU45_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c56627f..b1f6cd0 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -56,6 +56,7 @@ F(cxx_nonstatic_member_init) \ F(cxx_nullptr) \ F(cxx_override) \ + F(cxx_range_for) \ F(cxx_static_assert) \ F(cxx_strong_enums) \ F(cxx_trailing_return_types) \ diff --git a/Tests/CompileFeatures/cxx_range_for.cpp b/Tests/CompileFeatures/cxx_range_for.cpp new file mode 100644 index 0000000..892109e --- /dev/null +++ b/Tests/CompileFeatures/cxx_range_for.cpp @@ -0,0 +1,10 @@ + +void someFunc() +{ + int accumulated = 0; + int numbers[] = { 1, 2, 5 }; + for (int i : numbers) + { + accumulated += i; + } +} -- cgit v0.12 From ea9c445f066589067992694cb6abc0d70ad97dd7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 09:15:18 +0200 Subject: Features: Add cxx_raw_string_literals. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_raw_string_literals.cpp | 7 +++++++ 4 files changed, 14 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_raw_string_literals.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index b8af28f..e482fe3 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -87,6 +87,11 @@ The features known to this version of CMake are: .. _N2930: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2930.html +``cxx_raw_string_literals`` + Raw string literals, as defined in N2442_. + + .. _N2442: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm + ``cxx_static_assert`` Static assert, as defined in N1720_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index c48fca8..5c1f2c8 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -25,6 +25,7 @@ set(_cmake_feature_test_cxx_range_for "${GNU46_CXX11}") set(GNU45_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_explicit_conversions "${GNU45_CXX11}") set(_cmake_feature_test_cxx_lambdas "${GNU45_CXX11}") +set(_cmake_feature_test_cxx_raw_string_literals "${GNU45_CXX11}") # TODO: Should be supported by GNU 4.4 set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index b1f6cd0..2a10f1e 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -57,6 +57,7 @@ F(cxx_nullptr) \ F(cxx_override) \ F(cxx_range_for) \ + F(cxx_raw_string_literals) \ F(cxx_static_assert) \ F(cxx_strong_enums) \ F(cxx_trailing_return_types) \ diff --git a/Tests/CompileFeatures/cxx_raw_string_literals.cpp b/Tests/CompileFeatures/cxx_raw_string_literals.cpp new file mode 100644 index 0000000..ea4d231 --- /dev/null +++ b/Tests/CompileFeatures/cxx_raw_string_literals.cpp @@ -0,0 +1,7 @@ + +void someFunc() +{ +const char p[] = R"(a\ +b +c)"; +} -- cgit v0.12 From b1c5bd531417b74ddb2cb4365c49f0723c7a8e75 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 09:25:46 +0200 Subject: Features: Add cxx_reference_qualified_functions. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 3 +++ Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_reference_qualified_functions.cpp | 11 +++++++++++ 4 files changed, 20 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_reference_qualified_functions.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index e482fe3..13ead96 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -92,6 +92,11 @@ The features known to this version of CMake are: .. _N2442: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm +``cxx_reference_qualified_functions`` + Reference qualified functions, as defined in N2439_. + + .. _N2439: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm + ``cxx_static_assert`` Static assert, as defined in N1720_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 5c1f2c8..b9ed092 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -2,6 +2,9 @@ # Reference: http://gcc.gnu.org/projects/cxx0x.html set(_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408") +# Introduced in GCC 4.8.1 +set(_cmake_feature_test_cxx_reference_qualified_functions + "((__GNUC__ * 100 + __GNUC_MINOR__) > 408 || __GNUC_PATCHLEVEL__ >= 1) && __cplusplus >= 201103L") set(GNU48_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}") # TODO: Should be supported by GNU 4.7 diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2a10f1e..0cca2d6 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -58,6 +58,7 @@ F(cxx_override) \ F(cxx_range_for) \ F(cxx_raw_string_literals) \ + F(cxx_reference_qualified_functions) \ F(cxx_static_assert) \ F(cxx_strong_enums) \ F(cxx_trailing_return_types) \ diff --git a/Tests/CompileFeatures/cxx_reference_qualified_functions.cpp b/Tests/CompileFeatures/cxx_reference_qualified_functions.cpp new file mode 100644 index 0000000..83a2361 --- /dev/null +++ b/Tests/CompileFeatures/cxx_reference_qualified_functions.cpp @@ -0,0 +1,11 @@ + +struct test{ + void f() & { } + void f() && { } +}; + +void someFunc(){ + test t; + t.f(); // lvalue + test().f(); // rvalue +} -- cgit v0.12 From 3300f783104b89c00bde1904e5528e9564c479a2 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 09:39:40 +0200 Subject: Features: Add cxx_rvalue_references. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_rvalue_references.cpp | 5 +++++ 4 files changed, 12 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_rvalue_references.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 13ead96..bdcd46b 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -97,6 +97,11 @@ The features known to this version of CMake are: .. _N2439: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm +``cxx_rvalue_references`` + R-value references, as defined in N2118_. + + .. _N2118: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2118.html + ``cxx_static_assert`` Static assert, as defined in N1720_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index b9ed092..5bf3420 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -47,5 +47,6 @@ set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}") # TODO: Should be supported by GNU 4.3 set(GNU43_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_decltype "${GNU43_CXX11}") +set(_cmake_feature_test_cxx_rvalue_references "${GNU43_CXX11}") set(_cmake_feature_test_cxx_static_assert "${GNU43_CXX11}") set(_oldestSupported) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 0cca2d6..d632db6 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -59,6 +59,7 @@ F(cxx_range_for) \ F(cxx_raw_string_literals) \ F(cxx_reference_qualified_functions) \ + F(cxx_rvalue_references) \ F(cxx_static_assert) \ F(cxx_strong_enums) \ F(cxx_trailing_return_types) \ diff --git a/Tests/CompileFeatures/cxx_rvalue_references.cpp b/Tests/CompileFeatures/cxx_rvalue_references.cpp new file mode 100644 index 0000000..787026a --- /dev/null +++ b/Tests/CompileFeatures/cxx_rvalue_references.cpp @@ -0,0 +1,5 @@ + +void someFunc(int&&) +{ + +} -- cgit v0.12 From e1e292cd069bf811b0635088539aace0f0eeaf68 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 10:50:41 +0200 Subject: Features: Add cxx_alias_templates. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_alias_templates.cpp | 11 +++++++++++ 4 files changed, 18 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_alias_templates.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index bdcd46b..fbc45c2 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -12,6 +12,11 @@ command. The features known to this version of CMake are: +``cxx_alias_templates`` + Template aliases, as defined in N2258_. + + .. _N2258: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf + ``cxx_auto_type`` Automatic type deduction, as defined in N1984_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 5bf3420..5f8d952 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -9,6 +9,7 @@ set(GNU48_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 2011 set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}") # TODO: Should be supported by GNU 4.7 set(GNU47_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_alias_templates "${GNU47_CXX11}") set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}") set(_cmake_feature_test_cxx_final "${GNU47_CXX11}") set(_cmake_feature_test_cxx_noexcept "${GNU47_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index d632db6..fc89d8e 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -42,6 +42,7 @@ #include #define FOR_EACH_CXX_FEATURE(F) \ + F(cxx_alias_templates) \ F(cxx_auto_type) \ F(cxx_constexpr) \ F(cxx_decltype) \ diff --git a/Tests/CompileFeatures/cxx_alias_templates.cpp b/Tests/CompileFeatures/cxx_alias_templates.cpp new file mode 100644 index 0000000..a47e27d --- /dev/null +++ b/Tests/CompileFeatures/cxx_alias_templates.cpp @@ -0,0 +1,11 @@ + +template +struct A +{ + typedef T1 MyT1; + using MyT2 = T2; +}; + +using B = A; +template +using C = A; -- cgit v0.12 From 04c5b99f38aef9a5c9627c35659891aecd8ab41e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 10:56:09 +0200 Subject: Features: Add cxx_user_literals. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_user_literals.cpp | 7 +++++++ 4 files changed, 14 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_user_literals.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index fbc45c2..1ea3b68 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -122,6 +122,11 @@ The features known to this version of CMake are: .. _N2541: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2541.htm +``cxx_user_literals`` + User-defined literals, as defined in N2765_. + + .. _N2765: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf + ``cxx_variadic_templates`` Variadic templates, as defined in N2242_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 5f8d952..12d2adc 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -15,6 +15,7 @@ set(_cmake_feature_test_cxx_final "${GNU47_CXX11}") set(_cmake_feature_test_cxx_noexcept "${GNU47_CXX11}") set(_cmake_feature_test_cxx_nonstatic_member_init "${GNU47_CXX11}") set(_cmake_feature_test_cxx_override "${GNU47_CXX11}") +set(_cmake_feature_test_cxx_user_literals "${GNU47_CXX11}") # NOTE: C++11 was ratified in September 2011. GNU 4.7 is the first minor # release following that (March 2012), and the first minor release to # support -std=c++11. Prior to that, support for C++11 features is technically diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index fc89d8e..bcd192d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -64,6 +64,7 @@ F(cxx_static_assert) \ F(cxx_strong_enums) \ F(cxx_trailing_return_types) \ + F(cxx_user_literals) \ F(cxx_variadic_templates) class cmMakefile::Internals diff --git a/Tests/CompileFeatures/cxx_user_literals.cpp b/Tests/CompileFeatures/cxx_user_literals.cpp new file mode 100644 index 0000000..9e5a588 --- /dev/null +++ b/Tests/CompileFeatures/cxx_user_literals.cpp @@ -0,0 +1,7 @@ + +long double operator "" _meters(long double); + +void someFunc() +{ + long double i = 1.2_meters; +} -- cgit v0.12 From 3322b393a265747ae7c187d426f7f1676b478de4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 10:59:22 +0200 Subject: Features: Add cxx_unicode_literals. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_unicode_literals.cpp | 3 +++ 4 files changed, 10 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_unicode_literals.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 1ea3b68..07defb3 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -122,6 +122,11 @@ The features known to this version of CMake are: .. _N2541: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2541.htm +``cxx_unicode_literals`` + Unicode string literals, as defined in N2442_. + + .. _N2442: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm + ``cxx_user_literals`` User-defined literals, as defined in N2765_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 12d2adc..44af004 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -38,6 +38,7 @@ set(_cmake_feature_test_cxx_defaulted_functions "${GNU44_CXX11}") set(_cmake_feature_test_cxx_deleted_functions "${GNU44_CXX11}") set(_cmake_feature_test_cxx_strong_enums "${GNU44_CXX11}") set(_cmake_feature_test_cxx_trailing_return_types "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_unicode_literals "${GNU44_CXX11}") set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}") # TODO: If features are ever recorded for GNU 4.3, there should possibly # be a new feature added like cxx_variadic_template_template_parameters, diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index bcd192d..993dcce 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -64,6 +64,7 @@ F(cxx_static_assert) \ F(cxx_strong_enums) \ F(cxx_trailing_return_types) \ + F(cxx_unicode_literals) \ F(cxx_user_literals) \ F(cxx_variadic_templates) diff --git a/Tests/CompileFeatures/cxx_unicode_literals.cpp b/Tests/CompileFeatures/cxx_unicode_literals.cpp new file mode 100644 index 0000000..a7b7df0 --- /dev/null +++ b/Tests/CompileFeatures/cxx_unicode_literals.cpp @@ -0,0 +1,3 @@ + +const char16_t lit_16[] = u"\u00DA"; +const char32_t lit_32[] = U"\u00DA"; -- cgit v0.12 From 9064f78b0c07a79f25ee04cf8afaf726d18ec722 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 11:06:02 +0200 Subject: Features: Add cxx_unrestricted_unions. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_unrestricted_unions.cpp | 11 +++++++++++ 4 files changed, 18 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_unrestricted_unions.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 07defb3..0a2f23c 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -127,6 +127,11 @@ The features known to this version of CMake are: .. _N2442: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm +``cxx_unrestricted_unions`` + Unrestricted unions, as defined in N2544_. + + .. _N2544: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf + ``cxx_user_literals`` User-defined literals, as defined in N2765_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 44af004..bd3e96e 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -26,6 +26,7 @@ set(GNU46_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}") set(_cmake_feature_test_cxx_nullptr "${GNU46_CXX11}") set(_cmake_feature_test_cxx_range_for "${GNU46_CXX11}") +set(_cmake_feature_test_cxx_unrestricted_unions "${GNU46_CXX11}") # TODO: Should be supported by GNU 4.5 set(GNU45_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_explicit_conversions "${GNU45_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 993dcce..aa9b7c7 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -65,6 +65,7 @@ F(cxx_strong_enums) \ F(cxx_trailing_return_types) \ F(cxx_unicode_literals) \ + F(cxx_unrestricted_unions) \ F(cxx_user_literals) \ F(cxx_variadic_templates) diff --git a/Tests/CompileFeatures/cxx_unrestricted_unions.cpp b/Tests/CompileFeatures/cxx_unrestricted_unions.cpp new file mode 100644 index 0000000..698fd61 --- /dev/null +++ b/Tests/CompileFeatures/cxx_unrestricted_unions.cpp @@ -0,0 +1,11 @@ + +struct point { + point() {} + point(int x, int y) : x_(x), y_(y) {} + int x_, y_; +}; +union u { + point p_; + int i_; + const char* s_; +}; -- cgit v0.12 From 32c2acd65c3d48433a50a6c2f9fc00c2a1a699f4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 13:11:37 +0200 Subject: Features: Add cxx_extern_templates. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 2 ++ Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_extern_templates.cpp | 12 ++++++++++++ 4 files changed, 20 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_extern_templates.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 0a2f23c..6c4bc15 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -52,6 +52,11 @@ The features known to this version of CMake are: .. _N2437: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf +``cxx_extern_templates`` + Extern templates, as defined in N1987_. + + .. _N1987: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1987.htm + ``cxx_final`` Override control ``final`` keyword, as defined in N2928_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index bd3e96e..ee7f2e4 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -53,4 +53,6 @@ set(GNU43_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_decltype "${GNU43_CXX11}") set(_cmake_feature_test_cxx_rvalue_references "${GNU43_CXX11}") set(_cmake_feature_test_cxx_static_assert "${GNU43_CXX11}") +# TODO: Should be supported since GNU 3.4? +set(_cmake_feature_test_cxx_extern_templates "${_oldestSupported} && __cplusplus >= 201103L") set(_oldestSupported) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index aa9b7c7..1803afe 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -50,6 +50,7 @@ F(cxx_delegating_constructors) \ F(cxx_deleted_functions) \ F(cxx_explicit_conversions) \ + F(cxx_extern_templates) \ F(cxx_final) \ F(cxx_inheriting_constructors) \ F(cxx_lambdas) \ diff --git a/Tests/CompileFeatures/cxx_extern_templates.cpp b/Tests/CompileFeatures/cxx_extern_templates.cpp new file mode 100644 index 0000000..9fa4aa4 --- /dev/null +++ b/Tests/CompileFeatures/cxx_extern_templates.cpp @@ -0,0 +1,12 @@ + +template +void someFunc() +{ +} + +extern template void someFunc(); + +void otherFunc() +{ + someFunc(); +} -- cgit v0.12 From e7d6e1f44f0f3bcf7ded76ec8d649b7a0552778c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 13:54:08 +0200 Subject: Features: Add cxx_alignas. cxx_alignof will be a separate feature known to CMake, because both can be implemented with separate backward compatibility versions. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_alignas.cpp | 4 ++++ 4 files changed, 11 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_alignas.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 6c4bc15..043863f 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -17,6 +17,11 @@ The features known to this version of CMake are: .. _N2258: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf +``cxx_alignas`` + Alignment control ``alignas``, as defined in N2341_. + + .. _N2341: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf + ``cxx_auto_type`` Automatic type deduction, as defined in N1984_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index ee7f2e4..86d5557 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -6,6 +6,7 @@ set(_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408") set(_cmake_feature_test_cxx_reference_qualified_functions "((__GNUC__ * 100 + __GNUC_MINOR__) > 408 || __GNUC_PATCHLEVEL__ >= 1) && __cplusplus >= 201103L") set(GNU48_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_alignas "${GNU48_CXX11}") set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}") # TODO: Should be supported by GNU 4.7 set(GNU47_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 1803afe..b1dd721 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -43,6 +43,7 @@ #define FOR_EACH_CXX_FEATURE(F) \ F(cxx_alias_templates) \ + F(cxx_alignas) \ F(cxx_auto_type) \ F(cxx_constexpr) \ F(cxx_decltype) \ diff --git a/Tests/CompileFeatures/cxx_alignas.cpp b/Tests/CompileFeatures/cxx_alignas.cpp new file mode 100644 index 0000000..35b7c82 --- /dev/null +++ b/Tests/CompileFeatures/cxx_alignas.cpp @@ -0,0 +1,4 @@ + +struct S1 { + alignas(8) int n; +}; -- cgit v0.12 From 7605fee593a00e0345a4842241ff1f2a043b7ebf Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 13:55:27 +0200 Subject: Features: Add cxx_alignof. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_alignof.cpp | 5 +++++ 4 files changed, 12 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_alignof.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 043863f..7e10853 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -22,6 +22,11 @@ The features known to this version of CMake are: .. _N2341: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf +``cxx_alignof`` + Alignment control ``alignof``, as defined in N2341_. + + .. _N2341: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf + ``cxx_auto_type`` Automatic type deduction, as defined in N1984_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 86d5557..26b7ff6 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -7,6 +7,7 @@ set(_cmake_feature_test_cxx_reference_qualified_functions "((__GNUC__ * 100 + __GNUC_MINOR__) > 408 || __GNUC_PATCHLEVEL__ >= 1) && __cplusplus >= 201103L") set(GNU48_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_alignas "${GNU48_CXX11}") +set(_cmake_feature_test_cxx_alignof "${GNU48_CXX11}") set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}") # TODO: Should be supported by GNU 4.7 set(GNU47_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index b1dd721..2b76d45 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -44,6 +44,7 @@ #define FOR_EACH_CXX_FEATURE(F) \ F(cxx_alias_templates) \ F(cxx_alignas) \ + F(cxx_alignof) \ F(cxx_auto_type) \ F(cxx_constexpr) \ F(cxx_decltype) \ diff --git a/Tests/CompileFeatures/cxx_alignof.cpp b/Tests/CompileFeatures/cxx_alignof.cpp new file mode 100644 index 0000000..63b14fe --- /dev/null +++ b/Tests/CompileFeatures/cxx_alignof.cpp @@ -0,0 +1,5 @@ + +int someFunc() +{ + return alignof(int); +} -- cgit v0.12 From ff80c3b4201918c2f30241972d3553a99571eed8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 14:10:17 +0200 Subject: Features: Add cxx_attributes. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_attributes.cpp | 2 ++ 4 files changed, 9 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_attributes.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 7e10853..05fc1bd 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -27,6 +27,11 @@ The features known to this version of CMake are: .. _N2341: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf +``cxx_attributes`` + Generic attributes, as defined in N2761_. + + .. _N2761: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf + ``cxx_auto_type`` Automatic type deduction, as defined in N1984_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 26b7ff6..be3c27e 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -8,6 +8,7 @@ set(_cmake_feature_test_cxx_reference_qualified_functions set(GNU48_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_alignas "${GNU48_CXX11}") set(_cmake_feature_test_cxx_alignof "${GNU48_CXX11}") +set(_cmake_feature_test_cxx_attributes "${GNU48_CXX11}") set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}") # TODO: Should be supported by GNU 4.7 set(GNU47_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2b76d45..63c00cc 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -45,6 +45,7 @@ F(cxx_alias_templates) \ F(cxx_alignas) \ F(cxx_alignof) \ + F(cxx_attributes) \ F(cxx_auto_type) \ F(cxx_constexpr) \ F(cxx_decltype) \ diff --git a/Tests/CompileFeatures/cxx_attributes.cpp b/Tests/CompileFeatures/cxx_attributes.cpp new file mode 100644 index 0000000..a3c89ea --- /dev/null +++ b/Tests/CompileFeatures/cxx_attributes.cpp @@ -0,0 +1,2 @@ + +void unusedFunc [[noreturn]] () { throw 1; } -- cgit v0.12 From e74b216c90d33548e7b248276346a5d00eff5ee3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 14:52:48 +0200 Subject: Features: Add cxx_generalized_initializers. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + .../cxx_generalized_initializers.cpp | 23 ++++++++++++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_generalized_initializers.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 05fc1bd..9329968 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -77,6 +77,11 @@ The features known to this version of CMake are: .. _N2928: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm +``cxx_generalized_initializers`` + Initializer lists, as defined in N2672_. + + .. _N2672: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm + ``cxx_inheriting_constructors`` Inheriting constructors, as defined in N2540_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index be3c27e..fcdffac 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -40,6 +40,7 @@ set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}") set(_cmake_feature_test_cxx_defaulted_functions "${GNU44_CXX11}") set(_cmake_feature_test_cxx_deleted_functions "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_generalized_initializers "${GNU44_CXX11}") set(_cmake_feature_test_cxx_strong_enums "${GNU44_CXX11}") set(_cmake_feature_test_cxx_trailing_return_types "${GNU44_CXX11}") set(_cmake_feature_test_cxx_unicode_literals "${GNU44_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 63c00cc..c1d276e 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -55,6 +55,7 @@ F(cxx_explicit_conversions) \ F(cxx_extern_templates) \ F(cxx_final) \ + F(cxx_generalized_initializers) \ F(cxx_inheriting_constructors) \ F(cxx_lambdas) \ F(cxx_noexcept) \ diff --git a/Tests/CompileFeatures/cxx_generalized_initializers.cpp b/Tests/CompileFeatures/cxx_generalized_initializers.cpp new file mode 100644 index 0000000..8013ef5 --- /dev/null +++ b/Tests/CompileFeatures/cxx_generalized_initializers.cpp @@ -0,0 +1,23 @@ + +// Dummy implementation. Test only the compiler feature. +namespace std { + typedef decltype(sizeof(int)) size_t; + template + class initializer_list + { + const _E* __begin_; + size_t __size_; + + }; +} + +template +struct A +{ + A(std::initializer_list) {} +}; + +void someFunc() +{ + A as = { 1, 2, 3, 4 }; +} -- cgit v0.12 From 3d76656fb3db56f364bbf7a7655ab1433b72d284 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 14:53:25 +0200 Subject: Features: Add cxx_uniform_initialization. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_uniform_initialization.cpp | 9 +++++++++ 4 files changed, 16 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_uniform_initialization.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 9329968..55521d9 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -152,6 +152,11 @@ The features known to this version of CMake are: .. _N2442: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm +``cxx_uniform_initialization`` + Uniform intialization, as defined in N2640_. + + .. _N2640: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2640.pdf + ``cxx_unrestricted_unions`` Unrestricted unions, as defined in N2544_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index fcdffac..a3b4339 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -44,6 +44,7 @@ set(_cmake_feature_test_cxx_generalized_initializers "${GNU44_CXX11}") set(_cmake_feature_test_cxx_strong_enums "${GNU44_CXX11}") set(_cmake_feature_test_cxx_trailing_return_types "${GNU44_CXX11}") set(_cmake_feature_test_cxx_unicode_literals "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_uniform_initialization "${GNU44_CXX11}") set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}") # TODO: If features are ever recorded for GNU 4.3, there should possibly # be a new feature added like cxx_variadic_template_template_parameters, diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c1d276e..65f9594 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -70,6 +70,7 @@ F(cxx_strong_enums) \ F(cxx_trailing_return_types) \ F(cxx_unicode_literals) \ + F(cxx_uniform_initialization) \ F(cxx_unrestricted_unions) \ F(cxx_user_literals) \ F(cxx_variadic_templates) diff --git a/Tests/CompileFeatures/cxx_uniform_initialization.cpp b/Tests/CompileFeatures/cxx_uniform_initialization.cpp new file mode 100644 index 0000000..82c76e2 --- /dev/null +++ b/Tests/CompileFeatures/cxx_uniform_initialization.cpp @@ -0,0 +1,9 @@ +struct A {}; +struct B { + B(A) {} +}; + +void Func() +{ + B b{A{}}; +} -- cgit v0.12 From f9d04a96b57ad5f68259b978983289043ae22716 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 15:05:10 +0200 Subject: Features: Add cxx_variadic_macros. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 2 ++ Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_variadic_macros.cpp | 12 ++++++++++++ 4 files changed, 20 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_variadic_macros.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 55521d9..7b94560 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -167,6 +167,11 @@ The features known to this version of CMake are: .. _N2765: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf +``cxx_variadic_macros`` + Variadic macros, as defined in N1653_. + + .. _N1653: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1653.htm + ``cxx_variadic_templates`` Variadic templates, as defined in N2242_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index a3b4339..df34b7a 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -60,4 +60,6 @@ set(_cmake_feature_test_cxx_rvalue_references "${GNU43_CXX11}") set(_cmake_feature_test_cxx_static_assert "${GNU43_CXX11}") # TODO: Should be supported since GNU 3.4? set(_cmake_feature_test_cxx_extern_templates "${_oldestSupported} && __cplusplus >= 201103L") +# TODO: Should be supported forever? +set(_cmake_feature_test_cxx_variadic_macros "${_oldestSupported} && __cplusplus >= 201103L") set(_oldestSupported) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 65f9594..a5a76c8 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -73,6 +73,7 @@ F(cxx_uniform_initialization) \ F(cxx_unrestricted_unions) \ F(cxx_user_literals) \ + F(cxx_variadic_macros) \ F(cxx_variadic_templates) class cmMakefile::Internals diff --git a/Tests/CompileFeatures/cxx_variadic_macros.cpp b/Tests/CompileFeatures/cxx_variadic_macros.cpp new file mode 100644 index 0000000..4d007a5 --- /dev/null +++ b/Tests/CompileFeatures/cxx_variadic_macros.cpp @@ -0,0 +1,12 @@ + +int someFunc(int, char, int) +{ + return 0; +} + +#define FUNC_WRAPPER(...) someFunc(__VA_ARGS__) + +void otherFunc() +{ + FUNC_WRAPPER(42, 'a', 7); +} -- cgit v0.12 From 300ce2481eae64f44ca4a4bec4f975db4f3e16c8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Apr 2014 10:07:19 +0200 Subject: Features: Add cxx_inline_namespaces. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_inline_namespaces.cpp | 26 +++++++++++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_inline_namespaces.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 7b94560..f419366 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -87,6 +87,11 @@ The features known to this version of CMake are: .. _N2540: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2540.htm +``cxx_inline_namespaces`` + Inline namespaces, as defined in N2535_. + + .. _N2535: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2535.htm + ``cxx_lambdas`` Lambda functions, as defined in N2927_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index df34b7a..73cd145 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -41,6 +41,7 @@ set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}") set(_cmake_feature_test_cxx_defaulted_functions "${GNU44_CXX11}") set(_cmake_feature_test_cxx_deleted_functions "${GNU44_CXX11}") set(_cmake_feature_test_cxx_generalized_initializers "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_inline_namespaces "${GNU44_CXX11}") set(_cmake_feature_test_cxx_strong_enums "${GNU44_CXX11}") set(_cmake_feature_test_cxx_trailing_return_types "${GNU44_CXX11}") set(_cmake_feature_test_cxx_unicode_literals "${GNU44_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index a5a76c8..2f2747d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -57,6 +57,7 @@ F(cxx_final) \ F(cxx_generalized_initializers) \ F(cxx_inheriting_constructors) \ + F(cxx_inline_namespaces) \ F(cxx_lambdas) \ F(cxx_noexcept) \ F(cxx_nonstatic_member_init) \ diff --git a/Tests/CompileFeatures/cxx_inline_namespaces.cpp b/Tests/CompileFeatures/cxx_inline_namespaces.cpp new file mode 100644 index 0000000..59fa9c8 --- /dev/null +++ b/Tests/CompileFeatures/cxx_inline_namespaces.cpp @@ -0,0 +1,26 @@ +namespace Lib +{ +inline namespace Lib_1 +{ + template class A; +} + +template void g(T); +} + +struct MyClass { + +}; +namespace Lib +{ +template<> +class A { + +}; +} + +void someFunc() +{ + Lib::A a; + g(a); // ok, Lib is an associated namespace of A +} -- cgit v0.12 From ab455ebafd55653f87168d9e6c32cfc15403a973 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Apr 2014 10:10:54 +0200 Subject: Features: Add cxx_thread_local. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_thread_local.cpp | 2 ++ 4 files changed, 9 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_thread_local.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index f419366..b544d7e 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -147,6 +147,11 @@ The features known to this version of CMake are: .. _N2347: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf +``cxx_thread_local`` + Thread-local variables, as defined in N2659_. + + .. _N2659: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2659.htm + ``cxx_trailing_return_types`` Automatic function return type, as defined in N2541_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 73cd145..1f56ace 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -10,6 +10,7 @@ set(_cmake_feature_test_cxx_alignas "${GNU48_CXX11}") set(_cmake_feature_test_cxx_alignof "${GNU48_CXX11}") set(_cmake_feature_test_cxx_attributes "${GNU48_CXX11}") set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}") +set(_cmake_feature_test_cxx_thread_local "${GNU48_CXX11}") # TODO: Should be supported by GNU 4.7 set(GNU47_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_alias_templates "${GNU47_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2f2747d..6d2a576 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -69,6 +69,7 @@ F(cxx_rvalue_references) \ F(cxx_static_assert) \ F(cxx_strong_enums) \ + F(cxx_thread_local) \ F(cxx_trailing_return_types) \ F(cxx_unicode_literals) \ F(cxx_uniform_initialization) \ diff --git a/Tests/CompileFeatures/cxx_thread_local.cpp b/Tests/CompileFeatures/cxx_thread_local.cpp new file mode 100644 index 0000000..1fb27e2 --- /dev/null +++ b/Tests/CompileFeatures/cxx_thread_local.cpp @@ -0,0 +1,2 @@ + +thread_local unsigned int rage = 1; -- cgit v0.12 From 1889045ca672e295c18203401c27a9e62ff45424 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Apr 2014 10:09:37 +0200 Subject: Features: Add cxx_sizeof_member. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_sizeof_member.cpp | 10 ++++++++++ 4 files changed, 17 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_sizeof_member.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index b544d7e..a16dced 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -137,6 +137,11 @@ The features known to this version of CMake are: .. _N2118: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2118.html +``cxx_sizeof_member`` + Size of non-static data members, as defined in N2253_. + + .. _N2253: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2253.html + ``cxx_static_assert`` Static assert, as defined in N1720_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 1f56ace..a98ae3a 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -43,6 +43,7 @@ set(_cmake_feature_test_cxx_defaulted_functions "${GNU44_CXX11}") set(_cmake_feature_test_cxx_deleted_functions "${GNU44_CXX11}") set(_cmake_feature_test_cxx_generalized_initializers "${GNU44_CXX11}") set(_cmake_feature_test_cxx_inline_namespaces "${GNU44_CXX11}") +set(_cmake_feature_test_cxx_sizeof_member "${GNU44_CXX11}") set(_cmake_feature_test_cxx_strong_enums "${GNU44_CXX11}") set(_cmake_feature_test_cxx_trailing_return_types "${GNU44_CXX11}") set(_cmake_feature_test_cxx_unicode_literals "${GNU44_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 6d2a576..58c874d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -67,6 +67,7 @@ F(cxx_raw_string_literals) \ F(cxx_reference_qualified_functions) \ F(cxx_rvalue_references) \ + F(cxx_sizeof_member) \ F(cxx_static_assert) \ F(cxx_strong_enums) \ F(cxx_thread_local) \ diff --git a/Tests/CompileFeatures/cxx_sizeof_member.cpp b/Tests/CompileFeatures/cxx_sizeof_member.cpp new file mode 100644 index 0000000..ae143d2 --- /dev/null +++ b/Tests/CompileFeatures/cxx_sizeof_member.cpp @@ -0,0 +1,10 @@ + +struct A +{ + int m_i; +}; + +int someFunc() +{ + return sizeof(A::m_i) > 0 ? 1 : 2; +} -- cgit v0.12 From 9a49fd21bedacdda51ecfa82a15a0e52dd64948f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Apr 2014 10:17:15 +0200 Subject: Features: Add cxx_decltype_incomplete_return_types. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 5 +++-- Source/cmMakefile.cxx | 1 + .../cxx_decltype_incomplete_return_types.cpp | 14 ++++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 Tests/CompileFeatures/cxx_decltype_incomplete_return_types.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index a16dced..437d000 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -42,6 +42,11 @@ The features known to this version of CMake are: .. _N2235: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf +``cxx_decltype_incomplete_return_types`` + Decltype on incomplete return types, as defined in N3276_. + + .. _N3276 : http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3276.pdf + ``cxx_decltype`` Decltype, as defined in N2343_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index a98ae3a..e93888c 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -3,8 +3,9 @@ set(_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408") # Introduced in GCC 4.8.1 -set(_cmake_feature_test_cxx_reference_qualified_functions - "((__GNUC__ * 100 + __GNUC_MINOR__) > 408 || __GNUC_PATCHLEVEL__ >= 1) && __cplusplus >= 201103L") +set(GNU481_CXX11 "((__GNUC__ * 100 + __GNUC_MINOR__) > 408 || __GNUC_PATCHLEVEL__ >= 1) && __cplusplus >= 201103L") +set(_cmake_feature_test_cxx_decltype_incomplete_return_types "${GNU481_CXX11}") +set(_cmake_feature_test_cxx_reference_qualified_functions "${GNU481_CXX11}") set(GNU48_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_alignas "${GNU48_CXX11}") set(_cmake_feature_test_cxx_alignof "${GNU48_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 58c874d..8ae07b1 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -49,6 +49,7 @@ F(cxx_auto_type) \ F(cxx_constexpr) \ F(cxx_decltype) \ + F(cxx_decltype_incomplete_return_types) \ F(cxx_defaulted_functions) \ F(cxx_delegating_constructors) \ F(cxx_deleted_functions) \ diff --git a/Tests/CompileFeatures/cxx_decltype_incomplete_return_types.cpp b/Tests/CompileFeatures/cxx_decltype_incomplete_return_types.cpp new file mode 100644 index 0000000..109d038 --- /dev/null +++ b/Tests/CompileFeatures/cxx_decltype_incomplete_return_types.cpp @@ -0,0 +1,14 @@ + +template +struct A +{ + ~A() = delete; +}; + +template auto h() -> A; +template auto i(T) -> T; +template auto f(T) -> decltype(i(h())); +template auto f(T) -> void; +auto g() -> void { + f(42); +} -- cgit v0.12 From 7b3e8a05349e13ee300980c1a4789cc9175a6c42 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Apr 2014 10:17:20 +0200 Subject: Features: Add cxx_right_angle_brackets. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_right_angle_brackets.cpp | 12 ++++++++++++ 4 files changed, 19 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_right_angle_brackets.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 437d000..710fdcf 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -137,6 +137,11 @@ The features known to this version of CMake are: .. _N2439: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm +``cxx_right_angle_brackets`` + Right angle bracket parsing, as defined in N1757_. + + .. _N1757: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1757.html + ``cxx_rvalue_references`` R-value references, as defined in N2118_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index e93888c..be6fed4 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -60,6 +60,7 @@ set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}") # TODO: Should be supported by GNU 4.3 set(GNU43_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_decltype "${GNU43_CXX11}") +set(_cmake_feature_test_cxx_right_angle_brackets "${GNU43_CXX11}") set(_cmake_feature_test_cxx_rvalue_references "${GNU43_CXX11}") set(_cmake_feature_test_cxx_static_assert "${GNU43_CXX11}") # TODO: Should be supported since GNU 3.4? diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8ae07b1..61549ae 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -67,6 +67,7 @@ F(cxx_range_for) \ F(cxx_raw_string_literals) \ F(cxx_reference_qualified_functions) \ + F(cxx_right_angle_brackets) \ F(cxx_rvalue_references) \ F(cxx_sizeof_member) \ F(cxx_static_assert) \ diff --git a/Tests/CompileFeatures/cxx_right_angle_brackets.cpp b/Tests/CompileFeatures/cxx_right_angle_brackets.cpp new file mode 100644 index 0000000..2713fd8 --- /dev/null +++ b/Tests/CompileFeatures/cxx_right_angle_brackets.cpp @@ -0,0 +1,12 @@ + +template +struct A +{ + typedef T Result; +}; + +void someFunc() +{ + A> object; + (void)object; +} -- cgit v0.12 From adf22f611e2e4213df31cc7e1d8c1513847b72ff Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Apr 2014 10:41:01 +0200 Subject: Features: Add cxx_default_function_template_args. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_default_function_template_args.cpp | 12 ++++++++++++ 4 files changed, 19 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_default_function_template_args.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 710fdcf..1f9cbbd 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -52,6 +52,11 @@ The features known to this version of CMake are: .. _N2343: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf +``cxx_default_function_template_args`` + Default template arguments for function templates, as defined in DR226_ + + .. _DR226: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#226 + ``cxx_defaulted_functions`` Defaulted functions, as defined in N2346_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index be6fed4..94a31c8 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -60,6 +60,7 @@ set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}") # TODO: Should be supported by GNU 4.3 set(GNU43_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_decltype "${GNU43_CXX11}") +set(_cmake_feature_test_cxx_default_function_template_args "${GNU43_CXX11}") set(_cmake_feature_test_cxx_right_angle_brackets "${GNU43_CXX11}") set(_cmake_feature_test_cxx_rvalue_references "${GNU43_CXX11}") set(_cmake_feature_test_cxx_static_assert "${GNU43_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 61549ae..577aa37 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -50,6 +50,7 @@ F(cxx_constexpr) \ F(cxx_decltype) \ F(cxx_decltype_incomplete_return_types) \ + F(cxx_default_function_template_args) \ F(cxx_defaulted_functions) \ F(cxx_delegating_constructors) \ F(cxx_deleted_functions) \ diff --git a/Tests/CompileFeatures/cxx_default_function_template_args.cpp b/Tests/CompileFeatures/cxx_default_function_template_args.cpp new file mode 100644 index 0000000..3d14c52 --- /dev/null +++ b/Tests/CompileFeatures/cxx_default_function_template_args.cpp @@ -0,0 +1,12 @@ + +template +int someFunc() +{ + T t = 0; + return t; +} + +void otherFunc() +{ + someFunc(); +} -- cgit v0.12 From 16603f7cdb76ad4f9377d583b5234d92f85dd22d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Apr 2014 10:37:08 +0200 Subject: Features: Add cxx_enum_forward_declarations. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_enum_forward_declarations.cpp | 8 ++++++++ 4 files changed, 15 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_enum_forward_declarations.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 1f9cbbd..5ac646c 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -72,6 +72,11 @@ The features known to this version of CMake are: .. _N2346: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm +``cxx_enum_forward_declarations`` + Enum forward declarations, as defined in N2764_. + + .. _N2764: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2764.pdf + ``cxx_explicit_conversions`` Explicit conversion operators, as defined in N2437_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 94a31c8..d1bd4a0 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -29,6 +29,7 @@ set(_cmake_feature_test_cxx_user_literals "${GNU47_CXX11}") # TODO: Should be supported by GNU 4.6 set(GNU46_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}") +set(_cmake_feature_test_cxx_enum_forward_declarations "${GNU46_CXX11}") set(_cmake_feature_test_cxx_nullptr "${GNU46_CXX11}") set(_cmake_feature_test_cxx_range_for "${GNU46_CXX11}") set(_cmake_feature_test_cxx_unrestricted_unions "${GNU46_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 577aa37..7c5ec81 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -54,6 +54,7 @@ F(cxx_defaulted_functions) \ F(cxx_delegating_constructors) \ F(cxx_deleted_functions) \ + F(cxx_enum_forward_declarations) \ F(cxx_explicit_conversions) \ F(cxx_extern_templates) \ F(cxx_final) \ diff --git a/Tests/CompileFeatures/cxx_enum_forward_declarations.cpp b/Tests/CompileFeatures/cxx_enum_forward_declarations.cpp new file mode 100644 index 0000000..a7e1445 --- /dev/null +++ b/Tests/CompileFeatures/cxx_enum_forward_declarations.cpp @@ -0,0 +1,8 @@ + +enum SomeEnum : short; + +void someFunc() +{ + SomeEnum value; + int i = value; +} -- cgit v0.12 From 53fe7773e6335b71161310a2c948bc99145ee59e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Apr 2014 10:37:52 +0200 Subject: Features: Add cxx_extended_friend_declarations. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + .../cxx_extended_friend_declarations.cpp | 25 ++++++++++++++++++++++ 4 files changed, 32 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_extended_friend_declarations.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 5ac646c..fab8535 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -82,6 +82,11 @@ The features known to this version of CMake are: .. _N2437: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf +``cxx_extended_friend_declarations`` + Extended friend declarations, as defined in N1791_. + + .. _N1791: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1791.pdf + ``cxx_extern_templates`` Extern templates, as defined in N1987_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index d1bd4a0..506d718 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -16,6 +16,7 @@ set(_cmake_feature_test_cxx_thread_local "${GNU48_CXX11}") set(GNU47_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_alias_templates "${GNU47_CXX11}") set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}") +set(_cmake_feature_test_cxx_extended_friend_declarations "${GNU47_CXX11}") set(_cmake_feature_test_cxx_final "${GNU47_CXX11}") set(_cmake_feature_test_cxx_noexcept "${GNU47_CXX11}") set(_cmake_feature_test_cxx_nonstatic_member_init "${GNU47_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7c5ec81..f86a999 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -56,6 +56,7 @@ F(cxx_deleted_functions) \ F(cxx_enum_forward_declarations) \ F(cxx_explicit_conversions) \ + F(cxx_extended_friend_declarations) \ F(cxx_extern_templates) \ F(cxx_final) \ F(cxx_generalized_initializers) \ diff --git a/Tests/CompileFeatures/cxx_extended_friend_declarations.cpp b/Tests/CompileFeatures/cxx_extended_friend_declarations.cpp new file mode 100644 index 0000000..631c699 --- /dev/null +++ b/Tests/CompileFeatures/cxx_extended_friend_declarations.cpp @@ -0,0 +1,25 @@ + +template +struct B +{ + B() : m_i(42) {} +private: + int m_i; + friend T; +}; + +struct A +{ + template + int getBValue(B b) + { + return b.m_i; + } +}; + +void someFunc() +{ + A a; + B b; + a.getBValue(b); +} -- cgit v0.12 From 251a1f02a0ae7eb93690dd0daad8575a3c0451b3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Apr 2014 10:38:50 +0200 Subject: Features: Add cxx_local_type_template_args. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + .../cxx_local_type_template_args.cpp | 21 +++++++++++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_local_type_template_args.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index fab8535..1a76a3b 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -117,6 +117,11 @@ The features known to this version of CMake are: .. _N2927: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2927.pdf +``cxx_local_type_template_args`` + Local and unnamed types as template arguments, as defined in N2657_. + + .. _N2657: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm + ``cxx_noexcept`` Exception specifications, as defined in N3050_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 506d718..586ab4b 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -38,6 +38,7 @@ set(_cmake_feature_test_cxx_unrestricted_unions "${GNU46_CXX11}") set(GNU45_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_explicit_conversions "${GNU45_CXX11}") set(_cmake_feature_test_cxx_lambdas "${GNU45_CXX11}") +set(_cmake_feature_test_cxx_local_type_template_args "${GNU45_CXX11}") set(_cmake_feature_test_cxx_raw_string_literals "${GNU45_CXX11}") # TODO: Should be supported by GNU 4.4 set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f86a999..7b960a3 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -63,6 +63,7 @@ F(cxx_inheriting_constructors) \ F(cxx_inline_namespaces) \ F(cxx_lambdas) \ + F(cxx_local_type_template_args) \ F(cxx_noexcept) \ F(cxx_nonstatic_member_init) \ F(cxx_nullptr) \ diff --git a/Tests/CompileFeatures/cxx_local_type_template_args.cpp b/Tests/CompileFeatures/cxx_local_type_template_args.cpp new file mode 100644 index 0000000..802ea7a --- /dev/null +++ b/Tests/CompileFeatures/cxx_local_type_template_args.cpp @@ -0,0 +1,21 @@ + +template +class X { }; +template +void f(T t) { } +struct {} unnamed_obj; +void f() { + struct A { }; + enum { e1 }; + typedef struct {} B; + B b; + X x1; + X x2; + X x3; + f(e1); + f(unnamed_obj); + f(b); + (void)x1; + (void)x2; + (void)x3; +} -- cgit v0.12 From dcaafada0e213ae74082be84812a38d7f2a4a860 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Apr 2014 10:52:38 +0200 Subject: Features: Add cxx_func_identifier. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_func_identifier.cpp | 6 ++++++ 4 files changed, 13 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_func_identifier.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 1a76a3b..32b47e4 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -97,6 +97,11 @@ The features known to this version of CMake are: .. _N2928: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm +``cxx_func_identifier`` + Predefined ``__func__`` identifier, as defined in N2340_. + + .. _N2340: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2340.htm + ``cxx_generalized_initializers`` Initializer lists, as defined in N2672_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index 586ab4b..d727cac 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -70,5 +70,6 @@ set(_cmake_feature_test_cxx_static_assert "${GNU43_CXX11}") # TODO: Should be supported since GNU 3.4? set(_cmake_feature_test_cxx_extern_templates "${_oldestSupported} && __cplusplus >= 201103L") # TODO: Should be supported forever? +set(_cmake_feature_test_cxx_func_identifier "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_variadic_macros "${_oldestSupported} && __cplusplus >= 201103L") set(_oldestSupported) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7b960a3..508ace5 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -59,6 +59,7 @@ F(cxx_extended_friend_declarations) \ F(cxx_extern_templates) \ F(cxx_final) \ + F(cxx_func_identifier) \ F(cxx_generalized_initializers) \ F(cxx_inheriting_constructors) \ F(cxx_inline_namespaces) \ diff --git a/Tests/CompileFeatures/cxx_func_identifier.cpp b/Tests/CompileFeatures/cxx_func_identifier.cpp new file mode 100644 index 0000000..0c3595c --- /dev/null +++ b/Tests/CompileFeatures/cxx_func_identifier.cpp @@ -0,0 +1,6 @@ + +void someFunc() +{ + bool b = sizeof(__func__); + (void)b; +} -- cgit v0.12 From c4e672358c4945e78234b8c7075924c80750d61b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Apr 2014 11:14:42 +0200 Subject: Features: Add cxx_long_long_type. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_long_long_type.cpp | 5 +++++ 4 files changed, 12 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_long_long_type.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 32b47e4..5f578bb 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -127,6 +127,11 @@ The features known to this version of CMake are: .. _N2657: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm +``cxx_long_long_type`` + ``long long`` type, as defined in N1811_. + + .. _N1811: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1811.pdf + ``cxx_noexcept`` Exception specifications, as defined in N3050_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index d727cac..c044f17 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -64,6 +64,7 @@ set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}") set(GNU43_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_decltype "${GNU43_CXX11}") set(_cmake_feature_test_cxx_default_function_template_args "${GNU43_CXX11}") +set(_cmake_feature_test_cxx_long_long_type "${GNU43_CXX11}") set(_cmake_feature_test_cxx_right_angle_brackets "${GNU43_CXX11}") set(_cmake_feature_test_cxx_rvalue_references "${GNU43_CXX11}") set(_cmake_feature_test_cxx_static_assert "${GNU43_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 508ace5..12f770c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -65,6 +65,7 @@ F(cxx_inline_namespaces) \ F(cxx_lambdas) \ F(cxx_local_type_template_args) \ + F(cxx_long_long_type) \ F(cxx_noexcept) \ F(cxx_nonstatic_member_init) \ F(cxx_nullptr) \ diff --git a/Tests/CompileFeatures/cxx_long_long_type.cpp b/Tests/CompileFeatures/cxx_long_long_type.cpp new file mode 100644 index 0000000..670324c --- /dev/null +++ b/Tests/CompileFeatures/cxx_long_long_type.cpp @@ -0,0 +1,5 @@ + +void someFunc() +{ + long long ll = 9223372036854775807LL; +} -- cgit v0.12 From 60c0d2dd812af663b2b009a253072dc481b604fe Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Apr 2014 11:22:49 +0200 Subject: Features: Add cxx_defaulted_move_initializers. --- Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst | 5 +++++ Modules/Compiler/GNU-CXX-FeatureTests.cmake | 1 + Source/cmMakefile.cxx | 1 + Tests/CompileFeatures/cxx_defaulted_move_initializers.cpp | 7 +++++++ 4 files changed, 14 insertions(+) create mode 100644 Tests/CompileFeatures/cxx_defaulted_move_initializers.cpp diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst index 5f578bb..6d34a2b 100644 --- a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst @@ -62,6 +62,11 @@ The features known to this version of CMake are: .. _N2346: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm +``cxx_defaulted_move_initializers`` + Defaulted move initializers, as defined in N3053_. + + .. _N3053: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3053.html + ``cxx_delegating_constructors`` Delegating constructors, as defined in N1986_. diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake index c044f17..3f169d2 100644 --- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake +++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake @@ -30,6 +30,7 @@ set(_cmake_feature_test_cxx_user_literals "${GNU47_CXX11}") # TODO: Should be supported by GNU 4.6 set(GNU46_CXX11 "${_oldestSupported} && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}") +set(_cmake_feature_test_cxx_defaulted_move_initializers "${GNU46_CXX11}") set(_cmake_feature_test_cxx_enum_forward_declarations "${GNU46_CXX11}") set(_cmake_feature_test_cxx_nullptr "${GNU46_CXX11}") set(_cmake_feature_test_cxx_range_for "${GNU46_CXX11}") diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 12f770c..6ec40fb 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -52,6 +52,7 @@ F(cxx_decltype_incomplete_return_types) \ F(cxx_default_function_template_args) \ F(cxx_defaulted_functions) \ + F(cxx_defaulted_move_initializers) \ F(cxx_delegating_constructors) \ F(cxx_deleted_functions) \ F(cxx_enum_forward_declarations) \ diff --git a/Tests/CompileFeatures/cxx_defaulted_move_initializers.cpp b/Tests/CompileFeatures/cxx_defaulted_move_initializers.cpp new file mode 100644 index 0000000..14f9871 --- /dev/null +++ b/Tests/CompileFeatures/cxx_defaulted_move_initializers.cpp @@ -0,0 +1,7 @@ + +struct A +{ + A() = default; + A& operator=(A&&) = default; + A(A&&) = default; +}; -- cgit v0.12 From a9fe65c316dbfebe5b69269cf50659fe1aa5919d Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 8 Apr 2014 08:48:08 -0400 Subject: cmSystemTools: Remove unreachable return on HP compiler Follow up commit 1de08685 (cmSystemTools: Restore unreachable return to silence warnings, 2014-04-02) by excluding the unreachable return on the HP compiler as well as Clang. Both recognize that it is unreachable and warn. --- Source/cmSystemTools.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 635e31c..c27b561 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1616,7 +1616,7 @@ long copy_data(struct archive *ar, struct archive *aw) return (r); } } -#if !defined(__clang__) +#if !defined(__clang__) && !defined(__HP_aCC) return r; /* this should not happen but it quiets some compilers */ #endif } -- cgit v0.12 From c54be58309fbf9c2a5cfec8ba190c631e1db4a6c Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 7 Apr 2014 09:49:13 -0400 Subject: KWSys 2014-04-07 (8b085635) Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ 8b085635 | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' 39f98b5d..8b085635 Rolf Eike Beer (2): a99a9235 set the compile flags for older HP compilers to fix compilation 8b085635 MD5: avoid casting back and forth between size_t and int Change-Id: I6386b521dbaba2e4f9ed5b2be34a504b9c17fc36 --- CMakeLists.txt | 7 +++++++ MD5.c | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 977d57b..5e6a226 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -299,6 +299,13 @@ IF(NOT CMAKE_COMPILER_IS_GNUCXX) ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*") IF(CMAKE_SYSTEM MATCHES "HP-UX") SET(KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS "+p") + IF(CMAKE_CXX_COMPILER_ID MATCHES "HP") + # it is known that version 3.85 fails and 6.25 works without these flags + IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4) + # use new C++ library and improved template support + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA +hpxstd98") + ENDIF() + ENDIF() ENDIF(CMAKE_SYSTEM MATCHES "HP-UX") ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) diff --git a/MD5.c b/MD5.c index 56776a3..a147057 100644 --- a/MD5.c +++ b/MD5.c @@ -478,11 +478,16 @@ void kwsysMD5_Initialize(kwsysMD5* md5) /*--------------------------------------------------------------------------*/ void kwsysMD5_Append(kwsysMD5* md5, unsigned char const* data, int length) { + size_t dlen; if(length < 0) { - length = (int)strlen((char const*)data); + dlen = strlen((char const*)data); } - md5_append(&md5->md5_state, (md5_byte_t const*)data, (size_t)length); + else + { + dlen = (size_t)length; + } + md5_append(&md5->md5_state, (md5_byte_t const*)data, dlen); } /*--------------------------------------------------------------------------*/ -- cgit v0.12 From cb9b1e13e4de88deb1d675ee26859615c393e9c5 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 4 Apr 2014 23:06:13 +0200 Subject: Watcom: Use single quote for all file/path items in wlink command Watcom Linker use single quote if necessary for quoting target name, libraries names and libraries search path. Object names were already fixed. --- Modules/Platform/Windows-wcl386.cmake | 4 +-- Source/cmLocalGenerator.cxx | 34 ++++++++++++++++---------- Source/cmLocalGenerator.h | 11 ++++++--- Source/cmMakefileExecutableTargetGenerator.cxx | 13 +++++++--- Source/cmMakefileLibraryTargetGenerator.cxx | 14 ++++++++--- Source/cmMakefileTargetGenerator.cxx | 6 +++-- Source/cmMakefileTargetGenerator.h | 3 ++- Source/cmNinjaNormalTargetGenerator.cxx | 8 +++++- Source/cmake.cxx | 2 +- 9 files changed, 64 insertions(+), 31 deletions(-) diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake index 72a5929..ac410de 100644 --- a/Modules/Platform/Windows-wcl386.cmake +++ b/Modules/Platform/Windows-wcl386.cmake @@ -51,7 +51,7 @@ set(CMAKE_C_CREATE_IMPORT_LIBRARY set(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY}) set(CMAKE_C_LINK_EXECUTABLE - "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '' file {} ${CMAKE_END_TEMP_FILE}") + "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name file {} ${CMAKE_END_TEMP_FILE}") set(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE}) @@ -73,7 +73,7 @@ set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE " ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -d+ -fo -pl -cc++ ${CMAKE_END_TEMP_FILE}") set(CMAKE_CXX_CREATE_SHARED_LIBRARY - "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '' option implib= file {} ${CMAKE_END_TEMP_FILE}") + "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name option implib= file {} ${CMAKE_END_TEMP_FILE}") string(REPLACE " option implib=" "" CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}") diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 1e65a02..8e56d2f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -689,6 +689,7 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, std::string createRule = "CMAKE_"; createRule += llang; createRule += target.GetCreateRuleVariable(); + bool useWatcomQuote = this->Makefile->IsOn(createRule+"_USE_WATCOM_QUOTE"); std::string targetName = target.Target->GetFullName(); // Executable : // Shared Library: @@ -700,7 +701,7 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, std::string flags; // should be set std::string linkFlags; // should be set this->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags, - &target); + &target, useWatcomQuote); linkLibs = frameworkPath + linkPath + linkLibs; cmLocalGenerator::RuleVariables vars; vars.Language = llang.c_str(); @@ -1611,7 +1612,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, std::string& linkFlags, std::string& frameworkPath, std::string& linkPath, - cmGeneratorTarget* target) + cmGeneratorTarget* target, + bool useWatcomQuote) { std::string buildType = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); @@ -1675,7 +1677,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, } } this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, - *target, false, false); + *target, false, false, useWatcomQuote); } break; case cmTarget::EXECUTABLE: @@ -1700,7 +1702,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, } this->AddLanguageFlags(flags, linkLanguage, buildType); this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, - *target, false, false); + *target, false, false, useWatcomQuote); if(cmSystemTools::IsOn (this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { @@ -1759,9 +1761,8 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib, OutputFormat format) { #if defined(_WIN32) && !defined(__CYGWIN__) - // Work-ardound command line parsing limitations in MSVC 6.0 and - // Watcom. - if(this->Makefile->IsOn("MSVC60") || this->Makefile->IsOn("WATCOM")) + // Work-ardound command line parsing limitations in MSVC 6.0 + if(this->Makefile->IsOn("MSVC60")) { // Search for the last space. std::string::size_type pos = lib.rfind(' '); @@ -1798,9 +1799,11 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, std::string& linkPath, cmGeneratorTarget &tgt, bool relink, - bool forResponseFile) + bool forResponseFile, + bool useWatcomQuote) { - OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL; + OutputFormat shellFormat = (forResponseFile) ? RESPONSE : + ((useWatcomQuote) ? WATCOMQUOTE : SHELL); bool escapeAllowMakeVars = !forResponseFile; cmOStringStream fout; const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); @@ -2594,7 +2597,7 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const std::string& source, { result = cmSystemTools::ConvertToOutputPath(result.c_str()); } - else if( output == SHELL) + else if(output == SHELL || output == WATCOMQUOTE) { // For the MSYS shell convert drive letters to posix paths, so // that c:/some/path becomes /c/some/path. This is needed to @@ -2616,11 +2619,11 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const std::string& source, pos++; } } - result = this->EscapeForShell(result, true, false); + result = this->EscapeForShell(result, true, false, output == WATCOMQUOTE); } else if(output == RESPONSE) { - result = this->EscapeForShell(result, false, false); + result = this->EscapeForShell(result, false, false, false); } return result; } @@ -3247,7 +3250,8 @@ static bool cmLocalGeneratorIsShellOperator(const std::string& str) //---------------------------------------------------------------------------- std::string cmLocalGenerator::EscapeForShell(const std::string& str, bool makeVars, - bool forEcho) + bool forEcho, + bool useWatcomQuote) { // Do not escape shell operators. if(cmLocalGeneratorIsShellOperator(str)) @@ -3273,6 +3277,10 @@ std::string cmLocalGenerator::EscapeForShell(const std::string& str, { flags |= cmsysSystem_Shell_Flag_EchoWindows; } + if(useWatcomQuote) + { + flags |= cmsysSystem_Shell_Flag_WatcomQuote; + } if(this->WatcomWMake) { flags |= cmsysSystem_Shell_Flag_WatcomWMake; diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 8f30149..8090b34 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -106,7 +106,7 @@ public: * path setting */ enum RelativeRoot { NONE, FULL, HOME, START, HOME_OUTPUT, START_OUTPUT }; - enum OutputFormat { UNCHANGED, MAKEFILE, SHELL, RESPONSE }; + enum OutputFormat { UNCHANGED, MAKEFILE, SHELL, WATCOMQUOTE, RESPONSE }; std::string ConvertToOutputFormat(const std::string& source, OutputFormat output); std::string Convert(const std::string& remote, RelativeRoot local, @@ -288,7 +288,8 @@ public: escapes for the special case of passing to the native echo command. */ std::string EscapeForShell(const std::string& str, bool makeVars = false, - bool forEcho = false); + bool forEcho = false, + bool useWatcomQuote = false); /** Backwards-compatibility version of EscapeForShell. */ std::string EscapeForShellOldStyle(const std::string& str); @@ -370,7 +371,8 @@ public: std::string& linkFlags, std::string& frameworkPath, std::string& linkPath, - cmGeneratorTarget* target); + cmGeneratorTarget* target, + bool useWatcomQuote); virtual void ComputeObjectFilenames( std::map& mapping, @@ -383,7 +385,8 @@ protected: std::string& linkPath, cmGeneratorTarget &, bool relink, - bool forResponseFile); + bool forResponseFile, + bool useWatcomQuote); // Expand rule variables in CMake of the type found in language rules void ExpandRuleVariables(std::string& string, diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 701d5a0..fc52ccc 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -290,7 +290,6 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) linkRuleVar += linkLanguage; linkRuleVar += "_LINK_EXECUTABLE"; std::string linkRule = this->GetLinkRule(linkRuleVar); - bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE"); std::vector commands1; cmSystemTools::ExpandListArgument(linkRule, real_link_commands); if(this->Target->IsExecutableWithExports()) @@ -333,12 +332,15 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Expand the rule variables. { + bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE"); + // Set path conversion for link script shells. this->LocalGenerator->SetLinkScriptShell(useLinkScript); // Collect up flags to link in needed libraries. std::string linkLibs; - this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends); + this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends, + useWatcomQuote); // Construct object file lists that may be needed to expand the // rule. @@ -357,7 +359,12 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); vars.ObjectDir = objectDir.c_str(); - vars.Target = targetOutPathReal.c_str(); + cmLocalGenerator::OutputFormat output = (useWatcomQuote) ? + cmLocalGenerator::WATCOMQUOTE : cmLocalGenerator::SHELL; + std::string target = this->Convert(targetFullPathReal, + cmLocalGenerator::START_OUTPUT, + output); + vars.Target = target.c_str(); vars.TargetPDB = targetOutPathPDB.c_str(); // Setup the target version. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 754f62f..7ac0256 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -458,8 +458,6 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules this->Target); } - bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE"); - // Determine whether a link script will be used. bool useLinkScript = this->GlobalGenerator->GetUseLinkScript(); @@ -541,6 +539,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Expand the rule variables. std::vector real_link_commands; { + bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE"); + // Set path conversion for link script shells. this->LocalGenerator->SetLinkScriptShell(useLinkScript); @@ -548,7 +548,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string linkLibs; if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) { - this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends); + this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends, + useWatcomQuote); } // Construct object file lists that may be needed to expand the @@ -587,7 +588,12 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); vars.ObjectDir = objectDir.c_str(); - vars.Target = targetOutPathReal.c_str(); + cmLocalGenerator::OutputFormat output = (useWatcomQuote) ? + cmLocalGenerator::WATCOMQUOTE : cmLocalGenerator::SHELL; + std::string target = this->Convert(targetFullPathReal, + cmLocalGenerator::START_OUTPUT, + output); + vars.Target = target.c_str(); vars.LinkLibraries = linkLibs.c_str(); vars.ObjectsQuoted = buildObjs.c_str(); if (this->Target->HasSOName(this->ConfigName)) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f940ac4..d4723ad 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1826,14 +1826,16 @@ void cmMakefileTargetGenerator ::CreateLinkLibs(std::string& linkLibs, bool relink, bool useResponseFile, - std::vector& makefile_depends) + std::vector& makefile_depends, + bool useWatcomQuote) { std::string frameworkPath; std::string linkPath; this->LocalGenerator ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, *this->GeneratorTarget, relink, - useResponseFile); + useResponseFile, + useWatcomQuote); linkLibs = frameworkPath + linkPath + linkLibs; if(useResponseFile) diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index ff94660..9fac574 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -168,7 +168,8 @@ protected: /** Create list of flags for link libraries. */ void CreateLinkLibs(std::string& linkLibs, bool relink, bool useResponseFile, - std::vector& makefile_depends); + std::vector& makefile_depends, + bool useWatcomQuote); /** Create lists of object files for linking and cleaning. */ void CreateObjectLists(bool useLinkScript, bool useArchiveRules, diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 1d0336a..c865617 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -439,12 +439,18 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::string frameworkPath; std::string linkPath; cmGeneratorTarget* gtarget = this->GetGeneratorTarget(); + + std::string createRule = "CMAKE_"; + createRule += this->TargetLinkLanguage; + createRule += gtarget->GetCreateRuleVariable(); + bool useWatcomQuote = mf->IsOn(createRule+"_USE_WATCOM_QUOTE"); this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"], vars["FLAGS"], vars["LINK_FLAGS"], frameworkPath, linkPath, - gtarget); + gtarget, + useWatcomQuote); this->addPoolNinjaVariable("JOB_POOL_LINK", this->GetTarget(), vars); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 2cf636c..71ea3f5 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -600,7 +600,7 @@ bool cmake::FindPackage(const std::vector& args) gg->CreateGeneratorTargets(mf); cmGeneratorTarget *gtgt = gg->GetGeneratorTarget(tgt); lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags, - gtgt); + gtgt, false); linkLibs = frameworkPath + linkPath + linkLibs; printf("%s\n", linkLibs.c_str() ); -- cgit v0.12 From 8512bb4fff741360994317ed832be05b8b122721 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 9 Apr 2014 00:01:06 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 641c801..89b5c69 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 0) -set(CMake_VERSION_PATCH 20140408) +set(CMake_VERSION_PATCH 20140409) #set(CMake_VERSION_RC 1) -- cgit v0.12 From b1c3ae33eacb55a54a7ce28c5a5d6aa8903fbac2 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 9 Apr 2014 00:05:36 +0200 Subject: cmTarget: Short-circuit language computation if context independent. Computing the language involves computing the source files, which is an expensive operation. It requires calling cmMakefile::GetOrCreateSource many times, which involves creating and matching on many cmSourceFileLocation objects. Source files of a target may depend on the head-target and the config as of commit e6971df6 (cmTarget: Make the source files depend on the config., 2014-02-13). The results are cached for each context as of commit c5b26f3b (cmTarget: Cache the cmSourceFiles in GetSourceFiles., 2014-04-05). Each target in the build graph causes language computation of all of its dependents with itself as the head-target. This means that for 'core' libraries on which everything depends, the source files are computed once for every transitive target-level-dependee and the result is not cached because the head-target is different. This was observed in the VTK buildsystem. Short circuit the computation for targets which have a source-list that is independent of the head-target. If the source-list has already been computed and the generator expression evaluation reports that it was context-independent, return the only source-list already cached for the target. Reset the short-circuit logic when sources are added and when the link libraries are re-computed. --- Source/cmTarget.cxx | 36 ++++++++++++++++++++++++++++++------ Source/cmTarget.h | 2 ++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d28ac3f..4903f8b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -229,6 +229,7 @@ cmTarget::cmTarget() this->DebugCompileOptionsDone = false; this->DebugCompileDefinitionsDone = false; this->DebugSourcesDone = false; + this->LinkImplementationLanguageIsContextDependent = true; } //---------------------------------------------------------------------------- @@ -461,6 +462,7 @@ void cmTarget::FinishConfigure() //---------------------------------------------------------------------------- void cmTarget::ClearLinkMaps() { + this->LinkImplementationLanguageIsContextDependent = true; this->Internal->LinkImplMap.clear(); this->Internal->LinkInterfaceMap.clear(); this->Internal->LinkClosureMap.clear(); @@ -552,7 +554,7 @@ bool cmTarget::IsBundleOnApple() const } //---------------------------------------------------------------------------- -static void processSources(cmTarget const* tgt, +static bool processSources(cmTarget const* tgt, const std::vector &entries, std::vector &srcs, std::set &uniqueSrcs, @@ -562,6 +564,8 @@ static void processSources(cmTarget const* tgt, { cmMakefile *mf = tgt->GetMakefile(); + bool contextDependent = false; + for (std::vector::const_iterator it = entries.begin(), end = entries.end(); it != end; ++it) { @@ -576,8 +580,12 @@ static void processSources(cmTarget const* tgt, tgt, dagChecker), entrySources); - if (mf->IsGeneratingBuildSystem() - && !(*it)->ge->GetHadContextSensitiveCondition()) + + if ((*it)->ge->GetHadContextSensitiveCondition()) + { + contextDependent = true; + } + else if (mf->IsGeneratingBuildSystem()) { cacheSources = true; } @@ -598,7 +606,7 @@ static void processSources(cmTarget const* tgt, cm->IssueMessage(cmake::FATAL_ERROR, e, tgt->GetBacktrace()); } - return; + return contextDependent; } } if (cacheSources) @@ -629,6 +637,7 @@ static void processSources(cmTarget const* tgt, + usedSources, (*it)->ge->GetBacktrace()); } } + return contextDependent; } //---------------------------------------------------------------------------- @@ -664,7 +673,7 @@ void cmTarget::GetSourceFiles(std::vector &files, "SOURCES", 0, 0); std::set uniqueSrcs; - processSources(this, + bool contextDependentDirectSources = processSources(this, this->Internal->SourceEntries, files, uniqueSrcs, @@ -716,7 +725,8 @@ void cmTarget::GetSourceFiles(std::vector &files, } } - processSources(this, + std::vector::size_type numFilesBefore = files.size(); + bool contextDependentInterfaceSources = processSources(this, this->Internal->CachedLinkInterfaceSourcesEntries[config], files, uniqueSrcs, @@ -725,6 +735,12 @@ void cmTarget::GetSourceFiles(std::vector &files, config, debugSources); + if (!contextDependentDirectSources + && !(contextDependentInterfaceSources && numFilesBefore < files.size())) + { + this->LinkImplementationLanguageIsContextDependent = false; + } + if (!this->Makefile->IsGeneratingBuildSystem()) { deleteAndClear(this->Internal->CachedLinkInterfaceSourcesEntries); @@ -801,6 +817,12 @@ void cmTarget::GetSourceFiles(std::vector &files, // Lookup any existing link implementation for this configuration. TargetConfigPair key(head, cmSystemTools::UpperCase(config)); + if(!this->LinkImplementationLanguageIsContextDependent) + { + files = this->Internal->SourceFilesMap.begin()->second; + return; + } + cmTargetInternals::SourceFilesMapType::iterator it = this->Internal->SourceFilesMap.find(key); if(it != this->Internal->SourceFilesMap.end()) @@ -854,6 +876,7 @@ void cmTarget::AddSources(std::vector const& srcs) if (!srcFiles.empty()) { this->Internal->SourceFilesMap.clear(); + this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); cmGeneratorExpression ge(lfbt); @@ -989,6 +1012,7 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) == this->Internal->SourceEntries.end()) { this->Internal->SourceFilesMap.clear(); + this->LinkImplementationLanguageIsContextDependent = true; cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); cmGeneratorExpression ge(lfbt); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index da9d0a1..868e260 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -784,6 +784,8 @@ private: std::string const& suffix, std::string const& name, const char* version) const; + + mutable bool LinkImplementationLanguageIsContextDependent; }; typedef std::map cmTargets; -- cgit v0.12 From 4f1c71fdd25f33bd0cdeb2b705723db02f8fddf4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 9 Apr 2014 01:32:14 +0200 Subject: cmTarget: Add all sources traced from custom commands at once. The AddSource method accepts one file and tries to avoiding adding it to the sources-list of the target if it already exists. This involves creating many cmSourceFileLocation objects for matching on existing files, which is an expensive operation. Avoid the searching algorithm by appending the new sources as one group. Generate-time processing of source files will ensure uniqueness. Add a new AddTracedSources for this purpose. The existing AddSources method must process the input for policy CMP0049, but as these source filenames come from cmSourceFile::GetFullPath(), we can forego that extra processing. --- Source/cmGeneratorTarget.cxx | 7 +++++-- Source/cmTarget.cxx | 27 +++++++++++++++++++++++++++ Source/cmTarget.h | 1 + 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 0d25a00..ec5ce9e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -610,6 +610,7 @@ private: std::set SourcesQueued; typedef std::map NameMapType; NameMapType NameMap; + std::vector NewSources; void QueueSource(cmSourceFile* sf); void FollowName(std::string const& name); @@ -698,6 +699,8 @@ void cmTargetTraceDependencies::Trace() } } this->CurrentEntry = 0; + + this->Target->AddTracedSources(this->NewSources); } //---------------------------------------------------------------------------- @@ -707,8 +710,8 @@ void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf) { this->SourceQueue.push(sf); - // Make sure this file is in the target. - this->Target->AddSource(sf->GetFullPath()); + // Make sure this file is in the target at the end. + this->NewSources.push_back(sf->GetFullPath()); } } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 4903f8b..1f8cddb 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -850,6 +850,33 @@ void cmTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +void cmTarget::AddTracedSources(std::vector const& srcs) +{ + std::string srcFiles; + const char* sep = ""; + for(std::vector::const_iterator i = srcs.begin(); + i != srcs.end(); ++i) + { + std::string filename = *i; + srcFiles += sep; + srcFiles += filename; + sep = ";"; + } + if (!srcFiles.empty()) + { + this->Internal->SourceFilesMap.clear(); + this->LinkImplementationLanguageIsContextDependent = true; + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr cge = ge.Parse(srcFiles); + cge->SetEvaluateForBuildsystem(true); + this->Internal->SourceEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); + } +} + +//---------------------------------------------------------------------------- void cmTarget::AddSources(std::vector const& srcs) { std::string srcFiles; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 868e260..45ae487 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -144,6 +144,7 @@ public: * Add sources to the target. */ void AddSources(std::vector const& srcs); + void AddTracedSources(std::vector const& srcs); cmSourceFile* AddSourceCMP0049(const std::string& src); cmSourceFile* AddSource(const std::string& src); -- cgit v0.12 From 783bce295b98640ebcd56a4a6ca9f673992bcaa7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 31 Mar 2014 17:37:02 +0200 Subject: Export: Disallow exported interface includes in src/build tree (#14592). Allow directories in the source tree or build tree only if the install tree is a subdirectory of the source tree or build tree, as appropriate. Re-use the test files in the RunCMake.include_directories test to run in multiple scenarios. Bump the required CMake version in the test to 3.0 to ensure that the new policy warnings are emitted correctly. --- Help/manual/cmake-policies.7.rst | 1 + Help/policy/CMP0052.rst | 21 ++++ Help/release/dev/CMP0052.rst | 5 + Source/cmExportFileGenerator.cxx | 38 ++++++- Source/cmPolicies.cxx | 6 + Source/cmPolicies.h | 2 + Source/cmTarget.h | 3 +- .../RunCMake/TargetPolicies/PolicyList-stderr.txt | 1 + .../BinInInstallPrefix-CMP0052-NEW-result.txt | 1 + .../BinInInstallPrefix-CMP0052-NEW-stderr.txt | 6 + .../BinInInstallPrefix-CMP0052-OLD-result.txt | 1 + .../BinInInstallPrefix-CMP0052-OLD-stderr.txt | 1 + .../BinInInstallPrefix-CMP0052-WARN-result.txt | 1 + .../BinInInstallPrefix-CMP0052-WARN-stderr.txt | 15 +++ Tests/RunCMake/include_directories/CMakeLists.txt | 2 +- .../include_directories/InstallInBinDir-result.txt | 1 + .../include_directories/InstallInBinDir-stderr.txt | 6 + .../include_directories/InstallInSrcDir-result.txt | 1 + .../include_directories/InstallInSrcDir-stderr.txt | 6 + .../InstallPrefixInInterface-result.txt | 1 + .../InstallPrefixInInterface-stderr.txt | 1 + .../InstallPrefixInInterface.cmake | 11 ++ .../InstallToPrefixInSrcDirInSource-result.txt | 1 + .../InstallToPrefixInSrcDirInSource-stderr.txt | 1 + .../InstallToPrefixInSrcDirOutOfSource-result.txt | 1 + .../InstallToPrefixInSrcDirOutOfSource-stderr.txt | 1 + .../include_directories/RunCMakeTest.cmake | 125 +++++++++++++++++++++ .../SrcInInstallPrefix-CMP0052-NEW-result.txt | 1 + .../SrcInInstallPrefix-CMP0052-NEW-stderr.txt | 6 + .../SrcInInstallPrefix-CMP0052-OLD-result.txt | 1 + .../SrcInInstallPrefix-CMP0052-OLD-stderr.txt | 1 + .../SrcInInstallPrefix-CMP0052-WARN-result.txt | 1 + .../SrcInInstallPrefix-CMP0052-WARN-stderr.txt | 15 +++ 33 files changed, 282 insertions(+), 3 deletions(-) create mode 100644 Help/policy/CMP0052.rst create mode 100644 Help/release/dev/CMP0052.rst create mode 100644 Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-result.txt create mode 100644 Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-stderr.txt create mode 100644 Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-result.txt create mode 100644 Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-stderr.txt create mode 100644 Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-result.txt create mode 100644 Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt create mode 100644 Tests/RunCMake/include_directories/InstallInBinDir-result.txt create mode 100644 Tests/RunCMake/include_directories/InstallInBinDir-stderr.txt create mode 100644 Tests/RunCMake/include_directories/InstallInSrcDir-result.txt create mode 100644 Tests/RunCMake/include_directories/InstallInSrcDir-stderr.txt create mode 100644 Tests/RunCMake/include_directories/InstallPrefixInInterface-result.txt create mode 100644 Tests/RunCMake/include_directories/InstallPrefixInInterface-stderr.txt create mode 100644 Tests/RunCMake/include_directories/InstallPrefixInInterface.cmake create mode 100644 Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-result.txt create mode 100644 Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-stderr.txt create mode 100644 Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-result.txt create mode 100644 Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-stderr.txt create mode 100644 Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-result.txt create mode 100644 Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-stderr.txt create mode 100644 Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-result.txt create mode 100644 Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-stderr.txt create mode 100644 Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-result.txt create mode 100644 Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index b763882..4b895fe 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -103,3 +103,4 @@ All Policies /policy/CMP0049 /policy/CMP0050 /policy/CMP0051 + /policy/CMP0052 diff --git a/Help/policy/CMP0052.rst b/Help/policy/CMP0052.rst new file mode 100644 index 0000000..f857f36 --- /dev/null +++ b/Help/policy/CMP0052.rst @@ -0,0 +1,21 @@ +CMP0052 +------- + +Reject source and build dirs in installed INTERFACE_INCLUDE_DIRECTORIES. + +CMake 3.0 and lower allowed subdirectories of the source directory or build +directory to be in the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` of +installed and exported targets, if the directory was also a subdirectory of +the installation prefix. This makes the installation depend on the +existence of the source dir or binary dir, and the installation will be +broken if either are removed after installation. + +The OLD behavior for this policy is to export the content of the +:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` with the source or binary +directory. The NEW behavior for this +policy is to issue an error if such a directory is used. + +This policy was introduced in CMake version 3.1. +CMake version |release| warns when the policy is not set and uses +``OLD`` behavior. Use the :command:`cmake_policy` command to set it +to ``OLD`` or ``NEW`` explicitly. diff --git a/Help/release/dev/CMP0052.rst b/Help/release/dev/CMP0052.rst new file mode 100644 index 0000000..adb3d44 --- /dev/null +++ b/Help/release/dev/CMP0052.rst @@ -0,0 +1,5 @@ +CMP0052 +------- + +* Policy :policy:`CMP0052` introduced to control directories in the + :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` of exported targets. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index b38c48b..42fce6d 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -279,7 +279,43 @@ static bool checkInterfaceDirs(const std::string &prepro, } if (isSubDirectory(li->c_str(), installDir)) { - continue; + // The include directory is inside the install tree. If the + // install tree is not inside the source tree or build tree then + // fall through to the checks below that the include directory is not + // also inside the source tree or build tree. + bool shouldContinue = + isSubDirectory(installDir, topBinaryDir) + || isSubDirectory(installDir, topSourceDir); + + if (!shouldContinue) + { + switch(target->GetPolicyStatusCMP0052()) + { + case cmPolicies::WARN: + { + cmOStringStream s; + s << target->GetMakefile()->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0052) << "\n"; + s << "Directory:\n \"" << *li << "\"\nin " + "INTERFACE_INCLUDE_DIRECTORIES of target \"" + << target->GetName() << "\" is a subdirectory of the install " + "directory:\n \"" << installDir << "\""; + target->GetMakefile()->IssueMessage(cmake::AUTHOR_WARNING, + s.str()); + } + case cmPolicies::OLD: + shouldContinue = true; + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + break; + } + } + if (shouldContinue) + { + continue; + } } if (isSubDirectory(li->c_str(), topBinaryDir)) { diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 759df91..309f280 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -348,6 +348,12 @@ cmPolicies::cmPolicies() CMP0051, "CMP0051", "List TARGET_OBJECTS in SOURCES target property.", 3,1,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0052, "CMP0052", + "Reject source and build dirs in installed " + "INTERFACE_INCLUDE_DIRECTORIES.", + 3,1,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 7a08a34..60f35c2 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -105,6 +105,8 @@ public: CMP0049, ///< Do not expand variables in target source entries CMP0050, ///< Disallow add_custom_command SOURCE signatures CMP0051, ///< List TARGET_OBJECTS in SOURCES target property + CMP0052, ///< Reject source and build dirs in installed + /// INTERFACE_INCLUDE_DIRECTORIES /** \brief Always the last entry. * diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 055e029..33db768 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -30,7 +30,8 @@ F(CMP0038) \ F(CMP0041) \ F(CMP0042) \ - F(CMP0046) + F(CMP0046) \ + F(CMP0052) class cmake; class cmMakefile; diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt index f30c9a9..f4b744b 100644 --- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt +++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt @@ -16,6 +16,7 @@ \* CMP0041 \* CMP0042 \* CMP0046 + \* CMP0052 Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-result.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-stderr.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-stderr.txt new file mode 100644 index 0000000..f0adc9f --- /dev/null +++ b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-stderr.txt @@ -0,0 +1,6 @@ +CMake Error in CMakeLists.txt: + Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path: + + ".*Tests/RunCMake/include_directories/prefix/BinInInstallPrefix-CMP0052-NEW-build/foo" + + which is prefixed in the build directory. diff --git a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-result.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-stderr.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-result.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt new file mode 100644 index 0000000..f6d408c --- /dev/null +++ b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt @@ -0,0 +1,15 @@ +CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0052 is not set: Reject source and build dirs in installed + INTERFACE_INCLUDE_DIRECTORIES. Run "cmake --help-policy CMP0052" for + policy details. Use the cmake_policy command to set the policy and + suppress this warning. + + Directory: + + ".*Tests/RunCMake/include_directories/prefix/BinInInstallPrefix-CMP0052-WARN-build/foo" + + in INTERFACE_INCLUDE_DIRECTORIES of target "testTarget" is a subdirectory + of the install directory: + + ".*Tests/RunCMake/include_directories/prefix" +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/include_directories/CMakeLists.txt b/Tests/RunCMake/include_directories/CMakeLists.txt index f452db1..3482e6b 100644 --- a/Tests/RunCMake/include_directories/CMakeLists.txt +++ b/Tests/RunCMake/include_directories/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 2.8.4) +cmake_minimum_required(VERSION 3.0) project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/include_directories/InstallInBinDir-result.txt b/Tests/RunCMake/include_directories/InstallInBinDir-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/include_directories/InstallInBinDir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/include_directories/InstallInBinDir-stderr.txt b/Tests/RunCMake/include_directories/InstallInBinDir-stderr.txt new file mode 100644 index 0000000..254fae1 --- /dev/null +++ b/Tests/RunCMake/include_directories/InstallInBinDir-stderr.txt @@ -0,0 +1,6 @@ +CMake Error in CMakeLists.txt: + Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path: + + ".*Tests/RunCMake/include_directories/InstallInBinDir-build/foo" + + which is prefixed in the build directory. diff --git a/Tests/RunCMake/include_directories/InstallInSrcDir-result.txt b/Tests/RunCMake/include_directories/InstallInSrcDir-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/include_directories/InstallInSrcDir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/include_directories/InstallInSrcDir-stderr.txt b/Tests/RunCMake/include_directories/InstallInSrcDir-stderr.txt new file mode 100644 index 0000000..7be3044 --- /dev/null +++ b/Tests/RunCMake/include_directories/InstallInSrcDir-stderr.txt @@ -0,0 +1,6 @@ +CMake Error in CMakeLists.txt: + Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path: + + ".*Tests/RunCMake/include_directories/copy/foo" + + which is prefixed in the source directory. diff --git a/Tests/RunCMake/include_directories/InstallPrefixInInterface-result.txt b/Tests/RunCMake/include_directories/InstallPrefixInInterface-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/include_directories/InstallPrefixInInterface-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/include_directories/InstallPrefixInInterface-stderr.txt b/Tests/RunCMake/include_directories/InstallPrefixInInterface-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/include_directories/InstallPrefixInInterface-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/include_directories/InstallPrefixInInterface.cmake b/Tests/RunCMake/include_directories/InstallPrefixInInterface.cmake new file mode 100644 index 0000000..0f08e58 --- /dev/null +++ b/Tests/RunCMake/include_directories/InstallPrefixInInterface.cmake @@ -0,0 +1,11 @@ + +project(InstallPrefixInInterface) + +add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp") +target_include_directories(testTarget INTERFACE "${CMAKE_INSTALL_PREFIX}/foo") + +install(TARGETS testTarget EXPORT testTargets + DESTINATION lib +) + +install(EXPORT testTargets DESTINATION lib/cmake) diff --git a/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-result.txt b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-stderr.txt b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-result.txt b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-stderr.txt b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/include_directories/RunCMakeTest.cmake b/Tests/RunCMake/include_directories/RunCMakeTest.cmake index c00b924..434beb9 100644 --- a/Tests/RunCMake/include_directories/RunCMakeTest.cmake +++ b/Tests/RunCMake/include_directories/RunCMakeTest.cmake @@ -12,3 +12,128 @@ run_cmake(CMP0021) run_cmake(install_config) run_cmake(incomplete-genex) run_cmake(export-NOWARN) + +configure_file( + "${RunCMake_SOURCE_DIR}/CMakeLists.txt" + "${RunCMake_BINARY_DIR}/copy/CMakeLists.txt" + COPYONLY +) +configure_file( + "${RunCMake_SOURCE_DIR}/empty.cpp" + "${RunCMake_BINARY_DIR}/copy/empty.cpp" + COPYONLY +) +configure_file( + "${RunCMake_SOURCE_DIR}/SourceDirectoryInInterface.cmake" + "${RunCMake_BINARY_DIR}/copy/SourceDirectoryInInterface.cmake" + COPYONLY +) +set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/copy/SourceDirectoryInInterface/prefix") +set(RunCMake_TEST_FILE "${RunCMake_BINARY_DIR}/copy/SourceDirectoryInInterface") +set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/copy") +run_cmake(InstallInSrcDir) +unset(RunCMake_TEST_SOURCE_DIR) +unset(RunCMake_TEST_FILE) + +set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/InstallInBinDir-build/prefix") +set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/InstallInBinDir-build") +set(RunCMake_TEST_FILE "${RunCMake_SOURCE_DIR}/BinaryDirectoryInInterface") +run_cmake(InstallInBinDir) +unset(RunCMake_TEST_BINARY_DIR) +unset(RunCMake_TEST_FILE) + +configure_file( + "${RunCMake_SOURCE_DIR}/CMakeLists.txt" + "${RunCMake_BINARY_DIR}/prefix/src/CMakeLists.txt" + COPYONLY +) +configure_file( + "${RunCMake_SOURCE_DIR}/empty.cpp" + "${RunCMake_BINARY_DIR}/prefix/src/empty.cpp" + COPYONLY +) +configure_file( + "${RunCMake_SOURCE_DIR}/SourceDirectoryInInterface.cmake" + "${RunCMake_BINARY_DIR}/prefix/src/SourceDirectoryInInterface.cmake" + COPYONLY +) + +foreach(policyStatus "" NEW OLD) + if (NOT "${policyStatus}" STREQUAL "") + set(policyOption -DCMAKE_POLICY_DEFAULT_CMP0052=${policyStatus}) + else() + unset(policyOption) + set(policyStatus WARN) + endif() + set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/prefix" ${policyOption}) + # Set the RunCMake_TEST_SOURCE_DIR here to the copy too. This is needed to run + # the test suite in-source properly. Otherwise the install directory would be + # a subdirectory or the source directory, which is allowed and tested separately + # below. + set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/prefix/src") + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/prefix/BinInInstallPrefix-CMP0052-${policyStatus}-build") + set(RunCMake_TEST_FILE "${RunCMake_SOURCE_DIR}/BinaryDirectoryInInterface") + run_cmake(BinInInstallPrefix-CMP0052-${policyStatus}) + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_FILE) + + set(RunCMake_TEST_FILE "${RunCMake_BINARY_DIR}/prefix/src/SourceDirectoryInInterface") + run_cmake(SrcInInstallPrefix-CMP0052-${policyStatus}) + unset(RunCMake_TEST_SOURCE_DIR) + unset(RunCMake_TEST_FILE) +endforeach() + +set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/InstallPrefixInInterface-build/prefix") +run_cmake(InstallPrefixInInterface) + +configure_file( + "${RunCMake_SOURCE_DIR}/CMakeLists.txt" + "${RunCMake_BINARY_DIR}/installToSrc/CMakeLists.txt" + COPYONLY +) +configure_file( + "${RunCMake_SOURCE_DIR}/empty.cpp" + "${RunCMake_BINARY_DIR}/installToSrc/empty.cpp" + COPYONLY +) +configure_file( + "${RunCMake_SOURCE_DIR}/InstallPrefixInInterface.cmake" + "${RunCMake_BINARY_DIR}/installToSrc/InstallPrefixInInterface.cmake" + COPYONLY +) +set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/installToSrc/InstallPrefixInInterface/prefix") +set(RunCMake_TEST_FILE "${RunCMake_BINARY_DIR}/installToSrc/InstallPrefixInInterface") +set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/installToSrc") +run_cmake(InstallToPrefixInSrcDirOutOfSource) +unset(RunCMake_TEST_SOURCE_DIR) +unset(RunCMake_TEST_FILE) + + +file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}/installToSrcInSrc") +set(RunCMake_TEST_NO_CLEAN ON) + +configure_file( + "${RunCMake_SOURCE_DIR}/CMakeLists.txt" + "${RunCMake_BINARY_DIR}/installToSrcInSrc/CMakeLists.txt" + COPYONLY +) +configure_file( + "${RunCMake_SOURCE_DIR}/empty.cpp" + "${RunCMake_BINARY_DIR}/installToSrcInSrc/empty.cpp" + COPYONLY +) +configure_file( + "${RunCMake_SOURCE_DIR}/InstallPrefixInInterface.cmake" + "${RunCMake_BINARY_DIR}/installToSrcInSrc/InstallPrefixInInterface.cmake" + COPYONLY +) + +set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/installToSrcInSrc/InstallPrefixInInterface/prefix") +set(RunCMake_TEST_FILE "${RunCMake_BINARY_DIR}/installToSrcInSrc/InstallPrefixInInterface") +set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/installToSrcInSrc") +set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/installToSrcInSrc") +run_cmake(InstallToPrefixInSrcDirInSource) +unset(RunCMake_TEST_SOURCE_DIR) +unset(RunCMake_TEST_BINARY_DIR) +unset(RunCMake_TEST_FILE) +unset(RunCMake_TEST_NO_CLEAN) diff --git a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-result.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-stderr.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-stderr.txt new file mode 100644 index 0000000..afa43e0 --- /dev/null +++ b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-stderr.txt @@ -0,0 +1,6 @@ +CMake Error in CMakeLists.txt: + Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path: + + ".*Tests/RunCMake/include_directories/prefix/src/foo" + + which is prefixed in the source directory. diff --git a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-result.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-stderr.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-result.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt new file mode 100644 index 0000000..78710c0 --- /dev/null +++ b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt @@ -0,0 +1,15 @@ +CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0052 is not set: Reject source and build dirs in installed + INTERFACE_INCLUDE_DIRECTORIES. Run "cmake --help-policy CMP0052" for + policy details. Use the cmake_policy command to set the policy and + suppress this warning. + + Directory: + + ".*Tests/RunCMake/include_directories/prefix/src/foo" + + in INTERFACE_INCLUDE_DIRECTORIES of target "testTarget" is a subdirectory + of the install directory: + + ".*Tests/RunCMake/include_directories/prefix" +This warning is for project developers. Use -Wno-dev to suppress it. -- cgit v0.12 From 22018b6e939b6eaae3d738c44e16b9ea82b7d0ad Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 10 Apr 2014 00:01:06 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 89b5c69..65f9b38 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 0) -set(CMake_VERSION_PATCH 20140409) +set(CMake_VERSION_PATCH 20140410) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 111bb67c14e90e372be300cbbd98fa88d87a8b99 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 10 Apr 2014 10:36:43 +0200 Subject: Help: Use a more-appropriate qthelp namespace and file name. Use the namespace org.cmake instead of org.sphinx.cmake. Add the version to the output file name. --- Utilities/Sphinx/CMakeLists.txt | 5 +++++ Utilities/Sphinx/conf.py.in | 4 ++++ Utilities/Sphinx/fixup_qthelp_names.cmake | 32 +++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 Utilities/Sphinx/fixup_qthelp_names.cmake diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index 4ae4bec..0ae67bd 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -79,6 +79,11 @@ if(SPHINX_QTHELP) # https://codereview.qt-project.org/#change,82250 in Qt 4. COMMAND ${CMAKE_COMMAND} "-DCSS_DIR=${CMAKE_CURRENT_BINARY_DIR}/qthelp/_static" -P "${CMAKE_CURRENT_SOURCE_DIR}/apply_qthelp_css_workaround.cmake" + # Workaround sphinx configurability: + # https://bitbucket.org/birkenfeld/sphinx/issue/1448/make-qthelp-more-configurable + COMMAND ${CMAKE_COMMAND} "-DQTHELP_DIR=${CMAKE_CURRENT_BINARY_DIR}/qthelp/" + "-DCMake_VERSION=${CMake_VERSION_MAJOR}${CMake_VERSION_MINOR}${CMake_VERSION_PATCH}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/fixup_qthelp_names.cmake" COMMAND qcollectiongenerator ${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake.qhcp ) endif() diff --git a/Utilities/Sphinx/conf.py.in b/Utilities/Sphinx/conf.py.in index ef622fd..f7e4b8b 100644 --- a/Utilities/Sphinx/conf.py.in +++ b/Utilities/Sphinx/conf.py.in @@ -61,3 +61,7 @@ html_theme = 'default' html_title = 'CMake %s Documentation' % release html_short_title = '%s Documentation' % release html_favicon = 'cmake-favicon.ico' +# Not supported yet by sphinx: +# https://bitbucket.org/birkenfeld/sphinx/issue/1448/make-qthelp-more-configurable +# qthelp_namespace = "org.cmake" +# qthelp_qch_name = "CMake-300.qch" diff --git a/Utilities/Sphinx/fixup_qthelp_names.cmake b/Utilities/Sphinx/fixup_qthelp_names.cmake new file mode 100644 index 0000000..e35ef25 --- /dev/null +++ b/Utilities/Sphinx/fixup_qthelp_names.cmake @@ -0,0 +1,32 @@ + +file(READ "${QTHELP_DIR}/CMake.qhcp" QHCP_CONTENT) + +string(REPLACE + "qthelp://org.sphinx.cmake" "qthelp://org.cmake" + QHCP_CONTENT "${QHCP_CONTENT}" +) +string(REPLACE + "qthelp://org.sphinx.cmake" "qthelp://org.cmake" + QHCP_CONTENT "${QHCP_CONTENT}" +) + +string(REPLACE + "CMake.qch" "CMake-${CMake_VERSION}.qch" + QHCP_CONTENT "${QHCP_CONTENT}" +) +string(REPLACE + "CMake.qch" "CMake-${CMake_VERSION}.qch" + QHCP_CONTENT "${QHCP_CONTENT}" +) + +file(WRITE "${QTHELP_DIR}/CMake.qhcp" "${QHCP_CONTENT}") + + +file(READ "${QTHELP_DIR}/CMake.qhp" QHP_CONTENT) + +string(REPLACE + "org.sphinx.cmake" "org.cmake" + QHP_CONTENT "${QHP_CONTENT}" +) + +file(WRITE "${QTHELP_DIR}/CMake.qhp" "${QHP_CONTENT}") -- cgit v0.12 From 4b31f0649c530e34044dd4cb87b3267b2ec5e620 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 10 Apr 2014 17:34:41 +0200 Subject: Revert "Modules: Add an Andriod platform file" This reverts commit 77f06b145d57c4665ff5d71b89a70c54a009ad14. It may be re-added in the future when the requirements for that platform are better known and supported by CMake. --- Modules/Platform/Android.cmake | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 Modules/Platform/Android.cmake diff --git a/Modules/Platform/Android.cmake b/Modules/Platform/Android.cmake deleted file mode 100644 index a4c122d..0000000 --- a/Modules/Platform/Android.cmake +++ /dev/null @@ -1,5 +0,0 @@ -include(Platform/Linux) -set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "") -# RPath is useless on Android, because we can't determine the installation -# location ahead of time. -set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") -- cgit v0.12 From 6736b3e7465b5f870cc64bbd608fff07caadd191 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 11 Apr 2014 00:01:09 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 65f9b38..864bf1a 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 0) -set(CMake_VERSION_PATCH 20140410) +set(CMake_VERSION_PATCH 20140411) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 5a58efaac3557b0cee27f06e49183069cd598a7f Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 11 Apr 2014 09:01:27 -0400 Subject: libarchive: Avoid using name 'u_long' The system headers on some platforms define a 'u_long' type so we cannot use the name. Spell out 'unsigned long' instead. --- .../cmlibarchive/libarchive/archive_pack_dev.c | 54 +++++++++++----------- .../cmlibarchive/libarchive/archive_pack_dev.h | 3 +- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/Utilities/cmlibarchive/libarchive/archive_pack_dev.c b/Utilities/cmlibarchive/libarchive/archive_pack_dev.c index c90d8de..6b7b472 100644 --- a/Utilities/cmlibarchive/libarchive/archive_pack_dev.c +++ b/Utilities/cmlibarchive/libarchive/archive_pack_dev.c @@ -103,15 +103,15 @@ static const char tooManyFields[] = "too many fields for format"; /* exported */ dev_t -pack_native(int n, u_long numbers[], const char **error) +pack_native(int n, unsigned long numbers[], const char **error) { dev_t dev = 0; if (n == 2) { dev = apd_makedev(numbers[0], numbers[1]); - if ((u_long)major(dev) != numbers[0]) + if ((unsigned long)major(dev) != numbers[0]) *error = iMajorError; - else if ((u_long)minor(dev) != numbers[1]) + else if ((unsigned long)minor(dev) != numbers[1]) *error = iMinorError; } else *error = tooManyFields; @@ -120,15 +120,15 @@ pack_native(int n, u_long numbers[], const char **error) static dev_t -pack_netbsd(int n, u_long numbers[], const char **error) +pack_netbsd(int n, unsigned long numbers[], const char **error) { dev_t dev = 0; if (n == 2) { dev = makedev_netbsd(numbers[0], numbers[1]); - if ((u_long)major_netbsd(dev) != numbers[0]) + if ((unsigned long)major_netbsd(dev) != numbers[0]) *error = iMajorError; - else if ((u_long)minor_netbsd(dev) != numbers[1]) + else if ((unsigned long)minor_netbsd(dev) != numbers[1]) *error = iMinorError; } else *error = tooManyFields; @@ -142,15 +142,15 @@ pack_netbsd(int n, u_long numbers[], const char **error) (((y) << 0) & 0xffff00ff))) static dev_t -pack_freebsd(int n, u_long numbers[], const char **error) +pack_freebsd(int n, unsigned long numbers[], const char **error) { dev_t dev = 0; if (n == 2) { dev = makedev_freebsd(numbers[0], numbers[1]); - if ((u_long)major_freebsd(dev) != numbers[0]) + if ((unsigned long)major_freebsd(dev) != numbers[0]) *error = iMajorError; - if ((u_long)minor_freebsd(dev) != numbers[1]) + if ((unsigned long)minor_freebsd(dev) != numbers[1]) *error = iMinorError; } else *error = tooManyFields; @@ -164,15 +164,15 @@ pack_freebsd(int n, u_long numbers[], const char **error) (((y) << 0) & 0x000000ff))) static dev_t -pack_8_8(int n, u_long numbers[], const char **error) +pack_8_8(int n, unsigned long numbers[], const char **error) { dev_t dev = 0; if (n == 2) { dev = makedev_8_8(numbers[0], numbers[1]); - if ((u_long)major_8_8(dev) != numbers[0]) + if ((unsigned long)major_8_8(dev) != numbers[0]) *error = iMajorError; - if ((u_long)minor_8_8(dev) != numbers[1]) + if ((unsigned long)minor_8_8(dev) != numbers[1]) *error = iMinorError; } else *error = tooManyFields; @@ -186,15 +186,15 @@ pack_8_8(int n, u_long numbers[], const char **error) (((y) << 0) & 0x000fffff))) static dev_t -pack_12_20(int n, u_long numbers[], const char **error) +pack_12_20(int n, unsigned long numbers[], const char **error) { dev_t dev = 0; if (n == 2) { dev = makedev_12_20(numbers[0], numbers[1]); - if ((u_long)major_12_20(dev) != numbers[0]) + if ((unsigned long)major_12_20(dev) != numbers[0]) *error = iMajorError; - if ((u_long)minor_12_20(dev) != numbers[1]) + if ((unsigned long)minor_12_20(dev) != numbers[1]) *error = iMinorError; } else *error = tooManyFields; @@ -208,15 +208,15 @@ pack_12_20(int n, u_long numbers[], const char **error) (((y) << 0) & 0x0003ffff))) static dev_t -pack_14_18(int n, u_long numbers[], const char **error) +pack_14_18(int n, unsigned long numbers[], const char **error) { dev_t dev = 0; if (n == 2) { dev = makedev_14_18(numbers[0], numbers[1]); - if ((u_long)major_14_18(dev) != numbers[0]) + if ((unsigned long)major_14_18(dev) != numbers[0]) *error = iMajorError; - if ((u_long)minor_14_18(dev) != numbers[1]) + if ((unsigned long)minor_14_18(dev) != numbers[1]) *error = iMinorError; } else *error = tooManyFields; @@ -230,15 +230,15 @@ pack_14_18(int n, u_long numbers[], const char **error) (((y) << 0) & 0x00ffffff))) static dev_t -pack_8_24(int n, u_long numbers[], const char **error) +pack_8_24(int n, unsigned long numbers[], const char **error) { dev_t dev = 0; if (n == 2) { dev = makedev_8_24(numbers[0], numbers[1]); - if ((u_long)major_8_24(dev) != numbers[0]) + if ((unsigned long)major_8_24(dev) != numbers[0]) *error = iMajorError; - if ((u_long)minor_8_24(dev) != numbers[1]) + if ((unsigned long)minor_8_24(dev) != numbers[1]) *error = iMinorError; } else *error = tooManyFields; @@ -254,23 +254,23 @@ pack_8_24(int n, u_long numbers[], const char **error) (((z) << 0) & 0x000000ff))) static dev_t -pack_bsdos(int n, u_long numbers[], const char **error) +pack_bsdos(int n, unsigned long numbers[], const char **error) { dev_t dev = 0; if (n == 2) { dev = makedev_12_20(numbers[0], numbers[1]); - if ((u_long)major_12_20(dev) != numbers[0]) + if ((unsigned long)major_12_20(dev) != numbers[0]) *error = iMajorError; - if ((u_long)minor_12_20(dev) != numbers[1]) + if ((unsigned long)minor_12_20(dev) != numbers[1]) *error = iMinorError; } else if (n == 3) { dev = makedev_12_12_8(numbers[0], numbers[1], numbers[2]); - if ((u_long)major_12_12_8(dev) != numbers[0]) + if ((unsigned long)major_12_12_8(dev) != numbers[0]) *error = iMajorError; - if ((u_long)unit_12_12_8(dev) != numbers[1]) + if ((unsigned long)unit_12_12_8(dev) != numbers[1]) *error = "invalid unit number"; - if ((u_long)subunit_12_12_8(dev) != numbers[2]) + if ((unsigned long)subunit_12_12_8(dev) != numbers[2]) *error = "invalid subunit number"; } else *error = tooManyFields; diff --git a/Utilities/cmlibarchive/libarchive/archive_pack_dev.h b/Utilities/cmlibarchive/libarchive/archive_pack_dev.h index 7c7b80b..749fd3d 100644 --- a/Utilities/cmlibarchive/libarchive/archive_pack_dev.h +++ b/Utilities/cmlibarchive/libarchive/archive_pack_dev.h @@ -34,8 +34,7 @@ #ifndef _PACK_DEV_H #define _PACK_DEV_H -typedef dev_t pack_t(int, u_long [], const char **); -typedef unsigned long u_long; +typedef dev_t pack_t(int, unsigned long [], const char **); pack_t *pack_find(const char *); pack_t pack_native; -- cgit v0.12 From 856bfe238c8efa7f9cd4e07b883f1571e7d01277 Mon Sep 17 00:00:00 2001 From: Melven Roehrig-Zoellner Date: Wed, 9 Apr 2014 16:22:00 -0400 Subject: FindMPI: Use compiler implicit link dirs for matching language (#14870) Update the logic added by commit 2f9ad7c6 (Fix FindMPI for the intel compiler on linux, 2012-03-20) to use the implicit link directories for the current ${lang} instead of hard-coding C or CXX which may not be enabled. This is necessary for Fortran-only projects. --- Modules/FindMPI.cmake | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index c8d46ba..aa2dcee 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -378,19 +378,14 @@ function (interrogate_mpi_compiler lang try_libs) # Extract the set of libraries to link against from the link command # line string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") + # add the compiler implicit directories because some compilers # such as the intel compiler have libraries that show up # in the showme list that can only be found in the implicit - # link directories of the compiler. Do this for C++ and C - # compilers if the implicit link directories are defined. - if (DEFINED CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES) - set(MPI_LINK_PATH - "${MPI_LINK_PATH};${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES}") - endif () - - if (DEFINED CMAKE_C_IMPLICIT_LINK_DIRECTORIES) + # link directories of the compiler. + if (DEFINED CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES) set(MPI_LINK_PATH - "${MPI_LINK_PATH};${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + "${MPI_LINK_PATH};${CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES}") endif () # Determine full path names for all of the libraries that one needs -- cgit v0.12 From a553dc0a09024c4548d3cd8e9e2625f1e34931be Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 11 Apr 2014 10:39:58 -0400 Subject: CTestCustom: Suppress -Wcast-align warnings in sha2 code This is third party code and we know that at run time the correct alignment is achieved. --- CTestCustom.cmake.in | 1 + 1 file changed, 1 insertion(+) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index 3c589b4..fd5d744 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -19,6 +19,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION "Utilities.cmbzip2." "Source.CTest.Curl" "Source.CursesDialog.form" + "Source.cm_sha2.*warning.*cast increases required alignment of target type" "Utilities.cmcurl" "Utilities.cmexpat." "Utilities.cmlibarchive" -- cgit v0.12 From 973b3e7dcdd7e21103e330e1c82be897ce2bc322 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 12 Apr 2014 00:01:13 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 864bf1a..47d8ff1 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 0) -set(CMake_VERSION_PATCH 20140411) +set(CMake_VERSION_PATCH 20140412) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 185b4efe332d3d5465b307b29e5439427e863b2c Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Sun, 13 Apr 2014 00:48:02 +0200 Subject: CompileFlags: add better selection which aCC version gets -AA +hpxstd98 flags --- CompileFlags.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CompileFlags.cmake b/CompileFlags.cmake index 873af8f..5874031 100644 --- a/CompileFlags.cmake +++ b/CompileFlags.cmake @@ -54,8 +54,12 @@ if(CMAKE_SYSTEM MATCHES "OSF1-V.*") endif() if(CMAKE_SYSTEM_NAME MATCHES "HP-UX" AND CMAKE_CXX_COMPILER_ID MATCHES "HP") - # it is known that version 3.85 fails and 6.25 works without these flags - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4) + # HP aCC since version 3.80 supports the flag +hpxstd98 to get ANSI C++98 + # template support. It is known that version 6.25 doesn't need that flag. + # Versions prior to 3.80 will not be able to build CMake. Current assumption: + # it is needed for every version from 3.80 to 4 to get it working. + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4 AND + NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.80) # use new C++ library and improved template support set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA +hpxstd98") endif() -- cgit v0.12 From 99514c7e9cfb23c96ab234df349d6de38693332a Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 13 Apr 2014 00:01:07 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 47d8ff1..5e9630c 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 0) -set(CMake_VERSION_PATCH 20140412) +set(CMake_VERSION_PATCH 20140413) #set(CMake_VERSION_RC 1) -- cgit v0.12 From b8af20116854b51923da9ebef668fba0072b06c4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 13 Apr 2014 10:07:16 +0200 Subject: cmTarget: Fix listing of source files at configure-time. Since commit e5da9e51 (cmTarget: Allow any generator expression in SOURCES property., 2014-03-18), source files are computed by true evaluation of generator expressions, including TARGET_OBJECTS. This evaluation requires the presence of cmGeneratorTarget objects since commit bf98cc25 (Genex: Evaluate TARGET_OBJECTS as a normal expression., 2014-02-26). Ensure that we don't attempt to evaluate the TARGET_OBJECTS generator expression at configure-time, as can happen if CMP0024 or CMP0026 are OLD. Use old-style parsing of the source item to extract object target names in that case. Avoid calling GetProperty("SOURCES") to bypass warnings from CMP0051. Refactor existing logic in GetLanguages which is similar in intent to the new GetSourceFiles code. --- Source/cmTarget.cxx | 92 +++++++++++++++++----- Source/cmTarget.h | 2 + .../TargetSources/CMP0026-LOCATION-result.txt | 1 + .../TargetSources/CMP0026-LOCATION-stderr.txt | 1 + .../RunCMake/TargetSources/CMP0026-LOCATION.cmake | 13 +++ Tests/RunCMake/TargetSources/CMakeLists.txt | 2 +- Tests/RunCMake/TargetSources/RunCMakeTest.cmake | 2 + 7 files changed, 92 insertions(+), 21 deletions(-) create mode 100644 Tests/RunCMake/TargetSources/CMP0026-LOCATION-result.txt create mode 100644 Tests/RunCMake/TargetSources/CMP0026-LOCATION-stderr.txt create mode 100644 Tests/RunCMake/TargetSources/CMP0026-LOCATION.cmake diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1f8cddb..6a87342 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -647,6 +647,38 @@ void cmTarget::GetSourceFiles(std::vector &files, { assert(this->GetType() != INTERFACE_LIBRARY); + if (this->Makefile->GetGeneratorTargets().empty()) + { + // At configure-time, this method can be called as part of getting the + // LOCATION property or to export() a file to be include()d. However + // there is no cmGeneratorTarget at configure-time, so search the SOURCES + // for TARGET_OBJECTS instead for backwards compatibility with OLD + // behavior of CMP0024 and CMP0026 only. + + typedef cmTargetInternals::TargetPropertyEntry + TargetPropertyEntry; + for(std::vector::const_iterator + i = this->Internal->SourceEntries.begin(); + i != this->Internal->SourceEntries.end(); ++i) + { + std::string entry = (*i)->ge->GetInput(); + + std::vector items; + cmSystemTools::ExpandListArgument(entry, items); + for (std::vector::const_iterator + li = items.begin(); li != items.end(); ++li) + { + if(cmHasLiteralPrefix(*li, "$size() - 1] == '>') + { + continue; + } + files.push_back(*li); + } + } + return; + } + std::vector debugProperties; const char *debugProp = this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); @@ -5343,6 +5375,45 @@ bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, } //---------------------------------------------------------------------------- +void +cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const +{ + // At configure-time, this method can be called as part of getting the + // LOCATION property or to export() a file to be include()d. However + // there is no cmGeneratorTarget at configure-time, so search the SOURCES + // for TARGET_OBJECTS instead for backwards compatibility with OLD + // behavior of CMP0024 and CMP0026 only. + typedef cmTargetInternals::TargetPropertyEntry + TargetPropertyEntry; + for(std::vector::const_iterator + i = this->Internal->SourceEntries.begin(); + i != this->Internal->SourceEntries.end(); ++i) + { + std::string entry = (*i)->ge->GetInput(); + + std::vector files; + cmSystemTools::ExpandListArgument(entry, files); + for (std::vector::const_iterator + li = files.begin(); li != files.end(); ++li) + { + if(cmHasLiteralPrefix(*li, "$size() - 1] == '>') + { + std::string objLibName = li->substr(17, li->size()-18); + + if (cmGeneratorExpression::Find(objLibName) != std::string::npos) + { + continue; + } + cmTarget *objLib = this->Makefile->FindTargetToUse(objLibName.c_str()); + assert(objLib); + objlibs.push_back(objLib); + } + } + } +} + +//---------------------------------------------------------------------------- void cmTarget::GetLanguages(std::set& languages, const std::string& config, cmTarget const* head) const @@ -5363,26 +5434,7 @@ void cmTarget::GetLanguages(std::set& languages, std::vector externalObjects; if (this->Makefile->GetGeneratorTargets().empty()) { - // At configure-time, this method can be called as part of getting the - // LOCATION property or to export() a file to be include()d. However - // there is no cmGeneratorTarget at configure-time, so search the SOURCES - // for TARGET_OBJECTS instead for backwards compatibility with OLD - // behavior of CMP0024 and CMP0026 only. - std::vector srcs; - cmSystemTools::ExpandListArgument(this->GetProperty("SOURCES"), srcs); - for(std::vector::const_iterator it = srcs.begin(); - it != srcs.end(); ++it) - { - if (cmHasLiteralPrefix(*it, "$")) - { - std::string objLibName = it->substr(17, it->size()-18); - if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLibName)) - { - objectLibraries.push_back(tgt); - } - } - } + this->GetObjectLibrariesCMP0026(objectLibraries); } else { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 92b5201..0a086cb 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -241,6 +241,8 @@ public: bool IsImported() const {return this->IsImportedTarget;} + void GetObjectLibrariesCMP0026(std::vector& objlibs) const; + /** The link interface specifies transitive library dependencies and other information needed by targets that link to this target. */ struct LinkInterface diff --git a/Tests/RunCMake/TargetSources/CMP0026-LOCATION-result.txt b/Tests/RunCMake/TargetSources/CMP0026-LOCATION-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/TargetSources/CMP0026-LOCATION-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/TargetSources/CMP0026-LOCATION-stderr.txt b/Tests/RunCMake/TargetSources/CMP0026-LOCATION-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/TargetSources/CMP0026-LOCATION-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/TargetSources/CMP0026-LOCATION.cmake b/Tests/RunCMake/TargetSources/CMP0026-LOCATION.cmake new file mode 100644 index 0000000..464df36 --- /dev/null +++ b/Tests/RunCMake/TargetSources/CMP0026-LOCATION.cmake @@ -0,0 +1,13 @@ + +cmake_policy(SET CMP0026 OLD) + +add_library(objlib OBJECT + empty_1.cpp +) + +add_executable(my_exe + empty_2.cpp + $ +) + +get_target_property( loc my_exe LOCATION) diff --git a/Tests/RunCMake/TargetSources/CMakeLists.txt b/Tests/RunCMake/TargetSources/CMakeLists.txt index 12cd3c7..f452db1 100644 --- a/Tests/RunCMake/TargetSources/CMakeLists.txt +++ b/Tests/RunCMake/TargetSources/CMakeLists.txt @@ -1,3 +1,3 @@ cmake_minimum_required(VERSION 2.8.4) -project(${RunCMake_TEST} NONE) +project(${RunCMake_TEST} CXX) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake index b9095f9..01e505c 100644 --- a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake @@ -7,3 +7,5 @@ if(RunCMake_GENERATOR MATCHES Xcode else() run_cmake(OriginDebug) endif() + +run_cmake(CMP0026-LOCATION) -- cgit v0.12 From b8fd66f31c9399cf1ea2552b6bc8c4cae606c172 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 14 Apr 2014 00:01:05 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 5e9630c..cf4b121 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 0) -set(CMake_VERSION_PATCH 20140413) +set(CMake_VERSION_PATCH 20140414) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 6578508ca31f8394b5c04b1fa70260e917643bf6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 14 Apr 2014 13:14:31 +0200 Subject: Help: Fix installation of the Qt qch file. The file was changed to have the version in its name in commit 111bb67c (Help: Use a more-appropriate qthelp namespace and file name., 2014-04-10). --- Utilities/Sphinx/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index 0ae67bd..132ce60 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -149,7 +149,7 @@ if(SPHINX_HTML) ) endif() if(SPHINX_QTHELP) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake.qch + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake-${CMake_VERSION_MAJOR}${CMake_VERSION_MINOR}${CMake_VERSION_PATCH}.qch DESTINATION ${CMAKE_DOC_DIR} ) endif() -- cgit v0.12 From 73721c7ce0dc8fc9ee07fe70746aa44284390d89 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Apr 2014 11:03:41 -0400 Subject: CMakeDetermineVSServicePack: Add deprecation diagnostic Warn project developers at runtime that the module should not be used anymore. Issue the diagnostic only when the project requires a new enough CMake to use the alternative. Honor the CMAKE_(ERROR|WARN)_DEPRECATED settings. --- Help/release/dev/CMakeDetermineVSServicePack.rst | 6 ++++++ Modules/CMakeDetermineVSServicePack.cmake | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 Help/release/dev/CMakeDetermineVSServicePack.rst diff --git a/Help/release/dev/CMakeDetermineVSServicePack.rst b/Help/release/dev/CMakeDetermineVSServicePack.rst new file mode 100644 index 0000000..d9d7b41 --- /dev/null +++ b/Help/release/dev/CMakeDetermineVSServicePack.rst @@ -0,0 +1,6 @@ +CMakeDetermineVSServicePack +--------------------------- + +* The :module:`CMakeDetermineVSServicePack` module now warns that + it is deprecated and should not longer be used. Use the + :variable:`CMAKE__COMPILER_VERSION` variable instead. diff --git a/Modules/CMakeDetermineVSServicePack.cmake b/Modules/CMakeDetermineVSServicePack.cmake index 2854387..6886084 100644 --- a/Modules/CMakeDetermineVSServicePack.cmake +++ b/Modules/CMakeDetermineVSServicePack.cmake @@ -43,6 +43,13 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.8) + message(DEPRECATION + "This module is deprecated and should not be used. " + "Use the CMAKE__COMPILER_VERSION variable instead." + ) +endif() + # [INTERNAL] # Please do not call this function directly function(_DetermineVSServicePackFromCompiler _OUT_VAR _cl_version) -- cgit v0.12 From d9b591790e7cae2042db3b98bf98aa9a83a5cb06 Mon Sep 17 00:00:00 2001 From: Mike Crowe Date: Tue, 8 Apr 2014 13:08:46 +0100 Subject: libarchive: Skip finding libacl.h when ENABLE_ACL is OFF (#14866) --- Utilities/cmlibarchive/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt index e493966..afb7cea 100644 --- a/Utilities/cmlibarchive/CMakeLists.txt +++ b/Utilities/cmlibarchive/CMakeLists.txt @@ -350,7 +350,11 @@ ENDMACRO (LA_CHECK_INCLUDE_FILE) LA_CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H) # Alphabetize the rest unless there's a compelling reason -LA_CHECK_INCLUDE_FILE("acl/libacl.h" HAVE_ACL_LIBACL_H) +IF(ENABLE_ACL) + LA_CHECK_INCLUDE_FILE("acl/libacl.h" HAVE_ACL_LIBACL_H) +ELSE(ENABLE_ACL) + SET(HAVE_ACL_LIBACL_H FALSE) +ENDIF(ENABLE_ACL) LA_CHECK_INCLUDE_FILE("ctype.h" HAVE_CTYPE_H) LA_CHECK_INCLUDE_FILE("copyfile.h" HAVE_COPYFILE_H) LA_CHECK_INCLUDE_FILE("direct.h" HAVE_DIRECT_H) -- cgit v0.12 From 2622bc3f65162bf6d6cb5838da6999f8b5ca75cf Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Sun, 6 Apr 2014 21:30:00 +0200 Subject: Clean up usage of if(... MATCHES regex) followed string(REGEX REPLACE regex) The matches have already been calculated and can simply be taken from CMAKE_MATCH_n variables. This avoids multiple compilations of the same or very similar regular expressions. --- Modules/CMakeDetermineCompilerABI.cmake | 4 ++-- Modules/CMakeDetermineCompilerId.cmake | 15 +++++---------- Modules/CMakeParseImplicitLinkInfo.cmake | 10 ++++------ Modules/CheckTypeSize.cmake | 2 +- Modules/ExternalData.cmake | 10 ++++------ Modules/ExternalProject.cmake | 9 ++++----- Modules/FindBISON.cmake | 15 ++++++--------- Modules/FindBoost.cmake | 12 ++++++------ Modules/FindCUDA/parse_cubin.cmake | 8 ++++---- Modules/FindCups.cmake | 5 ++--- Modules/FindEXPAT.cmake | 5 ++--- Modules/FindFLTK.cmake | 4 +--- Modules/FindFLTK2.cmake | 4 +--- Modules/FindFreetype.cmake | 5 ++--- Modules/FindGettext.cmake | 4 ++-- Modules/FindImageMagick.cmake | 4 ++-- Modules/FindJava.cmake | 15 ++++++--------- Modules/FindPNG.cmake | 6 ++---- Modules/FindPerl.cmake | 4 ++-- Modules/FindPkgConfig.cmake | 8 ++++---- Modules/FindPythonInterp.cmake | 4 ++-- Modules/FindXMLRPC.cmake | 19 ++++++++----------- Modules/FortranCInterface/Detect.cmake | 5 ++--- Modules/Qt4Macros.cmake | 4 ++-- Source/CMakeVersionSource.cmake | 4 ++-- Tests/CMakeTests/ExecuteScriptTests.cmake | 4 ++-- 26 files changed, 80 insertions(+), 109 deletions(-) diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 5d35ce3..a8c89a4 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -53,10 +53,10 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) file(STRINGS "${BIN}" ABI_STRINGS LIMIT_COUNT 2 REGEX "INFO:[^[]*\\[") foreach(info ${ABI_STRINGS}) if("${info}" MATCHES ".*INFO:sizeof_dptr\\[0*([^]]*)\\].*") - string(REGEX REPLACE ".*INFO:sizeof_dptr\\[0*([^]]*)\\].*" "\\1" ABI_SIZEOF_DPTR "${info}") + set(ABI_SIZEOF_DPTR "${CMAKE_MATCH_1}") endif() if("${info}" MATCHES ".*INFO:abi\\[([^]]*)\\].*") - string(REGEX REPLACE ".*INFO:abi\\[([^]]*)\\].*" "\\1" ABI_NAME "${info}") + set(ABI_NAME "${CMAKE_MATCH_1}") endif() endforeach() diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 067892d..f977639 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -360,28 +360,23 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) if(COMPILER_ID) set(COMPILER_ID_TWICE 1) endif() - string(REGEX REPLACE ".*INFO:compiler\\[([^]]*)\\].*" "\\1" - COMPILER_ID "${info}") + set(COMPILER_ID "${CMAKE_MATCH_1}") endif() if("${info}" MATCHES ".*INFO:platform\\[([^]\"]*)\\].*") - string(REGEX REPLACE ".*INFO:platform\\[([^]]*)\\].*" "\\1" - PLATFORM_ID "${info}") + set(PLATFORM_ID "${CMAKE_MATCH_1}") endif() if("${info}" MATCHES ".*INFO:arch\\[([^]\"]*)\\].*") - string(REGEX REPLACE ".*INFO:arch\\[([^]]*)\\].*" "\\1" - ARCHITECTURE_ID "${info}") + set(ARCHITECTURE_ID "${CMAKE_MATCH_1}") endif() if("${info}" MATCHES ".*INFO:compiler_version\\[([^]\"]*)\\].*") - string(REGEX REPLACE ".*INFO:compiler_version\\[([^]]*)\\].*" "\\1" COMPILER_VERSION "${info}") - string(REGEX REPLACE "^0+([0-9])" "\\1" COMPILER_VERSION "${COMPILER_VERSION}") + string(REGEX REPLACE "^0+([0-9])" "\\1" COMPILER_VERSION "${CMAKE_MATCH_1}") string(REGEX REPLACE "\\.0+([0-9])" ".\\1" COMPILER_VERSION "${COMPILER_VERSION}") endif() if("${info}" MATCHES ".*INFO:simulate\\[([^]\"]*)\\].*") set(SIMULATE_ID "${CMAKE_MATCH_1}") endif() if("${info}" MATCHES ".*INFO:simulate_version\\[([^]\"]*)\\].*") - set(SIMULATE_VERSION "${CMAKE_MATCH_1}") - string(REGEX REPLACE "^0+([0-9])" "\\1" SIMULATE_VERSION "${SIMULATE_VERSION}") + string(REGEX REPLACE "^0+([0-9])" "\\1" SIMULATE_VERSION "${CMAKE_MATCH_1}") string(REGEX REPLACE "\\.0+([0-9])" ".\\1" SIMULATE_VERSION "${SIMULATE_VERSION}") endif() if("${info}" MATCHES ".*INFO:qnxnto") diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake index 4724a8c..bfcf455 100644 --- a/Modules/CMakeParseImplicitLinkInfo.cmake +++ b/Modules/CMakeParseImplicitLinkInfo.cmake @@ -64,10 +64,9 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj string(REGEX REPLACE "^-L" "" dir "${arg}") list(APPEND implicit_dirs_tmp ${dir}) set(log "${log} arg [${arg}] ==> dir [${dir}]\n") - elseif("${arg}" MATCHES "^-l[^:]") + elseif("${arg}" MATCHES "^-l([^:].*)$") # Unix library. - string(REGEX REPLACE "^-l" "" lib "${arg}") - list(APPEND implicit_libs_tmp ${lib}) + list(APPEND implicit_libs_tmp ${CMAKE_MATCH_1}) set(log "${log} arg [${arg}] ==> lib [${lib}]\n") elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.a$") # Unix library full path. @@ -97,11 +96,10 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj endif() endforeach() break() - elseif("${line}" MATCHES "LPATH(=| is:? )") + elseif("${line}" MATCHES "LPATH(=| is:? *)(.*)$") set(log "${log} LPATH line: [${line}]\n") # HP search path. - string(REGEX REPLACE ".*LPATH(=| is:? *)" "" paths "${line}") - string(REPLACE ":" ";" paths "${paths}") + string(REPLACE ":" ";" paths "${CMAKE_MATCH_2}") list(APPEND implicit_dirs_tmp ${paths}) set(log "${log} dirs [${paths}]\n") else() diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index d4651b9..ad3b6b5 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -142,7 +142,7 @@ function(__check_type_size_impl type var map builtin language) foreach(info ${strings}) if("${info}" MATCHES "${regex_size}") # Get the type size. - string(REGEX REPLACE "${regex_size}" "\\1" size "${info}") + set(size "${CMAKE_MATCH_1}") if(first) set(${var} ${size}) elseif(NOT "${size}" STREQUAL "${${var}}") diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 1e2698c..ee20693 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -292,8 +292,7 @@ function(ExternalData_expand_arguments target outArgsVar) foreach(piece IN LISTS pieces) if("x${piece}" MATCHES "^x${data_regex}$") # Replace this DATA{}-piece with a file path. - string(REGEX REPLACE "${data_regex}" "\\1" data "${piece}") - _ExternalData_arg("${target}" "${piece}" "${data}" file) + _ExternalData_arg("${target}" "${piece}" "${CMAKE_MATCH_1}" file) set(outArg "${outArg}${file}") else() # No replacement needed for this piece. @@ -428,10 +427,9 @@ function(_ExternalData_arg target arg options var_file) set(associated_files "") set(associated_regex "") foreach(opt ${options}) - if("x${opt}" MATCHES "^xREGEX:[^:/]+$") - # Regular expression to match associated files. - string(REGEX REPLACE "^REGEX:" "" regex "${opt}") - list(APPEND associated_regex "${regex}") + # Regular expression to match associated files. + if("x${opt}" MATCHES "^xREGEX:([^:/]+)$") + list(APPEND associated_regex "${CMAKE_MATCH_1}") elseif(opt STREQUAL ":") # Activate series matching. set(series_option "${opt}") diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 3ba91de..f587985 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -201,11 +201,11 @@ file(STRINGS "${CMAKE_CURRENT_LIST_FILE}" lines LIMIT_COUNT ${_ep_documentation_line_count} REGEX "^# ( \\[[A-Z0-9_]+ [^]]*\\] +#.*$|[A-Za-z0-9_]+\\()") foreach(line IN LISTS lines) - if("${line}" MATCHES "^# [A-Za-z0-9_]+\\(") + if("${line}" MATCHES "^# ([A-Za-z0-9_]+)\\(") if(_ep_func) set(_ep_keywords_${_ep_func} "${_ep_keywords_${_ep_func}})$") endif() - string(REGEX REPLACE "^# ([A-Za-z0-9_]+)\\(.*" "\\1" _ep_func "${line}") + set(_ep_func "${CMAKE_MATCH_1}") #message("function [${_ep_func}]") set(_ep_keywords_${_ep_func} "^(") set(_ep_keyword_sep) @@ -907,7 +907,8 @@ function(_ep_write_initial_cache target_name script_filename args) set(regex "^([^:]+):([^=]+)=(.*)$") set(setArg "") foreach(line ${args}) - if("${line}" MATCHES "^-D") + if("${line}" MATCHES "^-D(.*)") + set(line "${CMAKE_MATCH_1}") if(setArg) # This is required to build up lists in variables, or complete an entry set(setArg "${setArg}${accumulator}\" CACHE ${type} \"Initial cache\" FORCE)") @@ -915,9 +916,7 @@ function(_ep_write_initial_cache target_name script_filename args) set(accumulator "") set(setArg "") endif() - string(REGEX REPLACE "^-D" "" line ${line}) if("${line}" MATCHES "${regex}") - string(REGEX MATCH "${regex}" match "${line}") set(name "${CMAKE_MATCH_1}") set(type "${CMAKE_MATCH_2}") set(value "${CMAKE_MATCH_3}") diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index 9ca428e..ec3ee78 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -92,16 +92,13 @@ if(BISON_EXECUTABLE) message(SEND_ERROR "Command \"${BISON_EXECUTABLE} --version\" failed with output:\n${BISON_version_error}") else() # Bison++ - if("${BISON_version_output}" MATCHES "^bison\\+\\+") - string(REGEX REPLACE "^bison\\+\\+ Version ([^,]+).*" "\\1" - BISON_VERSION "${BISON_version_output}") + if("${BISON_version_output}" MATCHES "^bison\\+\\+ Version ([^,]+)") + set(BISON_VERSION "${CMAKE_MATCH_1}") # GNU Bison - elseif("${BISON_version_output}" MATCHES "^bison[^+]") - string(REGEX REPLACE "^bison \\(GNU Bison\\) ([^\n]+)\n.*" "\\1" - BISON_VERSION "${BISON_version_output}") - elseif("${BISON_version_output}" MATCHES "^GNU Bison ") - string(REGEX REPLACE "^GNU Bison (version )?([^\n]+).*" "\\2" - BISON_VERSION "${BISON_version_output}") + elseif("${BISON_version_output}" MATCHES "^bison \\(GNU Bison\\) ([^\n]+)\n") + set(BISON_VERSION "${CMAKE_MATCH_1}") + elseif("${BISON_version_output}" MATCHES "^GNU Bison (version )?([^\n]+)") + set(BISON_VERSION "${CMAKE_MATCH_2}") endif() endif() diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index d4026af..e894ba4 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -631,12 +631,12 @@ if(NOT Boost_INCLUDE_DIR) set(_boost_BOOSTIFIED_VERSION) # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0 - if(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+") - string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" - _boost_BOOSTIFIED_VERSION ${_boost_VER}) - elseif(_boost_VER MATCHES "[0-9]+\\.[0-9]+") - string(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" - _boost_BOOSTIFIED_VERSION ${_boost_VER}) + if(_boost_VER MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)") + set(_boost_BOOSTIFIED_VERSION + "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}_${CMAKE_MATCH_3}") + elseif(_boost_VER MATCHES "([0-9]+)\\.([0-9]+)") + set(_boost_BOOSTIFIED_VERSION + "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}") endif() list(APPEND _boost_PATH_SUFFIXES diff --git a/Modules/FindCUDA/parse_cubin.cmake b/Modules/FindCUDA/parse_cubin.cmake index 94be7e2..a42ccab 100644 --- a/Modules/FindCUDA/parse_cubin.cmake +++ b/Modules/FindCUDA/parse_cubin.cmake @@ -57,7 +57,7 @@ if (${file_text} MATCHES ".+") # Extract kernel names. if (${entry} MATCHES "[^g]name = ([^ ]+)") - string(REGEX REPLACE ".* = ([^ ]+)" "\\1" entry ${entry}) + set(entry "${CMAKE_MATCH_1}") # Check to see if the kernel name starts with "_" set(skip FALSE) @@ -76,19 +76,19 @@ if (${file_text} MATCHES ".+") # Registers if (${entry} MATCHES "reg([ ]+)=([ ]+)([^ ]+)") - string(REGEX REPLACE ".*([ ]+)=([ ]+)([^ ]+)" "\\3" entry ${entry}) + set(entry "${CMAKE_MATCH_3}") message("Registers: ${entry}") endif() # Local memory if (${entry} MATCHES "lmem([ ]+)=([ ]+)([^ ]+)") - string(REGEX REPLACE ".*([ ]+)=([ ]+)([^ ]+)" "\\3" entry ${entry}) + set(entry "${CMAKE_MATCH_3}") message("Local: ${entry}") endif() # Shared memory if (${entry} MATCHES "smem([ ]+)=([ ]+)([^ ]+)") - string(REGEX REPLACE ".*([ ]+)=([ ]+)([^ ]+)" "\\3" entry ${entry}) + set(entry "${CMAKE_MATCH_3}") message("Shared: ${entry}") endif() diff --git a/Modules/FindCups.cmake b/Modules/FindCups.cmake index 61353ca..51eb7c5 100644 --- a/Modules/FindCups.cmake +++ b/Modules/FindCups.cmake @@ -52,9 +52,8 @@ if (CUPS_INCLUDE_DIR AND EXISTS "${CUPS_INCLUDE_DIR}/cups/cups.h") unset(CUPS_VERSION_STRING) foreach(VPART MAJOR MINOR PATCH) foreach(VLINE ${cups_version_str}) - if(VLINE MATCHES "^#[\t ]*define[\t ]+CUPS_VERSION_${VPART}") - string(REGEX REPLACE "^#[\t ]*define[\t ]+CUPS_VERSION_${VPART}[\t ]+([0-9]+)$" "\\1" - CUPS_VERSION_PART "${VLINE}") + if(VLINE MATCHES "^#[\t ]*define[\t ]+CUPS_VERSION_${VPART}[\t ]+([0-9]+)$") + set(CUPS_VERSION_PART "${CMAKE_MATCH_1}") if(CUPS_VERSION_STRING) set(CUPS_VERSION_STRING "${CUPS_VERSION_STRING}.${CUPS_VERSION_PART}") else() diff --git a/Modules/FindEXPAT.cmake b/Modules/FindEXPAT.cmake index 6183af8..653094c 100644 --- a/Modules/FindEXPAT.cmake +++ b/Modules/FindEXPAT.cmake @@ -38,9 +38,8 @@ if (EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h") unset(EXPAT_VERSION_STRING) foreach(VPART MAJOR MINOR MICRO) foreach(VLINE ${expat_version_str}) - if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION") - string(REGEX REPLACE "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$" "\\1" - EXPAT_VERSION_PART "${VLINE}") + if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$") + set(EXPAT_VERSION_PART "${CMAKE_MATCH_1}") if(EXPAT_VERSION_STRING) set(EXPAT_VERSION_STRING "${EXPAT_VERSION_STRING}.${EXPAT_VERSION_PART}") else() diff --git a/Modules/FindFLTK.cmake b/Modules/FindFLTK.cmake index b87bc7f..76f702e 100644 --- a/Modules/FindFLTK.cmake +++ b/Modules/FindFLTK.cmake @@ -285,9 +285,7 @@ endif() OUTPUT_VARIABLE FLTK_IMAGES_LDFLAGS) set(FLTK_LIBS_EXTRACT_REGEX ".*-lfltk_images (.*) -lfltk.*") if("${FLTK_IMAGES_LDFLAGS}" MATCHES "${FLTK_LIBS_EXTRACT_REGEX}") - string(REGEX REPLACE "${FLTK_LIBS_EXTRACT_REGEX}" "\\1" - FLTK_IMAGES_LIBS "${FLTK_IMAGES_LDFLAGS}") - string(REGEX REPLACE " +" ";" FLTK_IMAGES_LIBS "${FLTK_IMAGES_LIBS}") + string(REGEX REPLACE " +" ";" FLTK_IMAGES_LIBS "${CMAKE_MATCH_1}") # The EXEC_PROGRAM will not be inherited into subdirectories from # the file that originally included this module. Save the answer. set(FLTK_IMAGES_LIBS "${FLTK_IMAGES_LIBS}" CACHE INTERNAL diff --git a/Modules/FindFLTK2.cmake b/Modules/FindFLTK2.cmake index 4deffda..930acca 100644 --- a/Modules/FindFLTK2.cmake +++ b/Modules/FindFLTK2.cmake @@ -226,9 +226,7 @@ if(FLTK2_DIR) OUTPUT_VARIABLE FLTK2_IMAGES_LDFLAGS) set(FLTK2_LIBS_EXTRACT_REGEX ".*-lfltk2_images (.*) -lfltk2.*") if("${FLTK2_IMAGES_LDFLAGS}" MATCHES "${FLTK2_LIBS_EXTRACT_REGEX}") - string(REGEX REPLACE "${FLTK2_LIBS_EXTRACT_REGEX}" "\\1" - FLTK2_IMAGES_LIBS "${FLTK2_IMAGES_LDFLAGS}") - string(REGEX REPLACE " +" ";" FLTK2_IMAGES_LIBS "${FLTK2_IMAGES_LIBS}") + string(REGEX REPLACE " +" ";" FLTK2_IMAGES_LIBS "${CMAKE_MATCH_1}") # The EXEC_PROGRAM will not be inherited into subdirectories from # the file that originally included this module. Save the answer. set(FLTK2_IMAGES_LIBS "${FLTK2_IMAGES_LIBS}" CACHE INTERNAL diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake index f0f9fe1..1779b78 100644 --- a/Modules/FindFreetype.cmake +++ b/Modules/FindFreetype.cmake @@ -117,9 +117,8 @@ if(FREETYPE_INCLUDE_DIR_freetype2 AND FREETYPE_H) unset(FREETYPE_VERSION_STRING) foreach(VPART MAJOR MINOR PATCH) foreach(VLINE ${freetype_version_str}) - if(VLINE MATCHES "^#[\t ]*define[\t ]+FREETYPE_${VPART}") - string(REGEX REPLACE "^#[\t ]*define[\t ]+FREETYPE_${VPART}[\t ]+([0-9]+)$" "\\1" - FREETYPE_VERSION_PART "${VLINE}") + if(VLINE MATCHES "^#[\t ]*define[\t ]+FREETYPE_${VPART}[\t ]+([0-9]+)$") + set(FREETYPE_VERSION_PART "${CMAKE_MATCH_1}") if(FREETYPE_VERSION_STRING) set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_STRING}.${FREETYPE_VERSION_PART}") else() diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake index 6a1e36e..7ab867b 100644 --- a/Modules/FindGettext.cmake +++ b/Modules/FindGettext.cmake @@ -71,8 +71,8 @@ if(GETTEXT_MSGMERGE_EXECUTABLE) OUTPUT_VARIABLE gettext_version ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if (gettext_version MATCHES "^msgmerge \\(.*\\) [0-9]") - string(REGEX REPLACE "^msgmerge \\([^\\)]*\\) ([0-9\\.]+[^ \n]*).*" "\\1" GETTEXT_VERSION_STRING "${gettext_version}") + if (gettext_version MATCHES "^msgmerge \\([^\\)]*\\) ([0-9\\.]+[^ \n]*)") + set(GETTEXT_VERSION_STRING "${CMAKE_MATCH_1}") endif() unset(gettext_version) endif() diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake index 1e7bda5..4f0e687 100644 --- a/Modules/FindImageMagick.cmake +++ b/Modules/FindImageMagick.cmake @@ -221,8 +221,8 @@ if(ImageMagick_mogrify_EXECUTABLE) OUTPUT_VARIABLE imagemagick_version ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if(imagemagick_version MATCHES "^Version: ImageMagick [0-9]") - string(REGEX REPLACE "^Version: ImageMagick ([-0-9\\.]+).*" "\\1" ImageMagick_VERSION_STRING "${imagemagick_version}") + if(imagemagick_version MATCHES "^Version: ImageMagick ([-0-9\\.]+)") + set(ImageMagick_VERSION_STRING "${CMAKE_MATCH_1}") endif() unset(imagemagick_version) endif() diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index a488c46..0bd7eb0 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -128,18 +128,15 @@ if(Java_JAVA_EXECUTABLE) # 3. GCJ 1.5 # 4. Kaffe 1.4.2 # 5. OpenJDK 1.7.x on OpenBSD - if(var MATCHES "java version \"[0-9]+\\.[0-9]+\\.[0-9_.]+.*\".*") + if(var MATCHES "java version \"([0-9]+\\.[0-9]+\\.[0-9_.]+.*)\"") # This is most likely Sun / OpenJDK, or maybe GCJ-java compat layer - string( REGEX REPLACE ".* version \"([0-9]+\\.[0-9]+\\.[0-9_.]+.*)\".*" - "\\1" Java_VERSION_STRING "${var}" ) - elseif(var MATCHES "java full version \"kaffe-[0-9]+\\.[0-9]+\\.[0-9_]+\".*") + set(Java_VERSION_STRING "${CMAKE_MATCH_1}") + elseif(var MATCHES "java full version \"kaffe-([0-9]+\\.[0-9]+\\.[0-9_]+)\"") # Kaffe style - string( REGEX REPLACE "java full version \"kaffe-([0-9]+\\.[0-9]+\\.[0-9_]+).*" - "\\1" Java_VERSION_STRING "${var}" ) - elseif(var MATCHES "openjdk version \"[0-9]+\\.[0-9]+\\.[0-9_]+\".*") + set(Java_VERSION_STRING "${CMAKE_MATCH_1}") + elseif(var MATCHES "openjdk version \"([0-9]+\\.[0-9]+\\.[0-9_]+)\"") # OpenJDK ver 1.7.x on OpenBSD - string( REGEX REPLACE "openjdk version \"([0-9]+\\.[0-9]+\\.[0-9_]+).*" - "\\1" Java_VERSION_STRING "${var}" ) + set(Java_VERSION_STRING "${CMAKE_MATCH_1}") else() if(NOT Java_FIND_QUIETLY) message(WARNING "regex not supported: ${var}. Please report") diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake index 873c3de..fa04bf0 100644 --- a/Modules/FindPNG.cmake +++ b/Modules/FindPNG.cmake @@ -56,10 +56,8 @@ if(ZLIB_FOUND) list(APPEND PNG_NAMES png libpng) unset(PNG_NAMES_DEBUG) set(_PNG_VERSION_SUFFIXES 17 16 15 14 12) - if (PNG_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\..*)?$") - string(REGEX REPLACE - "^([0-9]+)\\.([0-9]+).*" "\\1\\2" - _PNG_VERSION_SUFFIX_MIN "${PNG_FIND_VERSION}") + if (PNG_FIND_VERSION MATCHES "^([0-9]+)\\.([0-9]+)(\\..*)?$") + set(_PNG_VERSION_SUFFIX_MIN "${CMAKE_MATCH_1}${CMAKE_MATCH_2}") if (PNG_FIND_VERSION_EXACT) set(_PNG_VERSION_SUFFIXES ${_PNG_VERSION_SUFFIX_MIN}) else () diff --git a/Modules/FindPerl.cmake b/Modules/FindPerl.cmake index 3fd5d8e..70284b6 100644 --- a/Modules/FindPerl.cmake +++ b/Modules/FindPerl.cmake @@ -70,9 +70,9 @@ if(PERL_EXECUTABLE) OUTPUT_STRIP_TRAILING_WHITESPACE ) if(NOT PERL_VERSION_RESULT_VARIABLE AND PERL_VERSION_OUTPUT_VARIABLE MATCHES "This is perl.*[ \\(]v([0-9\\._]+)[ \\)]") - string(REGEX REPLACE ".*This is perl.*[ \\(]v([0-9\\._]+)[ \\)].*" "\\1" PERL_VERSION_STRING ${PERL_VERSION_OUTPUT_VARIABLE}) + set(PERL_VERSION_STRING "${CMAKE_MATCH_1}") elseif(NOT PERL_VERSION_RESULT_VARIABLE AND PERL_VERSION_OUTPUT_VARIABLE MATCHES "This is perl, version ([0-9\\._]+) +") - string(REGEX REPLACE ".*This is perl, version ([0-9\\._]+) +.*" "\\1" PERL_VERSION_STRING ${PERL_VERSION_OUTPUT_VARIABLE}) + set(PERL_VERSION_STRING "${CMAKE_MATCH_1}") endif() endif() endif() diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 8327143..d728324 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -277,10 +277,10 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma set(_pkg_check_modules_exist_query) # check whether version is given - if (_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*") - string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\1" _pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}") - string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\2" _pkg_check_modules_pkg_op "${_pkg_check_modules_pkg}") - string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\3" _pkg_check_modules_pkg_ver "${_pkg_check_modules_pkg}") + if (_pkg_check_modules_pkg MATCHES "(.*[^><])(>=|=|<=)(.*)") + set(_pkg_check_modules_pkg_name "${CMAKE_MATCH_1}") + set(_pkg_check_modules_pkg_op "${CMAKE_MATCH_2}") + set(_pkg_check_modules_pkg_ver "${CMAKE_MATCH_3}") else() set(_pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}") set(_pkg_check_modules_pkg_op) diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index c41f3a7..5e5c7b9 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -138,8 +138,8 @@ if(PYTHON_EXECUTABLE) string(REGEX REPLACE " .*" "" PYTHON_VERSION_STRING "${_VERSION}") string(REGEX REPLACE "^([0-9]+)\\.[0-9]+.*" "\\1" PYTHON_VERSION_MAJOR "${PYTHON_VERSION_STRING}") string(REGEX REPLACE "^[0-9]+\\.([0-9])+.*" "\\1" PYTHON_VERSION_MINOR "${PYTHON_VERSION_STRING}") - if(PYTHON_VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+.*") - string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" PYTHON_VERSION_PATCH "${PYTHON_VERSION_STRING}") + if(PYTHON_VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+\\.([0-9]+)") + set(PYTHON_VERSION_PATCH "${CMAKE_MATCH_1}") else() set(PYTHON_VERSION_PATCH "0") endif() diff --git a/Modules/FindXMLRPC.cmake b/Modules/FindXMLRPC.cmake index e855050..1491754 100644 --- a/Modules/FindXMLRPC.cmake +++ b/Modules/FindXMLRPC.cmake @@ -77,10 +77,9 @@ if(XMLRPC_FOUND) # Look for -I options. set(XMLRPC_INCLUDE_DIRS) foreach(flag ${XMLRPC_C_CONFIG_CFLAGS}) - if("${flag}" MATCHES "^-I") - string(REGEX REPLACE "^-I" "" DIR "${flag}") - file(TO_CMAKE_PATH "${DIR}" DIR) - set(XMLRPC_INCLUDE_DIRS ${XMLRPC_INCLUDE_DIRS} "${DIR}") + if("${flag}" MATCHES "^-I(.+)") + file(TO_CMAKE_PATH "${CMAKE_MATCH_1}" DIR) + list(APPEND XMLRPC_INCLUDE_DIRS "${DIR}") endif() endforeach() else() @@ -115,13 +114,11 @@ if(XMLRPC_FOUND) set(XMLRPC_LIBRARY_DIRS) set(XMLRPC_LIBRARY_NAMES) foreach(flag ${XMLRPC_C_CONFIG_LIBS}) - if("${flag}" MATCHES "^-L") - string(REGEX REPLACE "^-L" "" DIR "${flag}") - file(TO_CMAKE_PATH "${DIR}" DIR) - set(XMLRPC_LIBRARY_DIRS ${XMLRPC_LIBRARY_DIRS} "${DIR}") - elseif("${flag}" MATCHES "^-l") - string(REGEX REPLACE "^-l" "" NAME "${flag}") - set(XMLRPC_LIBRARY_NAMES ${XMLRPC_LIBRARY_NAMES} "${NAME}") + if("${flag}" MATCHES "^-L(.+)") + file(TO_CMAKE_PATH "${CMAKE_MATCH_1}" DIR) + list(APPEND XMLRPC_LIBRARY_DIRS "${DIR}") + elseif("${flag}" MATCHES "^-l(.+)") + list(APPEND XMLRPC_LIBRARY_NAMES "${CMAKE_MATCH_1}") endif() endforeach() diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake index afeb9c5..ceb1db4 100644 --- a/Modules/FortranCInterface/Detect.cmake +++ b/Modules/FortranCInterface/Detect.cmake @@ -69,9 +69,8 @@ if(FortranCInterface_EXE) file(STRINGS "${FortranCInterface_EXE}" _info_strings LIMIT_COUNT 8 REGEX "INFO:[^[]*\\[") foreach(info ${_info_strings}) - if("${info}" MATCHES ".*INFO:symbol\\[([^]]*)\\].*") - string(REGEX REPLACE ".*INFO:symbol\\[([^]]*)\\].*" "\\1" symbol "${info}") - list(APPEND FortranCInterface_SYMBOLS ${symbol}) + if("${info}" MATCHES "INFO:symbol\\[([^]]*)\\]") + list(APPEND FortranCInterface_SYMBOLS ${CMAKE_MATCH_1}) endif() endforeach() elseif(NOT _result) diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index 23c4fc0..b1b12d6 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -65,8 +65,8 @@ macro (QT4_MAKE_OUTPUT_FILE infile prefix ext outfile ) else() file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile}) endif() - if(WIN32 AND rel MATCHES "^[a-zA-Z]:") # absolute path - string(REGEX REPLACE "^([a-zA-Z]):(.*)$" "\\1_\\2" rel "${rel}") + if(WIN32 AND rel MATCHES "^([a-zA-Z]):(.*)$") # absolute path + set(rel "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}") endif() set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}") string(REPLACE ".." "__" _outfile ${_outfile}) diff --git a/Source/CMakeVersionSource.cmake b/Source/CMakeVersionSource.cmake index 05e265c..888f557 100644 --- a/Source/CMakeVersionSource.cmake +++ b/Source/CMakeVersionSource.cmake @@ -30,8 +30,8 @@ if(EXISTS ${CMake_SOURCE_DIR}/.git/HEAD) elseif(EXISTS ${CMake_SOURCE_DIR}/CVS/Repository) file(READ ${CMake_SOURCE_DIR}/CVS/Repository repo) set(branch "") - if("${repo}" MATCHES "\\.git/") - string(REGEX REPLACE ".*\\.git/([^\r\n]*).*" "-\\1" branch "${repo}") + if("${repo}" MATCHES "\\.git/([^\r\n]*)") + set(branch "${CMAKE_MATCH_1}") endif() set(CMake_VERSION_SOURCE "cvs${branch}") endif() diff --git a/Tests/CMakeTests/ExecuteScriptTests.cmake b/Tests/CMakeTests/ExecuteScriptTests.cmake index c71585a..bceac33 100644 --- a/Tests/CMakeTests/ExecuteScriptTests.cmake +++ b/Tests/CMakeTests/ExecuteScriptTests.cmake @@ -52,9 +52,9 @@ function(execute_all_script_tests scriptname result) foreach(line ${script}) if(line MATCHES "${regex}") + set(testname "${CMAKE_MATCH_2}") + set(expected_result "${CMAKE_MATCH_3}") math(EXPR count "${count} + 1") - string(REGEX REPLACE "${regex}" "\\2" testname "${line}") - string(REGEX REPLACE "${regex}" "\\3" expected_result "${line}") execute_one_script_test(${scriptname} ${testname} ${expected_result}) endif() endforeach() -- cgit v0.12 From 5bd48ac5348885e15ebb23ea825a1ea777985b97 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Sun, 6 Apr 2014 21:51:33 +0200 Subject: Replace string(REGEX REPLACE) with string(REPLACE) where possible The simple replacement is much faster. --- Modules/BundleUtilities.cmake | 6 +++--- Modules/CMakeDetermineCompilerId.cmake | 2 +- Modules/CMakeDetermineSystem.cmake | 4 ++-- Modules/CPackDeb.cmake | 2 +- Modules/CPackRPM.cmake | 2 +- Modules/FindCUDA/make2cmake.cmake | 3 +-- Modules/FindCUDA/parse_cubin.cmake | 5 ++--- Modules/FindGDAL.cmake | 4 ++-- Modules/FindHDF5.cmake | 4 ++-- Modules/FindKDE3.cmake | 2 +- Modules/FindMPI.cmake | 4 ++-- Modules/FindPackageMessage.cmake | 2 +- Modules/FortranCInterface.cmake | 2 +- Modules/GetPrerequisites.cmake | 8 ++++---- Modules/Platform/OpenBSD.cmake | 2 +- Tests/CMakeTests/CheckCMakeTest.cmake | 4 ++-- Tests/CTestUpdateCommon.cmake | 4 ++-- Tests/CustomCommand/CMakeLists.txt | 4 ++-- cmake_uninstall.cmake.in | 2 +- 19 files changed, 32 insertions(+), 34 deletions(-) diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index b896de2..eaddd04 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -235,8 +235,8 @@ function(get_bundle_main_executable bundle result_var) # set(eol_char "E") file(READ "${bundle}/Contents/Info.plist" info_plist) - string(REGEX REPLACE ";" "\\\\;" info_plist "${info_plist}") - string(REGEX REPLACE "\n" "${eol_char};" info_plist "${info_plist}") + string(REPLACE ";" "\\;" info_plist "${info_plist}") + string(REPLACE "\n" "${eol_char};" info_plist "${info_plist}") # Scan the lines for "CFBundleExecutable" - the line after that # is the name of the main executable. @@ -394,7 +394,7 @@ function(get_item_key item key_var) if(WIN32) string(TOLOWER "${item_name}" item_name) endif() - string(REGEX REPLACE "\\." "_" ${key_var} "${item_name}") + string(REPLACE "." "_" ${key_var} "${item_name}") set(${key_var} ${${key_var}} PARENT_SCOPE) endfunction() diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index f977639..73cb92a 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -27,7 +27,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) else() set(CMAKE_${lang}_COMPILER_ID_FLAGS $ENV{${flagvar}}) endif() - string(REGEX REPLACE " " ";" CMAKE_${lang}_COMPILER_ID_FLAGS_LIST "${CMAKE_${lang}_COMPILER_ID_FLAGS}") + string(REPLACE " " ";" CMAKE_${lang}_COMPILER_ID_FLAGS_LIST "${CMAKE_${lang}_COMPILER_ID_FLAGS}") # Compute the directory in which to run the test. set(CMAKE_${lang}_COMPILER_ID_DIR ${CMAKE_PLATFORM_INFO_DIR}/CompilerId${lang}) diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index f1bad99..1c0941a 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -72,8 +72,8 @@ if(CMAKE_HOST_UNIX) endif() set(CMAKE_UNAME ${CMAKE_UNAME} CACHE INTERNAL "uname command") # processor may have double quote in the name, and that needs to be removed - string(REGEX REPLACE "\"" "" CMAKE_HOST_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}") - string(REGEX REPLACE "/" "_" CMAKE_HOST_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}") + string(REPLACE "\"" "" CMAKE_HOST_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}") + string(REPLACE "/" "_" CMAKE_HOST_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}") endif() else() if(CMAKE_HOST_WIN32) diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index b210bbb..458bbed 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -259,7 +259,7 @@ if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS) OUTPUT_VARIABLE CPACK_DEB_INSTALL_FILES) # Convert to CMake list - string(REGEX REPLACE "\n" ";" CPACK_DEB_INSTALL_FILES ${CPACK_DEB_INSTALL_FILES}) + string(REPLACE "\n" ";" CPACK_DEB_INSTALL_FILES ${CPACK_DEB_INSTALL_FILES}) # Only dynamically linked ELF files are included # Extract only file name infront of ":" diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index a13a46f..ad88e6b 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -384,7 +384,7 @@ if(CPACK_RPM_PACKAGE_DEBUG) OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REGEX REPLACE "\n" ", " + string(REPLACE "\n" ", " LSB_RELEASE_OUTPUT ${_TMP_LSB_RELEASE_OUTPUT}) else () diff --git a/Modules/FindCUDA/make2cmake.cmake b/Modules/FindCUDA/make2cmake.cmake index 1b53d17..7194652 100644 --- a/Modules/FindCUDA/make2cmake.cmake +++ b/Modules/FindCUDA/make2cmake.cmake @@ -41,8 +41,7 @@ if (${depend_text} MATCHES ".+") # message("FOUND DEPENDS") - # Remember, four backslashes is escaped to one backslash in the string. - string(REGEX REPLACE "\\\\ " " " depend_text ${depend_text}) + string(REPLACE "\\ " " " depend_text ${depend_text}) # This works for the nvcc -M generated dependency files. string(REGEX REPLACE "^.* : " "" depend_text ${depend_text}) diff --git a/Modules/FindCUDA/parse_cubin.cmake b/Modules/FindCUDA/parse_cubin.cmake index a42ccab..ddb50de 100644 --- a/Modules/FindCUDA/parse_cubin.cmake +++ b/Modules/FindCUDA/parse_cubin.cmake @@ -39,9 +39,8 @@ file(READ ${input_file} file_text) if (${file_text} MATCHES ".+") - # Remember, four backslashes is escaped to one backslash in the string. - string(REGEX REPLACE ";" "\\\\;" file_text ${file_text}) - string(REGEX REPLACE "\ncode" ";code" file_text ${file_text}) + string(REPLACE ";" "\\;" file_text ${file_text}) + string(REPLACE "\ncode" ";code" file_text ${file_text}) list(LENGTH file_text len) diff --git a/Modules/FindGDAL.cmake b/Modules/FindGDAL.cmake index 4e04c31..bf374f9 100644 --- a/Modules/FindGDAL.cmake +++ b/Modules/FindGDAL.cmake @@ -90,9 +90,9 @@ if(UNIX) exec_program(${GDAL_CONFIG} ARGS --libs OUTPUT_VARIABLE GDAL_CONFIG_LIBS) if(GDAL_CONFIG_LIBS) string(REGEX MATCHALL "-l[^ ]+" _gdal_dashl ${GDAL_CONFIG_LIBS}) - string(REGEX REPLACE "-l" "" _gdal_lib "${_gdal_dashl}") + string(REPLACE "-l" "" _gdal_lib "${_gdal_dashl}") string(REGEX MATCHALL "-L[^ ]+" _gdal_dashL ${GDAL_CONFIG_LIBS}) - string(REGEX REPLACE "-L" "" _gdal_libpath "${_gdal_dashL}") + string(REPLACE "-L" "" _gdal_libpath "${_gdal_dashL}") endif() endif() endif() diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 2903bf8..1aa5dcf 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -162,7 +162,7 @@ macro( _HDF5_parse_compile_line ) foreach( IPATH ${include_path_flags} ) string( REGEX REPLACE "^-I" "" IPATH ${IPATH} ) - string( REGEX REPLACE "//" "/" IPATH ${IPATH} ) + string( REPLACE "//" "/" IPATH ${IPATH} ) list( APPEND ${include_paths} ${IPATH} ) endforeach() @@ -179,7 +179,7 @@ macro( _HDF5_parse_compile_line foreach( LPATH ${library_path_flags} ) string( REGEX REPLACE "^-L" "" LPATH ${LPATH} ) - string( REGEX REPLACE "//" "/" LPATH ${LPATH} ) + string( REPLACE "//" "/" LPATH ${LPATH} ) list( APPEND ${library_paths} ${LPATH} ) endforeach() diff --git a/Modules/FindKDE3.cmake b/Modules/FindKDE3.cmake index 159e29c..ea898a6 100644 --- a/Modules/FindKDE3.cmake +++ b/Modules/FindKDE3.cmake @@ -192,7 +192,7 @@ if(KDECONFIG_EXECUTABLE) if ("${kde_version}" MATCHES "KDE: 3\\.") execute_process(COMMAND ${KDECONFIG_EXECUTABLE} --prefix OUTPUT_VARIABLE kdedir ) - string(REGEX REPLACE "\n" "" KDE3PREFIX "${kdedir}") + string(REPLACE "\n" "" KDE3PREFIX "${kdedir}") endif () endif() diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index c8d46ba..b00040f 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -330,7 +330,7 @@ function (interrogate_mpi_compiler lang try_libs) string(REGEX MATCHALL "(^| )-I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") foreach(IPATH ${MPI_ALL_INCLUDE_PATHS}) string(REGEX REPLACE "^ ?-I" "" IPATH ${IPATH}) - string(REGEX REPLACE "//" "/" IPATH ${IPATH}) + string(REPLACE "//" "/" IPATH ${IPATH}) list(APPEND MPI_INCLUDE_PATH_WORK ${IPATH}) endforeach() @@ -354,7 +354,7 @@ function (interrogate_mpi_compiler lang try_libs) set(MPI_LINK_PATH) foreach(LPATH ${MPI_ALL_LINK_PATHS}) string(REGEX REPLACE "^(| |-Wl,)-L" "" LPATH ${LPATH}) - string(REGEX REPLACE "//" "/" LPATH ${LPATH}) + string(REPLACE "//" "/" LPATH ${LPATH}) list(APPEND MPI_LINK_PATH ${LPATH}) endforeach() diff --git a/Modules/FindPackageMessage.cmake b/Modules/FindPackageMessage.cmake index b6a58e4..a0349d3 100644 --- a/Modules/FindPackageMessage.cmake +++ b/Modules/FindPackageMessage.cmake @@ -42,7 +42,7 @@ function(FIND_PACKAGE_MESSAGE pkg msg details) # Avoid printing a message repeatedly for the same find result. if(NOT ${pkg}_FIND_QUIETLY) - string(REGEX REPLACE "[\n]" "" details "${details}") + string(REPLACE "\n" "" details "${details}") set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") # The message has not yet been printed. diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake index dccb26f..27f8a82 100644 --- a/Modules/FortranCInterface.cmake +++ b/Modules/FortranCInterface.cmake @@ -328,7 +328,7 @@ function(FortranCInterface_VERIFY) # Error if compilers are incompatible. if(NOT FortranCInterface_VERIFIED_${lang} AND NOT quiet) file(READ "${FortranCInterface_BINARY_DIR}/Verify${lang}/output.txt" _output) - string(REGEX REPLACE "\n" "\n " _output "${_output}") + string(REPLACE "\n" "\n " _output "${_output}") message(FATAL_ERROR "The Fortran compiler:\n ${CMAKE_Fortran_COMPILER}\n" "and the ${lang} compiler:\n ${CMAKE_${lang}_COMPILER}\n" diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index ac649e9..05c2edb 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -509,10 +509,10 @@ function(gp_resolved_file_type original_file file exepath dirs type_var) if(WIN32) string(TOLOWER "$ENV{SystemRoot}" sysroot) - string(REGEX REPLACE "\\\\" "/" sysroot "${sysroot}") + file(TO_CMAKE_PATH "${sysroot}" sysroot) string(TOLOWER "$ENV{windir}" windir) - string(REGEX REPLACE "\\\\" "/" windir "${windir}") + file(TO_CMAKE_PATH "${windir}" windir) if(lower MATCHES "^(${sysroot}/sys(tem|wow)|${windir}/sys(tem|wow)|(.*/)*msvc[^/]+dll)") set(is_system 1) @@ -772,8 +772,8 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa # Convert to a list of lines: # - string(REGEX REPLACE ";" "\\\\;" candidates "${gp_cmd_ov}") - string(REGEX REPLACE "\n" "${eol_char};" candidates "${candidates}") + string(REPLACE ";" "\\;" candidates "${gp_cmd_ov}") + string(REPLACE "\n" "${eol_char};" candidates "${candidates}") # check for install id and remove it from list, since otool -L can include a # reference to itself diff --git a/Modules/Platform/OpenBSD.cmake b/Modules/Platform/OpenBSD.cmake index 53cabed..a4f6114 100644 --- a/Modules/Platform/OpenBSD.cmake +++ b/Modules/Platform/OpenBSD.cmake @@ -10,7 +10,7 @@ if(NOT CMAKE_PLATFORM_RUNTIME_PATH) ERROR_QUIET) string(REGEX REPLACE ".*search\\ directories:\\ ([^\n]*).*" "\\1" LDCONFIG_HINTS "${LDCONFIG_HINTS}") - string(REGEX REPLACE ":" ";" + string(REPLACE ":" ";" CMAKE_PLATFORM_RUNTIME_PATH "${LDCONFIG_HINTS}") endif() diff --git a/Tests/CMakeTests/CheckCMakeTest.cmake b/Tests/CMakeTests/CheckCMakeTest.cmake index 7be7b30..1565394 100644 --- a/Tests/CMakeTests/CheckCMakeTest.cmake +++ b/Tests/CMakeTests/CheckCMakeTest.cmake @@ -9,8 +9,8 @@ function(check_cmake_test_single prefix test testfile) ERROR_VARIABLE stderr RESULT_VARIABLE result ) - string(REGEX REPLACE "\n" "\n out> " out " out> ${stdout}") - string(REGEX REPLACE "\n" "\n err> " err " err> ${stderr}") + string(REPLACE "\n" "\n out> " out " out> ${stdout}") + string(REPLACE "\n" "\n err> " err " err> ${stderr}") if(NOT "${result}" STREQUAL "${${test}-RESULT}") message(FATAL_ERROR "Test ${test} result is [${result}], not [${${test}-RESULT}].\n" diff --git a/Tests/CTestUpdateCommon.cmake b/Tests/CTestUpdateCommon.cmake index 642a618..857c6f5 100644 --- a/Tests/CTestUpdateCommon.cmake +++ b/Tests/CTestUpdateCommon.cmake @@ -9,7 +9,7 @@ function(run_child) ERROR_STRIP_TRAILING_WHITESPACE ) if(FAILED) - string(REGEX REPLACE "\n" "\n " OUTPUT "${OUTPUT}") + string(REPLACE "\n" "\n " OUTPUT "${OUTPUT}") message(FATAL_ERROR "Child failed (${FAILED}), output is\n ${OUTPUT}\n" "Command = [${ARGN}]\n") endif() @@ -108,7 +108,7 @@ function(check_updates build) ${TOP}/${build}/Testing/Temporary/LastUpdate*.log) if(UPDATE_LOG_FILE) file(READ ${UPDATE_LOG_FILE} UPDATE_LOG LIMIT ${max_update_xml_size}) - string(REGEX REPLACE "\n" "\n " UPDATE_LOG "${UPDATE_LOG}") + string(REPLACE "\n" "\n " UPDATE_LOG "${UPDATE_LOG}") set(MSG "${MSG}Update log:\n ${UPDATE_LOG}") else() set(MSG "${MSG}No update log found!") diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index a194a5f..e0854ce 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -367,8 +367,8 @@ endif() foreach(arg ${CHECK_ARGS} "") set(ARG "${arg}") - string(REGEX REPLACE "\\\\" "\\\\\\\\" ARG "${ARG}") - string(REGEX REPLACE "\"" "\\\\\"" ARG "${ARG}") + string(REPLACE "\\" "\\\\" ARG "${ARG}") + string(REPLACE "\"" "\\\"" ARG "${ARG}") set(EXPECTED_ARGUMENTS "${EXPECTED_ARGUMENTS} \"${ARG}\", ") diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in index 7cd7fc1..d81f62a 100644 --- a/cmake_uninstall.cmake.in +++ b/cmake_uninstall.cmake.in @@ -3,7 +3,7 @@ if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") endif() file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) -string(REGEX REPLACE "\n" ";" files "${files}") +string(REPLACE "\n" ";" files "${files}") foreach(file ${files}) message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") if(EXISTS "$ENV{DESTDIR}${file}") -- cgit v0.12 From b0b4b4602fd5f8508d6fcbb9ea3236585e6368e2 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 11 Apr 2014 18:17:46 +0200 Subject: Remove .* expressions from beginning and end of MATCHES regexs All these expressions work the same: "foo" ".*foo.*" "^.*foo.*$" This assumes that the "Intel*" expressions were meant to be "Intel.*". --- CompileFlags.cmake | 6 +++--- Modules/BasicConfigVersion-ExactVersion.cmake.in | 4 ++-- Modules/BundleUtilities.cmake | 4 ++-- Modules/CMakeBackwardCompatibilityCXX.cmake | 4 ++-- Modules/CMakeDetermineCCompiler.cmake | 2 +- Modules/CMakeDetermineCXXCompiler.cmake | 2 +- Modules/CMakeDetermineCompilerABI.cmake | 4 ++-- Modules/CMakeDetermineCompilerId.cmake | 14 +++++++------- Modules/CMakeDetermineFortranCompiler.cmake | 6 +++--- Modules/CPackRPM.cmake | 2 +- Modules/FindBLAS.cmake | 8 ++++---- Modules/FindBoost.cmake | 2 +- Modules/FindCUDA.cmake | 2 +- Modules/FindHDF5.cmake | 2 +- Modules/FindIcotool.cmake | 2 +- Modules/FindLAPACK.cmake | 4 ++-- Modules/FindQt.cmake | 2 +- Modules/FindQt3.cmake | 4 ++-- Modules/FindSquish.cmake | 2 +- Modules/FindThreads.cmake | 4 ++-- Modules/FindZLIB.cmake | 2 +- Modules/FindwxWidgets.cmake | 4 ++-- Modules/Platform/Darwin.cmake | 2 +- Modules/Platform/OSF1.cmake | 4 ++-- Modules/Platform/SunOS.cmake | 2 +- Modules/UseSWIG.cmake | 2 +- Modules/UseVTKConfig40.cmake | 2 +- Tests/CMakeLists.txt | 4 ++-- Tests/Complex/CMakeLists.txt | 2 +- Tests/ComplexOneConfig/CMakeLists.txt | 2 +- Tests/FindPackageModeMakefileTest/CMakeLists.txt | 2 +- Tests/PerConfig/perconfig.cmake | 2 +- 32 files changed, 55 insertions(+), 55 deletions(-) diff --git a/CompileFlags.cmake b/CompileFlags.cmake index 873af8f..a6ff8e0 100644 --- a/CompileFlags.cmake +++ b/CompileFlags.cmake @@ -34,20 +34,20 @@ else() endif() #silence duplicate symbol warnings on AIX -if(CMAKE_SYSTEM MATCHES "AIX.*") +if(CMAKE_SYSTEM MATCHES "AIX") if(NOT CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -bhalt:5 ") endif() endif() -if(CMAKE_SYSTEM MATCHES "IRIX.*") +if(CMAKE_SYSTEM MATCHES "IRIX") if(NOT CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-woff84 -no_auto_include") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-woff15") endif() endif() -if(CMAKE_SYSTEM MATCHES "OSF1-V.*") +if(CMAKE_SYSTEM MATCHES "OSF1-V") if(NOT CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ") endif() diff --git a/Modules/BasicConfigVersion-ExactVersion.cmake.in b/Modules/BasicConfigVersion-ExactVersion.cmake.in index 63f3f03..9fd0136 100644 --- a/Modules/BasicConfigVersion-ExactVersion.cmake.in +++ b/Modules/BasicConfigVersion-ExactVersion.cmake.in @@ -11,13 +11,13 @@ set(PACKAGE_VERSION "@CVF_VERSION@") -if("@CVF_VERSION@" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\..*") # strip the tweak version +if("@CVF_VERSION@" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\.") # strip the tweak version set(CVF_VERSION_NO_TWEAK "${CMAKE_MATCH_1}") else() set(CVF_VERSION_NO_TWEAK "@CVF_VERSION@") endif() -if("${PACKAGE_FIND_VERSION}" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\..*") # strip the tweak version +if("${PACKAGE_FIND_VERSION}" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\.") # strip the tweak version set(REQUESTED_VERSION_NO_TWEAK "${CMAKE_MATCH_1}") else() set(REQUESTED_VERSION_NO_TWEAK "${PACKAGE_FIND_VERSION}") diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index eaddd04..0c733fa 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -247,7 +247,7 @@ function(get_bundle_main_executable bundle result_var) break() endif() - if(line MATCHES "^.*CFBundleExecutable.*$") + if(line MATCHES "CFBundleExecutable") set(line_is_main_executable 1) endif() endforeach() @@ -287,7 +287,7 @@ endfunction() function(get_dotapp_dir exe dotapp_dir_var) set(s "${exe}") - if(s MATCHES "^.*/.*\\.app/.*$") + if(s MATCHES "/.*\\.app/") # If there is a ".app" parent directory, # ascend until we hit it: # (typical of a Mac bundle executable) diff --git a/Modules/CMakeBackwardCompatibilityCXX.cmake b/Modules/CMakeBackwardCompatibilityCXX.cmake index 343fdb2..a3da2d6 100644 --- a/Modules/CMakeBackwardCompatibilityCXX.cmake +++ b/Modules/CMakeBackwardCompatibilityCXX.cmake @@ -31,10 +31,10 @@ if(NOT CMAKE_SKIP_COMPATIBILITY_TESTS) if(NOT CMAKE_COMPILER_IS_GNUCXX) include(TestCXXAcceptsFlag) set(CMAKE_TRY_ANSI_CXX_FLAGS "") - if(CMAKE_SYSTEM MATCHES "IRIX.*") + if(CMAKE_SYSTEM MATCHES "IRIX") set(CMAKE_TRY_ANSI_CXX_FLAGS "-LANG:std") endif() - if(CMAKE_SYSTEM MATCHES "OSF.*") + if(CMAKE_SYSTEM MATCHES "OSF") set(CMAKE_TRY_ANSI_CXX_FLAGS "-std strict_ansi -nopure_cname") endif() # if CMAKE_TRY_ANSI_CXX_FLAGS has something in it, see diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index aa4cdc9..ace53ec 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -138,7 +138,7 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) elseif("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_C_COMPILER_TARGET}-) elseif(COMPILER_BASENAME MATCHES "qcc(\\.exe)?$") - if(CMAKE_C_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?.*$") + if(CMAKE_C_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?") set(_CMAKE_TOOLCHAIN_PREFIX nto${CMAKE_MATCH_1}-) endif() endif () diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index ef8445e..7df9f65 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -135,7 +135,7 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_CXX_COMPILER_TARGET}-) elseif(COMPILER_BASENAME MATCHES "QCC(\\.exe)?$") - if(CMAKE_CXX_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?.*$") + if(CMAKE_CXX_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?") set(_CMAKE_TOOLCHAIN_PREFIX nto${CMAKE_MATCH_1}-) endif() endif () diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index a8c89a4..8595b97 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -52,10 +52,10 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) "Detecting ${lang} compiler ABI info compiled with the following output:\n${OUTPUT}\n\n") file(STRINGS "${BIN}" ABI_STRINGS LIMIT_COUNT 2 REGEX "INFO:[^[]*\\[") foreach(info ${ABI_STRINGS}) - if("${info}" MATCHES ".*INFO:sizeof_dptr\\[0*([^]]*)\\].*") + if("${info}" MATCHES "INFO:sizeof_dptr\\[0*([^]]*)\\]") set(ABI_SIZEOF_DPTR "${CMAKE_MATCH_1}") endif() - if("${info}" MATCHES ".*INFO:abi\\[([^]]*)\\].*") + if("${info}" MATCHES "INFO:abi\\[([^]]*)\\]") set(ABI_NAME "${CMAKE_MATCH_1}") endif() endforeach() diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 73cb92a..f109dc4 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -356,30 +356,30 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) CMAKE_${lang}_COMPILER_ID_STRINGS LIMIT_COUNT 6 REGEX "INFO:") set(COMPILER_ID_TWICE) foreach(info ${CMAKE_${lang}_COMPILER_ID_STRINGS}) - if("${info}" MATCHES ".*INFO:compiler\\[([^]\"]*)\\].*") + if("${info}" MATCHES "INFO:compiler\\[([^]\"]*)\\]") if(COMPILER_ID) set(COMPILER_ID_TWICE 1) endif() set(COMPILER_ID "${CMAKE_MATCH_1}") endif() - if("${info}" MATCHES ".*INFO:platform\\[([^]\"]*)\\].*") + if("${info}" MATCHES "INFO:platform\\[([^]\"]*)\\]") set(PLATFORM_ID "${CMAKE_MATCH_1}") endif() - if("${info}" MATCHES ".*INFO:arch\\[([^]\"]*)\\].*") + if("${info}" MATCHES "INFO:arch\\[([^]\"]*)\\]") set(ARCHITECTURE_ID "${CMAKE_MATCH_1}") endif() - if("${info}" MATCHES ".*INFO:compiler_version\\[([^]\"]*)\\].*") + if("${info}" MATCHES "INFO:compiler_version\\[([^]\"]*)\\]") string(REGEX REPLACE "^0+([0-9])" "\\1" COMPILER_VERSION "${CMAKE_MATCH_1}") string(REGEX REPLACE "\\.0+([0-9])" ".\\1" COMPILER_VERSION "${COMPILER_VERSION}") endif() - if("${info}" MATCHES ".*INFO:simulate\\[([^]\"]*)\\].*") + if("${info}" MATCHES "INFO:simulate\\[([^]\"]*)\\]") set(SIMULATE_ID "${CMAKE_MATCH_1}") endif() - if("${info}" MATCHES ".*INFO:simulate_version\\[([^]\"]*)\\].*") + if("${info}" MATCHES "INFO:simulate_version\\[([^]\"]*)\\]") string(REGEX REPLACE "^0+([0-9])" "\\1" SIMULATE_VERSION "${CMAKE_MATCH_1}") string(REGEX REPLACE "\\.0+([0-9])" ".\\1" SIMULATE_VERSION "${SIMULATE_VERSION}") endif() - if("${info}" MATCHES ".*INFO:qnxnto") + if("${info}" MATCHES "INFO:qnxnto") set(COMPILER_QNXNTO 1) endif() endforeach() diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index d38bf25..0eb75a2 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -130,7 +130,7 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN) ARGS ${CMAKE_Fortran_COMPILER_ID_FLAGS_LIST} -E "\"${CMAKE_ROOT}/Modules/CMakeTestGNU.c\"" OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT RETURN_VALUE CMAKE_COMPILER_RETURN) if(NOT CMAKE_COMPILER_RETURN) - if("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" ) + if("${CMAKE_COMPILER_OUTPUT}" MATCHES "THIS_IS_GNU") set(CMAKE_Fortran_COMPILER_ID "GNU") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the Fortran compiler is GNU succeeded with " @@ -141,10 +141,10 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN) "the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n") endif() if(NOT CMAKE_Fortran_PLATFORM_ID) - if("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_MINGW.*" ) + if("${CMAKE_COMPILER_OUTPUT}" MATCHES "THIS_IS_MINGW") set(CMAKE_Fortran_PLATFORM_ID "MinGW") endif() - if("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_CYGWIN.*" ) + if("${CMAKE_COMPILER_OUTPUT}" MATCHES "THIS_IS_CYGWIN") set(CMAKE_Fortran_PLATFORM_ID "Cygwin") endif() endif() diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index ad88e6b..2864b21 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -397,7 +397,7 @@ endif() # to shut down warning about space in buildtree # some recent RPM version should support space in different places. # not checked [yet]. -if(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*") +if(CPACK_TOPLEVEL_DIRECTORY MATCHES " ") message(FATAL_ERROR "${RPMBUILD_EXECUTABLE} can't handle paths with spaces, use a build directory without spaces for building RPMs.") endif() diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 1cf9124..7a5c259 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -288,7 +288,7 @@ if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") endif () #BLAS in acml library? -if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") +if (BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All") if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR ((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR ((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS)) @@ -465,7 +465,7 @@ if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") endif () #BLAS in intel mkl 10 library? (em64t 64bit) -if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") +if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") if (NOT WIN32) set(LM "-lm") endif () @@ -532,7 +532,7 @@ if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") "mkl_blas95 mkl_intel_lp64 mkl_intel_thread mkl_core guide") # mkl >= 10.3 - if (CMAKE_C_COMPILER MATCHES ".+gcc.*") + if (CMAKE_C_COMPILER MATCHES ".+gcc") list(APPEND BLAS_SEARCH_LIBS "mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core gomp") else () @@ -600,7 +600,7 @@ if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") "mkl_intel_lp64 mkl_intel_thread mkl_core guide") # mkl >= 10.3 - if (CMAKE_C_COMPILER MATCHES ".+gcc.*") + if (CMAKE_C_COMPILER MATCHES ".+gcc") list(APPEND BLAS_SEARCH_LIBS "mkl_intel_lp64 mkl_gnu_thread mkl_core gomp") else () diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index e894ba4..dfd4460 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -684,7 +684,7 @@ if(Boost_INCLUDE_DIR) set(_Boost_VERSION_REGEX "([0-9]+)") set(_Boost_LIB_VERSION_REGEX "\"([0-9_]+)\"") foreach(v VERSION LIB_VERSION) - if("${_boost_VERSION_HPP_CONTENTS}" MATCHES ".*#define BOOST_${v} ${_Boost_${v}_REGEX}.*") + if("${_boost_VERSION_HPP_CONTENTS}" MATCHES "#define BOOST_${v} ${_Boost_${v}_REGEX}") set(Boost_${v} "${CMAKE_MATCH_1}") endif() endforeach() diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 94f82f6..c02809d 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -1194,7 +1194,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) foreach(file ${ARGN}) # Ignore any file marked as a HEADER_FILE_ONLY get_source_file_property(_is_header ${file} HEADER_FILE_ONLY) - if(${file} MATCHES ".*\\.cu$" AND NOT _is_header) + if(${file} MATCHES "\\.cu$" AND NOT _is_header) # Allow per source file overrides of the format. get_source_file_property(_cuda_source_format ${file} CUDA_SOURCE_PROPERTY_FORMAT) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 1aa5dcf..0d58e13 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -253,7 +253,7 @@ if( NOT HDF5_FOUND ) list( APPEND HDF5_DEFINITIONS ${HDF5_${LANGUAGE}_DEFINITIONS} ) # find the HDF5 include directories - if(${LANGUAGE} MATCHES "Fortran.*") + if(${LANGUAGE} MATCHES "Fortran") set(HDF5_INCLUDE_FILENAME hdf5.mod) else() set(HDF5_INCLUDE_FILENAME hdf5.h) diff --git a/Modules/FindIcotool.cmake b/Modules/FindIcotool.cmake index e29fe2e..a7c5a64 100644 --- a/Modules/FindIcotool.cmake +++ b/Modules/FindIcotool.cmake @@ -37,7 +37,7 @@ if(ICOTOOL_EXECUTABLE) ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ) - if("${_icotool_version}" MATCHES "^icotool \\([^\\)]*\\) ([0-9\\.]+[^ \n]*).*") + if("${_icotool_version}" MATCHES "^icotool \\([^\\)]*\\) ([0-9\\.]+[^ \n]*)") set( ICOTOOL_VERSION_STRING "${CMAKE_MATCH_1}" ) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 33f4f0c..87938c8 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -183,7 +183,7 @@ endif () #acml lapack - if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") + if (BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All") if (BLAS_LIBRARIES MATCHES ".+acml.+") set (LAPACK_LIBRARIES ${BLAS_LIBRARIES}) endif () @@ -233,7 +233,7 @@ if (BLA_VENDOR STREQUAL "Generic" OR endif () endif () #intel lapack -if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") +if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") if (NOT WIN32) set(LM "-lm") endif () diff --git a/Modules/FindQt.cmake b/Modules/FindQt.cmake index e893c7a..98ba43d 100644 --- a/Modules/FindQt.cmake +++ b/Modules/FindQt.cmake @@ -87,7 +87,7 @@ find_program(QT_QMAKE_EXECUTABLE_FINDQT NAMES qmake PATHS "${QT_SEARCH_PATH}/bin if(QT_QMAKE_EXECUTABLE_FINDQT) exec_program(${QT_QMAKE_EXECUTABLE_FINDQT} ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION) - if(QTVERSION MATCHES "4.*") + if(QTVERSION MATCHES "4") set(QT_QMAKE_EXECUTABLE ${QT_QMAKE_EXECUTABLE_FINDQT} CACHE PATH "Qt4 qmake program.") set(QT4_INSTALLED TRUE) endif() diff --git a/Modules/FindQt3.cmake b/Modules/FindQt3.cmake index 6cd12c6..4fc6829 100644 --- a/Modules/FindQt3.cmake +++ b/Modules/FindQt3.cmake @@ -295,12 +295,12 @@ if(QT_UIC_EXECUTABLE) endif() set(_QT_UIC_VERSION_3 FALSE) -if("${QTVERSION_UIC}" MATCHES ".* 3..*") +if("${QTVERSION_UIC}" MATCHES " 3.") set(_QT_UIC_VERSION_3 TRUE) endif() set(_QT_MOC_VERSION_3 FALSE) -if("${QTVERSION_MOC}" MATCHES ".* 3..*") +if("${QTVERSION_MOC}" MATCHES " 3.") set(_QT_MOC_VERSION_3 TRUE) endif() diff --git a/Modules/FindSquish.cmake b/Modules/FindSquish.cmake index 5cff122..4076521 100644 --- a/Modules/FindSquish.cmake +++ b/Modules/FindSquish.cmake @@ -184,7 +184,7 @@ if(SQUISH_CLIENT_EXECUTABLE) execute_process(COMMAND "${SQUISH_CLIENT_EXECUTABLE}" --version OUTPUT_VARIABLE _squishVersionOutput ERROR_QUIET ) - if("${_squishVersionOutput}" MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+).*$") + if("${_squishVersionOutput}" MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)") set(SQUISH_VERSION_MAJOR "${CMAKE_MATCH_1}") set(SQUISH_VERSION_MINOR "${CMAKE_MATCH_2}") set(SQUISH_VERSION_PATCH "${CMAKE_MATCH_3}") diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index 6d1c65d..b5cc67f 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -162,12 +162,12 @@ if(CMAKE_USE_PTHREADS_INIT) set(CMAKE_USE_PTHREADS_INIT 1) endif() - if(CMAKE_SYSTEM MATCHES "OSF1-V*") + if(CMAKE_SYSTEM MATCHES "OSF1-V") set(CMAKE_USE_PTHREADS_INIT 0) set(CMAKE_THREAD_LIBS_INIT ) endif() - if(CMAKE_SYSTEM MATCHES "CYGWIN_NT*") + if(CMAKE_SYSTEM MATCHES "CYGWIN_NT") set(CMAKE_USE_PTHREADS_INIT 1) set(Threads_FOUND TRUE) set(CMAKE_THREAD_LIBS_INIT ) diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index 75b0076..8cc382c 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -85,7 +85,7 @@ if(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h") # only append a TWEAK version if it exists: set(ZLIB_VERSION_TWEAK "") - if( "${ZLIB_H}" MATCHES "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$") + if( "${ZLIB_H}" MATCHES "ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+)") set(ZLIB_VERSION_TWEAK "${CMAKE_MATCH_1}") set(ZLIB_VERSION_STRING "${ZLIB_VERSION_STRING}.${ZLIB_VERSION_TWEAK}") endif() diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 3c664e7..45596a0 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -560,7 +560,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") if(WX_LIB_DIR) # If building shared libs, define WXUSINGDLL to use dllimport. - if(WX_LIB_DIR MATCHES ".*[dD][lL][lL].*") + if(WX_LIB_DIR MATCHES "[dD][lL][lL]") set(wxWidgets_DEFINITIONS WXUSINGDLL) DBG_MSG_V("detected SHARED/DLL tree WX_LIB_DIR=${WX_LIB_DIR}") endif() @@ -668,7 +668,7 @@ else() if(_wx_result EQUAL 0) foreach(_opt_name debug static unicode universal) string(TOUPPER ${_opt_name} _upper_opt_name) - if(_wx_selected_config MATCHES ".*${_opt_name}.*") + if(_wx_selected_config MATCHES "${_opt_name}") set(wxWidgets_DEFAULT_${_upper_opt_name} ON) else() set(wxWidgets_DEFAULT_${_upper_opt_name} OFF) diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index fc3f87e..df0756b 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -203,7 +203,7 @@ endif() # Make sure the combination of SDK and Deployment Target are allowed if(CMAKE_OSX_DEPLOYMENT_TARGET) - if("${_CMAKE_OSX_SYSROOT_PATH}" MATCHES "^.*/MacOSX([0-9]+\\.[0-9]+)[^/]*\\.sdk") + if("${_CMAKE_OSX_SYSROOT_PATH}" MATCHES "/MacOSX([0-9]+\\.[0-9]+)[^/]*\\.sdk") set(_sdk_ver "${CMAKE_MATCH_1}") elseif("${_CMAKE_OSX_SYSROOT_ORIG}" MATCHES "^macosx([0-9]+\\.[0-9]+)$") set(_sdk_ver "${CMAKE_MATCH_1}") diff --git a/Modules/Platform/OSF1.cmake b/Modules/Platform/OSF1.cmake index 9c3255e..f2ad612 100644 --- a/Modules/Platform/OSF1.cmake +++ b/Modules/Platform/OSF1.cmake @@ -2,7 +2,7 @@ set(CMAKE_DL_LIBS "") if(CMAKE_SYSTEM MATCHES "OSF1-1.[012]") endif() -if(CMAKE_SYSTEM MATCHES "OSF1-1.*") +if(CMAKE_SYSTEM MATCHES "OSF1-1") # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2 set(CMAKE_C_COMPILE_OPTIONS_PIC "-fpic") set(CMAKE_C_COMPILE_OPTIONS_PIE "-fpie") @@ -12,7 +12,7 @@ endif() -if(CMAKE_SYSTEM MATCHES "OSF1-V.*") +if(CMAKE_SYSTEM MATCHES "OSF1-V") set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,-expect_unresolved,\\*") # -shared if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-Wl,-rpath,") diff --git a/Modules/Platform/SunOS.cmake b/Modules/Platform/SunOS.cmake index da20f97..aaa79c4 100644 --- a/Modules/Platform/SunOS.cmake +++ b/Modules/Platform/SunOS.cmake @@ -1,4 +1,4 @@ -if(CMAKE_SYSTEM MATCHES "SunOS-4.*") +if(CMAKE_SYSTEM MATCHES "SunOS-4") set(CMAKE_C_COMPILE_OPTIONS_PIC "-PIC") set(CMAKE_C_COMPILE_OPTIONS_PIE "-PIE") set(CMAKE_SHARED_LIBRARY_C_FLAGS "-PIC") diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 23bf933..fa11585 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -181,7 +181,7 @@ macro(SWIG_ADD_MODULE name language) set(swig_dot_i_sources) set(swig_other_sources) foreach(it ${ARGN}) - if(${it} MATCHES ".*\\.i$") + if(${it} MATCHES "\\.i$") set(swig_dot_i_sources ${swig_dot_i_sources} "${it}") else() set(swig_other_sources ${swig_other_sources} "${it}") diff --git a/Modules/UseVTKConfig40.cmake b/Modules/UseVTKConfig40.cmake index 554b8c4..c5022e4 100644 --- a/Modules/UseVTKConfig40.cmake +++ b/Modules/UseVTKConfig40.cmake @@ -312,7 +312,7 @@ else() if(CMAKE_ANSI_CFLAGS) set(VTK_REQUIRED_C_FLAGS "${VTK_REQUIRED_C_FLAGS} ${CMAKE_ANSI_CFLAGS}") endif() - if(CMAKE_SYSTEM MATCHES "OSF1-V.*") + if(CMAKE_SYSTEM MATCHES "OSF1-V") set(VTK_REQUIRED_CXX_FLAGS "${VTK_REQUIRED_CXX_FLAGS} -timplicit_local -no_implicit_include") endif() diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 0e60ed1..7d4e8b4 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -798,7 +798,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release set(CTEST_package_X11_TEST ${CTEST_TEST_CPACK}) set(CTEST_RUN_CPackComponentsForAll ${CTEST_TEST_CPACK}) - if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*") + if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_CURRENT_BINARY_DIR MATCHES " ") find_program(RPMBUILD NAMES rpmbuild) endif() # Do not try to build RPM @@ -899,7 +899,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release if(APPLE) list(APPEND GENLST "DragNDrop") endif() - if (NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*") + if (NOT CMAKE_CURRENT_BINARY_DIR MATCHES " ") list(FIND ACTIVE_CPACK_GENERATORS "RPM" RPM_ACTIVE) if (NOT ${RPM_ACTIVE} EQUAL -1) list(APPEND GENLST "RPM") diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt index fcde44d..001ae56 100644 --- a/Tests/Complex/CMakeLists.txt +++ b/Tests/Complex/CMakeLists.txt @@ -70,7 +70,7 @@ if(NOT 2.4 EQUAL 2.4) message(FATAL_ERROR "Failed: NOT 2.4 EQUAL 2.4") endif() -if(CMAKE_SYSTEM MATCHES "OSF1-V.*") +if(CMAKE_SYSTEM MATCHES "OSF1-V") if(NOT CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ") endif() diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt index a4a0e0e..a908e11 100644 --- a/Tests/ComplexOneConfig/CMakeLists.txt +++ b/Tests/ComplexOneConfig/CMakeLists.txt @@ -70,7 +70,7 @@ if(NOT 2.4 EQUAL 2.4) message(FATAL_ERROR "Failed: NOT 2.4 EQUAL 2.4") endif() -if(CMAKE_SYSTEM MATCHES "OSF1-V.*") +if(CMAKE_SYSTEM MATCHES "OSF1-V") if(NOT CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ") endif() diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt index 5d1b376..8e21c32 100644 --- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -10,7 +10,7 @@ if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile") ERROR_QUIET TIMEOUT 10) string(TOUPPER "${makeVersionOutput}" MAKE_VERSION_OUTPUT) - if("${MAKE_VERSION_OUTPUT}" MATCHES ".*GNU MAKE.*") + if("${MAKE_VERSION_OUTPUT}" MATCHES "GNU MAKE") # build a library which we can search during the test add_library(foo STATIC foo.cpp) diff --git a/Tests/PerConfig/perconfig.cmake b/Tests/PerConfig/perconfig.cmake index 6a710ca..0731041 100644 --- a/Tests/PerConfig/perconfig.cmake +++ b/Tests/PerConfig/perconfig.cmake @@ -30,7 +30,7 @@ endif() # Verify that the implementation files are named correctly. foreach(lib pcStatic pcShared) file(STRINGS "${${lib}_file}" info LIMIT_COUNT 1 REGEX "INFO:[^[]*\\[") - if(NOT "${info}" MATCHES ".*INFO:symbol\\[${lib}\\].*") + if(NOT "${info}" MATCHES "INFO:symbol\\[${lib}\\]") message(SEND_ERROR "No INFO:symbol[${lib}] found in:\n ${${lib}_file}") endif() endforeach() -- cgit v0.12 From 3a71d34cf3a10ee215ae3899acafd29551ba6e7e Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 11 Apr 2014 18:27:01 +0200 Subject: Use CMAKE_SYSTEM_NAME instead of CMAKE_SYSTEM where sufficient --- CompileFlags.cmake | 4 ++-- Modules/CMakeBackwardCompatibilityCXX.cmake | 4 ++-- Modules/FindThreads.cmake | 6 +++--- Tests/SubDirSpaces/CMakeLists.txt | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CompileFlags.cmake b/CompileFlags.cmake index a6ff8e0..5f6a099 100644 --- a/CompileFlags.cmake +++ b/CompileFlags.cmake @@ -34,13 +34,13 @@ else() endif() #silence duplicate symbol warnings on AIX -if(CMAKE_SYSTEM MATCHES "AIX") +if(CMAKE_SYSTEM_NAME MATCHES "AIX") if(NOT CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -bhalt:5 ") endif() endif() -if(CMAKE_SYSTEM MATCHES "IRIX") +if(CMAKE_SYSTEM_NAME MATCHES "IRIX") if(NOT CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-woff84 -no_auto_include") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-woff15") diff --git a/Modules/CMakeBackwardCompatibilityCXX.cmake b/Modules/CMakeBackwardCompatibilityCXX.cmake index a3da2d6..94a94ee 100644 --- a/Modules/CMakeBackwardCompatibilityCXX.cmake +++ b/Modules/CMakeBackwardCompatibilityCXX.cmake @@ -31,10 +31,10 @@ if(NOT CMAKE_SKIP_COMPATIBILITY_TESTS) if(NOT CMAKE_COMPILER_IS_GNUCXX) include(TestCXXAcceptsFlag) set(CMAKE_TRY_ANSI_CXX_FLAGS "") - if(CMAKE_SYSTEM MATCHES "IRIX") + if(CMAKE_SYSTEM_NAME MATCHES "IRIX") set(CMAKE_TRY_ANSI_CXX_FLAGS "-LANG:std") endif() - if(CMAKE_SYSTEM MATCHES "OSF") + if(CMAKE_SYSTEM_NAME MATCHES "OSF") set(CMAKE_TRY_ANSI_CXX_FLAGS "-std strict_ansi -nopure_cname") endif() # if CMAKE_TRY_ANSI_CXX_FLAGS has something in it, see diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index b5cc67f..6050dcd 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -41,7 +41,7 @@ set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) set(CMAKE_REQUIRED_QUIET ${Threads_FIND_QUIETLY}) # Do we have sproc? -if(CMAKE_SYSTEM MATCHES IRIX AND NOT CMAKE_THREAD_PREFER_PTHREAD) +if(CMAKE_SYSTEM_NAME MATCHES IRIX AND NOT CMAKE_THREAD_PREFER_PTHREAD) CHECK_INCLUDE_FILES("sys/types.h;sys/prctl.h" CMAKE_HAVE_SPROC_H) endif() @@ -138,13 +138,13 @@ if(CMAKE_THREAD_LIBS_INIT OR CMAKE_HAVE_LIBC_CREATE) set(Threads_FOUND TRUE) endif() -if(CMAKE_SYSTEM MATCHES "Windows") +if(CMAKE_SYSTEM_NAME MATCHES "Windows") set(CMAKE_USE_WIN32_THREADS_INIT 1) set(Threads_FOUND TRUE) endif() if(CMAKE_USE_PTHREADS_INIT) - if(CMAKE_SYSTEM MATCHES "HP-UX-*") + if(CMAKE_SYSTEM_NAME MATCHES "HP-UX") # Use libcma if it exists and can be used. It provides more # symbols than the plain pthread library. CMA threads # have actually been deprecated: diff --git a/Tests/SubDirSpaces/CMakeLists.txt b/Tests/SubDirSpaces/CMakeLists.txt index 69f1d68..40c265e 100644 --- a/Tests/SubDirSpaces/CMakeLists.txt +++ b/Tests/SubDirSpaces/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.6) project(SUBDIR) # Some systems do not seem to support rpath with spaces. -if("${CMAKE_SYSTEM}" MATCHES "IRIX|QNX") +if(CMAKE_SYSTEM_NAME MATCHES "IRIX|QNX") set(CMAKE_SKIP_BUILD_RPATH 1) endif() -- cgit v0.12 From 7eacbaed4db3c3fe5d6c0e3a31e239530a7468f1 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 11 Apr 2014 18:36:08 +0200 Subject: Replace MATCHES ".+" tests with NOT STREQUAL "" --- Modules/CMakeBackwardCompatibilityCXX.cmake | 2 +- Modules/CMakeDetermineASMCompiler.cmake | 2 +- Modules/CMakeDetermineCCompiler.cmake | 2 +- Modules/CMakeDetermineCXXCompiler.cmake | 2 +- Modules/CMakeDetermineFortranCompiler.cmake | 2 +- Modules/CMakeDetermineJavaCompiler.cmake | 6 +++--- Modules/CMakeDetermineRCCompiler.cmake | 2 +- Modules/CMakeExportBuildSettings.cmake | 2 +- Modules/CMakeImportBuildSettings.cmake | 3 +-- Modules/FeatureSummary.cmake | 4 ++-- Modules/FindBLAS.cmake | 2 +- Modules/FindCUDA/make2cmake.cmake | 2 +- Modules/FindCUDA/parse_cubin.cmake | 2 +- Modules/FindLAPACK.cmake | 2 +- 14 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Modules/CMakeBackwardCompatibilityCXX.cmake b/Modules/CMakeBackwardCompatibilityCXX.cmake index 94a94ee..f1db46e 100644 --- a/Modules/CMakeBackwardCompatibilityCXX.cmake +++ b/Modules/CMakeBackwardCompatibilityCXX.cmake @@ -39,7 +39,7 @@ if(NOT CMAKE_SKIP_COMPATIBILITY_TESTS) endif() # if CMAKE_TRY_ANSI_CXX_FLAGS has something in it, see # if the compiler accepts it - if( CMAKE_TRY_ANSI_CXX_FLAGS MATCHES ".+") + if(NOT CMAKE_TRY_ANSI_CXX_FLAGS STREQUAL "") CHECK_CXX_ACCEPTS_FLAG(${CMAKE_TRY_ANSI_CXX_FLAGS} CMAKE_CXX_ACCEPTS_FLAGS) # if the compiler liked the flag then set CMAKE_ANSI_CXXFLAGS # to the flag diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 1d9617f..25af3e3 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -18,7 +18,7 @@ include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake) if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER) # prefer the environment variable ASM - if($ENV{ASM${ASM_DIALECT}} MATCHES ".+") + if(NOT $ENV{ASM${ASM_DIALECT}} STREQUAL "") set(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT "$ENV{ASM${ASM_DIALECT}}") endif() diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index ace53ec..3847b75 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -48,7 +48,7 @@ else() set(CMAKE_C_COMPILER_INIT NOTFOUND) # prefer the environment variable CC - if($ENV{CC} MATCHES ".+") + if(NOT $ENV{CC} STREQUAL "") get_filename_component(CMAKE_C_COMPILER_INIT $ENV{CC} PROGRAM PROGRAM_ARGS CMAKE_C_FLAGS_ENV_INIT) if(CMAKE_C_FLAGS_ENV_INIT) set(CMAKE_C_COMPILER_ARG1 "${CMAKE_C_FLAGS_ENV_INIT}" CACHE STRING "First argument to C compiler") diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 7df9f65..e6a9d9a 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -47,7 +47,7 @@ else() set(CMAKE_CXX_COMPILER_INIT NOTFOUND) # prefer the environment variable CXX - if($ENV{CXX} MATCHES ".+") + if(NOT $ENV{CXX} STREQUAL "") get_filename_component(CMAKE_CXX_COMPILER_INIT $ENV{CXX} PROGRAM PROGRAM_ARGS CMAKE_CXX_FLAGS_ENV_INIT) if(CMAKE_CXX_FLAGS_ENV_INIT) set(CMAKE_CXX_COMPILER_ARG1 "${CMAKE_CXX_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler") diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 0eb75a2..96df6a2 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -32,7 +32,7 @@ elseif("${CMAKE_GENERATOR}" MATCHES "Xcode") else() if(NOT CMAKE_Fortran_COMPILER) # prefer the environment variable CC - if($ENV{FC} MATCHES ".+") + if(NOT $ENV{FC} STREQUAL "") get_filename_component(CMAKE_Fortran_COMPILER_INIT $ENV{FC} PROGRAM PROGRAM_ARGS CMAKE_Fortran_FLAGS_ENV_INIT) if(CMAKE_Fortran_FLAGS_ENV_INIT) set(CMAKE_Fortran_COMPILER_ARG1 "${CMAKE_Fortran_FLAGS_ENV_INIT}" CACHE STRING "First argument to Fortran compiler") diff --git a/Modules/CMakeDetermineJavaCompiler.cmake b/Modules/CMakeDetermineJavaCompiler.cmake index 7ae7856..f657801 100644 --- a/Modules/CMakeDetermineJavaCompiler.cmake +++ b/Modules/CMakeDetermineJavaCompiler.cmake @@ -18,7 +18,7 @@ if(NOT CMAKE_Java_COMPILER) # prefer the environment variable CC - if($ENV{JAVA_COMPILER} MATCHES ".+") + if(NOT $ENV{JAVA_COMPILER} STREQUAL "") get_filename_component(CMAKE_Java_COMPILER_INIT $ENV{JAVA_COMPILER} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT) if(CMAKE_Java_FLAGS_ENV_INIT) set(CMAKE_Java_COMPILER_ARG1 "${CMAKE_Java_FLAGS_ENV_INIT}" CACHE STRING "First argument to Java compiler") @@ -28,14 +28,14 @@ if(NOT CMAKE_Java_COMPILER) endif() endif() - if($ENV{JAVA_RUNTIME} MATCHES ".+") + if(NOT $ENV{JAVA_RUNTIME} STREQUAL "") get_filename_component(CMAKE_Java_RUNTIME_INIT $ENV{JAVA_RUNTIME} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT) if(NOT EXISTS ${CMAKE_Java_RUNTIME_INIT}) message(SEND_ERROR "Could not find compiler set in environment variable JAVA_RUNTIME:\n$ENV{JAVA_RUNTIME}.") endif() endif() - if($ENV{JAVA_ARCHIVE} MATCHES ".+") + if(NOT $ENV{JAVA_ARCHIVE} STREQUAL "") get_filename_component(CMAKE_Java_ARCHIVE_INIT $ENV{JAVA_ARCHIVE} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT) if(NOT EXISTS ${CMAKE_Java_ARCHIVE_INIT}) message(SEND_ERROR "Could not find compiler set in environment variable JAVA_ARCHIVE:\n$ENV{JAVA_ARCHIVE}.") diff --git a/Modules/CMakeDetermineRCCompiler.cmake b/Modules/CMakeDetermineRCCompiler.cmake index f23846e..e5414eb 100644 --- a/Modules/CMakeDetermineRCCompiler.cmake +++ b/Modules/CMakeDetermineRCCompiler.cmake @@ -20,7 +20,7 @@ # as a default compiler if(NOT CMAKE_RC_COMPILER) # prefer the environment variable RC - if($ENV{RC} MATCHES ".+") + if(NOT $ENV{RC} STREQUAL "") get_filename_component(CMAKE_RC_COMPILER_INIT $ENV{RC} PROGRAM PROGRAM_ARGS CMAKE_RC_FLAGS_ENV_INIT) if(CMAKE_RC_FLAGS_ENV_INIT) set(CMAKE_RC_COMPILER_ARG1 "${CMAKE_RC_FLAGS_ENV_INIT}" CACHE STRING "First argument to RC compiler") diff --git a/Modules/CMakeExportBuildSettings.cmake b/Modules/CMakeExportBuildSettings.cmake index 90a7a89..a8dd8c2 100644 --- a/Modules/CMakeExportBuildSettings.cmake +++ b/Modules/CMakeExportBuildSettings.cmake @@ -27,7 +27,7 @@ endif() # loaded by another project using CMAKE_IMPORT_BUILD_SETTINGS. Now it # creates a file that refuses to load (with comment explaining why). macro(CMAKE_EXPORT_BUILD_SETTINGS SETTINGS_FILE) - if(${SETTINGS_FILE} MATCHES ".+") + if(NOT ${SETTINGS_FILE} STREQUAL "") configure_file(${CMAKE_ROOT}/Modules/CMakeBuildSettings.cmake.in ${SETTINGS_FILE} @ONLY) else() diff --git a/Modules/CMakeImportBuildSettings.cmake b/Modules/CMakeImportBuildSettings.cmake index 60b887a..edecc1f 100644 --- a/Modules/CMakeImportBuildSettings.cmake +++ b/Modules/CMakeImportBuildSettings.cmake @@ -17,8 +17,7 @@ # This macro used to load build settings from another project that # stored settings using the CMAKE_EXPORT_BUILD_SETTINGS macro. macro(CMAKE_IMPORT_BUILD_SETTINGS SETTINGS_FILE) - if(${SETTINGS_FILE} MATCHES ".+") - else() + if("${SETTINGS_FILE}" STREQUAL "") message(SEND_ERROR "CMAKE_IMPORT_BUILD_SETTINGS called with no argument.") endif() endmacro() diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake index a72954c..12ea384 100644 --- a/Modules/FeatureSummary.cmake +++ b/Modules/FeatureSummary.cmake @@ -546,10 +546,10 @@ function(SET_PACKAGE_INFO _name _desc) set(_url "${ARGV2}") set(_purpose "${ARGV3}") set_property(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_desc}" ) - if(_url MATCHES ".+") + if(NOT _url STREQUAL "") set_property(GLOBAL PROPERTY _CMAKE_${_name}_URL "${_url}" ) endif() - if(_purpose MATCHES ".+") + if(NOT _purpose STREQUAL "") set_property(GLOBAL APPEND PROPERTY _CMAKE_${_name}_PURPOSE "${_purpose}" ) endif() endfunction() diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 7a5c259..6a583d9 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -150,7 +150,7 @@ endmacro() set(BLAS_LINKER_FLAGS) set(BLAS_LIBRARIES) set(BLAS95_LIBRARIES) -if ($ENV{BLA_VENDOR} MATCHES ".+") +if (NOT $ENV{BLA_VENDOR} STREQUAL "") set(BLA_VENDOR $ENV{BLA_VENDOR}) else () if(NOT BLA_VENDOR) diff --git a/Modules/FindCUDA/make2cmake.cmake b/Modules/FindCUDA/make2cmake.cmake index 7194652..c433fa8 100644 --- a/Modules/FindCUDA/make2cmake.cmake +++ b/Modules/FindCUDA/make2cmake.cmake @@ -37,7 +37,7 @@ file(READ ${input_file} depend_text) -if (${depend_text} MATCHES ".+") +if (NOT "${depend_text}" STREQUAL "") # message("FOUND DEPENDS") diff --git a/Modules/FindCUDA/parse_cubin.cmake b/Modules/FindCUDA/parse_cubin.cmake index ddb50de..626c8a2 100644 --- a/Modules/FindCUDA/parse_cubin.cmake +++ b/Modules/FindCUDA/parse_cubin.cmake @@ -37,7 +37,7 @@ file(READ ${input_file} file_text) -if (${file_text} MATCHES ".+") +if (NOT "${file_text}" STREQUAL "") string(REPLACE ";" "\\;" file_text ${file_text}) string(REPLACE "\ncode" ";code" file_text ${file_text}) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 87938c8..b11edc3 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -159,7 +159,7 @@ endif() if(BLAS_FOUND) set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS}) - if ($ENV{BLA_VENDOR} MATCHES ".+") + if (NOT $ENV{BLA_VENDOR} STREQUAL "") set(BLA_VENDOR $ENV{BLA_VENDOR}) else () if(NOT BLA_VENDOR) -- cgit v0.12 From f21ac16edd0d2fbe78daf17bf5f964e4cfbd694b Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 11 Apr 2014 18:49:03 +0200 Subject: Replace MATCHES test on numbers with EQUAL test The MATCHES tests were actually wrong, as "a4b" and "42" would also cause a match when it should not. --- Modules/FindQt.cmake | 4 ++-- Tests/Complex/CMakeLists.txt | 2 +- Tests/ComplexOneConfig/CMakeLists.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/FindQt.cmake b/Modules/FindQt.cmake index 98ba43d..1bc0940 100644 --- a/Modules/FindQt.cmake +++ b/Modules/FindQt.cmake @@ -154,12 +154,12 @@ else() endif() endif() -if(DESIRED_QT_VERSION MATCHES 3) +if(DESIRED_QT_VERSION EQUAL 3) set(Qt3_FIND_REQUIRED ${Qt_FIND_REQUIRED}) set(Qt3_FIND_QUIETLY ${Qt_FIND_QUIETLY}) include(${CMAKE_CURRENT_LIST_DIR}/FindQt3.cmake) endif() -if(DESIRED_QT_VERSION MATCHES 4) +if(DESIRED_QT_VERSION EQUAL 4) set(Qt4_FIND_REQUIRED ${Qt_FIND_REQUIRED}) set(Qt4_FIND_QUIETLY ${Qt_FIND_QUIETLY}) include(${CMAKE_CURRENT_LIST_DIR}/FindQt4.cmake) diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt index 001ae56..d250f53 100644 --- a/Tests/Complex/CMakeLists.txt +++ b/Tests/Complex/CMakeLists.txt @@ -36,7 +36,7 @@ ASSERT(Complex_BINARY_DIR "The PROJECT command is broken") # macro(TEST_ARGC value1 value2) add_definitions(${value1} ${value2}) - if (${ARGC} MATCHES 4) + if (${ARGC} EQUAL 4) add_definitions(${ARGV2} ${ARGV3}) endif () endmacro() diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt index a908e11..bb00341 100644 --- a/Tests/ComplexOneConfig/CMakeLists.txt +++ b/Tests/ComplexOneConfig/CMakeLists.txt @@ -36,7 +36,7 @@ ASSERT(Complex_BINARY_DIR "The PROJECT command is broken") # macro(TEST_ARGC value1 value2) add_definitions(${value1} ${value2}) - if (${ARGC} MATCHES 4) + if (${ARGC} EQUAL 4) add_definitions(${ARGV2} ${ARGV3}) endif () endmacro() -- cgit v0.12 From 39d0ade07ee9034b2e0469fc270e0aa55fc34135 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 14 Apr 2014 13:58:03 -0400 Subject: Windows-GNU: Support duplicate object names in large archives (#14874) Since commit v2.6.0~388 (Added build rule variables CMAKE__ARCHIVE_..., 2008-01-29) we use separate "ar cr ..." and "ar r ..." steps to incrementally add a large list of object files to an archive. Since the "r" command replaces existing objects of the same name in an archive, if multiple objects have the same file name and appear in separate append steps then one overwrites the other. Instead, use "ar cq ..." and "ar q ..." to always append to the archive. We already remove the archive before creating it so this will not cause objects to be appended to existing archives on incremental rebuilds. --- Modules/Platform/Windows-GNU.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index 2bb7a20..9038243 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -67,8 +67,8 @@ macro(__windows_compiler_gnu lang) if(MSYS OR MINGW) # Create archiving rules to support large object file lists for static libraries. - set(CMAKE_${lang}_ARCHIVE_CREATE " cr ") - set(CMAKE_${lang}_ARCHIVE_APPEND " r ") + set(CMAKE_${lang}_ARCHIVE_CREATE " cq ") + set(CMAKE_${lang}_ARCHIVE_APPEND " q ") set(CMAKE_${lang}_ARCHIVE_FINISH " ") # Initialize C link type selection flags. These flags are used when -- cgit v0.12 From 3022f2a1ef94b2c12df09b0ca420b6c2951888e2 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Mon, 14 Apr 2014 18:13:19 +0200 Subject: cmELF: fix signedness warning on OpenBSD OpenBSD defines Elf64_Dyn::d_tag to be of an unsigned type, which differs from what most other platforms do and what is the case for 32 bit. To have the tag as unsigned makes sense, but this causes a compilation warning: /.../CMake/Source/cmELF.cxx: In member function 'const cmELF::StringEntry* cmELFInternalImpl::GetDynamicSectionString(int) [with Types = cmELFTypes64]': /.../CMake/Source/cmELF.cxx:945: instantiated from here /.../CMake/Source/cmELF.cxx:668: warning: comparison between signed and unsigned integer expressions Add an explicit typedef to cast the value to for 32 and 64 bit. That type is unsigned and has the proper length for both platforms so no information is lost. Explicitely cast both arguments before comparing them to avoid the warning in all situations. --- Source/cmELF.cxx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index dc6772c..cab23b7 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -124,7 +124,7 @@ public: virtual unsigned int GetNumberOfSections() const = 0; virtual unsigned int GetDynamicEntryCount() = 0; virtual unsigned long GetDynamicEntryPosition(int j) = 0; - virtual StringEntry const* GetDynamicSectionString(int tag) = 0; + virtual StringEntry const* GetDynamicSectionString(unsigned int tag) = 0; virtual void PrintInfo(std::ostream& os) const = 0; bool ReadBytes(unsigned long pos, unsigned long size, char* buf) @@ -187,7 +187,7 @@ protected: } // Store string table entry states. - std::map DynamicSectionStrings; + std::map DynamicSectionStrings; }; //---------------------------------------------------------------------------- @@ -198,6 +198,7 @@ struct cmELFTypes32 typedef Elf32_Shdr ELF_Shdr; typedef Elf32_Dyn ELF_Dyn; typedef Elf32_Half ELF_Half; + typedef cmIML_INT_uint32_t tagtype; static const char* GetName() { return "32-bit"; } }; @@ -208,6 +209,7 @@ struct cmELFTypes64 typedef Elf64_Shdr ELF_Shdr; typedef Elf64_Dyn ELF_Dyn; typedef Elf64_Half ELF_Half; + typedef cmIML_INT_uint64_t tagtype; static const char* GetName() { return "64-bit"; } }; @@ -222,6 +224,7 @@ public: typedef typename Types::ELF_Shdr ELF_Shdr; typedef typename Types::ELF_Dyn ELF_Dyn; typedef typename Types::ELF_Half ELF_Half; + typedef typename Types::tagtype tagtype; // Construct with a stream and byte swap indicator. cmELFInternalImpl(cmELF* external, @@ -239,7 +242,7 @@ public: virtual unsigned long GetDynamicEntryPosition(int j); // Lookup a string from the dynamic section with the given tag. - virtual StringEntry const* GetDynamicSectionString(int tag); + virtual StringEntry const* GetDynamicSectionString(unsigned int tag); // Print information about the ELF file. virtual void PrintInfo(std::ostream& os) const @@ -624,10 +627,10 @@ unsigned long cmELFInternalImpl::GetDynamicEntryPosition(int j) //---------------------------------------------------------------------------- template cmELF::StringEntry const* -cmELFInternalImpl::GetDynamicSectionString(int tag) +cmELFInternalImpl::GetDynamicSectionString(unsigned int tag) { // Short-circuit if already checked. - std::map::iterator dssi = + std::map::iterator dssi = this->DynamicSectionStrings.find(tag); if(dssi != this->DynamicSectionStrings.end()) { @@ -665,7 +668,7 @@ cmELFInternalImpl::GetDynamicSectionString(int tag) di != this->DynamicSectionEntries.end(); ++di) { ELF_Dyn& dyn = *di; - if(dyn.d_tag == tag) + if(static_cast(dyn.d_tag) == static_cast(tag)) { // We found the tag requested. // Make sure the position given is within the string section. -- cgit v0.12 From 454b4bd244a02802bd0421b7232a92e4ff3da6c7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 14 Apr 2014 23:00:30 +0200 Subject: Help: Fix typo in CMP0051. STRIP_GENEX -> GENEX_STRIP. --- Help/policy/CMP0051.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Help/policy/CMP0051.rst b/Help/policy/CMP0051.rst index 7d85929..1b56cb0 100644 --- a/Help/policy/CMP0051.rst +++ b/Help/policy/CMP0051.rst @@ -10,7 +10,7 @@ returning the :prop_tgt:`SOURCES` target property. Configure-time CMake code is not able to handle generator expressions. If using the :prop_tgt:`SOURCES` target property at configure time, it may be necessary to first remove generator expressions using the -:command:`string(STRIP_GENEX)` command. Generate-time CMake code such as +:command:`string(GENEX_STRIP)` command. Generate-time CMake code such as :command:`file(GENERATE)` can handle the content without stripping. The ``OLD`` behavior for this policy is to omit ``TARGET_OBJECTS`` -- cgit v0.12 From 941a14042a06c4bb65c985a0bb9754160045a297 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Mon, 14 Apr 2014 23:06:36 +0200 Subject: AIX: fix compilation error because of missing Replace it by cmStandardIncludes.h which drags in the proper header depending on what the compiler provides to fix this error: CMake/Source/cmExtraCodeLiteGenerator.cxx:27: sstream: No such file or directory --- Source/cmExtraCodeLiteGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 33ffc90..8acc5b4 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -23,8 +23,8 @@ #include #include #include +#include "cmStandardIncludes.h" #include "cmXMLSafe.h" -#include //---------------------------------------------------------------------------- void cmExtraCodeLiteGenerator::GetDocumentation(cmDocumentationEntry& entry, -- cgit v0.12 From dd3a80b718ec4d501660b86a4f4710391087c0a7 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 15 Apr 2014 00:01:09 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index cf4b121..a6be93f 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 0) -set(CMake_VERSION_PATCH 20140414) +set(CMake_VERSION_PATCH 20140415) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 6ab7c326485b4af46a4e45faef2ac7d469df8840 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Apr 2014 09:07:48 -0400 Subject: libarchive: Avoid left-shift overflow of signed integer In libarchive/archive_write_set_format_zip.c there are two calls to archive_le32enc whose second argument is of the form archive_entry_mode(zip->entry) << 16 However, the return type from archive_entry_mode may be a signed integer so the shift may overflow. Since the second argument of archive_le32enc expects uint32_t anyway, simply cast to that prior to shifting. --- Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c index d856b2a..157f100 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c @@ -621,7 +621,7 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry) archive_le16enc(zip->file_header + 28, filename_length); /* Following Info-Zip, store mode in the "external attributes" field. */ archive_le32enc(zip->file_header + 38, - archive_entry_mode(zip->entry) << 16); + ((uint32_t)archive_entry_mode(zip->entry)) << 16); e = cd_alloc(zip, filename_length); /* If (e == NULL) XXXX */ copy_path(zip->entry, e); @@ -714,7 +714,7 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry) } if (included & 4) { archive_le32enc(e, /* external file attributes */ - archive_entry_mode(zip->entry) << 16); + ((uint32_t)archive_entry_mode(zip->entry)) << 16); e += 4; } if (included & 8) { -- cgit v0.12 From f9f91fa8b9eee3002aed62a205b57b0d6b5581fd Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Sat, 12 Apr 2014 23:58:19 +0200 Subject: CTestCustom: Suppress warnings about rand() and srand() on OpenBSD We don't do crypto here, so a "poor" random doesn't matter. In fact we have API to allow people to get a repeatable sequence by setting a specific seed. --- CTestCustom.cmake.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index 3c589b4..65a317d 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -55,6 +55,8 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION "warning.*This version of Mac OS X is unsupported" "clang.*: warning: argument unused during compilation: .-g" "note: in expansion of macro" # diagnostic context note + "cm(StringCommand|CTestTestHandler)\\.cxx.*warning.*rand.*isn.*t random" # we do not do crypto + "cm(StringCommand|CTestTestHandler)\\.cxx.*warning.*srand.*seed choices are.*poor" # we do not do crypto # Ignore clang's summary warning, assuming prior text has matched some # other warning expression: -- cgit v0.12 From 504bb62d9918e7cc57746f26d96ba705c7d701ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20K=C3=BCmmel?= Date: Sun, 13 Apr 2014 11:21:58 +0200 Subject: Ninja: replace \ in LINK_PATH for MinGW --- Source/cmNinjaNormalTargetGenerator.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c865617..73e36b0 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -523,6 +523,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() // ar.exe can't handle backslashes in rsp files (implicitly used by gcc) std::string& linkLibraries = vars["LINK_LIBRARIES"]; std::replace(linkLibraries.begin(), linkLibraries.end(), '\\', '/'); + std::string& link_path = vars["LINK_PATH"]; + std::replace(link_path.begin(), link_path.end(), '\\', '/'); } const std::vector *cmdLists[3] = { -- cgit v0.12 From b735c8cb431fda27229cb27f3c41cdd2382da01e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20K=C3=BCmmel?= Date: Sun, 13 Apr 2014 13:12:35 +0200 Subject: MinGW: link like on Unix and use compile flags when linking --- Modules/Platform/Windows-GNU.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index 5c5b360..b5e174b 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -113,9 +113,9 @@ macro(__windows_compiler_gnu lang) # Binary link rules. set(CMAKE_${lang}_CREATE_SHARED_MODULE - " -o ${CMAKE_GNULD_IMAGE_VERSION} ") + " -o ${CMAKE_GNULD_IMAGE_VERSION} ") set(CMAKE_${lang}_CREATE_SHARED_LIBRARY - " -o -Wl,--out-implib, ${CMAKE_GNULD_IMAGE_VERSION} ") + " -o -Wl,--out-implib, ${CMAKE_GNULD_IMAGE_VERSION} ") set(CMAKE_${lang}_LINK_EXECUTABLE " -o -Wl,--out-implib, ${CMAKE_GNULD_IMAGE_VERSION} ") -- cgit v0.12 From 49fcffc6ccec7ddbad8a8110b9b923d8846c8a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20K=C3=BCmmel?= Date: Sun, 13 Apr 2014 14:06:41 +0200 Subject: Ninja: cmake formatting, make code more readable --- Source/cmNinjaNormalTargetGenerator.cxx | 291 +++++++++++++++++--------------- 1 file changed, 153 insertions(+), 138 deletions(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c865617..92919ee 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -363,25 +363,39 @@ cmNinjaNormalTargetGenerator return std::vector(); } -void cmNinjaNormalTargetGenerator::WriteLinkStatement() + +static int calculateCommandLineLengthLimit(int linkRuleLength) { - cmTarget::TargetType targetType = this->GetTarget()->GetType(); +#ifdef _WIN32 + return 8000 - linkRuleLength; +#elif defined(__linux) || defined(__APPLE__) || defined(__HAIKU__) + // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac + return ((int)sysconf(_SC_ARG_MAX)) - linkRuleLength - 1000; +#else + (void)linkRuleLength; + return -1; +#endif +} + +void cmNinjaNormalTargetGenerator::WriteLinkStatement() +{ + cmTarget& target = *this->GetTarget(); + const std::string cfgName = this->GetConfigName(); std::string targetOutput = ConvertToNinjaPath( - this->GetTarget()->GetFullPath(this->GetConfigName()).c_str()); + target.GetFullPath(cfgName).c_str()); std::string targetOutputReal = ConvertToNinjaPath( - this->GetTarget()->GetFullPath(this->GetConfigName(), - /*implib=*/false, - /*realpath=*/true).c_str()); + target.GetFullPath(cfgName, + /*implib=*/false, + /*realpath=*/true).c_str()); std::string targetOutputImplib = ConvertToNinjaPath( - this->GetTarget()->GetFullPath(this->GetConfigName(), - /*implib=*/true).c_str()); + target.GetFullPath(cfgName, + /*implib=*/true).c_str()); - if (this->GetTarget()->IsAppBundleOnApple()) + if (target.IsAppBundleOnApple()) { // Create the app bundle - std::string outpath = - this->GetTarget()->GetDirectory(this->GetConfigName()); + std::string outpath = target.GetDirectory(cfgName); this->OSXBundleGenerator->CreateAppBundle(this->TargetNameOut, outpath); // Calculate the output path @@ -394,23 +408,22 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() targetOutputReal += this->TargetNameReal; targetOutputReal = this->ConvertToNinjaPath(targetOutputReal.c_str()); } - else if (this->GetTarget()->IsFrameworkOnApple()) + else if (target.IsFrameworkOnApple()) { // Create the library framework. - std::string outpath = - this->GetTarget()->GetDirectory(this->GetConfigName()); - this->OSXBundleGenerator->CreateFramework(this->TargetNameOut, outpath); + this->OSXBundleGenerator->CreateFramework(this->TargetNameOut, + target.GetDirectory(cfgName)); } - else if(this->GetTarget()->IsCFBundleOnApple()) + else if(target.IsCFBundleOnApple()) { // Create the core foundation bundle. - std::string outpath = - this->GetTarget()->GetDirectory(this->GetConfigName()); - this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut, outpath); + this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut, + target.GetDirectory(cfgName)); } // Write comments. cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); + const cmTarget::TargetType targetType = target.GetType(); this->GetBuildFileStream() << "# Link build statements for " << cmTarget::GetTargetTypeName(targetType) @@ -423,8 +436,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() // Compute the comment. cmOStringStream comment; - comment << "Link the " << this->GetVisibleTypeName() << " " - << targetOutputReal; + comment << + "Link the " << this->GetVisibleTypeName() << " " << targetOutputReal; // Compute outputs. cmNinjaDeps outputs; @@ -438,21 +451,21 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::string frameworkPath; std::string linkPath; - cmGeneratorTarget* gtarget = this->GetGeneratorTarget(); + cmGeneratorTarget& genTarget = *this->GetGeneratorTarget(); std::string createRule = "CMAKE_"; - createRule += this->TargetLinkLanguage; - createRule += gtarget->GetCreateRuleVariable(); + createRule += this->TargetLinkLanguage + genTarget.GetCreateRuleVariable(); bool useWatcomQuote = mf->IsOn(createRule+"_USE_WATCOM_QUOTE"); - this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"], - vars["FLAGS"], - vars["LINK_FLAGS"], - frameworkPath, - linkPath, - gtarget, - useWatcomQuote); + cmLocalNinjaGenerator& localGen = *this->GetLocalGenerator(); + localGen.GetTargetFlags(vars["LINK_LIBRARIES"], + vars["FLAGS"], + vars["LINK_FLAGS"], + frameworkPath, + linkPath, + &genTarget, + useWatcomQuote); - this->addPoolNinjaVariable("JOB_POOL_LINK", this->GetTarget(), vars); + this->addPoolNinjaVariable("JOB_POOL_LINK", &target, vars); this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]); vars["LINK_FLAGS"] = cmGlobalNinjaGenerator @@ -466,39 +479,43 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::string flags = (targetType == cmTarget::EXECUTABLE ? vars["FLAGS"] : vars["ARCH_FLAGS"]); - this->GetLocalGenerator()->AddArchitectureFlags(flags, - gtarget, - this->TargetLinkLanguage, - this->GetConfigName()); - if (targetType == cmTarget::EXECUTABLE) { + localGen.AddArchitectureFlags(flags, + &genTarget, + this->TargetLinkLanguage, + cfgName); + if (targetType == cmTarget::EXECUTABLE) + { vars["FLAGS"] = flags; - } else { + } + else + { vars["ARCH_FLAGS"] = flags; - } - if (this->GetTarget()->HasSOName(this->GetConfigName())) { - vars["SONAME_FLAG"] = - mf->GetSONameFlag(this->TargetLinkLanguage); + } + if (target.HasSOName(cfgName)) + { + vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage); vars["SONAME"] = this->TargetNameSO; - if (targetType == cmTarget::SHARED_LIBRARY) { - std::string install_name_dir = this->GetTarget() - ->GetInstallNameDirForBuildTree(this->GetConfigName()); - - if (!install_name_dir.empty()) { - vars["INSTALLNAME_DIR"] = - this->GetLocalGenerator()->Convert(install_name_dir, - cmLocalGenerator::NONE, - cmLocalGenerator::SHELL, false); + if (targetType == cmTarget::SHARED_LIBRARY) + { + std::string install_dir = target.GetInstallNameDirForBuildTree(cfgName); + if (!install_dir.empty()) + { + vars["INSTALLNAME_DIR"] = localGen.Convert(install_dir, + cmLocalGenerator::NONE, + cmLocalGenerator::SHELL, + false); + } } } - } - if (!this->TargetNameImport.empty()) { - const std::string impLibPath = this->GetLocalGenerator() - ->ConvertToOutputFormat(targetOutputImplib, - cmLocalGenerator::SHELL); + if (!this->TargetNameImport.empty()) + { + const std::string impLibPath = localGen.ConvertToOutputFormat( + targetOutputImplib, + cmLocalGenerator::SHELL); vars["TARGET_IMPLIB"] = impLibPath; EnsureParentDirectoryExists(impLibPath); - } + } if (!this->SetMsvcTargetPdbVariable(vars)) { @@ -507,11 +524,13 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::string prefix; std::string base; std::string suffix; - this->GetTarget()->GetFullNameComponents(prefix, base, suffix); + target.GetFullNameComponents(prefix, base, suffix); std::string dbg_suffix = ".dbg"; // TODO: Where to document? if (mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX")) + { dbg_suffix = mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX"); + } vars["TARGET_PDB"] = base + suffix + dbg_suffix; } @@ -526,9 +545,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } const std::vector *cmdLists[3] = { - &this->GetTarget()->GetPreBuildCommands(), - &this->GetTarget()->GetPreLinkCommands(), - &this->GetTarget()->GetPostBuildCommands() + &target.GetPreBuildCommands(), + &target.GetPreLinkCommands(), + &target.GetPostBuildCommands() }; std::vector preLinkCmdLines, postBuildCmdLines; @@ -538,100 +557,97 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() &postBuildCmdLines }; - for (unsigned i = 0; i != 3; ++i) { + for (unsigned i = 0; i != 3; ++i) + { for (std::vector::const_iterator ci = cmdLists[i]->begin(); - ci != cmdLists[i]->end(); ++ci) { - cmCustomCommandGenerator ccg(*ci, this->GetConfigName(), mf); - this->GetLocalGenerator()->AppendCustomCommandLines(ccg, - *cmdLineLists[i]); + ci != cmdLists[i]->end(); ++ci) + { + cmCustomCommandGenerator ccg(*ci, cfgName, mf); + localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]); + } } - } // If we have any PRE_LINK commands, we need to go back to HOME_OUTPUT for // the link commands. - if (!preLinkCmdLines.empty()) { - const std::string homeOutDir = this->GetLocalGenerator() - ->ConvertToOutputFormat(mf->GetHomeOutputDirectory(), - cmLocalGenerator::SHELL); + if (!preLinkCmdLines.empty()) + { + const std::string homeOutDir = localGen.ConvertToOutputFormat( + mf->GetHomeOutputDirectory(), + cmLocalGenerator::SHELL); preLinkCmdLines.push_back("cd " + homeOutDir); - } + } - vars["PRE_LINK"] = - this->GetLocalGenerator()->BuildCommandLine(preLinkCmdLines); - std::string postBuildCmdLine = - this->GetLocalGenerator()->BuildCommandLine(postBuildCmdLines); + vars["PRE_LINK"] = localGen.BuildCommandLine(preLinkCmdLines); + std::string postBuildCmdLine = localGen.BuildCommandLine(postBuildCmdLines); cmNinjaVars symlinkVars; - if (targetOutput == targetOutputReal) { + if (targetOutput == targetOutputReal) + { vars["POST_BUILD"] = postBuildCmdLine; - } else { + } + else + { vars["POST_BUILD"] = ":"; symlinkVars["POST_BUILD"] = postBuildCmdLine; - } + } - int linkRuleLength = this->GetGlobalGenerator()-> - GetRuleCmdLength(this->LanguageLinkerRule()); + cmGlobalNinjaGenerator& globalGen = *this->GetGlobalGenerator(); int commandLineLengthLimit = 1; const char* forceRspFile = "CMAKE_NINJA_FORCE_RESPONSE_FILE"; if (!mf->IsDefinitionSet(forceRspFile) && - cmSystemTools::GetEnv(forceRspFile) == 0) { -#ifdef _WIN32 - commandLineLengthLimit = 8000 - linkRuleLength; -#elif defined(__linux) || defined(__APPLE__) || defined(__HAIKU__) - // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac - commandLineLengthLimit = ((int)sysconf(_SC_ARG_MAX))-linkRuleLength-1000; -#else - (void)linkRuleLength; - commandLineLengthLimit = -1; -#endif - } - - //Get the global generator as we are going to be call WriteBuild numerous - //times in the following section - cmGlobalNinjaGenerator* globalGenerator = this->GetGlobalGenerator(); - + cmSystemTools::GetEnv(forceRspFile) == 0) + { + commandLineLengthLimit = calculateCommandLineLengthLimit( + globalGen.GetRuleCmdLength(this->LanguageLinkerRule())); + } - const std::string rspfile = std::string - (cmake::GetCMakeFilesDirectoryPostSlash()) + - this->GetTarget()->GetName() + ".rsp"; + const std::string rspfile = + std::string(cmake::GetCMakeFilesDirectoryPostSlash()) + + target.GetName() + ".rsp"; // Write the build statement for this target. - globalGenerator->WriteBuild(this->GetBuildFileStream(), - comment.str(), - this->LanguageLinkerRule(), - outputs, - explicitDeps, - implicitDeps, - emptyDeps, - vars, - rspfile, - commandLineLengthLimit); - - if (targetOutput != targetOutputReal && - !this->GetTarget()->IsFrameworkOnApple()) { - if (targetType == cmTarget::EXECUTABLE) { - globalGenerator->WriteBuild(this->GetBuildFileStream(), - "Create executable symlink " + targetOutput, - "CMAKE_SYMLINK_EXECUTABLE", - cmNinjaDeps(1, targetOutput), - cmNinjaDeps(1, targetOutputReal), - emptyDeps, - emptyDeps, - symlinkVars); - } else { + globalGen.WriteBuild(this->GetBuildFileStream(), + comment.str(), + this->LanguageLinkerRule(), + outputs, + explicitDeps, + implicitDeps, + emptyDeps, + vars, + rspfile, + commandLineLengthLimit); + + if (targetOutput != targetOutputReal && !target.IsFrameworkOnApple()) + { + if (targetType == cmTarget::EXECUTABLE) + { + globalGen.WriteBuild(this->GetBuildFileStream(), + "Create executable symlink " + targetOutput, + "CMAKE_SYMLINK_EXECUTABLE", + cmNinjaDeps(1, targetOutput), + cmNinjaDeps(1, targetOutputReal), + emptyDeps, + emptyDeps, + symlinkVars); + } + else + { cmNinjaDeps symlinks; const std::string soName = this->GetTargetFilePath(this->TargetNameSO); // If one link has to be created. - if (targetOutputReal == soName || targetOutput == soName) { + if (targetOutputReal == soName || targetOutput == soName) + { symlinkVars["SONAME"] = soName; - } else { + } + else + { symlinkVars["SONAME"] = ""; symlinks.push_back(soName); - } + } symlinks.push_back(targetOutput); - globalGenerator->WriteBuild(this->GetBuildFileStream(), + globalGen.WriteBuild(this->GetBuildFileStream(), "Create library symlink " + targetOutput, "CMAKE_SYMLINK_LIBRARY", symlinks, @@ -639,23 +655,22 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() emptyDeps, emptyDeps, symlinkVars); + } } - } - if (!this->TargetNameImport.empty()) { + if (!this->TargetNameImport.empty()) + { // Since using multiple outputs would mess up the $out variable, use an // alias for the import library. - globalGenerator->WritePhonyBuild(this->GetBuildFileStream(), - "Alias for import library.", - cmNinjaDeps(1, targetOutputImplib), - cmNinjaDeps(1, targetOutputReal)); - } + globalGen.WritePhonyBuild(this->GetBuildFileStream(), + "Alias for import library.", + cmNinjaDeps(1, targetOutputImplib), + cmNinjaDeps(1, targetOutputReal)); + } // Add aliases for the file name and the target name. - globalGenerator->AddTargetAlias(this->TargetNameOut, - this->GetTarget()); - globalGenerator->AddTargetAlias(this->GetTargetName(), - this->GetTarget()); + globalGen.AddTargetAlias(this->TargetNameOut, &target); + globalGen.AddTargetAlias(this->GetTargetName(), &target); } //---------------------------------------------------------------------------- -- cgit v0.12 From 97f2b7f5ab4db2c057a8e2103c5d71375e71c632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20K=C3=BCmmel?= Date: Sun, 13 Apr 2014 14:29:20 +0200 Subject: Ninja: set correct LANGUAGE_COMPILE_FLAGS when linking --- Source/cmNinjaNormalTargetGenerator.cxx | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 92919ee..e7e811b 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -232,13 +232,11 @@ cmNinjaNormalTargetGenerator vars.LinkFlags = "$LINK_FLAGS"; std::string langFlags; - if (targetType != cmTarget::EXECUTABLE) { - this->GetLocalGenerator()->AddLanguageFlags(langFlags, - this->TargetLinkLanguage, - this->GetConfigName()); - langFlags += " $ARCH_FLAGS"; + if (targetType != cmTarget::EXECUTABLE) + { + langFlags += "$LANGUAGE_COMPILE_FLAGS $ARCH_FLAGS"; vars.LanguageCompileFlags = langFlags.c_str(); - } + } // Rule for linking library/executable. std::vector linkCmds = this->ComputeLinkCmd(); @@ -476,21 +474,22 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() // Compute architecture specific link flags. Yes, these go into a different // variable for executables, probably due to a mistake made when duplicating // code between the Makefile executable and library generators. - std::string flags = (targetType == cmTarget::EXECUTABLE - ? vars["FLAGS"] - : vars["ARCH_FLAGS"]); - localGen.AddArchitectureFlags(flags, - &genTarget, - this->TargetLinkLanguage, - cfgName); if (targetType == cmTarget::EXECUTABLE) { - vars["FLAGS"] = flags; + std::string t = vars["FLAGS"]; + localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName); + vars["FLAGS"] = t; } else { - vars["ARCH_FLAGS"] = flags; + std::string t = vars["ARCH_FLAGS"]; + localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName); + vars["ARCH_FLAGS"] = t; + t = ""; + localGen.AddLanguageFlags(t, TargetLinkLanguage, cfgName); + vars["LANGUAGE_COMPILE_FLAGS"] = t; } + if (target.HasSOName(cfgName)) { vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage); -- cgit v0.12 From ef9366b0bbb19639244a06ac34c8a8ecd35e66e8 Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Tue, 15 Apr 2014 16:26:10 +0200 Subject: FindGTK2: Add /usr/X11R6/ to include paths Should fix builds on OpenBSD, see http://open.cdash.org/viewTest.php?onlyfailed&buildid=3286713 --- Modules/FindGTK2.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index a91da33..fecf929 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -267,6 +267,8 @@ function(_GTK2_FIND_INCLUDE_DIR _var _hdr) /usr/local/lib /usr/lib64 /usr/lib + /usr/X11R6/include + /usr/X11R6/lib /opt/gnome/include /opt/gnome/lib /opt/openwin/include -- cgit v0.12 From 0d048384694b7285ef739153757b57791d4ebb93 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Apr 2014 11:47:54 -0400 Subject: VS: Use full path to sources to allow deeper trees with VS >= 10 As explained in cmVisualStudio10TargetGenerator::WriteSource comments, VS tools append relative paths to the current directory, e.g. c:\path\to\current\dir\..\..\..\relative\path\to\source.c and fail if this is over 250 charaters or so. Previously we used a full path only if no relative path could be constructed with a leading "../" sequence that does not escape the source or build tree. This means that long relative paths can be generated when the build tree is inside the source tree, and can cause build failures due to the above path concatenation problem. Teach cmVisualStudio10TargetGenerator::ConvertPath to ask the Convert method to honor CMAKE_USE_RELATIVE_PATHS. This will cause it to use full paths by default but still give users the option of getting the relative paths when possible. Suggested-by: Josh Green --- Source/cmVisualStudio10TargetGenerator.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index a999b2d..72bb020 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -685,7 +685,8 @@ cmVisualStudio10TargetGenerator::ConvertPath(std::string const& path, this->Makefile->GetCurrentOutputDirectory(), path.c_str()) : this->LocalGenerator->Convert(path.c_str(), cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::UNCHANGED); + cmLocalGenerator::UNCHANGED, + /* optional = */ true); } void cmVisualStudio10TargetGenerator::ConvertToWindowsSlash(std::string& s) @@ -941,7 +942,7 @@ void cmVisualStudio10TargetGenerator::WriteSource( // c:\path\to\current\dir\..\..\..\relative\path\to\source.c // // and fail if this exceeds the maximum allowed path length. Our path - // conversion uses full paths outside the build tree to allow deeper trees. + // conversion uses full paths when possible to allow deeper trees. bool forceRelative = false; std::string sourceFile = this->ConvertPath(sf->GetFullPath(), false); if(this->LocalGenerator->GetVersion() == cmLocalVisualStudioGenerator::VS10 -- cgit v0.12 From c8e565a06e229e1524df01d965c8b7e7a757ce05 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Tue, 15 Apr 2014 20:13:42 +0200 Subject: CodeLite generator: simplify code a bit --- Source/cmExtraCodeLiteGenerator.cxx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 8acc5b4..946d9d2 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -443,26 +443,22 @@ cmExtraCodeLiteGenerator::GetConfigurationName(const cmMakefile* mf) const std::string cmExtraCodeLiteGenerator::GetBuildCommand(const cmMakefile* mf) const { - std::stringstream ss; std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR"); std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); std::string buildCommand = make; // Default - if ( generator == "NMake Makefiles" ) + if ( generator == "NMake Makefiles" || + generator == "Ninja" ) { buildCommand = make; } else if ( generator == "MinGW Makefiles" || generator == "Unix Makefiles" ) { + std::stringstream ss; ss << make << " -j " << this->CpuCount; buildCommand = ss.str(); } - else if ( generator == "Ninja" ) - { - ss << make; - buildCommand = ss.str(); - } - return buildCommand; + return buildCommand; } std::string -- cgit v0.12 From b84ee41abbea790ac93c012b1423ef012f933ca2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Apr 2014 15:50:47 -0400 Subject: Utilities/Release: Update to openssl-1.0.1g Update the prebuilt binary build configurations for machines where we build our own OpenSSL library to use a newer version. --- Utilities/Release/dashmacmini2_release.cmake | 6 +++--- Utilities/Release/dashmacmini5_release.cmake | 6 +++--- Utilities/Release/magrathea_release.cmake | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Utilities/Release/dashmacmini2_release.cmake b/Utilities/Release/dashmacmini2_release.cmake index 9d418d9..89c99bc 100644 --- a/Utilities/Release/dashmacmini2_release.cmake +++ b/Utilities/Release/dashmacmini2_release.cmake @@ -10,9 +10,9 @@ set(INITIAL_CACHE " CMAKE_BUILD_TYPE:STRING=Release CMAKE_OSX_ARCHITECTURES:STRING=ppc;i386 CMAKE_USE_OPENSSL:BOOL=ON -OPENSSL_CRYPTO_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1c-install/lib/libcrypto.a -OPENSSL_INCLUDE_DIR:PATH=/Users/kitware/openssl-1.0.1c-install/include -OPENSSL_SSL_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1c-install/lib/libssl.a +OPENSSL_CRYPTO_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1g-install/lib/libcrypto.a +OPENSSL_INCLUDE_DIR:PATH=/Users/kitware/openssl-1.0.1g-install/include +OPENSSL_SSL_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1g-install/lib/libssl.a CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE CPACK_SYSTEM_NAME:STRING=Darwin-universal BUILD_QtDialog:BOOL=TRUE diff --git a/Utilities/Release/dashmacmini5_release.cmake b/Utilities/Release/dashmacmini5_release.cmake index aba68f8..f777718 100644 --- a/Utilities/Release/dashmacmini5_release.cmake +++ b/Utilities/Release/dashmacmini5_release.cmake @@ -9,9 +9,9 @@ set(CPACK_BINARY_GENERATORS "PackageMaker TGZ TZ") set(CPACK_SOURCE_GENERATORS "TGZ TZ") set(INITIAL_CACHE " CMAKE_USE_OPENSSL:BOOL=ON -OPENSSL_CRYPTO_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1c-install/lib/libcrypto.a -OPENSSL_INCLUDE_DIR:PATH=/Users/kitware/openssl-1.0.1c-install/include -OPENSSL_SSL_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1c-install/lib/libssl.a +OPENSSL_CRYPTO_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1g-install/lib/libcrypto.a +OPENSSL_INCLUDE_DIR:PATH=/Users/kitware/openssl-1.0.1g-install/include +OPENSSL_SSL_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1g-install/lib/libssl.a CMAKE_BUILD_TYPE:STRING=Release CMAKE_OSX_ARCHITECTURES:STRING=x86_64;i386 CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.5 diff --git a/Utilities/Release/magrathea_release.cmake b/Utilities/Release/magrathea_release.cmake index 93916e2..1bf75dd 100644 --- a/Utilities/Release/magrathea_release.cmake +++ b/Utilities/Release/magrathea_release.cmake @@ -11,9 +11,9 @@ CURSES_LIBRARY:FILEPATH=/usr/i686-gcc-332s/lib/libncurses.a CURSES_INCLUDE_PATH:PATH=/usr/i686-gcc-332s/include/ncurses FORM_LIBRARY:FILEPATH=/usr/i686-gcc-332s/lib/libform.a CMAKE_USE_OPENSSL:BOOL=ON -OPENSSL_CRYPTO_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.1c-install/lib/libcrypto.a -OPENSSL_INCLUDE_DIR:PATH=/home/kitware/openssl-1.0.1c-install/include -OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.1c-install/lib/libssl.a +OPENSSL_CRYPTO_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.1g-install/lib/libcrypto.a +OPENSSL_INCLUDE_DIR:PATH=/home/kitware/openssl-1.0.1g-install/include +OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.1g-install/lib/libssl.a CPACK_SYSTEM_NAME:STRING=Linux-i386 BUILD_QtDialog:BOOL:=TRUE CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE -- cgit v0.12 From 37f225b72c8e4c440025a98f68eda9914f7ba5f7 Mon Sep 17 00:00:00 2001 From: LibArchive Upstream Date: Mon, 14 Apr 2014 19:19:05 -0700 Subject: libarchive 3.1.2-246-ga5a5d28b (reduced) Extract upstream libarchive using the following shell code. url=git://github.com/libarchive/libarchive.git && v=3.1.2-246-ga5a5d28b && r=a5a5d28b && paths=" CMakeLists.txt COPYING CTestConfig.cmake build/cmake build/pkgconfig build/utils build/version libarchive/*.* " && mkdir libarchive-$v-g$r-reduced && git clone $url libarchive-git && date=$(cd libarchive-git && git log -n 1 --format='%cd' $r) && (cd libarchive-git && git archive --format=tar $r -- $paths) | (cd libarchive-$v-g$r-reduced && tar xv) && fromdos libarchive-$v-g$r-reduced/build/cmake/Find*.cmake && echo "g$r date: $date" --- CMakeLists.txt | 10 ++ build/cmake/config.h.in | 3 + libarchive/CMakeLists.txt | 1 + libarchive/archive_read_extract.c | 134 +++----------------------- libarchive/archive_read_extract2.c | 137 +++++++++++++++++++++++++++ libarchive/archive_read_private.h | 11 ++- libarchive/archive_read_support_format_zip.c | 5 +- libarchive/archive_write_disk_posix.c | 3 +- libarchive/archive_write_set_format_zip.c | 30 +++--- 9 files changed, 195 insertions(+), 139 deletions(-) create mode 100644 libarchive/archive_read_extract2.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 2069c23..4bfb7f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ STRING(REGEX REPLACE "[0]*([^0]*[0-9])$" "\\1" _trimmed_revision ${_revision}) SET(VERSION "${_major}.${_trimmed_minor}.${_trimmed_revision}${_quality}") SET(BSDCPIO_VERSION_STRING "${VERSION}") SET(BSDTAR_VERSION_STRING "${VERSION}") +SET(BSDCAT_VERSION_STRING "${VERSION}") SET(LIBARCHIVE_VERSION_NUMBER "${_version_number}") SET(LIBARCHIVE_VERSION_STRING "${VERSION}") @@ -168,6 +169,8 @@ OPTION(ENABLE_TAR "Enable tar building" ON) OPTION(ENABLE_TAR_SHARED "Enable dynamic build of tar" FALSE) OPTION(ENABLE_CPIO "Enable cpio building" ON) OPTION(ENABLE_CPIO_SHARED "Enable dynamic build of cpio" FALSE) +OPTION(ENABLE_CAT "Enable cat building" ON) +OPTION(ENABLE_CAT_SHARED "Enable dynamic build of cat" FALSE) OPTION(ENABLE_XATTR "Enable extended attribute support" ON) OPTION(ENABLE_ACL "Enable ACL support" ON) OPTION(ENABLE_ICONV "Enable iconv support" ON) @@ -1536,6 +1539,12 @@ ADD_DEFINITIONS(-DHAVE_CONFIG_H) INCLUDE(CreatePkgConfigFile) # +# Expose ADDITIONAL_LIBS for projects using libarchive as a subdirectory +# and linking against archive_static. +# +set(LIBARCHIVE_ADDITIONAL_LIBS ${ADDITIONAL_LIBS} CACHE INTERNAL "libarchive dependencies") + +# # Register installation of PDF documents. # IF(WIN32 AND NOT CYGWIN) @@ -1565,5 +1574,6 @@ IF(ENABLE_TEST) ENDIF(ENABLE_TEST) add_subdirectory(libarchive) +add_subdirectory(cat) add_subdirectory(tar) add_subdirectory(cpio) diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in index a6933f6..179ffa7 100644 --- a/build/cmake/config.h.in +++ b/build/cmake/config.h.in @@ -289,6 +289,9 @@ typedef uint64_t uintmax_t; /* Version number of bsdtar */ #cmakedefine BSDTAR_VERSION_STRING "${BSDTAR_VERSION_STRING}" +/* Version number of bsdcat */ +#cmakedefine BSDCAT_VERSION_STRING "${BSDCAT_VERSION_STRING}" + /* Define to 1 if you have the `acl_create_entry' function. */ #cmakedefine HAVE_ACL_CREATE_ENTRY 1 diff --git a/libarchive/CMakeLists.txt b/libarchive/CMakeLists.txt index 986af97..4a0c15d 100644 --- a/libarchive/CMakeLists.txt +++ b/libarchive/CMakeLists.txt @@ -54,6 +54,7 @@ SET(libarchive_SOURCES archive_read_disk_private.h archive_read_disk_set_standard_lookup.c archive_read_extract.c + archive_read_extract2.c archive_read_open_fd.c archive_read_open_file.c archive_read_open_filename.c diff --git a/libarchive/archive_read_extract.c b/libarchive/archive_read_extract.c index 795f2ab..ce76a6c 100644 --- a/libarchive/archive_read_extract.c +++ b/libarchive/archive_read_extract.c @@ -26,146 +26,40 @@ #include "archive_platform.h" __FBSDID("$FreeBSD: src/lib/libarchive/archive_read_extract.c,v 1.61 2008/05/26 17:00:22 kientzle Exp $"); -#ifdef HAVE_SYS_TYPES_H -#include -#endif #ifdef HAVE_ERRNO_H #include #endif -#ifdef HAVE_STDLIB_H -#include -#endif -#ifdef HAVE_STRING_H -#include -#endif #include "archive.h" #include "archive_entry.h" #include "archive_private.h" #include "archive_read_private.h" -#include "archive_write_disk_private.h" - -struct extract { - struct archive *ad; /* archive_write_disk object */ - - /* Progress function invoked during extract. */ - void (*extract_progress)(void *); - void *extract_progress_user_data; -}; static int archive_read_extract_cleanup(struct archive_read *); -static int copy_data(struct archive *ar, struct archive *aw); -static struct extract *get_extract(struct archive_read *); - -static struct extract * -get_extract(struct archive_read *a) -{ - /* If we haven't initialized, do it now. */ - /* This also sets up a lot of global state. */ - if (a->extract == NULL) { - a->extract = (struct extract *)malloc(sizeof(*a->extract)); - if (a->extract == NULL) { - archive_set_error(&a->archive, ENOMEM, "Can't extract"); - return (NULL); - } - memset(a->extract, 0, sizeof(*a->extract)); - a->extract->ad = archive_write_disk_new(); - if (a->extract->ad == NULL) { - archive_set_error(&a->archive, ENOMEM, "Can't extract"); - return (NULL); - } - archive_write_disk_set_standard_lookup(a->extract->ad); - a->cleanup_archive_extract = archive_read_extract_cleanup; - } - return (a->extract); -} int archive_read_extract(struct archive *_a, struct archive_entry *entry, int flags) { - struct extract *extract; + struct archive_read_extract *extract; + struct archive_read * a = (struct archive_read *)_a; - extract = get_extract((struct archive_read *)_a); + extract = __archive_read_get_extract(a); if (extract == NULL) return (ARCHIVE_FATAL); - archive_write_disk_set_options(extract->ad, flags); - return (archive_read_extract2(_a, entry, extract->ad)); -} - -int -archive_read_extract2(struct archive *_a, struct archive_entry *entry, - struct archive *ad) -{ - struct archive_read *a = (struct archive_read *)_a; - int r, r2; - /* Set up for this particular entry. */ - if (a->skip_file_set) - archive_write_disk_set_skip_file(ad, - a->skip_file_dev, a->skip_file_ino); - r = archive_write_header(ad, entry); - if (r < ARCHIVE_WARN) - r = ARCHIVE_WARN; - if (r != ARCHIVE_OK) - /* If _write_header failed, copy the error. */ - archive_copy_error(&a->archive, ad); - else if (!archive_entry_size_is_set(entry) || archive_entry_size(entry) > 0) - /* Otherwise, pour data into the entry. */ - r = copy_data(_a, ad); - r2 = archive_write_finish_entry(ad); - if (r2 < ARCHIVE_WARN) - r2 = ARCHIVE_WARN; - /* Use the first message. */ - if (r2 != ARCHIVE_OK && r == ARCHIVE_OK) - archive_copy_error(&a->archive, ad); - /* Use the worst error return. */ - if (r2 < r) - r = r2; - return (r); -} - -void -archive_read_extract_set_progress_callback(struct archive *_a, - void (*progress_func)(void *), void *user_data) -{ - struct archive_read *a = (struct archive_read *)_a; - struct extract *extract = get_extract(a); - if (extract != NULL) { - extract->extract_progress = progress_func; - extract->extract_progress_user_data = user_data; - } -} - -static int -copy_data(struct archive *ar, struct archive *aw) -{ - int64_t offset; - const void *buff; - struct extract *extract; - size_t size; - int r; - - extract = get_extract((struct archive_read *)ar); - if (extract == NULL) - return (ARCHIVE_FATAL); - for (;;) { - r = archive_read_data_block(ar, &buff, &size, &offset); - if (r == ARCHIVE_EOF) - return (ARCHIVE_OK); - if (r != ARCHIVE_OK) - return (r); - r = (int)archive_write_data_block(aw, buff, size, offset); - if (r < ARCHIVE_WARN) - r = ARCHIVE_WARN; - if (r != ARCHIVE_OK) { - archive_set_error(ar, archive_errno(aw), - "%s", archive_error_string(aw)); - return (r); + /* If we haven't initialized the archive_write_disk object, do it now. */ + if (extract->ad == NULL) { + extract->ad = archive_write_disk_new(); + if (extract->ad == NULL) { + archive_set_error(&a->archive, ENOMEM, "Can't extract"); + return (ARCHIVE_FATAL); } - if (extract->extract_progress) - (extract->extract_progress) - (extract->extract_progress_user_data); + archive_write_disk_set_standard_lookup(extract->ad); + a->cleanup_archive_extract = archive_read_extract_cleanup; } + + archive_write_disk_set_options(extract->ad, flags); + return (archive_read_extract2(&a->archive, entry, extract->ad)); } /* diff --git a/libarchive/archive_read_extract2.c b/libarchive/archive_read_extract2.c new file mode 100644 index 0000000..3c65e80 --- /dev/null +++ b/libarchive/archive_read_extract2.c @@ -0,0 +1,137 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "archive_platform.h" +__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_extract.c,v 1.61 2008/05/26 17:00:22 kientzle Exp $"); + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_ERRNO_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif + +#include "archive.h" +#include "archive_entry.h" +#include "archive_private.h" +#include "archive_read_private.h" + +static int copy_data(struct archive *ar, struct archive *aw); + +/* Retrieve an extract object without initialising the associated + * archive_write_disk object. + */ +struct archive_read_extract * +__archive_read_get_extract(struct archive_read *a) +{ + if (a->extract == NULL) { + a->extract = (struct archive_read_extract *)malloc(sizeof(*a->extract)); + if (a->extract == NULL) { + archive_set_error(&a->archive, ENOMEM, "Can't extract"); + return (NULL); + } + memset(a->extract, 0, sizeof(*a->extract)); + } + return (a->extract); +} + +int +archive_read_extract2(struct archive *_a, struct archive_entry *entry, + struct archive *ad) +{ + struct archive_read *a = (struct archive_read *)_a; + int r, r2; + + /* Set up for this particular entry. */ + if (a->skip_file_set) + archive_write_disk_set_skip_file(ad, + a->skip_file_dev, a->skip_file_ino); + r = archive_write_header(ad, entry); + if (r < ARCHIVE_WARN) + r = ARCHIVE_WARN; + if (r != ARCHIVE_OK) + /* If _write_header failed, copy the error. */ + archive_copy_error(&a->archive, ad); + else if (!archive_entry_size_is_set(entry) || archive_entry_size(entry) > 0) + /* Otherwise, pour data into the entry. */ + r = copy_data(_a, ad); + r2 = archive_write_finish_entry(ad); + if (r2 < ARCHIVE_WARN) + r2 = ARCHIVE_WARN; + /* Use the first message. */ + if (r2 != ARCHIVE_OK && r == ARCHIVE_OK) + archive_copy_error(&a->archive, ad); + /* Use the worst error return. */ + if (r2 < r) + r = r2; + return (r); +} + +void +archive_read_extract_set_progress_callback(struct archive *_a, + void (*progress_func)(void *), void *user_data) +{ + struct archive_read *a = (struct archive_read *)_a; + struct archive_read_extract *extract = __archive_read_get_extract(a); + if (extract != NULL) { + extract->extract_progress = progress_func; + extract->extract_progress_user_data = user_data; + } +} + +static int +copy_data(struct archive *ar, struct archive *aw) +{ + int64_t offset; + const void *buff; + struct archive_read_extract *extract; + size_t size; + int r; + + extract = __archive_read_get_extract((struct archive_read *)ar); + if (extract == NULL) + return (ARCHIVE_FATAL); + for (;;) { + r = archive_read_data_block(ar, &buff, &size, &offset); + if (r == ARCHIVE_EOF) + return (ARCHIVE_OK); + if (r != ARCHIVE_OK) + return (r); + r = (int)archive_write_data_block(aw, buff, size, offset); + if (r < ARCHIVE_WARN) + r = ARCHIVE_WARN; + if (r != ARCHIVE_OK) { + archive_set_error(ar, archive_errno(aw), + "%s", archive_error_string(aw)); + return (r); + } + if (extract->extract_progress) + (extract->extract_progress) + (extract->extract_progress_user_data); + } +} diff --git a/libarchive/archive_read_private.h b/libarchive/archive_read_private.h index 6636a59..27e203b 100644 --- a/libarchive/archive_read_private.h +++ b/libarchive/archive_read_private.h @@ -142,6 +142,14 @@ struct archive_read_client { struct archive_read_data_node *dataset; }; +struct archive_read_extract { + struct archive *ad; /* archive_write_disk object */ + + /* Progress function invoked during extract. */ + void (*extract_progress)(void *); + void *extract_progress_user_data; +}; + struct archive_read { struct archive archive; @@ -215,7 +223,7 @@ struct archive_read { /* * Various information needed by archive_extract. */ - struct extract *extract; + struct archive_read_extract *extract; int (*cleanup_archive_extract)(struct archive_read *); }; @@ -245,4 +253,5 @@ int64_t __archive_read_filter_consume(struct archive_read_filter *, int64_t); int __archive_read_program(struct archive_read_filter *, const char *); void __archive_read_free_filters(struct archive_read *); int __archive_read_close_filters(struct archive_read *); +struct archive_read_extract *__archive_read_get_extract(struct archive_read *); #endif diff --git a/libarchive/archive_read_support_format_zip.c b/libarchive/archive_read_support_format_zip.c index 4460b30..dbe245e 100644 --- a/libarchive/archive_read_support_format_zip.c +++ b/libarchive/archive_read_support_format_zip.c @@ -204,10 +204,11 @@ compression_name(const int compression) { static const int num_compression_methods = sizeof(compression_methods)/sizeof(compression_methods[0]); int i=0; - while(compression >= 0 && i++ < num_compression_methods) { + while(compression >= 0 && i < num_compression_methods) { if (compression_methods[i].id == compression) { return compression_methods[i].name; } + i++; } return "??"; } @@ -743,7 +744,7 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry, zip->end_of_entry = 1; /* Set up a more descriptive format name. */ - sprintf(zip->format_name, "ZIP %d.%d (%s)", + snprintf(zip->format_name, sizeof(zip->format_name), "ZIP %d.%d (%s)", version / 10, version % 10, compression_name(zip->entry->compression)); a->archive.archive_format_name = zip->format_name; diff --git a/libarchive/archive_write_disk_posix.c b/libarchive/archive_write_disk_posix.c index bbd50a6..1fac4ce 100644 --- a/libarchive/archive_write_disk_posix.c +++ b/libarchive/archive_write_disk_posix.c @@ -2215,7 +2215,8 @@ _archive_write_disk_free(struct archive *_a) free(a->resource_fork); free(a->compressed_buffer); free(a->uncompressed_buffer); -#ifdef HAVE_ZLIB_H +#if defined(__APPLE__) && defined(UF_COMPRESSED) && defined(HAVE_SYS_XATTR_H)\ + && defined(HAVE_ZLIB_H) if (a->stream_valid) { switch (deflateEnd(&a->stream)) { case Z_OK: diff --git a/libarchive/archive_write_set_format_zip.c b/libarchive/archive_write_set_format_zip.c index ccd50ea..6ecf468 100644 --- a/libarchive/archive_write_set_format_zip.c +++ b/libarchive/archive_write_set_format_zip.c @@ -405,8 +405,8 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry) unsigned char *e; unsigned char *cd_extra; size_t filename_length; - const char *symlink = NULL; - size_t symlink_size = 0; + const char *slink = NULL; + size_t slink_size = 0; struct archive_string_conv *sconv = get_sconv(a, zip); int ret, ret2 = ARCHIVE_OK; int64_t size; @@ -528,16 +528,16 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry) /* Determine appropriate compression and size for this entry. */ if (type == AE_IFLNK) { - symlink = archive_entry_symlink(zip->entry); - if (symlink != NULL) - symlink_size = strlen(symlink); + slink = archive_entry_symlink(zip->entry); + if (slink != NULL) + slink_size = strlen(slink); else - symlink_size = 0; - zip->entry_uncompressed_limit = symlink_size; - zip->entry_compressed_size = symlink_size; - zip->entry_uncompressed_size = symlink_size; + slink_size = 0; + zip->entry_uncompressed_limit = slink_size; + zip->entry_compressed_size = slink_size; + zip->entry_uncompressed_size = slink_size; zip->entry_crc32 = zip->crc32func(zip->entry_crc32, - (const unsigned char *)symlink, symlink_size); + (const unsigned char *)slink, slink_size); zip->entry_compression = COMPRESSION_STORE; version_needed = 20; } else if (type != AE_IFREG) { @@ -742,13 +742,13 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry) zip->written_bytes += e - local_extra; /* For symlinks, write the body now. */ - if (symlink != NULL) { - ret = __archive_write_output(a, symlink, (size_t)symlink_size); + if (slink != NULL) { + ret = __archive_write_output(a, slink, slink_size); if (ret != ARCHIVE_OK) return (ARCHIVE_FATAL); - zip->entry_compressed_written += symlink_size; - zip->entry_uncompressed_written += symlink_size; - zip->written_bytes += symlink_size; + zip->entry_compressed_written += slink_size; + zip->entry_uncompressed_written += slink_size; + zip->written_bytes += slink_size; } #ifdef HAVE_ZLIB_H -- cgit v0.12 From 44d6b82f4351dc3941fd9794ad8f3909148c0314 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Apr 2014 16:34:17 -0400 Subject: libarchive: Disable all whitespace checks in third-party code --- Utilities/cmlibarchive/.gitattributes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/cmlibarchive/.gitattributes b/Utilities/cmlibarchive/.gitattributes index a87f192..562b12e 100644 --- a/Utilities/cmlibarchive/.gitattributes +++ b/Utilities/cmlibarchive/.gitattributes @@ -1 +1 @@ -* whitespace=-indent-with-non-tab,-tab-in-indent,-blank-at-eol,-blank-at-eof +* -whitespace -- cgit v0.12 From 61a649d974b7810ec6073ef088e1b65c1277dbda Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Apr 2014 16:36:44 -0400 Subject: libarchive: Update README-CMake.txt for new snapshot --- Utilities/cmlibarchive/README-CMake.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Utilities/cmlibarchive/README-CMake.txt b/Utilities/cmlibarchive/README-CMake.txt index 7cbee4c..8f3b29b 100644 --- a/Utilities/cmlibarchive/README-CMake.txt +++ b/Utilities/cmlibarchive/README-CMake.txt @@ -11,7 +11,7 @@ branch, but it is merged into our history. Update libarchive from upstream as follows. Create a local branch to explicitly reference the upstream snapshot branch head: - git branch libarchive-upstream 64713ae3 + git branch libarchive-upstream 37f225b7 Use a temporary directory to checkout the branch: @@ -24,7 +24,7 @@ Use a temporary directory to checkout the branch: Now place the (reduced) libarchive content in this directory. See instructions shown by - git log 64713ae3 + git log 37f225b7 for help extracting the content from the upstream svn repo. Then run the following commands to commit the new version. Substitute the @@ -34,8 +34,8 @@ appropriate date and version number: GIT_AUTHOR_NAME='LibArchive Upstream' \ GIT_AUTHOR_EMAIL='libarchive-discuss@googlegroups.com' \ - GIT_AUTHOR_DATE='Mon Mar 17 20:43:07 2014 -0700' \ - git commit -m 'libarchive 3.1.2-218-g00f4bd83 (reduced)' && + GIT_AUTHOR_DATE='Mon Apr 14 19:19:05 2014 -0700' \ + git commit -m 'libarchive 3.1.2-246-ga5a5d28b (reduced)' && git commit --amend Edit the commit message to describe the procedure used to obtain the -- cgit v0.12 From fcfbb0a9244ff52d03fec67de7a2a8d0ff406db3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Apr 2014 16:37:52 -0400 Subject: libarchive: Drop LIBARCHIVE_ADDITIONAL_LIBS, CMake does not need it --- Utilities/cmlibarchive/CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt index 77010c5..4bfc205 100644 --- a/Utilities/cmlibarchive/CMakeLists.txt +++ b/Utilities/cmlibarchive/CMakeLists.txt @@ -1292,12 +1292,6 @@ INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) ADD_DEFINITIONS(-DHAVE_CONFIG_H) # -# Expose ADDITIONAL_LIBS for projects using libarchive as a subdirectory -# and linking against archive_static. -# -set(LIBARCHIVE_ADDITIONAL_LIBS ${ADDITIONAL_LIBS} CACHE INTERNAL "libarchive dependencies") - -# # Register installation of PDF documents. # IF(WIN32 AND NOT CYGWIN) -- cgit v0.12 From 67f5f0a9fd012f3da7cadf653102671a8f316718 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Apr 2014 16:52:18 -0400 Subject: libarchive: Use _snprintf on Windows, not snprintf --- Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c index b2614a0..5ef2952 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c @@ -64,6 +64,10 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_zip.c 201102 #include "archive_crc32.h" #endif +#if defined(_WIN32) && !defined(__CYGWIN__) +# define snprintf _snprintf +#endif + struct zip_entry { struct archive_rb_node node; struct zip_entry *next; -- cgit v0.12 From fd8bb3427858017754d5b08a2eb1f57116feebb6 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 16 Apr 2014 00:01:07 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index a6be93f..60da8d6 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 0) -set(CMake_VERSION_PATCH 20140415) +set(CMake_VERSION_PATCH 20140416) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 597bb72ed7a74bf9b70dec8726113050e731d667 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 16 Apr 2014 17:20:15 +0200 Subject: Tests: Run RunCMake.target_compile_features unconditionally. It is so far testing only cases which are fatal regardless of recorded features. --- Tests/RunCMake/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 00e6702..e797a73 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -126,9 +126,7 @@ add_RunCMake_test(File_Generate) add_RunCMake_test(ExportWithoutLanguage) add_RunCMake_test(target_link_libraries) -if (CMAKE_CXX_COMPILER_ID STREQUAL GNU AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) - add_RunCMake_test(target_compile_features) -endif() +add_RunCMake_test(target_compile_features) add_RunCMake_test(CheckModules) add_RunCMake_test(CommandLine) -- cgit v0.12 From 1ec6485c6a16c230bf29696ab8fd48eb5edbb78a Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Apr 2014 08:05:59 -0400 Subject: Support duplicate object names in large archives (#14874) Generalize the change from commit 39d0ade0 (Windows-GNU: Support duplicate object names in large archives, 2014-04-14) to the default archive rules. These rules have used an incremental append approach since commit v2.8.0~1856 (Build large archives incrementally, 2008-08-04). Switch from "ar r" to "ar q" to be sure we always append objects instead of replacing them. --- Modules/CMakeCInformation.cmake | 4 ++-- Modules/CMakeCXXInformation.cmake | 4 ++-- Modules/CMakeFortranInformation.cmake | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index e0cce45..332b26e 100644 --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -175,10 +175,10 @@ endif() # Create a static archive incrementally for large object file counts. # If CMAKE_C_CREATE_STATIC_LIBRARY is set it will override these. if(NOT DEFINED CMAKE_C_ARCHIVE_CREATE) - set(CMAKE_C_ARCHIVE_CREATE " cr ") + set(CMAKE_C_ARCHIVE_CREATE " cq ") endif() if(NOT DEFINED CMAKE_C_ARCHIVE_APPEND) - set(CMAKE_C_ARCHIVE_APPEND " r ") + set(CMAKE_C_ARCHIVE_APPEND " q ") endif() if(NOT DEFINED CMAKE_C_ARCHIVE_FINISH) set(CMAKE_C_ARCHIVE_FINISH " ") diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index 3010a48..72b2857 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -266,10 +266,10 @@ endif() # Create a static archive incrementally for large object file counts. # If CMAKE_CXX_CREATE_STATIC_LIBRARY is set it will override these. if(NOT DEFINED CMAKE_CXX_ARCHIVE_CREATE) - set(CMAKE_CXX_ARCHIVE_CREATE " cr ") + set(CMAKE_CXX_ARCHIVE_CREATE " cq ") endif() if(NOT DEFINED CMAKE_CXX_ARCHIVE_APPEND) - set(CMAKE_CXX_ARCHIVE_APPEND " r ") + set(CMAKE_CXX_ARCHIVE_APPEND " q ") endif() if(NOT DEFINED CMAKE_CXX_ARCHIVE_FINISH) set(CMAKE_CXX_ARCHIVE_FINISH " ") diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index 080dc68..d638207 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -194,10 +194,10 @@ endif() # Create a static archive incrementally for large object file counts. # If CMAKE_Fortran_CREATE_STATIC_LIBRARY is set it will override these. if(NOT DEFINED CMAKE_Fortran_ARCHIVE_CREATE) - set(CMAKE_Fortran_ARCHIVE_CREATE " cr ") + set(CMAKE_Fortran_ARCHIVE_CREATE " cq ") endif() if(NOT DEFINED CMAKE_Fortran_ARCHIVE_APPEND) - set(CMAKE_Fortran_ARCHIVE_APPEND " r ") + set(CMAKE_Fortran_ARCHIVE_APPEND " q ") endif() if(NOT DEFINED CMAKE_Fortran_ARCHIVE_FINISH) set(CMAKE_Fortran_ARCHIVE_FINISH " ") -- cgit v0.12 From 1f3e95ba72cdafec0efb99d43a062b538780b093 Mon Sep 17 00:00:00 2001 From: Jack Morrison Date: Wed, 16 Apr 2014 13:15:59 -0400 Subject: FindGTest: Teach GTEST_ADD_TESTS about TYPED_TEST --- Modules/FindGTest.cmake | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index c4f911d..6a36ea6 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -116,19 +116,25 @@ function(GTEST_ADD_TESTS executable extra_args) get_property(ARGN TARGET ${executable} PROPERTY SOURCES) endif() set(gtest_case_name_regex ".*\\( *([A-Za-z_0-9]+), *([A-Za-z_0-9]+) *\\).*") + set(gtest_test_type_regex "(TYPED_TEST|TEST_?[FP]?)") foreach(source ${ARGN}) file(READ "${source}" contents) - string(REGEX MATCHALL "TEST_?[FP]?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents}) + string(REGEX MATCHALL "${gtest_test_type_regex}\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents}) foreach(hit ${found_tests}) - string(REGEX MATCH "TEST_?[FP]?" test_type ${hit}) + string(REGEX MATCH "${gtest_test_type_regex}" test_type ${hit}) - # Parameterized tests have a different signature for the filter - if(${test_type} STREQUAL "TEST_P") - string(REGEX REPLACE ${gtest_case_name_regex} "*/\\1.\\2/*" test_name ${hit}) - else() - string(REGEX REPLACE ${gtest_case_name_regex} "\\1.\\2" test_name ${hit}) - endif() - add_test(${test_name} ${executable} --gtest_filter=${test_name} ${extra_args}) + # Parameterized tests have a different signature for the filter + if(${test_type} STREQUAL "TEST_P") + string(REGEX REPLACE ${gtest_case_name_regex} "*/\\1.\\2/*" test_name ${hit}) + elseif(${test_type} STREQUAL "TEST_F" OR ${test_type} STREQUAL "TEST") + string(REGEX REPLACE ${gtest_case_name_regex} "\\1.\\2" test_name ${hit}) + elseif(${test_type} STREQUAL "TYPED_TEST") + string(REGEX REPLACE ${gtest_case_name_regex} "\\1/*.\\2" test_name ${hit}) + else() + message(WARNING "Could not parse GTest ${hit} for adding to CTest.") + continue() + endif() + add_test(${test_name} ${executable} --gtest_filter=${test_name} ${extra_args}) endforeach() endforeach() endfunction() -- cgit v0.12 From 9e0b3153fa2fa9e1b51d1fd7d265a114958e7f0a Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Apr 2014 15:53:57 -0400 Subject: CMP0052: Do not warn when include dir is not in source or build tree When the policy was added by commit 783bce29 (Export: Disallow exported interface includes in src/build tree, 2014-03-31) it accidentally left a code path that would warn when the include dir is in the install tree but *not* in the source or build tree. Fix that. --- Source/cmExportFileGenerator.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 42fce6d..25ffe1a 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -277,6 +277,8 @@ static bool checkInterfaceDirs(const std::string &prepro, " \"" << *li << "\""; target->GetMakefile()->IssueMessage(messageType, e.str()); } + bool inBinary = isSubDirectory(li->c_str(), topBinaryDir); + bool inSource = isSubDirectory(li->c_str(), topSourceDir); if (isSubDirectory(li->c_str(), installDir)) { // The include directory is inside the install tree. If the @@ -284,8 +286,8 @@ static bool checkInterfaceDirs(const std::string &prepro, // fall through to the checks below that the include directory is not // also inside the source tree or build tree. bool shouldContinue = - isSubDirectory(installDir, topBinaryDir) - || isSubDirectory(installDir, topSourceDir); + (!inBinary || isSubDirectory(installDir, topBinaryDir)) && + (!inSource || isSubDirectory(installDir, topSourceDir)); if (!shouldContinue) { @@ -317,7 +319,7 @@ static bool checkInterfaceDirs(const std::string &prepro, continue; } } - if (isSubDirectory(li->c_str(), topBinaryDir)) + if (inBinary) { e << "Target \"" << target->GetName() << "\" " "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n" @@ -326,7 +328,7 @@ static bool checkInterfaceDirs(const std::string &prepro, } if (!inSourceBuild) { - if (isSubDirectory(li->c_str(), topSourceDir)) + if (inSource) { e << "Target \"" << target->GetName() << "\" " "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n" -- cgit v0.12 From 858ed4b390fd21ee1cc29bced6724d2eeb4476a6 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 17 Apr 2014 00:01:08 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 60da8d6..6ac332b 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 0) -set(CMake_VERSION_PATCH 20140416) +set(CMake_VERSION_PATCH 20140417) #set(CMake_VERSION_RC 1) -- cgit v0.12 From e5e9b8e9a33186c0684974a54507d07596d72a1b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 17 Apr 2014 11:01:58 +0200 Subject: Help: Add code example for INSTALL_INTERFACE to cmake-buildsystem. --- Help/manual/cmake-buildsystem.7.rst | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst index 501b924..3e1f011 100644 --- a/Help/manual/cmake-buildsystem.7.rst +++ b/Help/manual/cmake-buildsystem.7.rst @@ -580,7 +580,17 @@ and the install-tree. The ``BUILD_INTERFACE`` and ``INSTALL_INTERFACE`` generator expressions can be used to describe separate usage requirements based on the usage location. Relative paths are allowed within these expressions, and are interpreted relative to the current source directory -or the installation prefix, as appropriate. +or the installation prefix, as appropriate: + +.. code-block:: cmake + + add_library(ClimbingStats climbingstats.cpp) + target_include_directories(ClimbingStats INTERFACE + $ + $ + $ + $/$/generated> + ) Two convenience APIs are provided relating to include directories usage requirements. The :variable:`CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE` variable -- cgit v0.12 From 692228e41821a1af1f904304984c7366ae2ca288 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 17 Apr 2014 11:05:20 +0200 Subject: Help: Link to cmake-buildsystem from CMP0052 docs. --- Help/policy/CMP0052.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Help/policy/CMP0052.rst b/Help/policy/CMP0052.rst index f857f36..48cfc9c 100644 --- a/Help/policy/CMP0052.rst +++ b/Help/policy/CMP0052.rst @@ -10,6 +10,9 @@ the installation prefix. This makes the installation depend on the existence of the source dir or binary dir, and the installation will be broken if either are removed after installation. +See :ref:`Include Directories and Usage Requirements` for more on +specifying include directories for targets. + The OLD behavior for this policy is to export the content of the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` with the source or binary directory. The NEW behavior for this -- cgit v0.12 From 5baa81592be69a87c10380daaa03da48c3fc729f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 16 Apr 2014 22:49:40 +0200 Subject: CMP0052: Test that include dirs in install locations cause no warnings. --- Tests/RunCMake/include_directories/DirInInstallPrefix-result.txt | 1 + Tests/RunCMake/include_directories/DirInInstallPrefix-stderr.txt | 1 + Tests/RunCMake/include_directories/DirInInstallPrefix.cmake | 9 +++++++++ Tests/RunCMake/include_directories/RunCMakeTest.cmake | 3 +++ 4 files changed, 14 insertions(+) create mode 100644 Tests/RunCMake/include_directories/DirInInstallPrefix-result.txt create mode 100644 Tests/RunCMake/include_directories/DirInInstallPrefix-stderr.txt create mode 100644 Tests/RunCMake/include_directories/DirInInstallPrefix.cmake diff --git a/Tests/RunCMake/include_directories/DirInInstallPrefix-result.txt b/Tests/RunCMake/include_directories/DirInInstallPrefix-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/include_directories/DirInInstallPrefix-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/include_directories/DirInInstallPrefix-stderr.txt b/Tests/RunCMake/include_directories/DirInInstallPrefix-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/include_directories/DirInInstallPrefix-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/include_directories/DirInInstallPrefix.cmake b/Tests/RunCMake/include_directories/DirInInstallPrefix.cmake new file mode 100644 index 0000000..d6f08bd --- /dev/null +++ b/Tests/RunCMake/include_directories/DirInInstallPrefix.cmake @@ -0,0 +1,9 @@ + +add_library(testTarget empty.cpp) +target_include_directories(testTarget INTERFACE "${CMAKE_INSTALL_PREFIX}/dir") + +install(TARGETS testTarget EXPORT testTargets + DESTINATION lib +) + +install(EXPORT testTargets DESTINATION lib/cmake) diff --git a/Tests/RunCMake/include_directories/RunCMakeTest.cmake b/Tests/RunCMake/include_directories/RunCMakeTest.cmake index 434beb9..c5b29d0 100644 --- a/Tests/RunCMake/include_directories/RunCMakeTest.cmake +++ b/Tests/RunCMake/include_directories/RunCMakeTest.cmake @@ -13,6 +13,9 @@ run_cmake(install_config) run_cmake(incomplete-genex) run_cmake(export-NOWARN) +set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/DirInInstallPrefix/prefix") +run_cmake(DirInInstallPrefix) + configure_file( "${RunCMake_SOURCE_DIR}/CMakeLists.txt" "${RunCMake_BINARY_DIR}/copy/CMakeLists.txt" -- cgit v0.12 From 3b673586f520cf87ae6a0a923a88ad9dadb80b52 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 16 Apr 2014 23:46:13 +0200 Subject: CMP0052: Make the warning message more informative. Print the reason for the offending entry in the INTERFACE_INCLUDE_DIRECTORIES. --- Source/cmExportFileGenerator.cxx | 5 ++++- .../include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt | 5 +++++ .../include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 25ffe1a..2db4086 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -301,7 +301,10 @@ static bool checkInterfaceDirs(const std::string &prepro, s << "Directory:\n \"" << *li << "\"\nin " "INTERFACE_INCLUDE_DIRECTORIES of target \"" << target->GetName() << "\" is a subdirectory of the install " - "directory:\n \"" << installDir << "\""; + "directory:\n \"" << installDir << "\"\nhowever it is also " + "a subdirectory of the " << (inBinary ? "build" : "source") + << " tree:\n \"" << (inBinary ? topBinaryDir : topSourceDir) + << "\"" << std::endl; target->GetMakefile()->IssueMessage(cmake::AUTHOR_WARNING, s.str()); } diff --git a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt index f6d408c..054bff5 100644 --- a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt +++ b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt @@ -12,4 +12,9 @@ CMake Warning \(dev\) in CMakeLists.txt: of the install directory: ".*Tests/RunCMake/include_directories/prefix" + + however it is also a subdirectory of the build tree: + + ".*Tests/RunCMake/include_directories/prefix/BinInInstallPrefix-CMP0052-WARN-build" + This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt index 78710c0..0b13fd8 100644 --- a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt +++ b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt @@ -12,4 +12,9 @@ CMake Warning \(dev\) in CMakeLists.txt: of the install directory: ".*Tests/RunCMake/include_directories/prefix" + + however it is also a subdirectory of the source tree: + + ".*Tests/RunCMake/include_directories/prefix/src" + This warning is for project developers. Use -Wno-dev to suppress it. -- cgit v0.12 From ccd29b9af849316a9361ceb8d0addb24e7158382 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Apr 2014 09:31:41 -0400 Subject: ExternalData: Warn on missing file instead of failing When the primary source tree path named by a DATA{} reference does not exist, produce an AUTHOR_WARNING instead of a FATAL_ERROR. This is useful when writing a new DATA{} reference to a test reference output that has not been created yet. This way the developer can run the test, manually verify the output, and then copy it into place to provide the reference and eliminate the warning. If the named source tree path is expected to be a file but exists as a directory, we still need to produce a FATAL_ERROR. --- Modules/ExternalData.cmake | 44 ++++++++++++++-------- Tests/Module/ExternalData/CMakeLists.txt | 2 + Tests/Module/ExternalData/Data1Check.cmake | 22 +++++++++++ Tests/RunCMake/ExternalData/Directory1-stderr.txt | 2 +- Tests/RunCMake/ExternalData/Directory3-result.txt | 1 - Tests/RunCMake/ExternalData/Directory3-stderr.txt | 3 +- Tests/RunCMake/ExternalData/MissingData-result.txt | 1 - Tests/RunCMake/ExternalData/MissingData-stderr.txt | 5 ++- Tests/RunCMake/ExternalData/MissingData-stdout.txt | 1 + Tests/RunCMake/ExternalData/MissingData.cmake | 13 +++++-- .../MissingDataWithAssociated-stderr.txt | 15 ++++++++ .../MissingDataWithAssociated-stdout.txt | 1 + .../ExternalData/MissingDataWithAssociated.cmake | 10 +++++ Tests/RunCMake/ExternalData/RunCMakeTest.cmake | 1 + 14 files changed, 96 insertions(+), 25 deletions(-) delete mode 100644 Tests/RunCMake/ExternalData/Directory3-result.txt delete mode 100644 Tests/RunCMake/ExternalData/MissingData-result.txt create mode 100644 Tests/RunCMake/ExternalData/MissingData-stdout.txt create mode 100644 Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt create mode 100644 Tests/RunCMake/ExternalData/MissingDataWithAssociated-stdout.txt create mode 100644 Tests/RunCMake/ExternalData/MissingDataWithAssociated.cmake diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index ee20693..73a4990 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -421,6 +421,7 @@ function(_ExternalData_arg target arg options var_file) set(external "") # Entries external to the source tree. set(internal "") # Entries internal to the source tree. set(have_original ${data_is_directory}) + set(have_original_as_dir 0) # Process options. set(series_option "") @@ -470,11 +471,18 @@ function(_ExternalData_arg target arg options var_file) endif() if(NOT have_original) - message(FATAL_ERROR "Data file referenced by argument\n" + if(have_original_as_dir) + set(msg_kind FATAL_ERROR) + set(msg "that is directory instead of a file!") + else() + set(msg_kind AUTHOR_WARNING) + set(msg "that does not exist as a file (with or without an extension)!") + endif() + message(${msg_kind} "Data file referenced by argument\n" " ${arg}\n" "corresponds to source tree path\n" " ${reldata}\n" - "that does not exist as a file (with or without an extension)!") + "${msg}") endif() if(external) @@ -591,27 +599,33 @@ function(_ExternalData_arg_find_files pattern regex) set(alg "") endif() if("x${relname}" MATCHES "^x${regex}$" # matches - AND NOT IS_DIRECTORY "${top_src}/${entry}" # not a directory AND NOT "x${relname}" MATCHES "(^x|/)\\.ExternalData_" # not staged obj ) - set(name "${top_src}/${relname}") - set(file "${top_bin}/${relname}") - if(alg) - list(APPEND external "${file}|${name}|${alg}") - elseif(ExternalData_LINK_CONTENT) - _ExternalData_link_content("${name}" alg) - list(APPEND external "${file}|${name}|${alg}") - elseif(NOT top_same) - list(APPEND internal "${file}|${name}") - endif() - if("${relname}" STREQUAL "${reldata}") - set(have_original 1) + if(IS_DIRECTORY "${top_src}/${entry}") + if("${relname}" STREQUAL "${reldata}") + set(have_original_as_dir 1) + endif() + else() + set(name "${top_src}/${relname}") + set(file "${top_bin}/${relname}") + if(alg) + list(APPEND external "${file}|${name}|${alg}") + elseif(ExternalData_LINK_CONTENT) + _ExternalData_link_content("${name}" alg) + list(APPEND external "${file}|${name}|${alg}") + elseif(NOT top_same) + list(APPEND internal "${file}|${name}") + endif() + if("${relname}" STREQUAL "${reldata}") + set(have_original 1) + endif() endif() endif() endforeach() set(external "${external}" PARENT_SCOPE) set(internal "${internal}" PARENT_SCOPE) set(have_original "${have_original}" PARENT_SCOPE) + set(have_original_as_dir "${have_original_as_dir}" PARENT_SCOPE) endfunction() #----------------------------------------------------------------------------- diff --git a/Tests/Module/ExternalData/CMakeLists.txt b/Tests/Module/ExternalData/CMakeLists.txt index 5a6f3d5..ebca48e 100644 --- a/Tests/Module/ExternalData/CMakeLists.txt +++ b/Tests/Module/ExternalData/CMakeLists.txt @@ -23,6 +23,8 @@ ExternalData_Add_Test(Data1 COMMAND ${CMAKE_COMMAND} -D Data=DATA{Data.dat} ${Data1CheckSpaces} + -D DataMissing=DATA{DataMissing.dat} + -D DataMissingWithAssociated=DATA{DataMissing.dat,Data.dat} -D SeriesA=DATA{SeriesA.dat,:} -D SeriesB=DATA{SeriesB.dat,:} -D SeriesC=DATA{SeriesC.dat,:} diff --git a/Tests/Module/ExternalData/Data1Check.cmake b/Tests/Module/ExternalData/Data1Check.cmake index 5770245..485b5c6 100644 --- a/Tests/Module/ExternalData/Data1Check.cmake +++ b/Tests/Module/ExternalData/Data1Check.cmake @@ -8,6 +8,28 @@ if(DEFINED DataSpace) message(SEND_ERROR "Input file:\n ${DataSpace}\ndoes not have expected content, but [[${lines}]]") endif() endif() +if(DataMissing) + if(EXISTS "${DataMissing}") + message(SEND_ERROR + "Input file:\n" + " ${DataMissing}\n" + "exists but should not." + ) + endif() +else() + message(SEND_ERROR "DataMissing is not set!") +endif() +if(DataMissingWithAssociated) + if(EXISTS "${DataMissingWithAssociated}") + message(SEND_ERROR + "Input file:\n" + " ${DataMissingWithAssociated}\n" + "exists but should not." + ) + endif() +else() + message(SEND_ERROR "DataMissingWithAssociated is not set!") +endif() set(SeriesAn1 "1\\.dat") set(SeriesBn1 "_1\\.dat") set(SeriesCn1 "\\.1\\.dat") diff --git a/Tests/RunCMake/ExternalData/Directory1-stderr.txt b/Tests/RunCMake/ExternalData/Directory1-stderr.txt index 85c250f..2bc3c60 100644 --- a/Tests/RunCMake/ExternalData/Directory1-stderr.txt +++ b/Tests/RunCMake/ExternalData/Directory1-stderr.txt @@ -7,7 +7,7 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): Directory1 - that does not exist as a file \(with or without an extension\)! + that is directory instead of a file! Call Stack \(most recent call first\): .* Directory1.cmake:3 \(ExternalData_Add_Test\) diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/ExternalData/Directory3-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/ExternalData/Directory3-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/ExternalData/Directory3-stderr.txt b/Tests/RunCMake/ExternalData/Directory3-stderr.txt index 56a341e..ceed2a0 100644 --- a/Tests/RunCMake/ExternalData/Directory3-stderr.txt +++ b/Tests/RunCMake/ExternalData/Directory3-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): +CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): Data file referenced by argument DATA{Directory3/\*} @@ -12,3 +12,4 @@ Call Stack \(most recent call first\): .* Directory3.cmake:3 \(ExternalData_Add_Test\) CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/ExternalData/MissingData-result.txt b/Tests/RunCMake/ExternalData/MissingData-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/ExternalData/MissingData-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/ExternalData/MissingData-stderr.txt b/Tests/RunCMake/ExternalData/MissingData-stderr.txt index e794f95..39ed2f1 100644 --- a/Tests/RunCMake/ExternalData/MissingData-stderr.txt +++ b/Tests/RunCMake/ExternalData/MissingData-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): +CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): Data file referenced by argument DATA{MissingData.txt} @@ -10,5 +10,6 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): that does not exist as a file \(with or without an extension\)! Call Stack \(most recent call first\): .* - MissingData.cmake:2 \(ExternalData_Add_Test\) + MissingData.cmake:4 \(ExternalData_Expand_Arguments\) CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/ExternalData/MissingData-stdout.txt b/Tests/RunCMake/ExternalData/MissingData-stdout.txt new file mode 100644 index 0000000..addd40e --- /dev/null +++ b/Tests/RunCMake/ExternalData/MissingData-stdout.txt @@ -0,0 +1 @@ +-- Missing data reference correctly transformed! diff --git a/Tests/RunCMake/ExternalData/MissingData.cmake b/Tests/RunCMake/ExternalData/MissingData.cmake index b3c8a5c..f5fefd5 100644 --- a/Tests/RunCMake/ExternalData/MissingData.cmake +++ b/Tests/RunCMake/ExternalData/MissingData.cmake @@ -1,5 +1,10 @@ include(ExternalData) -ExternalData_Add_Test(Data - NAME Test - COMMAND ${CMAKE_COMMAND} -E echo DATA{MissingData.txt} - ) + +set(output "${CMAKE_SOURCE_DIR}/MissingData.txt") +ExternalData_Expand_Arguments(Data args DATA{MissingData.txt}) +if("x${args}" STREQUAL "x${output}") + message(STATUS "Missing data reference correctly transformed!") +else() + message(FATAL_ERROR "Missing data reference transformed to:\n ${args}\n" + "but we expected:\n ${output}") +endif() diff --git a/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt b/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt new file mode 100644 index 0000000..315af5e --- /dev/null +++ b/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt @@ -0,0 +1,15 @@ +CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\): + Data file referenced by argument + + DATA{MissingData.txt,Data.txt} + + corresponds to source tree path + + MissingData.txt + + that does not exist as a file \(with or without an extension\)! +Call Stack \(most recent call first\): + .* + MissingDataWithAssociated.cmake:4 \(ExternalData_Expand_Arguments\) + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stdout.txt b/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stdout.txt new file mode 100644 index 0000000..addd40e --- /dev/null +++ b/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stdout.txt @@ -0,0 +1 @@ +-- Missing data reference correctly transformed! diff --git a/Tests/RunCMake/ExternalData/MissingDataWithAssociated.cmake b/Tests/RunCMake/ExternalData/MissingDataWithAssociated.cmake new file mode 100644 index 0000000..a4c4638 --- /dev/null +++ b/Tests/RunCMake/ExternalData/MissingDataWithAssociated.cmake @@ -0,0 +1,10 @@ +include(ExternalData) + +set(output "${CMAKE_BINARY_DIR}/MissingData.txt") +ExternalData_Expand_Arguments(Data args DATA{MissingData.txt,Data.txt}) +if("x${args}" STREQUAL "x${output}") + message(STATUS "Missing data reference correctly transformed!") +else() + message(FATAL_ERROR "Missing data reference transformed to:\n ${args}\n" + "but we expected:\n ${output}") +endif() diff --git a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake index 93ff08f..04e3d59 100644 --- a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake @@ -15,6 +15,7 @@ run_cmake(LinkContentMD5) run_cmake(LinkContentSHA1) run_cmake(LinkDirectory1) run_cmake(MissingData) +run_cmake(MissingDataWithAssociated) run_cmake(NoLinkInSource) run_cmake(NoURLTemplates) run_cmake(NormalData1) -- cgit v0.12 From 447fbb3facd09a29a2a402df258acf01cbf0bc34 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 16 Apr 2014 17:22:01 +0200 Subject: Tests: Execute compile features tests unconditionally. Conditionally create a dummy test if there are no known features. --- Tests/CMakeCommands/target_compile_features/CMakeLists.txt | 8 ++++++++ Tests/CMakeLists.txt | 8 +++----- Tests/CompileFeatures/CMakeLists.txt | 8 ++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Tests/CMakeCommands/target_compile_features/CMakeLists.txt b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt index ad76411..62e3ce0 100644 --- a/Tests/CMakeCommands/target_compile_features/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt @@ -1,6 +1,14 @@ cmake_minimum_required(VERSION 3.0) project(target_compile_features) +if (NOT CMAKE_CXX_COMPILE_FEATURES) + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_dummy.cpp" + "int main(int,char**) { return 0; }\n" + ) + add_executable(target_compile_features "${CMAKE_CURRENT_BINARY_DIR}/test_dummy.cpp") + return() +endif() + set(CMAKE_VERBOSE_MAKEFILE ON) add_executable(target_compile_features main.cpp) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 12bd3b2..9d642cc 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -197,11 +197,9 @@ if(BUILD_TESTING) ADD_TEST_MACRO(TarTest TarTest) ADD_TEST_MACRO(SystemInformation SystemInformation) ADD_TEST_MACRO(MathTest MathTest) - if(CMAKE_CXX_COMPILER_ID STREQUAL GNU - AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) - ADD_TEST_MACRO(CompileFeatures CompileFeatures) - ADD_TEST_MACRO(CMakeCommands.target_compile_features target_compile_features) - endif() + ADD_TEST_MACRO(CompileFeatures CompileFeatures) + ADD_TEST_MACRO(CMakeCommands.target_compile_features target_compile_features) + # assume no resources building to test set(TEST_RESOURCES FALSE) # for windows and cygwin assume we have resources diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index bceb6bb..ce5004b 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -3,6 +3,14 @@ cmake_minimum_required(VERSION 3.0) project(CompileFeatures) +if (NOT CMAKE_CXX_COMPILE_FEATURES) + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp" + "int main(int,char**) { return 0; }\n" + ) + add_executable(CompileFeatures "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp") + return() +endif() + macro(run_test feature) if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ${feature}) add_library(test_${feature} OBJECT ${feature}.cpp) -- cgit v0.12 From 8d0b1ccac13389255a318422d38b246cf47d9ace Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 15 Apr 2014 18:09:21 +0200 Subject: Features: FATAL_ERROR on compilers with no recorded features. Users of the new target_compile_features command are expected to check the existence of the CMAKE_CXX_COMPILE_FEATURES variable before attempting to use it to require features. --- Source/cmMakefile.cxx | 24 ++++++++++++++++++++-- .../NoSupportedCxxFeatures-result.txt | 1 + .../NoSupportedCxxFeatures-stderr.txt | 8 ++++++++ .../CompileFeatures/NoSupportedCxxFeatures.cmake | 3 +++ .../NoSupportedCxxFeaturesGenex-result.txt | 1 + .../NoSupportedCxxFeaturesGenex-stderr.txt | 6 ++++++ .../NoSupportedCxxFeaturesGenex.cmake | 3 +++ Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake | 11 ++++++++++ .../CompileFeatures/generate_feature_list.cmake | 4 ++++ 9 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-result.txt create mode 100644 Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-stderr.txt create mode 100644 Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures.cmake create mode 100644 Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-result.txt create mode 100644 Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-stderr.txt create mode 100644 Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex.cmake create mode 100644 Tests/RunCMake/CompileFeatures/generate_feature_list.cmake diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 6ec40fb..07cfe12 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4604,8 +4604,28 @@ AddRequiredTargetFeature(cmTarget *target, const std::string& feature, if (!featuresKnown || !*featuresKnown) { - // We know of no features for the compiler at all. - return true; + cmOStringStream e; + if (error) + { + e << "no"; + } + else + { + e << "No"; + } + e << " known features for compiler\n\"" + << this->GetDefinition("CMAKE_" + lang + "_COMPILER_ID") + << "\"\nversion " + << this->GetDefinition("CMAKE_" + lang + "_COMPILER_VERSION") << "."; + if (error) + { + *error = e.str(); + } + else + { + this->IssueMessage(cmake::FATAL_ERROR, e.str()); + } + return false; } std::vector availableFeatures; diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-result.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-stderr.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-stderr.txt new file mode 100644 index 0000000..8b029ac --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at NoSupportedCxxFeatures.cmake:3 \(target_compile_features\): + target_compile_features no known features for compiler + + "[^"]*" + + version *[.0-9]+\. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures.cmake b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures.cmake new file mode 100644 index 0000000..5121948 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures.cmake @@ -0,0 +1,3 @@ + +add_library(no_features empty.cpp) +target_compile_features(no_features PRIVATE cxx_constexpr) diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-result.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-stderr.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-stderr.txt new file mode 100644 index 0000000..d8366b2 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-stderr.txt @@ -0,0 +1,6 @@ +CMake Error in CMakeLists.txt: + No known features for compiler + + "[^"]*" + + version *[.0-9]+\. diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex.cmake b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex.cmake new file mode 100644 index 0000000..490f187 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex.cmake @@ -0,0 +1,3 @@ + +add_library(no_features empty.cpp) +target_compile_features(no_features PRIVATE $<1:cxx_constexpr>) diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index a6aeeee..43d4cb3 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -7,3 +7,14 @@ run_cmake(NotAFeature_OriginDebug) run_cmake(NotAFeature_OriginDebugGenex) run_cmake(NotAFeature_OriginDebugTransitive) run_cmake(NotAFeature_OriginDebug_target_compile_features) + +run_cmake(generate_feature_list) +file(READ + "${RunCMake_BINARY_DIR}/generate_feature_list-build/features.txt" + FEATURES +) + +if (NOT FEATURES) + run_cmake(NoSupportedCxxFeatures) + run_cmake(NoSupportedCxxFeaturesGenex) +endif() diff --git a/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake b/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake new file mode 100644 index 0000000..2bbbd17 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake @@ -0,0 +1,4 @@ + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/features.txt" + "${CMAKE_CXX_COMPILE_FEATURES}" +) -- cgit v0.12 From 3de4c2956539a4251b65b88bff477d5866e98510 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Apr 2014 11:20:13 -0400 Subject: cmake: Print C++ stack trace after INTERNAL_ERROR messages Since an INTERNAL_ERROR is always a bug, it will be useful to have the program stack trace available in the report. --- Source/cmake.cxx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 71ea3f5..7aada4b 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -24,6 +24,7 @@ #if defined(CMAKE_BUILD_WITH_CMAKE) # include "cmGraphVizWriter.h" # include "cmVariableWatch.h" +# include #endif #include @@ -2601,6 +2602,22 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, // Add a terminating blank line. msg << "\n"; +#if defined(CMAKE_BUILD_WITH_CMAKE) + // Add a C++ stack trace to internal errors. + if(t == cmake::INTERNAL_ERROR) + { + std::string stack = cmsys::SystemInformation::GetProgramStack(0,0); + if(!stack.empty()) + { + if(cmHasLiteralPrefix(stack, "WARNING:")) + { + stack = "Note:" + stack.substr(8); + } + msg << stack << "\n"; + } + } +#endif + // Output the message. if(isError) { -- cgit v0.12 From c9d13f841e5ce58ac158e4b5e35b619c0bc7aaab Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 18 Apr 2014 00:01:15 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 6ac332b..ce5f6ba 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 0) -set(CMake_VERSION_PATCH 20140417) +set(CMake_VERSION_PATCH 20140418) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 33774ca2018666138e5d31dde457643357f33815 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 17 Apr 2014 10:50:50 +0200 Subject: QtAutogen: Put generated qrc files in a target-specific dir. --- Modules/AutogenInfo.cmake.in | 1 + Source/cmQtAutoGenerators.cxx | 12 ++++++++++-- Source/cmQtAutoGenerators.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Modules/AutogenInfo.cmake.in b/Modules/AutogenInfo.cmake.in index b6f9791..602b065 100644 --- a/Modules/AutogenInfo.cmake.in +++ b/Modules/AutogenInfo.cmake.in @@ -16,6 +16,7 @@ set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/") set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/") set(AM_QT_VERSION_MAJOR "@_target_qt_version@") set(AM_TARGET_NAME @_moc_target_name@) +set(AM_ORIGIN_TARGET_NAME @_origin_target_name@) set(AM_RELAXED_MODE "@_moc_relaxed_mode@") set(AM_UIC_TARGET_OPTIONS @_uic_target_options@) set(AM_UIC_OPTIONS_FILES @_qt_uic_options_files@) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index ae11462..cc6932d 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -367,6 +367,8 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) makefile->AddDefinition("_moc_target_name", cmLocalGenerator::EscapeForCMake(autogenTargetName).c_str()); + makefile->AddDefinition("_origin_target_name", + cmLocalGenerator::EscapeForCMake(target->GetName()).c_str()); std::string targetDir = getAutogenTargetDir(target); @@ -506,7 +508,9 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) std::string basename = cmsys::SystemTools:: GetFilenameWithoutLastExtension(absFile); - std::string rcc_output_file = makefile->GetCurrentOutputDirectory(); + std::string rcc_output_dir = target->GetSupportDirectory(); + cmSystemTools::MakeDirectory(rcc_output_dir.c_str()); + std::string rcc_output_file = rcc_output_dir; rcc_output_file += "/qrc_" + basename + ".cpp"; makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", rcc_output_file.c_str(), false); @@ -1063,6 +1067,8 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, this->ProjectBinaryDir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR"); this->ProjectSourceDir = makefile->GetSafeDefinition("AM_CMAKE_SOURCE_DIR"); this->TargetName = makefile->GetSafeDefinition("AM_TARGET_NAME"); + this->OriginTargetName + = makefile->GetSafeDefinition("AM_ORIGIN_TARGET_NAME"); { const char *uicOptionsFiles @@ -2057,7 +2063,9 @@ bool cmQtAutoGenerators::GenerateQrc() std::string basename = cmsys::SystemTools:: GetFilenameWithoutLastExtension(*si); - std::string rcc_output_file = this->Builddir + "qrc_" + basename + ".cpp"; + std::string rcc_output_file = this->Builddir + + "CMakeFiles/" + this->OriginTargetName + + ".dir/qrc_" + basename + ".cpp"; int sourceNewerThanQrc = 0; bool success = cmsys::SystemTools::FileTimeCompare(si->c_str(), diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index 8003795..501e13a 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -104,6 +104,7 @@ private: std::string ProjectBinaryDir; std::string ProjectSourceDir; std::string TargetName; + std::string OriginTargetName; std::string CurrentCompileSettingsStr; std::string OldCompileSettingsStr; -- cgit v0.12 From cb59f5da97723f648df78fd16d95697008d5d42b Mon Sep 17 00:00:00 2001 From: Nils Gladitz Date: Fri, 18 Apr 2014 22:45:30 +0200 Subject: CPackWIX: Delay creation of cmWIXPatch until CPack has initialized Logger Without the fix CPack will crash when the cmWIXPatch class tries to issue any diagnostics. --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 19 ++++++++++++++----- Source/CPack/WiX/cmCPackWIXGenerator.h | 3 ++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index a385e40..ec59715 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -33,14 +33,23 @@ cmCPackWIXGenerator::cmCPackWIXGenerator(): HasDesktopShortcuts(false), - Patch(Logger) + Patch(0) { } +cmCPackWIXGenerator::~cmCPackWIXGenerator() +{ + if(this->Patch) + { + delete this->Patch; + } +} + int cmCPackWIXGenerator::InitializeInternal() { componentPackageMethod = ONE_PACKAGE; + this->Patch = new cmWIXPatch(this->Logger); return this->Superclass::InitializeInternal(); } @@ -232,7 +241,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE"); if(patchFilePath) { - this->Patch.LoadFragments(patchFilePath); + this->Patch->LoadFragments(patchFilePath); } return true; @@ -525,7 +534,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() return false; } - return this->Patch.CheckForUnappliedFragments(); + return this->Patch->CheckForUnappliedFragments(); } std::string cmCPackWIXGenerator::GetProgramFilesFolderId() const @@ -857,13 +866,13 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( desktopExecutables, shortcutMap); - this->Patch.ApplyFragment(subDirectoryId, directoryDefinitions); + this->Patch->ApplyFragment(subDirectoryId, directoryDefinitions); directoryDefinitions.EndElement("Directory"); } else { std::string componentId = fileDefinitions.EmitComponentFile( - directoryId, id, fullPath, this->Patch); + directoryId, id, fullPath, *(this->Patch)); featureDefinitions.EmitComponentRef(componentId); diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index 4c9f8c7..8705d40 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -35,6 +35,7 @@ public: cmCPackTypeMacro(cmCPackWIXGenerator, cmCPackGenerator); cmCPackWIXGenerator(); + ~cmCPackWIXGenerator(); protected: virtual int InitializeInternal(); @@ -166,7 +167,7 @@ private: std::string CPackTopLevel; - cmWIXPatch Patch; + cmWIXPatch* Patch; }; #endif -- cgit v0.12 From 1a4eb509468ce8e8766f6e0dab2565c66168e56b Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 19 Apr 2014 00:01:22 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index ce5f6ba..b16676e 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 0) -set(CMake_VERSION_PATCH 20140418) +set(CMake_VERSION_PATCH 20140419) #set(CMake_VERSION_RC 1) -- cgit v0.12 From bae94522008d4b18c2afa171d3498461c8289d3b Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 20 Apr 2014 00:01:06 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index b16676e..21e272b 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 0) -set(CMake_VERSION_PATCH 20140419) +set(CMake_VERSION_PATCH 20140420) #set(CMake_VERSION_RC 1) -- cgit v0.12 From c770d404d23e9530341c791f37697ee5bc70838c Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 21 Apr 2014 00:01:06 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 21e272b..d8b6065 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 0) -set(CMake_VERSION_PATCH 20140420) +set(CMake_VERSION_PATCH 20140421) #set(CMake_VERSION_RC 1) -- cgit v0.12 From e147c5c5558fbb1a6a704173a9a7c71848893ab0 Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Tue, 1 Apr 2014 12:12:52 +0200 Subject: UseSWIG: Detect module name from interface file (#10080) If no SWIG_MODULE_NAME is specified explicitly and the .i file exists, scan it for the module name declaration. --- Modules/UseSWIG.cmake | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 11ca205..b694c40 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -86,7 +86,30 @@ macro(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile) get_source_file_property(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename ${infile} SWIG_MODULE_NAME) if(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND") - get_filename_component(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${infile}" NAME_WE) + + # try to get module name from "%module foo" syntax + if ( EXISTS ${infile} ) + file ( STRINGS ${infile} _MODULE_NAME REGEX "[ ]*%module[ ]*[a-zA-Z0-9_]+.*" ) + endif () + if ( _MODULE_NAME ) + string ( REGEX REPLACE "[ ]*%module[ ]*([a-zA-Z0-9_]+).*" "\\1" _MODULE_NAME "${_MODULE_NAME}" ) + set(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${_MODULE_NAME}") + + else () + # try to get module name from "%module (options=...) foo" syntax + if ( EXISTS ${infile} ) + file ( STRINGS ${infile} _MODULE_NAME REGEX "[ ]*%module[ ]*\\(.*\\)[ ]*[a-zA-Z0-9_]+.*" ) + endif () + if ( _MODULE_NAME ) + string ( REGEX REPLACE "[ ]*%module[ ]*\\(.*\\)[ ]*([a-zA-Z0-9_]+).*" "\\1" _MODULE_NAME "${_MODULE_NAME}" ) + set(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${_MODULE_NAME}") + + else () + # fallback to file basename + get_filename_component(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename ${infile} NAME_WE) + endif () + endif () + endif() foreach(it ${SWIG_${language}_EXTRA_FILE_EXTENSION}) set(${outfiles} ${${outfiles}} -- cgit v0.12 From 2c96192f4c09bc9784ac7c483118a818cbf2701e Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Thu, 3 Apr 2014 08:28:10 +0200 Subject: UseSWIG: Revise and format documentation Also add some documentation of SWIG_MODULE_NAME. --- Modules/UseSWIG.cmake | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index b694c40..060b44c 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -2,9 +2,7 @@ # UseSWIG # ------- # -# SWIG module for CMake -# -# Defines the following macros: +# Defines the following macros for use with SWIG: # # :: # @@ -13,20 +11,38 @@ # SWIG_LINK_LIBRARIES(name [ libraries ]) # - Link libraries to swig module # -# All other macros are for internal use only. To get the actual name of -# the swig module, use: ${SWIG_MODULE_${name}_REAL_NAME}. Set Source -# files properties such as CPLUSPLUS and SWIG_FLAGS to specify special -# behavior of SWIG. Also global CMAKE_SWIG_FLAGS can be used to add -# special flags to all swig calls. Another special variable is -# CMAKE_SWIG_OUTDIR, it allows one to specify where to write all the -# swig generated module (swig -outdir option) The name-specific variable -# SWIG_MODULE__EXTRA_DEPS may be used to specify extra -# dependencies for the generated modules. If the source file generated -# by swig need some special flag you can use:: +# Source files properties on module files can be set before the invocation +# of the SWIG_ADD_MODULE macro to specify special behavior of SWIG. # -# set_source_files_properties( ${swig_generated_file_fullname} -# PROPERTIES COMPILE_FLAGS "-bla") - +# The source file property CPLUSPLUS calls SWIG in c++ mode, e.g.:: +# +# set_property(SOURCE mymod.i PROPERTY CPLUSPLUS ON) +# swig_add_module(mymod python mymod.i) +# +# The source file property SWIG_FLAGS adds custom flags to the SWIG executable. +# +# The source-file property SWIG_MODULE_NAME have to be provided to specify the actual +# import name of the module in the target language if it cannot be scanned automatically +# from source or different from the module file basename.:: +# +# set_property(SOURCE mymod.i PROPERTY SWIG_MODULE_NAME mymod_realname) +# +# To get the name of the swig module target library, use: ${SWIG_MODULE_${name}_REAL_NAME}. +# +# Also some variables can be set to specify special behavior of SWIG. +# +# CMAKE_SWIG_FLAGS can be used to add special flags to all swig calls. +# +# Another special variable is CMAKE_SWIG_OUTDIR, it allows one to specify +# where to write all the swig generated module (swig -outdir option) +# +# The name-specific variable SWIG_MODULE__EXTRA_DEPS may be used to specify extra +# dependencies for the generated modules. +# +# If the source file generated by swig need some special flag you can use:: +# +# set_source_files_properties( ${swig_generated_file_fullname} +# PROPERTIES COMPILE_FLAGS "-bla") #============================================================================= # Copyright 2004-2009 Kitware, Inc. -- cgit v0.12 From d5a6069a12675d1fbea26aad8c37d53fcd5461e4 Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Tue, 15 Apr 2014 16:54:24 +0200 Subject: FindGTK2: Add GTK2_(FONTCONFIG|X11)_INCLUDE_DIR optional includes --- Modules/FindGTK2.cmake | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index fecf929..1bdad16 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -682,11 +682,15 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) _GTK2_FIND_LIBRARY (PANGOFT2 pangoft2 false true) _GTK2_ADD_TARGET (PANGOFT2 GTK2_DEPENDS pango gobject glib - OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}) + OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} + ${GTK2_FONTCONFIG_INCLUDE_DIR} + ${GTK2_X11_INCLUDE_DIR}) _GTK2_FIND_LIBRARY (PANGOXFT pangoxft false true) _GTK2_ADD_TARGET (PANGOXFT GTK2_DEPENDS pangoft2 pango gobject glib - OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}) + OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} + ${GTK2_FONTCONFIG_INCLUDE_DIR} + ${GTK2_X11_INCLUDE_DIR}) _GTK2_FIND_INCLUDE_DIR(GDK gdk/gdk.h) _GTK2_FIND_INCLUDE_DIR(GDKCONFIG gdkconfig.h) @@ -717,8 +721,9 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) _GTK2_ADD_TARGET (GTK GTK2_DEPENDS gdk atk pangoft2 pango gdk_pixbuf gthread gobject glib GTK2_OPTIONAL_DEPENDS gio pangocairo cairo) - # Left for compatibility with previous versions. It doesn't seem to be required + # Left for compatibility with previous versions. _GTK2_FIND_INCLUDE_DIR(FONTCONFIG fontconfig/fontconfig.h) + _GTK2_FIND_INCLUDE_DIR(X11 X11/Xlib.h) elseif(_GTK2_component STREQUAL "gtkmm") @@ -745,29 +750,36 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) _GTK2_FIND_INCLUDE_DIR(CAIROMMCONFIG cairommconfig.h) _GTK2_FIND_LIBRARY (CAIROMM cairomm true true) _GTK2_ADD_TARGET (CAIROMM GTK2_DEPENDS cairo sigc++ - OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}) + OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} + ${GTK2_FONTCONFIG_INCLUDE_DIR} + ${GTK2_X11_INCLUDE_DIR}) _GTK2_FIND_INCLUDE_DIR(PANGOMM pangomm.h) _GTK2_FIND_INCLUDE_DIR(PANGOMMCONFIG pangommconfig.h) _GTK2_FIND_LIBRARY (PANGOMM pangomm true true) _GTK2_ADD_TARGET (PANGOMM GTK2_DEPENDS glibmm sigc++ pango gobject glib GTK2_OPTIONAL_DEPENDS cairomm pangocairo cairo - OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}) - + OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} + ${GTK2_FONTCONFIG_INCLUDE_DIR} + ${GTK2_X11_INCLUDE_DIR}) _GTK2_FIND_INCLUDE_DIR(GDKMM gdkmm.h) _GTK2_FIND_INCLUDE_DIR(GDKMMCONFIG gdkmmconfig.h) _GTK2_FIND_LIBRARY (GDKMM gdkmm true true) _GTK2_ADD_TARGET (GDKMM GTK2_DEPENDS pangomm gtk glibmm sigc++ gdk atk pangoft2 gdk_pixbuf pango gobject glib GTK2_OPTIONAL_DEPENDS giomm cairomm gio pangocairo cairo - OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}) + OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} + ${GTK2_FONTCONFIG_INCLUDE_DIR} + ${GTK2_X11_INCLUDE_DIR}) _GTK2_FIND_INCLUDE_DIR(GTKMM gtkmm.h) _GTK2_FIND_INCLUDE_DIR(GTKMMCONFIG gtkmmconfig.h) _GTK2_FIND_LIBRARY (GTKMM gtkmm true true) _GTK2_ADD_TARGET (GTKMM GTK2_DEPENDS atkmm gdkmm pangomm gtk glibmm sigc++ gdk atk pangoft2 gdk_pixbuf pango gthread gobject glib GTK2_OPTIONAL_DEPENDS giomm cairomm gio pangocairo cairo - OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}) + OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} + ${GTK2_FONTCONFIG_INCLUDE_DIR} + ${GTK2_X11_INCLUDE_DIR}) elseif(_GTK2_component STREQUAL "glade") @@ -775,7 +787,9 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) _GTK2_FIND_LIBRARY (GLADE glade false true) _GTK2_ADD_TARGET (GLADE GTK2_DEPENDS gtk gdk atk gio pangoft2 gdk_pixbuf pango gobject glib GTK2_OPTIONAL_DEPENDS pangocairo cairo - OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}) + OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} + ${GTK2_FONTCONFIG_INCLUDE_DIR} + ${GTK2_X11_INCLUDE_DIR}) elseif(_GTK2_component STREQUAL "glademm") @@ -784,7 +798,9 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) _GTK2_FIND_LIBRARY (GLADEMM glademm true true) _GTK2_ADD_TARGET (GLADEMM GTK2_DEPENDS gtkmm glade atkmm gdkmm giomm pangomm glibmm sigc++ gtk gdk atk pangoft2 gdk_pixbuf pango gthread gobject glib GTK2_OPTIONAL_DEPENDS giomm cairomm gio pangocairo cairo - OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}) + OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} + ${GTK2_FONTCONFIG_INCLUDE_DIR} + ${GTK2_X11_INCLUDE_DIR}) else() message(FATAL_ERROR "Unknown GTK2 component ${_component}") -- cgit v0.12 From 2475acc4974ff9c48a23ba62013714f25743a21b Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 22 Apr 2014 00:01:08 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d8b6065..45c6f6f 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 0) -set(CMake_VERSION_PATCH 20140421) +set(CMake_VERSION_PATCH 20140422) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 817db64c2c3b27098e0fd45825e29e01d784435a Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Tue, 22 Apr 2014 21:57:16 +0200 Subject: fix compile error on AIX/gcc-2.9 because of unknown std::stringstream --- Source/cmExtraCodeLiteGenerator.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 946d9d2..cc42bca 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -454,7 +454,7 @@ cmExtraCodeLiteGenerator::GetBuildCommand(const cmMakefile* mf) const else if ( generator == "MinGW Makefiles" || generator == "Unix Makefiles" ) { - std::stringstream ss; + cmOStringStream ss; ss << make << " -j " << this->CpuCount; buildCommand = ss.str(); } @@ -482,7 +482,7 @@ cmExtraCodeLiteGenerator::GetSingleFileBuildCommand std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR"); if ( generator == "Unix Makefiles" || generator == "MinGW Makefiles" ) { - std::stringstream ss; + cmOStringStream ss; ss << make << " -f$(ProjectPath)/Makefile $(CurrentFileName).cpp.o"; buildCommand = ss.str(); } -- cgit v0.12 From 608532fa2b0b9ac289eeb2052e0a9dfebba4d90f Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 23 Apr 2014 00:01:11 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 45c6f6f..ba34535 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 0) -set(CMake_VERSION_PATCH 20140422) +set(CMake_VERSION_PATCH 20140423) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 55f5ea7b0eae53ba04315397f2874411a94943e5 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Wed, 23 Apr 2014 22:49:38 +0200 Subject: FindGTK2: search for Fontconfig and X11 before using them --- Modules/FindGTK2.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index 1bdad16..15bcab8 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -643,6 +643,10 @@ endif() foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) if(_GTK2_component STREQUAL "gtk") + # Left for compatibility with previous versions. + _GTK2_FIND_INCLUDE_DIR(FONTCONFIG fontconfig/fontconfig.h) + _GTK2_FIND_INCLUDE_DIR(X11 X11/Xlib.h) + _GTK2_FIND_INCLUDE_DIR(GLIB glib.h) _GTK2_FIND_INCLUDE_DIR(GLIBCONFIG glibconfig.h) _GTK2_FIND_LIBRARY (GLIB glib false true) @@ -721,10 +725,6 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) _GTK2_ADD_TARGET (GTK GTK2_DEPENDS gdk atk pangoft2 pango gdk_pixbuf gthread gobject glib GTK2_OPTIONAL_DEPENDS gio pangocairo cairo) - # Left for compatibility with previous versions. - _GTK2_FIND_INCLUDE_DIR(FONTCONFIG fontconfig/fontconfig.h) - _GTK2_FIND_INCLUDE_DIR(X11 X11/Xlib.h) - elseif(_GTK2_component STREQUAL "gtkmm") _GTK2_FIND_INCLUDE_DIR(SIGC++ sigc++/sigc++.h) -- cgit v0.12 From 533d10e48c530fe10bc199fa00596c2c87d24bf8 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 24 Apr 2014 00:01:10 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index ba34535..69af0a0 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 0) -set(CMake_VERSION_PATCH 20140423) +set(CMake_VERSION_PATCH 20140424) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 041dfea55b689fc1e0376c6f68c2e65b38a0507d Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 25 Apr 2014 00:01:10 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 69af0a0..53f81ed 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 0) -set(CMake_VERSION_PATCH 20140424) +set(CMake_VERSION_PATCH 20140425) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 415b75ff378b1498d86b5c84616c65e5f68bfb66 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 26 Apr 2014 00:01:06 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 53f81ed..0b521ac 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 0) -set(CMake_VERSION_PATCH 20140425) +set(CMake_VERSION_PATCH 20140426) #set(CMake_VERSION_RC 1) -- cgit v0.12 From c8b76d58bd27c929f70ae999d14bb414cf8c4c43 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 27 Apr 2014 00:01:09 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 0b521ac..98f854e 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 0) -set(CMake_VERSION_PATCH 20140426) +set(CMake_VERSION_PATCH 20140427) #set(CMake_VERSION_RC 1) -- cgit v0.12 From bb1c41a085c6eb9296bf701ea7633f715a06f6e1 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 28 Apr 2014 00:01:10 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 98f854e..f6f3a70 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 0) -set(CMake_VERSION_PATCH 20140427) +set(CMake_VERSION_PATCH 20140428) #set(CMake_VERSION_RC 1) -- cgit v0.12 From c51d07d4397ceed55c534a036ef81df44b741ff6 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 29 Apr 2014 00:01:08 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f6f3a70..1e0d885 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 0) -set(CMake_VERSION_PATCH 20140428) +set(CMake_VERSION_PATCH 20140429) #set(CMake_VERSION_RC 1) -- cgit v0.12