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