diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2019-04-25 16:48:43 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2019-05-02 09:01:10 (GMT) |
commit | 6e5ccabe9ba1b92bb5244683c4315964b01e0df7 (patch) | |
tree | b1c4c1fb7c20689d8c3865b72800b1e868a1e6fd | |
parent | 1f4c9aa7d2c93f2377a6d1cb4cf2c1137466e927 (diff) | |
download | CMake-6e5ccabe9ba1b92bb5244683c4315964b01e0df7.zip CMake-6e5ccabe9ba1b92bb5244683c4315964b01e0df7.tar.gz CMake-6e5ccabe9ba1b92bb5244683c4315964b01e0df7.tar.bz2 |
Genex: Update $<TARGET_FILE_BASE_NAME:...>: take care of POSTFIX
This capability complement MR !3190 and !3207
and is also needed to solve issue #18771.
5 files changed, 100 insertions, 8 deletions
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 3dc3221..ce62893 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -404,16 +404,25 @@ Target-Dependent Queries :prop_tgt:`LIBRARY_OUTPUT_NAME_<CONFIG>` and :prop_tgt:`RUNTIME_OUTPUT_NAME_<CONFIG>`. + The :prop_tgt:`<CONFIG>_POSTFIX` and :prop_tgt:`DEBUG_POSTFIX` target + properties can also be considered. + Note that ``tgt`` is not added as a dependency of the target this expression is evaluated on. ``$<TARGET_FILE_PREFIX:tgt>`` Prefix of main file where ``tgt`` is the name of a target. + See also the :prop_tgt:`PREFIX` target property. + Note that ``tgt`` is not added as a dependency of the target this expression is evaluated on. ``$<TARGET_FILE_SUFFIX:tgt>`` Suffix of main file where ``tgt`` is the name of a target. + The suffix corresponds to the file extension (such as ".so" or ".exe"). + + See also the :prop_tgt:`SUFFIX` target property. + Note that ``tgt`` is not added as a dependency of the target this expression is evaluated on. ``$<TARGET_FILE_NAME:tgt>`` @@ -435,16 +444,27 @@ Target-Dependent Queries :prop_tgt:`ARCHIVE_OUTPUT_NAME_<CONFIG>` and :prop_tgt:`LIBRARY_OUTPUT_NAME_<CONFIG>`. + The :prop_tgt:`<CONFIG>_POSTFIX` and :prop_tgt:`DEBUG_POSTFIX` target + properties can also be considered. + Note that ``tgt`` is not added as a dependency of the target this expression is evaluated on. ``$<TARGET_LINKER_FILE_PREFIX:tgt>`` Prefix of file used to link where ``tgt`` is the name of a target. + See also the :prop_tgt:`PREFIX` and :prop_tgt:`IMPORT_PREFIX` target + properties. + Note that ``tgt`` is not added as a dependency of the target this expression is evaluated on. ``$<TARGET_LINKER_FILE_SUFFIX:tgt>`` Suffix of file used to link where ``tgt`` is the name of a target. + The suffix corresponds to the file extension (such as ".so" or ".lib"). + + See also the :prop_tgt:`SUFFIX` and :prop_tgt:`IMPORT_SUFFIX` target + properties. + Note that ``tgt`` is not added as a dependency of the target this expression is evaluated on. ``$<TARGET_LINKER_FILE_NAME:tgt>`` @@ -475,6 +495,9 @@ Target-Dependent Queries See also the :prop_tgt:`PDB_NAME` target property and its configuration specific variant :prop_tgt:`PDB_NAME_<CONFIG>`. + The :prop_tgt:`<CONFIG>_POSTFIX` and :prop_tgt:`DEBUG_POSTFIX` target + properties can also be considered. + Note that ``tgt`` is not added as a dependency of the target this expression is evaluated on. ``$<TARGET_PDB_FILE_NAME:tgt>`` diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 8803830..a207b5f 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -2202,7 +2202,8 @@ struct TargetOutputNameArtifactResultGetter<ArtifactNameTag> const GeneratorExpressionContent* /*unused*/) { return target->GetOutputName(context->Config, - cmStateEnums::RuntimeBinaryArtifact); + cmStateEnums::RuntimeBinaryArtifact) + + target->GetFilePostfix(context->Config); } }; @@ -2224,7 +2225,8 @@ struct TargetOutputNameArtifactResultGetter<ArtifactLinkerTag> target->HasImportLibrary(context->Config) ? cmStateEnums::ImportLibraryArtifact : cmStateEnums::RuntimeBinaryArtifact; - return target->GetOutputName(context->Config, artifact); + return target->GetOutputName(context->Config, artifact) + + target->GetFilePostfix(context->Config); } }; @@ -2264,7 +2266,8 @@ struct TargetOutputNameArtifactResultGetter<ArtifactPdbTag> return std::string(); } - return target->GetPDBOutputName(context->Config); + return target->GetPDBOutputName(context->Config) + + target->GetFilePostfix(context->Config); } }; diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 477b593..a491e99 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -41,8 +41,8 @@ run_cmake(TARGET_FILE_SUFFIX) run_cmake(TARGET_FILE_SUFFIX-imported-target) run_cmake(TARGET_FILE_SUFFIX-non-valid-target) run_cmake(TARGET_LINKER_FILE_SUFFIX-non-valid-target) -run_cmake(TARGET_FILE_BASE_NAME) -run_cmake(TARGET_FILE_BASE_NAME-imported-target) +run_cmake_with_options(TARGET_FILE_BASE_NAME -DCMAKE_BUILD_TYPE:STRING=Debug) +run_cmake_with_options(TARGET_FILE_BASE_NAME-imported-target -DCMAKE_BUILD_TYPE:STRING=Debug) run_cmake(TARGET_FILE_BASE_NAME-non-valid-target) run_cmake(TARGET_LINKER_FILE_BASE_NAME-non-valid-target) run_cmake(TARGET_PROPERTY-LOCATION) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target.cmake index aa54b31..40f7c66 100644 --- a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target.cmake +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target.cmake @@ -46,17 +46,14 @@ add_executable (exec3 IMPORTED) set_property (TARGET exec3 PROPERTY RUNTIME_OUTPUT_NAME exec3_runtime) set_property (TARGET exec3 PROPERTY LIBRARY_OUTPUT_NAME exec3_library) set_property (TARGET exec3 PROPERTY ARCHIVE_OUTPUT_NAME exec3_archive) -set_property (TARGET exec3 PROPERTY PDB_NAME exec3_pdb) add_library (shared3 SHARED IMPORTED) set_property (TARGET shared3 PROPERTY RUNTIME_OUTPUT_NAME shared3_runtime) set_property (TARGET shared3 PROPERTY LIBRARY_OUTPUT_NAME shared3_library) set_property (TARGET shared3 PROPERTY ARCHIVE_OUTPUT_NAME shared3_archive) -set_property (TARGET shared3 PROPERTY PDB_NAME shared3_pdb) add_library (static3 STATIC IMPORTED) set_property (TARGET static3 PROPERTY RUNTIME_OUTPUT_NAME static3_runtime) set_property (TARGET static3 PROPERTY LIBRARY_OUTPUT_NAME static3_library) set_property (TARGET static3 PROPERTY ARCHIVE_OUTPUT_NAME static3_archive) -set_property (TARGET static3 PROPERTY PDB_NAME static3_pdb) string (APPEND GENERATE_CONTENT [[ @@ -73,7 +70,37 @@ get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(_isMultiConfig) list(GET CMAKE_CONFIGURATION_TYPES 0 FIRST_CONFIG) set(GENERATE_CONDITION CONDITION $<CONFIG:${FIRST_CONFIG}>) +else() + set (FIRST_CONFIG ${CMAKE_BUILD_TYPE}) endif() +string (TOUPPER "${FIRST_CONFIG}" FIRST_CONFIG) + + +add_executable (exec4 IMPORTED) +set_property (TARGET exec4 PROPERTY RUNTIME_OUTPUT_NAME exec4_runtime) +set_property (TARGET exec4 PROPERTY LIBRARY_OUTPUT_NAME exec4_library) +set_property (TARGET exec4 PROPERTY ARCHIVE_OUTPUT_NAME exec4_archive) +set_property (TARGET exec4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix) +add_library (shared4 SHARED IMPORTED) +set_property (TARGET shared4 PROPERTY RUNTIME_OUTPUT_NAME shared4_runtime) +set_property (TARGET shared4 PROPERTY LIBRARY_OUTPUT_NAME shared4_library) +set_property (TARGET shared4 PROPERTY ARCHIVE_OUTPUT_NAME shared4_archive) +set_property (TARGET shared4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix) +add_library (static4 STATIC IMPORTED) +set_property (TARGET static4 PROPERTY RUNTIME_OUTPUT_NAME static4_runtime) +set_property (TARGET static4 PROPERTY LIBRARY_OUTPUT_NAME static4_library) +set_property (TARGET static4 PROPERTY ARCHIVE_OUTPUT_NAME static4_archive) +set_property (TARGET static4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix) + +string (APPEND GENERATE_CONTENT [[ + +check_value ("TARGET_FILE_BASE_NAME executable all properties + postfix" "$<TARGET_FILE_BASE_NAME:exec4>" "exec4_runtime_postfix") +check_value ("TARGET_FILE_BASE_NAME shared all properties + postfix" "$<TARGET_FILE_BASE_NAME:shared4>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared4_runtime,shared4_library>_postfix") +check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker all properties + postfix" "$<TARGET_LINKER_FILE_BASE_NAME:shared4>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared4_archive,shared4_library>_postfix") +check_value ("TARGET_FILE_BASE_NAME static all properties + postfix" "$<TARGET_FILE_BASE_NAME:static4>" "static4_archive_postfix") +check_value ("TARGET_LINKER_FILE_BASE_NAME static linker all properties + postfix" "$<TARGET_LINKER_FILE_BASE_NAME:static4>" "static4_archive_postfix") +]]) + file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/TARGET_FILE_BASE_NAME-generated.cmake" CONTENT "${GENERATE_CONTENT}" ${GENERATE_CONDITION}) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME.cmake index 5ea53a0..f88d710 100644 --- a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME.cmake +++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME.cmake @@ -90,7 +90,46 @@ get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(_isMultiConfig) list(GET CMAKE_CONFIGURATION_TYPES 0 FIRST_CONFIG) set(GENERATE_CONDITION CONDITION $<CONFIG:${FIRST_CONFIG}>) +else() + set (FIRST_CONFIG ${CMAKE_BUILD_TYPE}) endif() +string (TOUPPER "${FIRST_CONFIG}" FIRST_CONFIG) + + +add_executable (exec4 empty.c) +set_property (TARGET exec4 PROPERTY RUNTIME_OUTPUT_NAME exec4_runtime) +set_property (TARGET exec4 PROPERTY LIBRARY_OUTPUT_NAME exec4_library) +set_property (TARGET exec4 PROPERTY ARCHIVE_OUTPUT_NAME exec4_archive) +set_property (TARGET exec4 PROPERTY PDB_NAME exec4_pdb) +set_property (TARGET exec4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix) +add_library (shared4 SHARED empty.c) +set_property (TARGET shared4 PROPERTY RUNTIME_OUTPUT_NAME shared4_runtime) +set_property (TARGET shared4 PROPERTY LIBRARY_OUTPUT_NAME shared4_library) +set_property (TARGET shared4 PROPERTY ARCHIVE_OUTPUT_NAME shared4_archive) +set_property (TARGET shared4 PROPERTY PDB_NAME shared4_pdb) +set_property (TARGET shared4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix) +add_library (static4 STATIC empty.c) +set_property (TARGET static4 PROPERTY RUNTIME_OUTPUT_NAME static4_runtime) +set_property (TARGET static4 PROPERTY LIBRARY_OUTPUT_NAME static4_library) +set_property (TARGET static4 PROPERTY ARCHIVE_OUTPUT_NAME static4_archive) +set_property (TARGET static4 PROPERTY PDB_NAME static4_pdb) +set_property (TARGET static4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix) + +string (APPEND GENERATE_CONTENT [[ + +check_value ("TARGET_FILE_BASE_NAME executable all properties + postfix" "$<TARGET_FILE_BASE_NAME:exec4>" "exec4_runtime_postfix") +check_value ("TARGET_FILE_BASE_NAME shared all properties + postfix" "$<TARGET_FILE_BASE_NAME:shared4>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared4_runtime,shared4_library>_postfix") +check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker all properties + postfix" "$<TARGET_LINKER_FILE_BASE_NAME:shared4>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared4_archive,shared4_library>_postfix") +check_value ("TARGET_FILE_BASE_NAME static all properties + postfix" "$<TARGET_FILE_BASE_NAME:static4>" "static4_archive_postfix") +check_value ("TARGET_LINKER_FILE_BASE_NAME static linker all properties + postfix" "$<TARGET_LINKER_FILE_BASE_NAME:static4>" "static4_archive_postfix") +]]) +if (CMAKE_C_LINKER_SUPPORTS_PDB) + string (APPEND GENERATE_CONTENT [[ +check_value ("TARGET_PDB_FILE_BASE_NAME executable PDB all properties + postfix" "$<TARGET_PDB_FILE_BASE_NAME:exec4>" "exec4_pdb_postfix") +check_value ("TARGET_PDB_FILE_BASE_NAME shared PDB all properties + postfix" "$<TARGET_PDB_FILE_BASE_NAME:shared4>" "shared4_pdb_postfix") +]]) +endif() + file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/TARGET_FILE_BASE_NAME-generated.cmake" CONTENT "${GENERATE_CONTENT}" ${GENERATE_CONDITION}) |