Change debian changelog, add -c0 into rules file to prevent symbol whinges, fix point...
[freerdp-ubuntu-pcb-backport.git] / CMakeLists.txt
1 # FreeRDP: A Remote Desktop Protocol Client
2 # FreeRDP cmake build script
3 #
4 # Copyright 2011 O.S. Systems Software Ltda.
5 # Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
6 # Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 #     http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19
20 cmake_minimum_required(VERSION 2.6)
21 project(FreeRDP C)
22 set(CMAKE_COLOR_MAKEFILE ON)
23
24 # Include cmake modules
25 include(CheckIncludeFiles)
26 include(CheckLibraryExists)
27 include(FindPkgConfig)
28 include(TestBigEndian)
29
30 # Include our extra modules
31 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/)
32
33 include(AutoVersioning)
34 include(ConfigOptions)
35 include(FindOptionalPackage)
36 include(CheckCCompilerFlag)
37 include(GNUInstallDirsWrapper)
38
39 # Soname versioning
40 set(FREERDP_VERSION_MAJOR "1")
41 set(FREERDP_VERSION_MINOR "0")
42 set(FREERDP_VERSION_REVISION "1")
43 set(FREERDP_VERSION "${FREERDP_VERSION_MAJOR}.${FREERDP_VERSION_MINOR}")
44 set(FREERDP_VERSION_FULL "${FREERDP_VERSION}.${FREERDP_VERSION_REVISION}")
45
46 # Default to release build type
47 if(NOT CMAKE_BUILD_TYPE)
48    set(CMAKE_BUILD_TYPE "Release")
49 endif()
50
51 # build shared libs
52 if(NOT BUILD_SHARED_LIBS)
53     set(BUILD_SHARED_LIBS ON)
54 endif()
55
56 # Compiler-specific flags
57 if(CMAKE_COMPILER_IS_GNUCC)
58         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
59         CHECK_C_COMPILER_FLAG (-Wno-unused-result Wno-unused-result)
60         if(Wno-unused-result)
61                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-result")
62         endif()
63         CHECK_C_COMPILER_FLAG (-Wno-unused-but-set-variable Wno-unused-but-set-variable)
64         if(Wno-unused-but-set-variable)
65                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-but-set-variable")
66         endif()
67         if(CMAKE_BUILD_TYPE STREQUAL "Release")
68                 set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG")
69                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
70         endif()
71         if(WITH_SSE2_TARGET)
72                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
73         endif()
74 endif()
75
76 if(MSVC)
77         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd /MT")
78         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /O2 /Ob2")
79         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_X86_")
80         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_UNICODE")
81         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFREERDP_EXPORTS")
82         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
83         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32_LEAN_AND_MEAN")
84         SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
85         SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
86 endif()
87
88 # Include files
89 check_include_files(sys/param.h HAVE_SYS_PARAM_H)
90 check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
91 check_include_files(netdb.h HAVE_NETDB_H)
92 check_include_files(fcntl.h HAVE_FCNTL_H)
93 check_include_files(unistd.h HAVE_UNISTD_H)
94 check_include_files(limits.h HAVE_LIMITS_H)
95 check_include_files(stdint.h HAVE_STDINT_H)
96 check_include_files(stdbool.h HAVE_STDBOOL_H)
97 check_include_files(inttypes.h HAVE_INTTYPES_H)
98
99 # Libraries that we have a hard dependency on
100 find_required_package(OpenSSL)
101
102 # Mac OS X
103 if(APPLE)
104         include_directories(/opt/local/include)
105         link_directories(/opt/local/lib)
106         set(CMAKE_SHARED_LINKER_FLAGS "-mmacosx-version-min=10.4")
107 endif()
108
109 if(NOT WIN32)
110         find_required_package(ZLIB)
111         find_optional_package(PulseAudio)
112         find_optional_package(PCSC)
113         find_suggested_package(Cups)
114
115         if(NOT APPLE)
116                 find_suggested_package(FFmpeg)
117                 find_suggested_package(ALSA)
118         else(NOT APPLE)
119                 find_optional_package(FFmpeg)
120         endif()
121 endif()
122
123 # Endian
124 test_big_endian(BIG_ENDIAN)
125
126 # Path to put keymaps
127 set(FREERDP_KEYMAP_PATH "${CMAKE_INSTALL_PREFIX}/freerdp/keymaps")
128
129 # Path to put plugins
130 set(FREERDP_PLUGIN_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/freerdp")
131
132 # Include directories
133 include_directories(${CMAKE_CURRENT_BINARY_DIR})
134 include_directories(${CMAKE_SOURCE_DIR}/include)
135
136 # Configure files
137 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
138
139 # Generate pkg-config
140 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp.pc.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp.pc @ONLY)
141 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freerdp.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
142
143 # Build CUnit
144 find_optional_package(CUnit)
145 if(WITH_CUNIT)
146    enable_testing()
147    add_subdirectory(cunit)
148 endif()
149
150 # Sub-directories
151 add_subdirectory(include)
152 add_subdirectory(libfreerdp-utils)
153
154 if(NOT WIN32)
155         add_subdirectory(libfreerdp-kbd)
156 endif()
157
158 add_subdirectory(libfreerdp-gdi)
159 add_subdirectory(libfreerdp-rail)
160 add_subdirectory(libfreerdp-cache)
161 add_subdirectory(libfreerdp-codec)
162 add_subdirectory(libfreerdp-channels)
163 add_subdirectory(libfreerdp-core)
164
165 if(NOT WIN32)
166         add_subdirectory(channels)
167 endif()
168
169 option(WITH_CLIENT "Build client binaries" ON)
170 if(WITH_CLIENT)
171         add_subdirectory(client)
172 endif()
173
174 option(WITH_SERVER "Build server binaries" OFF)
175 if(WITH_SERVER)
176         add_subdirectory(server)
177 endif()
178
179 add_subdirectory(keymaps)
180
181 # Source package
182 set(CPACK_SOURCE_IGNORE_FILES "/\\\\.git/;/\\\\.gitignore;/CMakeCache.txt")
183
184 string(TOLOWER ${CMAKE_PROJECT_NAME} CMAKE_PROJECT_NAME_lower)
185 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME_lower}-${FREERDP_VERSION_FULL}")
186
187 include(CPack)