blob: bf49f987c7ebf754e318656dc472eeee24f8f65e [file] [log] [blame]
Jan Kundrátd9d26a92018-02-22 12:49:21 +01001project(netconf-cli LANGUAGES CXX)
2cmake_minimum_required(VERSION 3.0)
3set(CMAKE_CXX_STANDARD 14)
4set(CMAKE_CXX_STANDARD_REQUIRED ON)
Jan Kundrátd47f6552018-03-02 13:40:11 +01005
6include(GNUInstallDirs)
7
8# Set a default build type if none was specified. This was shamelessly stolen
9# from VTK's cmake setup because these guys produce both CMake and a project that
10# manipulates this variable, and the web is full of posts where people say that
11# it is apparently evil to just set the build type in a way an earlier version of
12# this patch did. Oh, and the location of this check/update matters, apparently.
13#
14# Yes, this is just plain crazy.
15if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
16 message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
17 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
18 # Set the possible values of build type for cmake-gui
19 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
20endif()
21
22# -Werror is not a default for sanity reasons (one cannot know what warnings a future compiler
23# might bring along), but it's a default in debug mode. The idea is that developers should care
24# about a warning-free build, and that this is easier than messing with yet another configure option.
25set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_FLAGS_DEBUG}")
26
27# I don't want to duplicate the compiler's optimizations
28set(CMAKE_CXX_FLAGS "-O2 ${CMAKE_CXX_FLAGS}")
29
30# Build warnings are useful tools (and this project should be warning-free anyway), enable them on all
31# configurations. They are warnings, not errors.
32set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic ${CMAKE_CXX_FLAGS}")
33
Jan Kundrát608818b2018-03-02 13:43:53 +010034find_package(Doxygen)
35option(WITH_DOCS "Create and install internal documentation (needs Doxygen)" ${DOXYGEN_FOUND})
36
Jan Kundrátd47f6552018-03-02 13:40:11 +010037find_package(docopt REQUIRED)
38find_package(spdlog REQUIRED)
Jan Kundrát608818b2018-03-02 13:43:53 +010039
40if(WITH_DOCS)
41 set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
42 set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
43 configure_file(${doxyfile_in} ${doxyfile} @ONLY)
44 add_custom_target(doc
45 COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
46 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
47 COMMENT "Generating API documentation with Doxygen"
48 VERBATIM
49 SOURCES ${doxyfile_in}
50 )
51endif()