From e574a4553aa5db4441828c7d4f8730c365edcffc Mon Sep 17 00:00:00 2001 From: "Tessa L. H. Lovelace" Date: Sun, 30 Jun 2019 06:40:25 -0700 Subject: [PATCH] Move cmake defaults into CMakeLists.txt file, and document default(s). --- CMakeLists.txt | 18 +++++++++++------- README.md | 5 ++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 446521e..dfbd8f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,8 +25,12 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) if(NOT CMAKE_INSTALL_PREFIX) set(CMAKE_INSTALL_PREFIX /) endif(NOT CMAKE_INSTALL_PREFIX) +message("-- Install prefix set to '${CMAKE_INSTALL_PREFIX}'") -message("-- Install prefix set to ${CMAKE_INSTALL_PREFIX}") +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release ) +endif(NOT CMAKE_BUILD_TYPE) +message("-- Install type set to '${CMAKE_BUILD_TYPE}'") add_definitions("-std=c++14 -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror -DDEBUG") @@ -120,20 +124,20 @@ install(TARGETS laminard laminarc RUNTIME DESTINATION usr/bin) install(FILES etc/laminar.service DESTINATION ${SYSTEMD_UNITDIR}) # An initial attempt at solving https://github.com/ohwgiles/laminar/issues/92 -if(NOT EXISTS "/etc/laminar.conf") +if(NOT EXISTS "${CMAKE_INSTALL_PREFIX}etc/laminar.conf") install( - FILES etc/laminar.conf + FILES ${CMAKE_INSTALL_PREFIX}etc/laminar.conf DESTINATION etc ) -else() +else(NOT EXISTS "${CMAKE_INSTALL_PREFIX}etc/laminar.conf") # hardcoded values are examples of technical debt, and in an ideal world, are eliminated. - MESSAGE("-- An /etc/laminar.conf file exists, will create /etc/laminar.conf.example instead of overwriting.") + MESSAGE("-- A ${CMAKE_INSTALL_PREFIX}etc/laminar.conf file exists, will create ${CMAKE_INSTALL_PREFIX}etc/laminar.conf.example instead of overwriting.") # This also displays at config time, rather than install time. # In an ideal world, the user gets offered the option to overwrite, compare, or keep/copy the file install( - FILES etc/laminar.conf + FILES ${CMAKE_INSTALL_PREFIX}etc/laminar.conf DESTINATION etc RENAME "laminar.conf.example" ) -endif() +endif(NOT EXISTS "${CMAKE_INSTALL_PREFIX}etc/laminar.conf") diff --git a/README.md b/README.md index 9e07702..4dd982c 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,13 @@ First install development packages for `capnproto (version 0.7.0 or newer)`, `ra ```bash git clone https://github.com/ohwgiles/laminar.git cd laminar -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/ +cmake . make -j4 sudo make install ``` +Note that by default, installing with `(c)make` will overwrite your existing configuration, binary, and unit files. Make backups! + +The CMakeLists.txt file sets `cmake` defaults to `CMAKE_INSTALL_PREFIX=/` and `CMAKE_BUILD_TYPE=Release`, which can be overridden with the `-DCMAKE_INSTALL_PREFIX=` and `-DCMAKE_BUILD_TYPE=` flags, respectively. `make install` includes a systemd unit file. If you intend to use it, consider creating a new user `laminar` or modifying the user specified in the unit file.