Skip to content

Commit 4f74e19

Browse files
committed
Merge #182 'Support installing library targets along with headers'
This makes installing of the built libraries along with their headers possible through the CMake-standard 'install' target. It responds to the usual DESTDIR and CMAKE_INSTALL_PREFIX variables to control installation location.
2 parents 870bfc2 + edea427 commit 4f74e19

File tree

5 files changed

+35
-3
lines changed

5 files changed

+35
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
99
* Better integrate Qt into buildsystem, it can now be disabled, and test it in CI ([#160](https://github.com/cucumber/cucumber-cpp/pull/160) Kamil Strzempowicz & Giel van Schijndel)
1010
* Support taking regex captures as arguments to the step definition's function ([#159](https://github.com/cucumber/cucumber-cpp/pull/159) Giel van Schijndel)
1111
* Support building as shared library on Windows and hide internal symbols on all platforms ([#147](https://github.com/cucumber/cucumber-cpp/pull/147) [Nik Reiman](https://github.com/nre-ableton))
12+
* Support installing library targets along with headers ([#182](https://github.com/cucumber/cucumber-cpp/pull/182) [Matthieu](https://github.com/matlo607))
1213

1314
### Changed
1415

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,17 @@ git submodule update
6464
cmake -E make_directory build
6565
6666
# Generate Makefiles
67-
cmake -E chdir build cmake -DCUKE_ENABLE_EXAMPLES=on ..
67+
cmake -E chdir build cmake -DCUKE_ENABLE_EXAMPLES=on -DCMAKE_INSTALL_PREFIX=${prefix} ..
6868
6969
# Build cucumber-cpp and tests
7070
cmake --build build
7171
7272
# Run unit tests
7373
cmake --build build --target test
7474
75+
# Run install
76+
cmake --build build --target install
77+
7578
# Check implementation against common cucumber test suite
7679
cmake --build build --target features
7780
```

appveyor.yml

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ test_script:
4848
- set CTEST_OUTPUT_ON_FAILURE=ON
4949
- cmake --build build --target test
5050
- cmake --build build --target features
51+
- cmake --build build --target install
5152

5253
after_test:
5354
- for /r %%v in (TEST-*.xml) do curl -s -F "file=@%%v;filename=%%~nxv" https://ci.appveyor.com/api/testresults/junit/%APPVEYOR_JOB_ID%

src/CMakeLists.txt

+26-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ foreach(TARGET
7171
)
7272
target_include_directories(${TARGET}
7373
PUBLIC
74-
${CMAKE_CURRENT_BINARY_DIR}
75-
${CMAKE_SOURCE_DIR}/include
74+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
75+
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
76+
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
7677
)
7778
target_link_libraries(${TARGET}
7879
PUBLIC
@@ -102,3 +103,26 @@ target_link_libraries(cucumber-cpp
102103
PRIVATE
103104
Boost::program_options
104105
)
106+
107+
include(GNUInstallDirs)
108+
install(DIRECTORY ${CUKE_INCLUDE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
109+
install(
110+
FILES
111+
"${CMAKE_CURRENT_BINARY_DIR}/cucumber-cpp/internal/CukeExport.hpp"
112+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/cucumber-cpp/internal"
113+
)
114+
install(
115+
TARGETS
116+
cucumber-cpp-nomain
117+
cucumber-cpp
118+
EXPORT CucumberCpp
119+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
120+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
121+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
122+
)
123+
install(
124+
EXPORT CucumberCpp
125+
NAMESPACE CucumberCpp::
126+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake
127+
FILE CucumberCppConfig.cmake
128+
)

travis.sh

+3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ cmake -E chdir build cmake \
5858
-G Ninja \
5959
-DCUKE_ENABLE_EXAMPLES=on \
6060
-DBUILD_SHARED_LIBS=ON \
61+
-DCMAKE_INSTALL_PREFIX=${HOME}/.local \
6162
${CMAKE_PREFIX_PATH:+"-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}"} \
6263
${COVERALLS_SERVICE_NAME:+"-DCMAKE_BUILD_TYPE=Debug"} \
6364
${COVERALLS_SERVICE_NAME:+"-DCMAKE_CXX_FLAGS='--coverage'"} \
@@ -109,3 +110,5 @@ if [ -f "${TEST}" ]; then
109110
fi
110111

111112
killXvfb
113+
114+
cmake --build build --target install

0 commit comments

Comments
 (0)