- cpp
- main.cpp (вызывает код из папок dataStructures/ и common/)
- CMakeLists.txt (самый верхний файл CMakeLists)
- создать
- common
CMakeLists.txt (должен отвечать за создание общей общей библиотеки) - include
utils.h
- utils.cpp
[*]dataStructures
- CMakeLists.txt (создайте общую библиотеку dataStructures, зависящую от общей библиотеки)
- include
dsLinkedList.h
- dsLinkedList.cpp
Каталоги *build* содержат собранную цель. Фактический код можно увидеть здесь: https://github.com/brainydexter/PublicC ... master/cpp
На данный момент CMakeLists.txt в каждом из подкаталогов создает свои собственные общие библиотеки. Затем самый верхний файл CMakeLists ссылается на библиотеки и пути следующим образом:
Самый верхний файл CMakeLists.txt
Код: Выделить всё
cmake_minimum_required(VERSION 3.2.2)
project(cpp)
# For the shared library:
set ( PROJECT_LINK_LIBS libcppDS.dylib libcppCommon.dylib)
link_directories( dataStructures/build )
link_directories( common/build )
# Bring the headers, into the project
include_directories(common/include)
include_directories(dataStructures/include)
# Can manually add the sources using the set command as follows:
set(MAINEXEC main.cpp)
add_executable(testDS ${MAINEXEC})
target_link_libraries(testDS ${PROJECT_LINK_LIBS} )
Код: Выделить всё
commonCMakeLists для common:
Код: Выделить всё
cmake_minimum_required(VERSION 3.2.2)
project(cpp_common)
set(CMAKE_BUILD_TYPE Release)
# Bring the headers, such as Student.h into the project
include_directories(include)
# However, the file (GLOB...) allows for wildcard additions:
file(GLOB SOURCES "src/*.cpp")
# Generate the shared library from the sources
add_library(cppCommon SHARED ${SOURCES})
Код: Выделить всё
cmake_minimum_required(VERSION 3.2.2)
project(cpp_dataStructures)
set(CMAKE_BUILD_TYPE Release)
# For the shared library:
set ( PROJECT_LINK_LIBS libcppCommon.dylib )
link_directories( ../common/build )
# Bring the headers, such as Student.h into the project
include_directories(include)
include_directories(../common/include/)
# However, the file(GLOB...) allows for wildcard additions:
file(GLOB SOURCES "src/*.cpp")
# Generate the shared library from the sources
add_library(cppDS SHARED ${SOURCES})
CMake fixes #1
И идентификатор фиксации: 4B4F1D3D24B5D82F78DA3CBFFE423754D8C39EC0 в моем репозитории Git
Подробнее здесь: https://stackoverflow.com/questions/326 ... sing-cmake
Мобильная версия