Issue
I've started a project with cmake, composed by two executables. A lot of code is used by the two executables.
Now, i need to configure differents include directories, for each executable.
if i use include_directories
, it add my directories for all executables.
it is possible to configure include directories independently for executable ?
This is my directories:
.
├── CMakeCache.txt
├── CMakeFiles
│ [...]
├── cmake_install.cmake
├── CMakeLists.txt
├── includes
│ ├── client
│ │ └── main.hpp
│ ├── server
│ │ └── main.hpp
│ └── shared
├── Makefile
└── sources
├── client
│ ├── main.cpp
├── shared
│ ├── lib.cpp
└── server
└── main.cpp
Solution
You should create CMakeLists.txt for both of your executables in their dirs (sources\client\CMakeLists.txt
and sources\server\CMakeLists.txt
). There you can include_directories()
and this would not interfere with other targets.
Do not forget to do add_subdirectory()
in your root CMakeLists.txt.
Answered By - arrowd Answer Checked By - Terry (WPSolving Volunteer)