Merge pull request #124 from mfleisz/master
[platform/upstream/freerdp.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
38 # Soname versioning - 0.0.0 since it is not being managed yet
39 set(FREERDP_VERSION_MAJOR "0")
40 set(FREERDP_VERSION_MINOR "0")
41 set(FREERDP_VERSION_PATCH "0")
42 set(FREERDP_VERSION "${FREERDP_VERSION_MAJOR}.${FREERDP_VERSION_MINOR}")
43 set(FREERDP_VERSION_FULL "${FREERDP_VERSION}.${FREERDP_VERSION_PATCH}")
44
45 # Default to release build type
46 if(NOT CMAKE_BUILD_TYPE)
47    set(CMAKE_BUILD_TYPE "Release")
48 endif()
49
50 # Set default libdir
51 if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
52         set(CMAKE_INSTALL_LIBDIR "lib")
53 endif()
54
55 # Set default bindir
56 if(NOT DEFINED CMAKE_INSTALL_BINDIR)
57         set(CMAKE_INSTALL_BINDIR "bin")
58 endif()
59
60 # build shared libs
61 if(NOT BUILD_SHARED_LIBS)
62     set(BUILD_SHARED_LIBS ON)
63 endif()
64
65 # Compiler-specific flags
66 if(CMAKE_COMPILER_IS_GNUCC)
67         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
68         CHECK_C_COMPILER_FLAG (-Wno-unused-but-set-variable Wno-unused-but-set-variable)
69         if(Wno-unused-but-set-variable)
70                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-but-set-variable")
71         endif()
72         if(CMAKE_BUILD_TYPE STREQUAL "Release")
73                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
74         endif()
75         if(WITH_SSE2)
76                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
77         endif()
78 endif()
79
80 if(MSVC)
81         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd /MT")
82         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /O2 /Ob2")
83         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_X86_")
84         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_UNICODE")
85         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFREERDP_EXPORTS")
86         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
87         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32_LEAN_AND_MEAN")
88         SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
89         SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
90 endif()
91
92 # Include files
93 check_include_files(sys/param.h HAVE_SYS_PARAM_H)
94 check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
95 check_include_files(netdb.h HAVE_NETDB_H)
96 check_include_files(fcntl.h HAVE_FCNTL_H)
97 check_include_files(unistd.h HAVE_UNISTD_H)
98
99 # Libraries that we have a hard dependency on
100 find_required_package(OpenSSL)
101
102 if(NOT WIN32)
103         find_required_package(ZLIB)
104         find_suggested_package(ALSA)
105         find_optional_package(PulseAudio)
106         find_suggested_package(Cups)
107         find_suggested_package(FFmpeg)
108 endif()
109
110 # Endian
111 test_big_endian(BIG_ENDIAN)
112
113 # Path to put keymaps
114 set(FREERDP_KEYMAP_PATH "${CMAKE_INSTALL_PREFIX}/freerdp/keymaps")
115
116 # Path to put plugins
117 set(FREERDP_PLUGIN_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/freerdp")
118
119 # Include directories
120 include_directories(${CMAKE_CURRENT_BINARY_DIR})
121 include_directories(${CMAKE_SOURCE_DIR}/include)
122
123 # Configure files
124 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
125
126 # Mac OS X
127 if(APPLE)
128         include_directories(/opt/local/include)
129         link_directories(/opt/local/lib)
130 endif()
131
132 # Build CUnit
133 find_optional_package(CUnit)
134 if(CUNIT_FOUND)
135    enable_testing()
136    add_subdirectory(cunit)
137 endif()
138
139 # Sub-directories
140 add_subdirectory(include)
141 add_subdirectory(libfreerdp-utils)
142
143 if(NOT WIN32)
144         add_subdirectory(libfreerdp-kbd)
145 endif()
146
147 add_subdirectory(libfreerdp-gdi)
148 add_subdirectory(libfreerdp-rail)
149 add_subdirectory(libfreerdp-cache)
150 add_subdirectory(libfreerdp-common)
151 add_subdirectory(libfreerdp-chanman)
152 add_subdirectory(libfreerdp-core)
153 add_subdirectory(libfreerdp-rfx)
154
155 if(NOT WIN32)
156         add_subdirectory(channels)
157 endif()
158
159 add_subdirectory(client)
160 add_subdirectory(server)
161 add_subdirectory(keymaps)