Given the following CMakeLists.txt
:
cmake_minimum_required(VERSION 3.27)
project(gubbins)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
add_library(gubbins SHARED
src/lib/gubbins.cpp
)
set_target_properties(gubbins PROPERTIES
SOVERSION 1
VERSION 1.1.1
)
include(GenerateExportHeader)
generate_export_header(gubbins)
target_sources(gubbins
PUBLIC
FILE_SET HEADERS
BASE_DIRS
src/include
${CMAKE_CURRENT_BINARY_DIR}
)
include(GNUInstallDirs)
install(TARGETS gubbins FILE_SET HEADERS)
I’m using the Ninja Multi-Config generator, CMake 3.30.5, and ninja 1.12.1. on macOS 14.
I would expect the following sequence of commands to result in build/staging/Release
containing include/*.h
and lib/*.dylib
, but no headers are being installed, just the library files:
$ cmake -G "Ninja Multi-Config" -B build
$ cmake --build build --config Release
$ cmake --install build --config Release --prefix build/staging/Release
(The same happens if I omit --prefix
but have set CMAKE_INSTALL_PREFIX
in CMakeLists.txt
)
I’m quite baffled - I created this new trivial project to test with, after experiencing this with my actual project. I’m assuming I’m doing something daft, but I’m at a loss for what…
The complete test project is at GitHub - fidothe/cmake-install-problem: Minimal repro for CMake install problems I'm having
Any insights gratefully received.