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

Use CMAKE_CURRENT_LIST_DIR instead of CMAKE_CURRENT_SOURCE_DIR in CMakeLists.txt #301

Closed
htfy96 opened this issue Oct 3, 2021 · 0 comments · Fixed by #302
Closed

Use CMAKE_CURRENT_LIST_DIR instead of CMAKE_CURRENT_SOURCE_DIR in CMakeLists.txt #301

htfy96 opened this issue Oct 3, 2021 · 0 comments · Fixed by #302

Comments

@htfy96
Copy link
Contributor

htfy96 commented Oct 3, 2021

Currently, this project uses:

project(Vc VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}" LANGUAGES C CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

to add the module directory into CMAKE_MODULE_PATH. However, it doesn't behave as expected when users try to embed this project into their own using CPM.cmake:

CMake Error at /home/lz/.cache/CPM/vc/c43a073d69c63625768cfeb76b77ea806113471c/CMakeLists.txt:25 (include):
  include could not find requested file:

    VcMacros


CMake Error at /home/lz/.cache/CPM/vc/c43a073d69c63625768cfeb76b77ea806113471c/CMakeLists.txt:26 (include):
  include could not find requested file:

    AddTargetProperty


CMake Error at /home/lz/.cache/CPM/vc/c43a073d69c63625768cfeb76b77ea806113471c/CMakeLists.txt:27 (include):
  include could not find requested file:

    OptimizeForArchitecture


CMake Error at /home/lz/.cache/CPM/vc/c43a073d69c63625768cfeb76b77ea806113471c/CMakeLists.txt:29 (vc_determine_compiler):
  Unknown CMake command "vc_determine_compiler"

This is because CMAKE_CURRENT_SOURCE_DIR only refers to the parent project's source dir when this project is embedded, which can be fixed with CMAKE_CURRENT_LIST_DIR which points to the correct directory

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 a pull request may close this issue.

1 participant