I'm trying to use CPack to package my project, but I've run into an issue with one of my dependencies.
First, I am trying to use modern CMake style by relying on targets and dependencies modeled between targets using target_link_libraries
. My project uses the CMocka library as a dependency. I have added the CMocka repo as a git submodule and I have add_subdirectory(cmocka_dir)
in my own CMakeLists.txt
file.
I also use CPack with the TGZ
generator to gather all my files into an archive. I simply set(CPACK_GENERATOR TGZ)
and include(CPack)
in my CMakeLists.txt
. I have found that this takes care of everything, that is, until I started using CMocka. CMocka sets a lot of CPACK_xxx
variables inside its root CMakeLists.txt
. I believe that when I include CMocka's subdirectory in my own project, these variables propagate inside my CMake scope and mess with my packaging process.
My question is how I can fix this. Specifically:
- Is there a way to isolate CMocka in its own environment, or otherwise prevent it from breaking my packaging process?
- Am I doing it wrong by including CMocka using
add_subdirectory
? - Am I doing CPack wrong by just setting
CPACK_GENERATOR
and doinginclude(CPack)
?
Thanks for your thoughts.