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

Update CMakeLists.txt to allow FetchContent to work #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Serinox
Copy link

@Serinox Serinox commented May 13, 2022

When trying to use this library with CMake's FetchContent command like so:

set(BUILD_EXAMPLES OFF)
set(BUILD_TESTING OFF)
FetchContent_Declare(
        MyGAL
        GIT_REPOSITORY https://github.com/pvigier/MyGAL
        GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(MyGAL)

I ran into a build issue where the configure_package_config_file was looking for MyGALConfig.cmake.in inside my project instead of the _deps/mygal-src folder that the FetchContent command downloads everything into. Swapping from CMAKE_SOURCE_DIR which is the the top level source directory to CMAKE_CURRENT_LIST_DIR which is the directory of the currently parsed CMakeLists.txt file should resolve it for standard builds and FetchContent builds.

Also let me know if there is an issue with this PR as I've not used GitHub's pull request system enough to be confident I have it correct.

make it so the build works when getting this code through CMake's FetchContent command. The previous usage of CMAKE_SOURCE_DIR instead of CMAKE_CURRENT_LIST_DIR caused a build error because it would look for the MyGALConfig.cmake.in inside of your project instead of the _deps/mygal-src/ folder setup by the FetchContent command
@Serinox Serinox changed the title Update CMakeLists.txt Update CMakeLists.txt to allow FetchContent to work May 13, 2022
fix a few more instances of CMAKE_SOURCE_DIR that were causing problems.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant