New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set cmake compile options based on language #7600
Merged
Merged
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0c4a190
Set cmake compile options based on language
danimtb 5e2d32c
changes affecting other generators
danimtb 6f2e78f
fixes
danimtb dde5092
fix cmake code and tests
danimtb 6b8844f
fix tests
danimtb 3f4ccc9
fix cmake_find_package generator
danimtb 2e2f51b
use ENABLED_LANGUAGES
danimtb de6e26f
use enabled_languages
danimtb f806ec8
revert some changes
danimtb a2beaaf
Merge branch 'develop' into feature/7499
danimtb aed0bef
test
danimtb dcbcbf6
revert some other changes
danimtb e4bf14a
test find_package without components
danimtb 5ac9416
add values to targets and test
danimtb File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
) | ||
set({name}_COMPILE_DEFINITIONS{build_type_suffix} {deps.compile_definitions}) | ||
set({name}_COMPILE_OPTIONS{build_type_suffix}_LIST "{deps.cxxflags_list}" "{deps.cflags_list}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here I kept the variable (although it is not used in targets) to avoid breaking |
||
set({name}_COMPILE_OPTIONS_C{build_type_suffix} "{deps.cflags_list}") | ||
set({name}_COMPILE_OPTIONS_CXX{build_type_suffix} "{deps.cxxflags_list}") | ||
set({name}_LIBRARIES_TARGETS{build_type_suffix} "") # Will be filled later, if CMake 3 | ||
set({name}_LIBRARIES{build_type_suffix} "") # Will be filled later | ||
set({name}_LIBS{build_type_suffix} "") # Same as {name}_LIBRARIES | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,10 +64,18 @@ class CMakeFindPackageMultiGenerator(CMakeFindPackageGenerator): | |
$<$<CONFIG:Debug>:${{{name}_COMPILE_DEFINITIONS_DEBUG}}>) | ||
set_property(TARGET {name}::{name} | ||
PROPERTY INTERFACE_COMPILE_OPTIONS | ||
$<$<CONFIG:Release>:${{{name}_COMPILE_OPTIONS_RELEASE_LIST}}> | ||
$<$<CONFIG:RelWithDebInfo>:${{{name}_COMPILE_OPTIONS_RELWITHDEBINFO_LIST}}> | ||
$<$<CONFIG:MinSizeRel>:${{{name}_COMPILE_OPTIONS_MINSIZEREL_LIST}}> | ||
$<$<CONFIG:Debug>:${{{name}_COMPILE_OPTIONS_DEBUG_LIST}}>) | ||
$<$<CONFIG:Release>: | ||
$<$<COMPILE_LANGUAGE:C>:${{{name}_COMPILE_OPTIONS_C_RELEASE}}> | ||
$<$<COMPILE_LANGUAGE:CXX>:${{{name}_COMPILE_OPTIONS_CXX_RELEASE}}>> | ||
$<$<CONFIG:RelWithDebInfo>: | ||
$<$<COMPILE_LANGUAGE:C>:${{{name}_COMPILE_OPTIONS_C_RELWITHDEBINFO}}> | ||
$<$<COMPILE_LANGUAGE:CXX>:${{{name}_COMPILE_OPTIONS_CXX_RELWITHDEBINFO}}>> | ||
$<$<CONFIG:MinSizeRel>: | ||
$<$<COMPILE_LANGUAGE:C>:${{{name}_COMPILE_OPTIONS_C_MINSIZEREL}}> | ||
$<$<COMPILE_LANGUAGE:CXX>:${{{name}_COMPILE_OPTIONS_CXX_MINSIZEREL}}>> | ||
$<$<CONFIG:Debug>: | ||
$<$<COMPILE_LANGUAGE:C>:${{{name}_COMPILE_OPTIONS_C_DEBUG}}> | ||
$<$<COMPILE_LANGUAGE:CXX>:${{{name}_COMPILE_OPTIONS_CXX_DEBUG}}>>) | ||
""" | ||
|
||
# https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/BasicConfigVersion-SameMajorVersion.cmake.in | ||
|
@@ -119,7 +127,8 @@ class CMakeFindPackageMultiGenerator(CMakeFindPackageGenerator): | |
set({{ pkg_name }}_{{ comp_name }}_RES_DIRS_{{ build_type }} {{ comp.res_paths }}) | ||
set({{ pkg_name }}_{{ comp_name }}_DEFINITIONS_{{ build_type }} {{ comp.defines }}) | ||
set({{ pkg_name }}_{{ comp_name }}_COMPILE_DEFINITIONS_{{ build_type }} {{ comp.compile_definitions }}) | ||
set({{ pkg_name }}_{{ comp_name }}_COMPILE_OPTIONS_LIST_{{ build_type }} "{{ comp.cxxflags_list }}" "{{ comp.cflags_list }}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed variable in the components flavour |
||
set({{ pkg_name }}_{{ comp_name }}_COMPILE_OPTIONS_C_{{ build_type }} "{{ comp.cflags_list }}") | ||
set({{ pkg_name }}_{{ comp_name }}_COMPILE_OPTIONS_CXX_{{ build_type }} "{{ comp.cxxflags_list }}") | ||
set({{ pkg_name }}_{{ comp_name }}_LIBS_{{ build_type }} {{ comp.libs }}) | ||
set({{ pkg_name }}_{{ comp_name }}_SYSTEM_LIBS_{{ build_type }} {{ comp.system_libs }}) | ||
set({{ pkg_name }}_{{ comp_name }}_FRAMEWORK_DIRS_{{ build_type }} {{ comp.framework_paths }}) | ||
|
@@ -239,10 +248,18 @@ class CMakeFindPackageMultiGenerator(CMakeFindPackageGenerator): | |
$<$<CONFIG:MinSizeRel>:{{ '${'+pkg_name+'_'+comp_name+'_COMPILE_DEFINITIONS_MINSIZEREL}' }}> | ||
$<$<CONFIG:Debug>:{{ '${'+pkg_name+'_'+comp_name+'_COMPILE_DEFINITIONS_DEBUG}' }}>) | ||
set_property(TARGET {{ pkg_name }}::{{ comp_name }} PROPERTY INTERFACE_COMPILE_OPTIONS | ||
$<$<CONFIG:Release>:{{ '${'+pkg_name+'_'+comp_name+'_COMPILE_OPTIONS_LIST_RELEASE}' }}> | ||
$<$<CONFIG:RelWithDebInfo>:{{ '${'+pkg_name+'_'+comp_name+'_COMPILE_OPTIONS_LIST_RELWITHDEBINFO}' }}> | ||
$<$<CONFIG:MinSizeRel>:{{ '${'+pkg_name+'_'+comp_name+'_COMPILE_OPTIONS_LIST_MINSIZEREL}' }}> | ||
$<$<CONFIG:Debug>:{{ '${'+pkg_name+'_'+comp_name+'_COMPILE_OPTIONS_LIST_DEBUG}' }}>) | ||
$<$<CONFIG:Release>: | ||
$<$<COMPILE_LANGUAGE:C>:{{ '${'+pkg_name+'_'+comp_name+'_COMPILE_OPTIONS_C_RELEASE}' }}> | ||
$<$<COMPILE_LANGUAGE:CXX>:{{ '${'+pkg_name+'_'+comp_name+'_COMPILE_OPTIONS_CXX_RELEASE}' }}>> | ||
$<$<CONFIG:RelWithDebInfo>: | ||
$<$<COMPILE_LANGUAGE:C>:{{ '${'+pkg_name+'_'+comp_name+'_COMPILE_OPTIONS_C_RELWITHDEBINFO}' }}> | ||
$<$<COMPILE_LANGUAGE:CXX>:{{ '${'+pkg_name+'_'+comp_name+'_COMPILE_OPTIONS_CXX_RELWITHDEBINFO}' }}>> | ||
$<$<CONFIG:MinSizeRel>: | ||
$<$<COMPILE_LANGUAGE:C>:{{ '${'+pkg_name+'_'+comp_name+'_COMPILE_OPTIONS_C_MINSIZEREL}' }}> | ||
$<$<COMPILE_LANGUAGE:CXX>:{{ '${'+pkg_name+'_'+comp_name+'_COMPILE_OPTIONS_CXX_MINSIZEREL}' }}>> | ||
$<$<CONFIG:Debug>: | ||
$<$<COMPILE_LANGUAGE:C>:{{ '${'+pkg_name+'_'+comp_name+'_COMPILE_OPTIONS_C_DEBUG}' }}> | ||
$<$<COMPILE_LANGUAGE:CXX>:{{ '${'+pkg_name+'_'+comp_name+'_COMPILE_OPTIONS_CXX_DEBUG}' }}>>) | ||
set({{ pkg_name }}_{{ comp_name }}_TARGET_PROPERTIES TRUE) | ||
|
||
{%- endfor %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removing this variable when using components, as this feature is marked as experimental