I′m a beginner user of CMake. My environment has several projects like:
project
|------ CMakeLists.txt (The main Cmake)
|------ ProjectA
| |----- .cpp files
| |----- .hpp files
| |----- CMakeList.txt
|------ ProjectB
| |----- .cpp files
| |----- .hpp files
| |----- CMakeList.txt
|
|------ build
| |----- CMakeStuff
|------ bin
| |---- executables
|------ lib
| |---- libwhatever.a
|------ db
|---- Database stuff
I would like to use a single build directory for every project, as showed above. Preferrably that It can be divided into multiple subprojects, like build/projectA
, build/ProjectB
so that if I need to rebuild a single project I can delete the whole build/Project
file and all is gone and a new Cmake
will build it again.
I′m having difficulties configuring CMAKE.
My original CMakeList.txt on the project folder:
cmake_minimum_required(VERSION 3.2.2.)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin)
project(projectA)
set(CMAKE_BUILD_TYPE Debug)
file(GLOB SOURCES "*.cpp")
add_library(commonmessage SHARED ${SOURCES})
install(TARGETS commonmessage DESTINATION ../lib)
My questions are:
A) What will happen if I run cmake on a single build directory - is that possible and what would be the correct CMAKE configuration ?
B) My compilation for ProjectA
needs to include files from ProjectB
- how can I set that in the CMakeLists.txt
for each individual project ?
C) At the end I need a single makefile to build all, as well as the option to build each project individually. Will that be possible with a single build directory ?
Thanks for helping.
See Question&Answers more detail:os