1

I have a CMakeLists.txt file for my project and under deps/SFML I have the SFML 2.5.0 git repo checked out as a dependency. I add this directory using add_subdirectory() to automatically build SFML while using target_link_libraries() to link against SFML.

SFML decided to call some install() directives with DIRECTORY and COMPONENT specified. As such, building my NSIS-generated installation package, I see a "devel" component you can install which installs some files.

How do I correctly disable these install targets?

The CMake mailing list says use the COMPONENT option to install() for your own project and then select a component-based package if you are packaging with CPack. Since I can't control what SFML does in the future with component naming, and my project or other projects might also use "devel" as a component, I can't possibly disable a generic component like that. What do I do to portably disable this?

Xunie
  • 437
  • 4
  • 21
  • 1
    Possible duplicate of [CPack: Exclude INSTALL commands from subdirectory (googletest directory)](https://stackoverflow.com/questions/35344132/cpack-exclude-install-commands-from-subdirectory-googletest-directory) – Tsyvarev Jul 16 '18 at 15:18
  • I argue that conditionally enabling/disabling tests in googletest is not the same as unconditionally disabling non-test install targets. – Xunie Jul 19 '18 at 16:49
  • Read the referenced question carefully - it is all about disabling `install` command, not about disabling the tests. The same is about the answer on it. – Tsyvarev Jul 19 '18 at 17:35
  • Yeah it does. But the wording (and intent) is a little different. I dunno, I managed to get an answer out of the link you linked me and fixed my problem. Thanks, dude. I just haven't had time to deal with this question. What do you propose I do? Delete it? Flag it? – Xunie Jul 19 '18 at 23:32
  • 1
    You may agree with a duplicate vote. Such a way your question will have reference to the other question at the top, and answers for your question will be disabled. But your question will remains on the cite, and can be searched by others, and can be upvoted. See [help center](https://stackoverflow.com/help/duplicates) for more info. – Tsyvarev Jul 20 '18 at 07:31

1 Answers1

0

You can use ExternalProject_Add() instead of add_subdirectory().

Something like this:

include(ExternalProject)
ExternalProject_Add( SFML_PROJ
    INSTALL_COMMAND "" #do nothing
    SOURCE_DIR "${CMAKE_SOURCE_DIR}/deps/SFML"
    BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}"
    STEP_TARGETS build
)
add_dependencies(YOUR_PROJ SFML_PROJ)
target_link_libraries(YOUR_PROJ "${CMAKE_CURRENT_BINARY_DIR}/SFML_libname")`