|
1 | 1 | cmake_minimum_required(VERSION 3.14)
|
2 | 2 |
|
3 |
| -# Project name |
| 3 | +# try to prevent modification of source directory |
| 4 | +# note: some files may still be written before CMake can abort and need to be removed manually |
| 5 | +if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) |
| 6 | + message( |
| 7 | + FATAL_ERROR |
| 8 | + "In-source build not allowed. " |
| 9 | + "Please create a new directory, preferably next to the source directory, and run CMake from there. " |
| 10 | + "You may want to remove CMakeCache.txt and CMakeFiles/ which were created in the source directory." |
| 11 | + ) |
| 12 | +endif() |
| 13 | + |
4 | 14 | project(mirco VERSION 0.1.0)
|
5 | 15 |
|
6 |
| -# Check for out-of-source build |
7 |
| -if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) |
8 |
| - message(FATAL_ERROR "\nIn-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.\n\nTo clean-up, you may need to remove CMakeCache.txt and CMakeFiles from your source directory.") |
9 |
| -endif() |
| 16 | +# Print CMake version to screen |
| 17 | +message(STATUS "Using CMake ${CMAKE_VERSION}") |
10 | 18 |
|
| 19 | +# Enforce the C++ standard we are using and turn off compiler-specific extensions |
11 | 20 | set(CMAKE_CXX_STANDARD 17)
|
| 21 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 22 | +set(CMAKE_CXX_EXTENSIONS OFF) |
| 23 | + |
| 24 | +# We do not use C++ modules (yet). Turn off scanning to avoid issues with clang-tidy. |
| 25 | +# If you want to add module support, this problem needs to be revisited. Our hope |
| 26 | +# is that CMake and/or clang-tidy will be updated to handle modules better. |
| 27 | +set(CMAKE_CXX_SCAN_FOR_MODULES OFF) |
| 28 | + |
| 29 | +# Ensure cmake setup the correct runtime path when installing |
| 30 | +# see here for more information: https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling |
| 31 | +include(GNUInstallDirs) |
| 32 | +set(CMAKE_SKIP_BUILD_RPATH FALSE) |
| 33 | +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) |
| 34 | +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") |
| 35 | +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) |
12 | 36 |
|
13 | 37 | # Add libraries
|
14 | 38 | if(GTEST_IN_MIRCO)
|
@@ -145,7 +169,7 @@ configure_package_config_file(cmake/mirco_libConfig.cmake.in
|
145 | 169 |
|
146 | 170 | install(FILES
|
147 | 171 | ${CMAKE_CURRENT_BINARY_DIR}/mirco_libConfig.cmake
|
148 |
| - DESTINATION lib/cmake/mirco |
| 172 | + DESTINATION lib/cmake/mirco |
149 | 173 | )
|
150 | 174 |
|
151 | 175 | install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/ DESTINATION include/mirco FILES_MATCHING PATTERN "*.h")
|
|
0 commit comments