Skip to content
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

CMake package should add the modules to CMAKE_MODULE_PATH #850

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ include(AwsFeatureTests)
include(AwsSanitizers)
include(AwsThreadAffinity)
include(AwsSIMD)
include(CMakePackageConfigHelpers)
include(CTest)

set(GENERATED_ROOT_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
Expand Down Expand Up @@ -228,9 +229,16 @@ endforeach()

aws_prepare_shared_lib_exports(${PROJECT_NAME})

configure_file("cmake/${PROJECT_NAME}-config.cmake"
set(AWS_MODULE_INSTALL_DIR "${LIBRARY_DIRECTORY}/cmake")

configure_package_config_file(
"cmake/${PROJECT_NAME}-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
@ONLY)
INSTALL_DESTINATION "${LIBRARY_DIRECTORY}/${PROJECT_NAME}/cmake"
PATH_VARS AWS_MODULE_INSTALL_DIR
# Imported targets do not require the following macros
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO)

if (BUILD_SHARED_LIBS)
set (TARGET_DIR "shared")
Expand Down Expand Up @@ -260,7 +268,7 @@ list(APPEND EXPORT_MODULES
)

install(FILES ${EXPORT_MODULES}
DESTINATION "${LIBRARY_DIRECTORY}/cmake"
DESTINATION "${AWS_MODULE_INSTALL_DIR}"
COMPONENT Development)

# This should come last, to ensure all variables defined by cmake will be available for export
Expand Down
4 changes: 4 additions & 0 deletions cmake/aws-c-common-config.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@PACKAGE_INIT@

list(APPEND CMAKE_MODULE_PATH "@PACKAGE_AWS_MODULE_INSTALL_DIR@")

set(THREADS_PREFER_PTHREAD_FLAG ON)

if(WIN32 OR UNIX OR APPLE)
Expand Down