-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
96 lines (74 loc) · 2.48 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# CMakeLists.txt for libyui-mga
#
# Usage:
#
# mkdir build
# cd build
# cmake ..
#
# make
# sudo make install
#
# Restart with a clean build environment:
# rm -rf build
#
# Show the complete compiler commands with all arguments:
# make VERBOSE=1
cmake_minimum_required( VERSION 3.17 )
project( libyui-mga )
# Options usage:
#
# cmake -DBUILD_DOC=on -DBUILD_EXAMPLES=off ..
option( BUILD_SRC "Build in src/ subdirectory" on )
option( BUILD_EXAMPLES "Build C++ -based libyui examples" on )
option( BUILD_DOC "Build class documentation" off )
option( BUILD_PKGCONFIG "Build pkg-config support files" on )
option( BUILD_WITH_LIBYUI_SOURCE "Build libyui-mga with libyui source" off )
option( WERROR "Treat all compiler warnings as errors" on )
#----------------------------------------------------------------------
# We use /usr as the default CMAKE_INSTALL_PREFIX, but it can be set on the
# cmake command line with
#
# cmake -DCMAKE_INSTALL_PREFIX=/my/install/prefix ..
#
# or in the environment with
#
# CMAKE_INSTALL_PREFIX=/usr/local cmake ..
if ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
if ( DEFINED ENV{CMAKE_INSTALL_PREFIX} )
set( CIP $ENV{CMAKE_INSTALL_PREFIX} )
else()
set( CIP /usr )
endif()
set( CMAKE_INSTALL_PREFIX "${CIP}" CACHE PATH "Install path prefix" FORCE)
endif()
message( STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}" )
set( CMAKE_INSTALL_MESSAGE LAZY ) # Suppress "up-to-date" messages during "make install"
# Initialize compiler flags for all targets in all subdirectories
add_compile_options( "-Wall" )
IF (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
# Initialize compiler flags for all targets in all subdirectories
add_compile_options( "-Os" ) # Optimize for size (overrides CMake's -O3 in RELEASE builds)
endif()
if ( WERROR )
add_compile_options( "-Werror" )
endif()
#
# Descend into subdirectories
#
# Build and install auxiliary files first so this doesn't scroll away any important messages
if ( BUILD_PKGCONFIG )
add_subdirectory( pkgconfig )
endif()
#----------------------------------------------------------------------
if ( BUILD_SRC )
add_subdirectory( src )
endif()
if ( BUILD_EXAMPLES )
add_subdirectory( examples )
endif()
if ( BUILD_DOC )
# Notice that this is only built upon "make doc". Docs are not installed.
#add_subdirectory( doc )
message (STATUS "TODO doc")
endif()