I have the following project structure.
project
-> build
-> sdk
-> calculator
-> include
-> calculator.h
-> calculator_p.h
-> src
-> calculator.cpp
-> calculator_p.cpp
-> interfaces
-> icalculator.h
-> client
-> main.cpp
I want to create a library from sdk and use it in client, so client can see icalculator.h and calculator.h, but not calculator_p.h. Official cmake documentation has very poor examples, unfortunelly. I digged through a lot of examples and I have to say that I'm even more lost than in the beggining.
Should I create only one CMakeLists.txt in sdk directory or another one in each calculator and interfaces?
EDIT: This is what I came up with so far.
project/CMakeLists.txt
cmake_minimum_required(VERSION 3.13)
project(test_project)
set(CMAKE_CXX_STANDARD 17)
add_subdirectory(sdk)
add_subdirectory(client)
project/sdk/CMakeLists.txt
add_library(sdk_library SHARED
calculator/src/calculator.cpp
calculator/src/calculator_p.cpp)
target_include_directories(sdk_library PUBLIC interfaces/include)
target_include_directories(sdk_library PUBLIC calculator/include)
project/client/CMakeLists.txt
add_executable(client main.cpp)
target_link_libraries(client sdk_library)
I build and run from the build directory.
cmake ..
make client
./client/client