-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
80 lines (62 loc) · 2.33 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
cmake_minimum_required(VERSION 2.6)
# Start
project(MyWebsite)
# Setup toolchain
SET (CMAKE_C_FLAGS "-Wall -Werror -std=c99")
SET (CMAKE_C_FLAGS_DEBUG "-g")
SET (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
SET (CMAKE_C_FLAGS_RELEASE "-O4 -DNDEBUG")
SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
SET (CMAKE_CXX_FLAGS "-Wall -Werror")
SET (CMAKE_CXX_FLAGS_DEBUG "-g")
SET (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
SET (CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG")
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
# Install-dirs
set(INSTALLBIN bin)
set(INSTALLLIB lib)
set(INSTALLARC lib)
# Continue with the building
#This hack is because for some reason GTK2_LIBS does not include gio
set(GIO_HACK "-lgio-2.0 -lgobject-2.0 -lgmodule-2.0")
include(FindGTK2)
include(FindLibSoup2.cmake)
include(FindGit.cmake)
include_directories(${GTK2_INCLUDE_DIRS} ${LIBSOUP2_INCLUDE_DIRS})
# Get git info
Git_WC_INFO(${CMAKE_SOURCE_DIR} MY)
# Generate config.h
configure_file("config.h.in" "config.h")
include_directories(${CMAKE_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR})
# Add targets
add_library(mywebsite_utils SHARED utils.c)
target_link_libraries(mywebsite_utils ${GTK2_GLIB_LIBRARY} ${LIBSOUP2_LIBRARIES} ${GIO_HACK})
install(TARGETS mywebsite_utils LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
add_executable(mywebsite main.c)
target_link_libraries(mywebsite ${GTK2_GLIB_LIBRARY} ${LIBSOUP2_LIBRARIES} ${GIO_HACK} mywebsite_utils)
install(TARGETS mywebsite RUNTIME DESTINATION bin)
# Modules
add_subdirectory(modules)
# Add support for "make docs"
find_package(Doxygen)
if(DOXYGEN_FOUND)
configure_file("Doxyfile.in" "Doxyfile")
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)
# Add support for "make dist"
set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${PROJECT_VERSION})
add_custom_target(dist
COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
| gzip > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.gz
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
# Add support for "make check"
add_custom_target(check COMMAND ctest "-v")
# Test Suite
#add_executable(<testprog> EXCLUDE_FROM_ALL ...)
#add_test(<testprog> <testprog>)
#add_dependencies(check <testprog>)