-
Notifications
You must be signed in to change notification settings - Fork 190
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
Include "built" header-only libraries with CPM. #354
Comments
Hey, it depends on the implementation of the library, but a simple way could be to create an interface target that includes the directory with the generated header. I believe you should be able to use If the library doesn't behave well with CMake you should be able to create a target that uses an external script through In any case this seems more CMake related than package management, so it could make sense to ask the question at discourse.cmake.org as well. |
If it's header only, you're pretty much better off creating an interface library target yourself (e.g. |
@oddko Would it be possible for you to link me to a code snippet, if it's not proprietary? |
Sure thing (note that it uses relative repositories that are added in this PR #333) CPMAddPackage(
RELATIVE_REPOSITORY ../eigen
GIT_TAG 3.4.0
VERSION 3.4.0
GIT_SHALLOW TRUE
DOWNLOAD_ONLY TRUE)
if (eigen_ADDED)
add_library(eigen INTERFACE)
target_include_directories(eigen INTERFACE "${eigen_SOURCE_DIR}")
if (MSVC)
# For compilers below MSVC2019, ask for extended aligned storage
if (${MSVC_VERSION} VERSION_LESS 1920)
target_compile_definitions(eigen INTERFACE _ENABLE_EXTENDED_ALIGNED_STORAGE)
endif()
endif()
endif() |
Hello,
First of all, thanks for the awesome library!
I'm trying to include header-only libraries that only have a valid configuration and all targets after they're built/installed, for example https://github.com/xtensor-stack/xtensor. In this case, the "build" directory is the actual source directory. Is there a way to handle this?
The text was updated successfully, but these errors were encountered: