Skip to content

Commit d133301

Browse files
committed
Highlight defect area
This part simply will not work, when any kind of package installation is wrapped inside a cmake function, due to cmake's variable scope. It is pure luck that our `FetchContent_Declare` example works.
1 parent 4643024 commit d133301

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,20 @@ project(rsp-cmake-scripts
5050
)
5151

5252
# Ensure parent project has modules and other properties available.
53-
#if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
5453
if(NOT PROJECT_IS_TOP_LEVEL)
54+
# TODO: PROBLEM - works only if FetchContent is done from the top-level
55+
# TODO: CMakeLists.txt file - or this is pure luck, if it works!!!
56+
# When FetchContent_MakeAvailable() is used, in a top-level project,
57+
# this will work fine, for adding this project's module path(s).
5558
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE)
59+
60+
# TODO: But, if CPM is used for obtaining project, then this will sadly
61+
# TODO: not work.
62+
63+
# TODO: Possible Solution: We need to create pacakge config and version files:
64+
# TODO: @see https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#package-configuration-file
65+
# TODO: @see https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html#command:configure_package_config_file
66+
5667
set("${PROJECT_NAME}_VERSION" "${PROJECT_VERSION}" PARENT_SCOPE)
5768
set("${PROJECT_NAME}_SEMVER" "${version_SEMVER}" PARENT_SCOPE)
5869
endif()

0 commit comments

Comments
 (0)