Код: Выделить всё
app
include
inc.hpp
lib
question.cpp
answer.cpp
CMakeLists.txt
src
answer.cpp
CMakeLists.txt
CMakeLists.txt
Код: Выделить всё
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(hg2g_example LANGUAGES CXX)
add_subdirectory(src)
add_subdirectory(lib)
Код: Выделить всё
include_directories(../include)
add_executable(answer answer.cpp)
target_link_libraries(answer liber)
install(TARGETS answer DESTINATION bin)
Код: Выделить всё
set(lib_headers ../include/inc.hpp
"${CMAKE_CURRENT_BINARY_DIR}/include/inc.hpp")
set(lib_sources answer.cpp question.cpp)
add_library(liber ${lib_sources} ${lib_headers})
target_include_directories(liber PUBLIC
include
"${CMAKE_CURRENT_BINARY_DIR}/include")
install(TARGETS liber DESTINATION lib)
install(FILES ${lib_headers} DESTINATION include)
Может ли кто -нибудь помочь мне понять, как это работает с несколькими каталогами, которые служат разным целям?
Подробнее здесь: https://stackoverflow.com/questions/677 ... ganization
Мобильная версия