1 # Build Common Sourcecode Project, Agar.
2 # (C) 2014 K.Ohta <whatisthis.sowhat@gmail.com>
3 # This is part of , but license is apache 2.2,
4 # this part was written only me.
6 cmake_minimum_required (VERSION 2.8)
7 cmake_policy(SET CMP0011 NEW)
9 #set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake")
11 include(CheckFunctionExists)
13 if(USE_DEVICES_SHARED_LIB)
14 add_definitions(-DUSE_DEVICES_SHARED_LIB)
16 # Use cmake if enabled.
17 find_program(USE_CCACHE ccache)
19 SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
20 SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
22 if(NOT CSP_CROSS_BUILD)
23 #SET(CMAKE_FIND_ROOT_PATH /opt/Qt5.5.1/5.5/gcc_64 ${CMAKE_FIND_ROOT_PATH})
25 FIND_PACKAGE(Qt5Widgets REQUIRED)
26 FIND_PACKAGE(Qt5Core REQUIRED)
27 FIND_PACKAGE(Qt5Gui REQUIRED)
28 FIND_PACKAGE(Qt5OpenGL REQUIRED)
29 include_directories(${Qt5Widgets_INCLUDE_DIRS})
30 include_directories(${Qt5Core_INCLUDE_DIRS})
31 include_directories(${Qt5Gui_INCLUDE_DIRS})
32 include_directories(${Qt5OpenGL_INCLUDE_DIRS})
33 add_definitions(-D_USE_OPENGL -DUSE_OPENGL)
35 FIND_PACKAGE(Qt5Network REQUIRED)
36 include_directories(${Qt5Network_INCLUDE_DIRS})
40 set(USE_QT5_4_APIS OFF CACHE BOOL "Build with Qt5.4 (or later) APIs if you can.")
41 set(USE_GCC_OLD_ABI ON CACHE BOOL "Build with older GCC ABIs if you can.")
42 set(USE_SDL2 ON CACHE BOOL "Build with libSDL2. DIsable is building with libSDL1.")
43 set(USE_MOVIE_SAVER OFF CACHE BOOL "Save screen/audio as MP4 MOVIE. Needs libav .")
44 set(USE_MOVIE_LOADER OFF CACHE BOOL "Load movie from screen for some VMs. Needs libav .")
45 set(USE_LTO ON CACHE BOOL "Use link-time-optimization to build.")
47 # set_property(DIRECTORY PROPERTY INTERPROCEDURAL_OPTIMIZATION true)
49 # set_property(DIRECTORY PROPERTY INTERPROCEDURAL_OPTIMIZATION false)
52 add_definitions(-D_USE_QT5)
54 add_definitions(-D_UNICODE)
58 add_definitions(-D_USE_QT_5_4)
60 #add_definitions(-DQT_NO_VERSION_TAGGING)
64 add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
66 add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)
71 add_definitions(-DUSE_ZLIB)
72 include_directories(${ZLIB_INCLUDE_DIRS})
75 SET(CMAKE_AUTOMOC OFF)
77 SET(CMAKE_INCLUDE_CURRENT_DIR ON)
80 add_definitions(-D_USE_QT)
81 add_definitions(-DUSE_QT)
82 add_definitions(-DQT_MAJOR_VERSION=${Qt5Widgets_VERSION_MAJOR})
83 add_definitions(-DQT_MINOR_VERSION=${Qt5Widgets_VERSION_MINOR})
87 include_directories(${OPENMP_INCLUDE_PATH})
91 include_directories(${THREADS_INCLUDE_PATH})
93 include(FindPkgConfig)
97 add_definitions(-DUSE_LIBAV)
99 add_definitions(-DUSE_MOVIE_SAVER)
102 add_definitions(-DUSE_MOVIE_LOADER)
104 add_definitions(-D__STDC_CONSTANT_MACROS)
105 add_definitions(-D__STDC_FORMAT_MACROS)
107 set(USE_MOVIE_SAVER OFF)
108 set(USE_MOVIE_LOADER OFF)
109 set(LIBAV_LIBRARIES "")
112 if(CMAKE_CROSSCOMPILING)
113 include_directories(${SDL2_INCLUDE_DIRS})
115 pkg_search_module(SDL2 REQUIRED sdl2)
116 include_directories(${SDL2_INCLUDE_DIRS})
118 set(SDL_LIBS ${SDL2_LIBRARIES})
119 add_definitions(-DUSE_SDL2)
121 if(CMAKE_CROSSCOMPILING)
122 include_directories(${SDL_INCLUDE_DIRS})
123 set(SDL_LIBS ${SDL_LIBRARIES})
126 #pkg_search_module(SDL REQUIRED sdl)
127 #include_directories(${SDL_INCLUDE_DIRS})
128 include_directories(${SDL_INCLUDE_DIR})
129 set(SDL_LIBS ${SDL_LIBRARY})
133 set(SRC_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../src)
136 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
137 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
141 include_directories(${LIBAV_INCLUDE_DIRS})
144 add_definitions(-D_USE_QT5)
147 add_definitions(-D_USE_QT_5_4)
151 if(CMAKE_COMPILER_IS_GNUCC)
152 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flax-vector-conversions")
155 if(CMAKE_COMPILER_IS_GNUCXX)
156 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -flax-vector-conversions")
160 check_function_exists("nanosleep" HAVE_NANOSLEEP)
161 if(NOT HAVE_NANOSLEEP)
162 check_library_exists("rt" "nanosleep" "" LIB_RT_HAS_NANOSLEEP)
163 endif(NOT HAVE_NANOSLEEP)
165 if(LIB_RT_HAS_NANOSLEEP)
166 add_target_library(${EXEC_TARGET} rt)
167 endif(LIB_RT_HAS_NANOSLEEP)
169 if(HAVE_NANOSLEEP OR LIB_RT_HAS_NANOSLEEP)
170 add_definitions(-DHAVE_NANOSLEEP)
171 endif(HAVE_NANOSLEEP OR LIB_RT_HAS_NANOSLEEP)
174 set(SRC_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../src)
177 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
178 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
181 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/common)
182 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/gui)
183 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt)
184 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src)