Move cmake defaults into CMakeLists.txt file, and document default(s).

pull/96/head
Tessa L. H. Lovelace 5 years ago
parent 09bfdb4eb9
commit e574a4553a

@ -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")

@ -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=<path>` and `-DCMAKE_BUILD_TYPE=<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.

Loading…
Cancel
Save