1 # Set configuration for building XM7/SDL.
2 # (C) 2014 K.Ohta <whatisthis.sowhat@gmail.com>
3 # This is part of XM7/SDL, but license is apache 2.2,
4 # this part was written only me.
6 include(CheckFunctionExists)
9 #set(ADDITIONAL_MAKE_CLEAN_FILES *.dwo *.obj)
11 if(USE_DEVICES_SHARED_LIB)
12 add_definitions(-DUSE_SHARED_DLL)
13 add_definitions(-DUSE_SHARED_UI_DLL)
14 add_definitions(-DUSE_SHARED_DEVICES_DLL)
16 # libcpu_newdev/i386.cpp
17 # libcpu_newdev/libcpu_i386/i386_real.cpp
18 # libcpu_newdev/libcpu_i386/i386op16_real.cpp
19 # libcpu_newdev/libcpu_i386/i386dasm.cpp
34 set(I386_CPPS i386.cpp)
35 set(MC6809_CPPS mc6809_base.cpp mc6809.cpp)
36 set(MCS48_CPPS mcs48_base.cpp mcs48.cpp)
37 set(IX86_CPPS i86.cpp)
38 set(Z80_CPPS z80_base.cpp z80.cpp)
39 set(VMFILES ${VMFILES} ${VMFILES_LIB})
43 set(VMFILES ${VMFILES} ${IX86_CPPS})
46 set(VMFILES ${VMFILES} i286.cpp)
49 set(VMFILES ${VMFILES} z80.cpp)
52 set(VMFILES ${VMFILES} ${MC6809_CPPS})
55 set(VMFILES ${VMFILES} ${MCS48_CPPS})
58 set(VMFILES ${VMFILES} ${Z80_CPPS})
61 if(DEFINED QT5_ROOT_PATH)
62 SET(CMAKE_FIND_ROOT_PATH ${QT5_ROOT_PATH} ${CMAKE_FIND_ROOT_PATH})
65 # Use ccache if enabled.
66 find_program(USE_CCACHE ccache)
68 SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
69 # SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
72 FIND_PACKAGE(Qt5Core REQUIRED)
74 FIND_PACKAGE(Qt5Widgets REQUIRED)
76 FIND_PACKAGE(Qt5Gui REQUIRED)
77 FIND_PACKAGE(Qt5OpenGL REQUIRED)
78 include_directories(${Qt5Widgets_INCLUDE_DIRS})
79 include_directories(${Qt5Core_INCLUDE_DIRS})
80 include_directories(${Qt5Gui_INCLUDE_DIRS})
81 include_directories(${Qt5OpenGL_INCLUDE_DIRS})
82 add_definitions(-D_USE_OPENGL -DUSE_OPENGL)
84 FIND_PACKAGE(Qt5Network REQUIRED)
85 include_directories(${Qt5Network_INCLUDE_DIRS})
89 set(USE_QT5_4_APIS OFF CACHE BOOL "Build with Qt5.4 (or later) APIs if you can.")
90 set(USE_GCC_OLD_ABI ON CACHE BOOL "Build with older GCC ABIs if you can.")
91 set(USE_SDL2 ON CACHE BOOL "Build with libSDL2. DIsable is building with libSDL1.")
92 set(USE_MOVIE_SAVER OFF CACHE BOOL "Save screen/audio as MP4 MOVIE. Needs libav .")
93 set(USE_MOVIE_LOADER OFF CACHE BOOL "Load movie from screen for some VMs. Needs libav .")
94 set(USE_LTO ON CACHE BOOL "Use link-time-optimization to build.")
97 # set_property(DIRECTORY PROPERTY INTERPROCEDURAL_OPTIMIZATION true)
99 # set_property(DIRECTORY PROPERTY INTERPROCEDURAL_OPTIMIZATION false)
102 add_definitions(-D_USE_QT5)
105 add_definitions(-D_USE_QT_5_4)
107 #add_definitions(-DQT_NO_VERSION_TAGGING)
111 add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
113 add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)
116 SET(CMAKE_AUTOMOC OFF)
117 SET(CMAKE_AUTORCC ON)
118 SET(CMAKE_INCLUDE_CURRENT_DIR ON)
120 add_definitions(-D_USE_QT)
121 add_definitions(-DUSE_QT)
122 add_definitions(-DQT_MAJOR_VERSION=${Qt5Widgets_VERSION_MAJOR})
123 add_definitions(-DQT_MINOR_VERSION=${Qt5Widgets_VERSION_MINOR})
128 include_directories(${OPENMP_INCLUDE_PATH})
130 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
131 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
135 find_package(Threads)
136 include_directories(${THREADS_INCLUDE_PATH})
138 include(FindPkgConfig)
142 execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD OUTPUT_VARIABLE __tstr)
143 string(FIND ${__tstr} "fatal" __notfound)
144 string(REPLACE "\n" "" __tstr2 ${__tstr})
145 if(${__notfound} EQUAL -1)
146 add_definitions(-D__GIT_REPO_VERSION=\"${__tstr2}\")
148 add_definitions(-U__GIT_REPO_VERSION)
152 string(TIMESTAMP __build_date "%b %d,%Y %H:%M:%S UTC" UTC)
153 add_definitions(-D__BUILD_DATE=\"${__build_date}\")
157 add_definitions(-DUSE_LIBAV)
159 add_definitions(-DUSE_MOVIE_SAVER)
162 add_definitions(-DUSE_MOVIE_LOADER)
164 add_definitions(-D__STDC_CONSTANT_MACROS)
165 add_definitions(-D__STDC_FORMAT_MACROS)
167 set(USE_MOVIE_SAVER OFF)
168 set(USE_MOVIE_LOADER OFF)
169 set(LIBAV_LIBRARIES "")
173 if(CMAKE_CROSSCOMPILING)
174 include_directories(${SDL2_INCLUDE_DIRS})
176 pkg_search_module(SDL2 REQUIRED sdl2)
177 include_directories(${SDL2_INCLUDE_DIRS})
179 set(SDL_LIBS ${SDL2_LIBRARIES})
180 add_definitions(-DUSE_SDL2)
182 if(CMAKE_CROSSCOMPILING)
183 include_directories(${SDL_INCLUDE_DIRS})
184 set(SDL_LIBS ${SDL_LIBRARIES})
187 #pkg_search_module(SDL REQUIRED sdl)
188 #include_directories(${SDL_INCLUDE_DIRS})
189 include_directories(${SDL_INCLUDE_DIR})
190 set(SDL_LIBS ${SDL_LIBRARY})
196 add_definitions(-DUSE_ZLIB)
197 include_directories(${ZLIB_INCLUDE_DIRS})
201 if(CMAKE_COMPILER_IS_GNUCC)
202 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flax-vector-conversions")
205 if(CMAKE_COMPILER_IS_GNUCXX)
206 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -flax-vector-conversions")
210 check_function_exists("nanosleep" HAVE_NANOSLEEP)
211 if(NOT HAVE_NANOSLEEP)
212 check_library_exists("rt" "nanosleep" "" LIB_RT_HAS_NANOSLEEP)
213 endif(NOT HAVE_NANOSLEEP)
215 if(LIB_RT_HAS_NANOSLEEP)
216 add_target_library(${EXEC_TARGET} rt)
217 endif(LIB_RT_HAS_NANOSLEEP)
219 if(HAVE_NANOSLEEP OR LIB_RT_HAS_NANOSLEEP)
220 add_definitions(-DHAVE_NANOSLEEP)
221 endif(HAVE_NANOSLEEP OR LIB_RT_HAS_NANOSLEEP)
224 set(SRC_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../src)
228 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
229 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
234 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/${VM_NAME})
236 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/fmgen)
238 # set(FMGEN_LIB vm_fmgen)
239 # set(FMGEN_LIB "-lCSPfmgen")
242 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/machines/${VM_NAME})
246 include_directories(${LIBAV_INCLUDE_DIRS})
249 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src)
250 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm)
251 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/common)
252 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/gui)
253 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt)
255 # add_subdirectory(../../src/qt/gui qt/gui)
257 #add_subdirectory(../../src/qt qt/osd)
258 add_subdirectory(../../src common)
259 add_subdirectory(../../src/vm vm/)
261 #add_custom_command(OUTPUT test.txt
262 # COMMAND grep ARGS -m 1 THIS_LIB_VERSION ${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/fmgen/CMakeLists.txt
263 # COMMAND sed ARGS "-r" "'s/.*THIS_VERSION\ //'"
264 # COMMAND sed ARGS "-r" "'s/\).*$//'"
270 set(DEBUG_LIBS qt_debugger)
271 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/debugger)
272 add_subdirectory(../../src/qt/debugger qt/debugger)
276 if(USE_DEVICES_SHARED_LIB)
279 set(VM_APPEND_LIBS fmgen ${VM_APPEND_LIBS})
282 set(VM_APPEND_LIBS ${VM_APPEND_LIBS})
320 ${ADDITIONAL_LIBRARIES}
323 #SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
324 #SET(CMAKE_C_ARCHIVE_FINISH true)
325 #SET(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
326 #SET(CMAKE_CXX_ARCHIVE_FINISH true)
328 add_definitions(-D_UNICODE)
336 ${ADDITIONAL_LIBRARIES}
338 if(USE_DEVICES_SHARED_LIB)
339 set(BUNDLE_LIBS ${BUNDLE_LIBS} -lCSPosd -lCSPcommon_vm -lCSPfmgen -lCSPgui -lCSPemu_utils -lCSPavio)
341 set(BUNDLE_LIBS ${BUNDLE_LIBS} -lCSPosd -lCSPgui -lCSPavio)
346 set(BUNDLE_LIBS ${BUNDLE_LIBS} ${QT_LIBRARIES} ${ZLIB_LIBRARIES})
349 set(BUNDLE_LIBS ${BUNDLE_LIBS} ${THREADS_LIBRARY})
352 if(USE_DEVICES_SHARED_LIB)
353 add_subdirectory(../../src/vm/${VM_NAME} vm/${VM_NAME})
354 add_subdirectory(../../src/qt/machines/${VM_NAME} qt/${VM_NAME})
355 add_subdirectory(../../src/qt/common qt/common)
357 add_subdirectory(../../src/vm/${VM_NAME} vm/${VM_NAME})
358 #add_subdirectory(../../src/vm vm/common)
359 #add_subdirectory(../../src common/common)
361 add_subdirectory(../../src/vm/fmgen vm/fmgen)
363 add_subdirectory(../../src/qt/machines/${VM_NAME} qt/${VM_NAME})
364 add_subdirectory(../../src/qt/common qt/common)