There is top-level project named 'cppserial', which depends on subproject 'cppstreams', which also depends on subproject 'cpputils'. The file structure of whole project:
cppserial/
|
CMakeLists.txt
src/
|
cppserial/
source files
libs/
|
cppstreams/
|
CMakeLists.txt
libs/
|
cpputils/
|
CMakeLists.txt
src/
|
cpputils/
source files
src/
|
cppstreams/
source files
cppserial CMakeLists.txt:
cmake_minimum_required(VERSION 3.8)
project(cppserial)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(SOURCE ...sources...)
add_library(${PROJECT_NAME} STATIC ${SOURCE})
add_subdirectory(libs/cppstreams)
target_link_libraries(${PROJECT_NAME} PUBLIC cppstreams)
target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
cppstreams CMakeLists.txt
cmake_minimum_required(VERSION 3.8)
project(cppstreams)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(SOURCES ...sources...)
set(HEADERS ...headers...)
set(BOOST_ROOT D:/Development/CXX/Libraries/Boost)
find_package(Boost REQUIRED)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME ON)
add_library(${PROJECT_NAME} STATIC ${HEADERS} ${SOURCES})
add_subdirectory(libs/cpputils)
target_link_libraries(${PROJECT_NAME} PUBLIC cpputils)
target_include_directories(${PROJECT_NAME} PUBLIC ${Boost_INCLUDE_DIR})
target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
cpputils CMakeLists.txt
cmake_minimum_required(VERSION 3.8)
project(cpputils)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(SOURCES ...sources...)
set(HEADERS ...headers...)
add_library(${PROJECT_NAME} STATIC ${HEADERS} ${SOURCES})
target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
Building:
cd build
cmake ..
cmake --build .
Build output:
[main] Configuring folder: cppserial
[proc] Executing command: D:\Software\CMake\bin\cmake.EXE --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -Sd:/Development/CXX/cppserial -Bd:/Development/CXX/cppserial/build -G "Visual Studio 17 2022"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
[cmake] -- The C compiler identification is MSVC 19.33.31630.0
[cmake] -- The CXX compiler identification is MSVC 19.33.31630.0
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: D:/Software/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: D:/Software/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Found Boost: D:/Development/CXX/Libraries/Boost/lib/cmake/Boost-1.80.0/BoostConfig.cmake (found version "1.80.0")
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: D:/Development/CXX/cppserial/build
[visual-studio] Patch Windows SDK path from C:\Program Files (x86)\Windows Kits\10\bin\x64 to C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64 for D:\Software\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat
Compiling output:
MSBuild version 17.3.1+2badb37d1 for .NET Framework
Checking Build System
Building Custom Rule D:/Development/CXX/cppserial/libs/cppstreams/libs/cpputils/CMakeLists.txt
...source files...
cpputils.vcxproj -> D:\Development\CXX\cppserial\build\libs\cppstreams\libs\cpputils\Debug\cpputils.lib
Building Custom Rule D:/Development/CXX/cppserial/libs/cppstreams/CMakeLists.txt
...source files...
cppstreams.vcxproj -> D:\Development\CXX\cppserial\build\libs\cppstreams\Debug\cppstreams.lib
Building Custom Rule D:/Development/CXX/cppserial/CMakeLists.txt
Building Custom Rule D:/Development/CXX/cppserial/CMakeLists.txt
As you can see, only subprojects are being built. There is no cppserial.lib in the build folder. I can't understand what could i miss.