Skip to content

Commit

Permalink
[CMAKE] Fix configuration issues with mq_link_libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
Takishima committed Sep 29, 2022
1 parent c1b9d23 commit ebc31ae
Showing 3 changed files with 40 additions and 17 deletions.
35 changes: 35 additions & 0 deletions cmake/commands/is_language_enabled.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# ==============================================================================
#
# Copyright 2022 <Huawei Technologies Co., Ltd>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ==============================================================================

# Check if a language has been enabled without attempting to enable it
#
# is_language_enabled(<lang> <resultvar>)
#
# If the language <lang> has already been enabled, <resultvar> is set to TRUE. Otherwise it is set to FALSE.
function(is_language_enabled _lang _var)
get_property(_supported_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
if(NOT _lang IN_LIST _supported_languages)
set(${_var}
FALSE
PARENT_SCOPE)
else()
set(${_var}
TRUE
PARENT_SCOPE)
endif()
endfunction()
4 changes: 4 additions & 0 deletions cmake/commands/mq_link_libraries.cmake
Original file line number Diff line number Diff line change
@@ -18,6 +18,10 @@

# lint_cmake: -whitespace/indent

include(is_language_enabled)

# ==============================================================================

# ~~~
# Add one or more link libraries to some of the language specific targets (see setup_languages())
#
18 changes: 1 addition & 17 deletions cmake/macros.cmake
Original file line number Diff line number Diff line change
@@ -28,23 +28,7 @@ include(CheckLinkerFlag)

# ==============================================================================

# Check if a language has been enabled without attempting to enable it
#
# is_language_enabled(<lang> <resultvar>)
#
# If the language <lang> has already been enabled, <resultvar> is set to TRUE. Otherwise it is set to FALSE.
function(is_language_enabled _lang _var)
get_property(_supported_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
if(NOT _lang IN_LIST _supported_languages)
set(${_var}
FALSE
PARENT_SCOPE)
else()
set(${_var}
TRUE
PARENT_SCOPE)
endif()
endfunction()
include(is_language_enabled)

# ------------------------------------------------------------------------------

0 comments on commit ebc31ae

Please sign in to comment.