|
| 1 | +cmake_minimum_required(VERSION 3.20) |
| 2 | + |
| 3 | +include(CMakePrintHelpers) |
| 4 | + |
| 5 | +# |
| 6 | +# Change default CMake options for convenience |
| 7 | +# |
| 8 | + |
| 9 | +# Change default build type |
| 10 | +set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build type") |
| 11 | + |
| 12 | +# Build .so by default |
| 13 | +set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libs") |
| 14 | + |
| 15 | +# Build tests by default |
| 16 | +set(BUILD_TESTING ON CACHE BOOL "Build tests") |
| 17 | + |
| 18 | +# Build -fPIC by default (even static) by default |
| 19 | +set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Position independent code") |
| 20 | + |
| 21 | +# Silent some install messages by default |
| 22 | +set(CMAKE_INSTALL_MESSAGE "LAZY" CACHE STRING "") |
| 23 | + |
| 24 | +# Add rpaths of external dependencies by default |
| 25 | +if (NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH) |
| 26 | + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) # not CACHE, only for our project |
| 27 | +endif() |
| 28 | + |
| 29 | +# |
| 30 | +# Read the version from version.txt |
| 31 | +# |
| 32 | + |
| 33 | +file(READ "version.txt" version_txt) |
| 34 | +string(REGEX REPLACE "^[ \t\n]+|[ \t\n]+$" "" version_txt "${version_txt}") # Strip |
| 35 | + |
| 36 | +# |
| 37 | +# |
| 38 | +# |
| 39 | + |
| 40 | +project(MachineTypes |
| 41 | + LANGUAGES C |
| 42 | + VERSION "${version_txt}" |
| 43 | + DESCRIPTION "Simple C numeric types definitions") |
| 44 | + |
| 45 | +cmake_print_variables(MachineTypes_VERSION) |
| 46 | + |
| 47 | +# (after project() is important here:) |
| 48 | +include(GNUInstallDirs) |
| 49 | + |
| 50 | +# Global PRIVATE compilation flags |
| 51 | +add_compile_options(-Wall -Wextra) |
| 52 | + |
| 53 | +add_subdirectory(machinetypes) |
| 54 | +add_subdirectory(cmake) |
0 commit comments