Hi everybody
My project is made of many executable binary files (namely “modules”).
My current directory structure is as follows :
scav
is the name of the toplevel directory
It contains the directories src, bin, build and a CMakeLists.txt
scav---|bin (the directory which is expected to contain the binary files of my three modules
|build (the directory from wich I launch cmake..
|CMakeLists.txt
|src---|modmngr ==> content : a library (.cpp, ..h) used by the other modules)
|modcam ==> content a module .cpp and .h
|modobs ==> content a module .cpp and .h)
|modcalc ==> content a module .cpp and .h)
In a fist step I have done separate CMakelists for each module.
For example to build modcam I have written the following CMakeLists.txt which is located in the modcam directory and it works perfectly. It generates an executable located also in the modcam directory/
cmake_minimum_required(VERSION 3.7.2)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# set the project name
project(modcam)
#pass the version number to the source code
#configure_file(tutorialConfig.h.in tutorialConfig.h)
#library
add_subdirectory(modmngr)
#add_executable(tutorial $(SRCS) $(HEADERS))
add_executable(modcam modcam.cpp)
#pass option
set(CMAKE_CXX_FLAGS "-pthread")
#libnkl to library
target_link_libraries(modcam PUBLIC modmngr)
# add the binary tree to the search path for include files
# so that we will find TutorialConfig.h
target_include_directories(modcam PUBLIC
"${PROJECT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}/modmngr"
)
But now I would like to build my three modules using a new CMakeLists.txt located on the toplevel directory which will build the three executable and records it in the bin
directory.
I try many things without success (it seems that it conflicts with the CMakeLists.txt which are located in each modules directory). It is important for me to solve this issue because in the future I will have many modules (about twenty) and I don’t want to build them one after one … So with this toplevel MakeLists.txt I expect to generate a Makefile which will build (or rebuild in case of change) all my modules at the same time.
Thank you for your help
Regards