Skip to content

Commit

Permalink
Rename to EXTERNAL_CONAN_COMPONENTS
Browse files Browse the repository at this point in the history
  • Loading branch information
thejohnfreeman committed Nov 6, 2024
1 parent 0992a5e commit bac33bb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
6 changes: 3 additions & 3 deletions cmake/cupcake_install_cpp_info.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ file(READ "${CUPCAKE_MODULE_DIR}/data/install_cpp_info.cmake"
# package with `find_package` and then generates and installs a `cpp_info.py`
# under `CMAKE_INSTALL_PREFIX`.
function(cupcake_install_cpp_info)
cupcake_get_project_property(CONAN_COMPONENTS)
string(REPLACE "\"" "\\\"" CONAN_COMPONENTS "${CONAN_COMPONENTS}")
cupcake_get_project_property(EXTERNAL_CONAN_COMPONENTS)
string(REPLACE "\"" "\\\"" EXTERNAL_CONAN_COMPONENTS "${EXTERNAL_CONAN_COMPONENTS}")
install(
CODE "
set(CONAN_COMPONENTS \"${CONAN_COMPONENTS}\")
set(EXTERNAL_CONAN_COMPONENTS \"${EXTERNAL_CONAN_COMPONENTS}\")
set(CMAKE_BINARY_DIR \"${CMAKE_BINARY_DIR}\")
set(PACKAGE_NAME ${PROJECT_NAME})
string(TOUPPER $<CONFIG> CONFIG)
Expand Down
2 changes: 1 addition & 1 deletion cmake/cupcake_project.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function(_cupcake_parse_json json)
endforeach()

endforeach()
cupcake_set_project_property(PROPERTY CONAN_COMPONENTS "${members}")
cupcake_set_project_property(PROPERTY EXTERNAL_CONAN_COMPONENTS "${members}")
endfunction()

function(cupcake_parse_component variable component)
Expand Down
6 changes: 3 additions & 3 deletions cmake/data/install_cpp_info.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# is `CMAKE_INSTALL_PREFIX`, because it can change at install time.

set(parameters
CONAN_COMPONENTS
# EXTERNAL_CONAN_COMPONENTS can be an empty string.
CMAKE_BINARY_DIR
PACKAGE_NAME
CONFIG
Expand All @@ -26,7 +26,7 @@ if(missing_parameters)
message(FATAL_ERROR "missing parameters: ${missing_parameters}")
endif()

message(STATUS "CONAN_COMPONENTS = '${CONAN_COMPONENTS}'")
message(STATUS "EXTERNAL_CONAN_COMPONENTS = '${EXTERNAL_CONAN_COMPONENTS}'")
message(STATUS "CMAKE_BINARY_DIR = '${CMAKE_BINARY_DIR}'")
message(STATUS "PACKAGE_NAME = '${PACKAGE_NAME}'")
message(STATUS "CONFIG = '${CONFIG}'")
Expand All @@ -39,7 +39,7 @@ set(tmp_dir "${CMAKE_BINARY_DIR}/cpp_info")
file(MAKE_DIRECTORY "${tmp_dir}")
execute_process(
COMMAND "${CMAKE_COMMAND}"
"-DCONAN_COMPONENTS=${CONAN_COMPONENTS}"
"-DEXTERNAL_CONAN_COMPONENTS=${EXTERNAL_CONAN_COMPONENTS}"
"-DPACKAGE_NAME=${PACKAGE_NAME}"
"-DCONFIG=${CONFIG}"
# CMake complains if `CMAKE_BUILD_TYPE` is not set for
Expand Down
13 changes: 11 additions & 2 deletions cmake/data/project_cpp_info/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ find_package(
PATHS ${CMAKE_INSTALL_PREFIX}
)

# Do not warn for unused variables.
if(EXTERNAL_CONAN_COMPONENTS)
endif()
if(CMAKE_POLICY_DEFAULT_CMP0091)
endif()

string(APPEND cpp_info
# - names[generator]: namespace name
"self.names['cmake_find_package'] = '${PACKAGE_NAME}'\n"
Expand Down Expand Up @@ -141,9 +147,12 @@ while(queue)
else()
# External target.
# Translate to Conan component name.
string(JSON lname ERROR_VARIABLE error GET "{${CONAN_COMPONENTS}}" "${link}")
string(
JSON lname ERROR_VARIABLE error
GET "{${EXTERNAL_CONAN_COMPONENTS}}" "${link}"
)
if(error)
log(ERROR "${error}")
log(ERROR "unrecognized target linked by ${target}: ${link}")
set(lname ${link})
endif()
endif()
Expand Down
1 change: 1 addition & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Cupcake(ConanFile):
license = 'ISC'
author = 'John Freeman <jfreeman08@gmail.com>'
url = 'https://github.com/thejohnfreeman/cupcake.cmake'
description = 'CMake boilerplate for an opinionated project structure.'

# TODO: The CMake helper requires the build_type setting to run its build
# or install methods.
Expand Down

0 comments on commit bac33bb

Please sign in to comment.