summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 3db52bb26eb77b07db8671f334e35403fc8ced24 (plain)
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
PROJECT(XTrkCAD)

# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/app)

# Setup high-level build options ...
IF(UNIX AND NOT APPLE)
	SET(XTRKCAD_USE_GTK_DEFAULT ON)
	SET(XTRKCAD_USE_GETTEXT_DEFAULT ON)
ENDIF(UNIX AND NOT APPLE)

IF(APPLE)
	SET(XTRKCAD_USE_GTK_DEFAULT ON)
	SET(XTRKCAD_USE_GETTEXT_DEFAULT OFF)
ENDIF(APPLE)

IF(WIN32)
	CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR)

	SET(XTRKCAD_USE_GTK_DEFAULT OFF)
	SET(XTRKCAD_USE_GETTEXT_DEFAULT OFF)

	SET(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /MTd /Zi  /Ob0 /Od /RTC1" CACHE STRING "Flags used by the compiler during debug builds" FORCE)
	SET(CMAKE_C_FLAGS_MINSIZEREL "/MT /O1 /Ob1 /D NDEBUG" CACHE STRING "Flags used by the compiler during release minumum size builds" FORCE)
	SET(CMAKE_C_FLAGS_RELEASE "/MT /O2 /Ob2 /D NDEBUG" CACHE STRING "Flags used by the compiler during release builds" FORCE)
	SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1 /D NDEBUG" CACHE STRING "Flags used by the compiler during release with debug info builds" FORCE)
	
	ADD_DEFINITIONS(-DWINDOWS)
	ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ENDIF(WIN32)

if(COMMAND cmake_policy)
    cmake_policy(SET CMP0003 NEW)
    if( POLICY CMP0026 )
	cmake_policy(SET CMP0026 OLD)
    endif( POLICY CMP0026 ) 	
endif(COMMAND cmake_policy)

SET(XTRKCAD_USE_DOXYGEN_DEFAULT OFF)
OPTION(XTRKCAD_USE_GTK "Use GTK for the graphical user interface back-end" ${XTRKCAD_USE_GTK_DEFAULT})
OPTION(XTRKCAD_USE_GETTEXT "Use gettext for internationalization" ${XTRKCAD_USE_GETTEXT_DEFAULT})
OPTION(XTRKCAD_USE_DOXYGEN "Generate internals documentation using doxygen" ${XTRKCAD_USE_DOXYGEN_DEFAULT})

IF(APPLE)
	OPTION(XTRKCAD_USE_PACKAGEMAKER "Generate an OSX PackageMaker package for distribution." OFF)
ENDIF(APPLE)

# Hide the advanced stuff ...
MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY)
MARK_AS_ADVANCED(CMAKE_EXECUTABLE_FORMAT)
MARK_AS_ADVANCED(CMAKE_OSX_ARCHITECTURES)
MARK_AS_ADVANCED(CMAKE_OSX_SYSROOT)
MARK_AS_ADVANCED(CMAKE_USE_CHRPATH)
MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH)
MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH)

# Test for dependencies ...
IF(WIN32 AND NOT XTRKCAD_USE_GTK)
	FIND_PACKAGE(HTMLHelp REQUIRED)
ENDIF(WIN32 AND NOT XTRKCAD_USE_GTK)

IF(XTRKCAD_USE_GTK)
	INCLUDE(FindPkgConfig)
	PKG_CHECK_MODULES(GTK REQUIRED "gtk+-2.0")
	PKG_CHECK_MODULES(GTK_WEBKIT REQUIRED "webkit-1.0")
ENDIF(XTRKCAD_USE_GTK)

IF(XTRKCAD_USE_PACKAGEMAKER)
	IF(NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr")
		MESSAGE(SEND_ERROR "XTRKCAD_USE_PACKAGEMAKER requires CMAKE_INSTALL_PREFIX set to /usr.")
	ENDIF(NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr")
ENDIF(XTRKCAD_USE_PACKAGEMAKER)

# Test for headers and libraries for portability ...

INCLUDE (CheckIncludeFiles)
CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)

# Setup some global options for installation ...
SET(XTRKCAD_MAJOR_VERSION "4")
SET(XTRKCAD_MINOR_VERSION "2")
SET(XTRKCAD_RELEASE_VERSION "4")
SET(XTRKCAD_VERSION_MODIFIER "a")
SET(XTRKCAD_VERSION "${XTRKCAD_MAJOR_VERSION}.${XTRKCAD_MINOR_VERSION}.${XTRKCAD_RELEASE_VERSION}${XTRKCAD_VERSION_MODIFIER}")

IF(WIN32)
	SET( CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX} ${XTRKCAD_VERSION}" )
ENDIF(WIN32)
SET(XTRKCAD_BIN_INSTALL_DIR "bin")
SET(XTRKCAD_LOCALE_INSTALL_DIR "share/locale")
SET(XTRKCAD_PACKAGE "xtrkcad")
SET(XTRKCAD_SHARE_INSTALL_DIR "share/xtrkcad")

# Enable use of a configuration file ...
ADD_DEFINITIONS(-DXTRKCAD_CMAKE_BUILD)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/xtrkcad-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/xtrkcad-config.h)

# Setup the rest of the build ...
ADD_SUBDIRECTORY(app)
ADD_SUBDIRECTORY(distribution)
ADD_SUBDIRECTORY(docs)