-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
115 lines (100 loc) · 4.03 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
cmake_minimum_required (VERSION 3.20)
set(PROJECT_NAME libreweb-browser)
option(DOXYGEN "Build Doxygen documentation" ON)
option(UNITTEST "Build unit tests")
option(PACKAGE "Build packages in release mode" OFF)
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "Minimum macOS deployment version")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# If we have a git folder, get GIT_TAG_VERSION from most recent git tag
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
include(GitVersion)
set(LOCAL_PROJECT_VERSION ${GIT_TAG_VERSION})
else()
# In source archives there is no .git folder present.
# If CUSTOM_PROJECT_VERSION is defined use it as version.
if(DEFINED CUSTOM_PROJECT_VERSION)
set(LOCAL_PROJECT_VERSION "${CUSTOM_PROJECT_VERSION}")
elseif(EXISTS "${CMAKE_SOURCE_DIR}/version.txt")
# Read version from version.txt file
file(READ "version.txt" LOCAL_PROJECT_VERSION)
else()
# Fallback to version 1.0.0
set(LOCAL_PROJECT_VERSION "1.0.0")
endif()
endif()
project(${PROJECT_NAME}
VERSION ${LOCAL_PROJECT_VERSION}
DESCRIPTION "LibreWeb Browser - Decentralized Web-Browser"
LANGUAGES C CXX)
message(STATUS "Project version: ${PROJECT_VERSION}")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Create packages: ${PACKAGE}")
message(STATUS "Generate documentation: ${DOXYGEN}")
if(UNITTEST)
message(STATUS "Building the unit tests")
endif()
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
endif()
# Build docs using Doxygen
if(DOXYGEN)
include(Doxygen)
endif()
# Install location
if(WIN32)
set(DATADIR share CACHE PATH "datadir")
elseif(APPLE)
set(BUNDLEDIR ${PROJECT_NAME}.app/Contents/)
set(RESOURCESDIR ${BUNDLEDIR}/Resources)
set(MACOSDIR ${BUNDLEDIR}/MacOS CACHE PATH "macosdir")
set(DATADIR ${RESOURCESDIR}/share CACHE PATH "datadir")
set(LIBDIR ${RESOURCESDIR}/lib CACHE PATH "libadir")
elseif(UNIX)
set (DATADIR share CACHE PATH "datadir")
endif()
# Production build, let's include the CPack settings
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND PACKAGE)
include(Packaging)
endif()
if(WIN32)
set(WINDOWS_FLAGS -mwindows)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -pedantic -Werror=incompatible-pointer-types")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${WINDOWS_FLAGS} -O2 -DNDEBUG")
# Disable CTest testcases & install in cpp-ipfs-http-client
set (BUILD_TESTING OFF CACHE BOOL "Disable CTest" FORCE)
set (DISABLE_INSTALL ON CACHE BOOL "Disable Install" FORCE)
add_subdirectory (lib/commonmarker/src)
add_subdirectory (lib/commonmarker/extensions)
add_subdirectory (lib/ipfs-http-client)
add_subdirectory (lib/whereami)
add_subdirectory (src)
if(UNITTEST)
add_subdirectory(tst)
endif()
# Additional install files
if(WIN32)
# Microsoft Windows specific
install(DIRECTORY misc/packaging_icons/ DESTINATION ${DATADIR}/icons)
install(DIRECTORY misc/packaging_win/ DESTINATION .)
install(PROGRAMS go-ipfs/ipfs.exe DESTINATION bin)
elseif(APPLE)
# Apple macOS specific
install(DIRECTORY misc/packaging_icons/ DESTINATION ${DATADIR}/icons)
install(DIRECTORY misc/packaging_macos/ DESTINATION ${MACOSDIR})
install(PROGRAMS go-ipfs/ipfs-darwin DESTINATION ${MACOSDIR})
elseif(UNIX)
# UNIX specific
install(FILES misc/libreweb-browser.desktop DESTINATION ${DATADIR}/applications)
install(PROGRAMS go-ipfs/ipfs DESTINATION bin)
endif()
# General
install(DIRECTORY images DESTINATION ${DATADIR}/libreweb)
install(FILES images/icons/libreweb-browser.png DESTINATION ${DATADIR}/icons/hicolor/48x48/apps)
install(FILES images/icons/libreweb-browser.svg DESTINATION ${DATADIR}/icons/hicolor/scalable/apps)