-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
141 lines (103 loc) · 3.68 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Example, run from _build directory :
#
# cmake ..
# cmake .. -DCMAKE_INSTALL_PREFIX=../_install
#
# BUILD TYPE
# ===============================
# Debug build type turns off optimization
# cmake -DCMAKE_BUILD_TYPE=Debug ..
#
# Release build type turns on optimization flags
# cmake -DCMAKE_BUILD_TYPE=Release ..
#
#
# COMPILING
# ================================
# make clean
# make
# sudo make install
#
#
# TESTING FOR MEMORY LEAKS
# ===============================
# Compile Debug build type
#
# valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --num-callers=200 --show-reachable=yes --log-file=shmimview.memcheck.log --max-stackframe=4442392 --gen-suppressions=all --suppressions=shmimview.memcheck.supp shmimview
#
cmake_minimum_required (VERSION 3.15)
PROJECT("shmimviewGTK" C)
# =======================================
# VERSION
# =======================================
# Version number
set ( VERSION_MAJOR 0 )
set ( VERSION_MINOR 2 )
set ( VERSION_PATCH 01 )
message("====================================================")
message("VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
message("====================================================")
message("PROJECT_SOURCE_DIR = ${PROJECT_SOURCE_DIR}")
# Configure a header file to pass some of the CMake settings
# to the source code
configure_file (
"${PROJECT_SOURCE_DIR}/src/Config.h.in"
"${PROJECT_SOURCE_DIR}/src/Config.h"
)
# =======================================
# REQUIRED PACKAGES
# =======================================
# Use the package PkgConfig to detect GTK+ headers/library files
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK REQUIRED gtk+-3.0)
# FIND MILK
find_package(PkgConfig REQUIRED)
pkg_check_modules(MILK REQUIRED milk>=1.01.02)
link_directories(${MILK_LIBRARY_DIRS})
include_directories(${MILK_INCLUDE_DIRS})
message("MILK_VERSION = ${MILK_VERSION}")
message("MILK_LIBRARY_DIRS = ${MILK_LIBRARY_DIRS}")
set(CMAKE_INSTALL_RPATH "${MILK_LIBRARY_DIRS}")
# =======================================
# PERFORMANCE ORIENTED COMPILING OPTIONS
# =======================================
# Set Release build flags
set(CMAKE_C_FLAGS_DEBUG "-O0 -g -Wall -Wextra -rdynamic -fanalyzer")
# Set Release build flags
# cmake -DCMAKE_BUILD_TYPE=Debug
set(CMAKE_C_FLAGS_RELEASE "-Ofast -DNDEBUG -rdynamic ")
# Set Release build flags
# Set a default build type if none was specified
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}")
endif()
message("CMAKE_BUILD_TYPE : ${CMAKE_BUILD_TYPE}")
# Adds options to the compiler command line for targets in the current directory
# and below that are added after this command is invoked
add_compile_options(-std=gnu11)
add_compile_options(-march=native)
message("COMPILE_OPTIONS: ${COMPILE_OPTIONS}")
# A common flag is -pipe. This flag has no effect on the generated code,
# but it makes the compilation process faster. It tells the compiler
# to use pipes instead of temporary files during the different stages
# of compilation, which uses more memory. On systems with low memory,
# GCC might get killed. In those cases do not use this flag.
add_compile_options(-pipe)
ADD_EXECUTABLE(shmimv
src/shmimview.c
src/shmimview-view.c
src/shmimview-scale.c
src/shmimview-zoom.c
src/shmimview-process.c
shmimview-ui.c
)
include_directories(${GTK_INCLUDE_DIRS})
set(LIBS ${LIBS} ${GTK_LIBRARIES})
# add ImageStreamIO
set(LIBS ${LIBS} ImageStreamIO)
target_link_libraries(shmimv ${LIBS} m)
#set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
message("LIBS : ${LIBS}")
install(TARGETS shmimv DESTINATION bin)