1
0
Fork 0
forked from suyu/suyu

CMake cleanup

Several cleanups to the buildsystem:
 - Do better factoring of common libs between platforms.
 - Add support to building on Windows.
 - Remove Qt4 support.
 - Re-sort file lists and add missing headers.
This commit is contained in:
Yuri Kunde Schlesner 2014-08-23 22:22:05 -03:00
parent 523385955c
commit 45976da975
9 changed files with 271 additions and 156 deletions

View file

@ -8,10 +8,16 @@ if [ "$TRAVIS_OS_NAME" = linux -o -z "$TRAVIS_OS_NAME" ]; then
sudo apt-get -qq update
sudo apt-get -qq install g++-4.8 xorg-dev libglu1-mesa-dev libxcursor-dev
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90
git clone https://github.com/glfw/glfw.git
(
git clone https://github.com/glfw/glfw.git --branch 3.0.4 --depth 1
mkdir glfw/build && cd glfw/build
cmake .. && make && sudo make install
cd -
cmake .. && make -j2 && sudo make install
)
sudo apt-get install lib32stdc++6
sudo mkdir -p /usr/local
curl http://www.cmake.org/files/v2.8/cmake-2.8.11-Linux-i386.tar.gz \
| sudo tar -xz -C /usr/local --strip-components=1
elif [ "$TRAVIS_OS_NAME" = osx ]; then
brew tap homebrew/versions
brew install qt5 glfw3 pkgconfig

View file

@ -1,78 +1,131 @@
cmake_minimum_required(VERSION 2.8.7)
# CMake 2.8.11 required for Qt5 settings to be applied automatically on
# dependent libraries.
cmake_minimum_required(VERSION 2.8.11)
project(citra)
SET(CXX_COMPILE_FLAGS "-std=c++11")
# silence some spam
add_definitions(-Wno-attributes)
if (NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes")
else()
# Silence deprecation warnings
add_definitions(/D_CRT_SECURE_NO_WARNINGS)
endif()
add_definitions(-DSINGLETHREADED)
add_definitions(${CXX_COMPILE_FLAGS})
find_package(PNG)
if (PNG_FOUND)
add_definitions(-DHAVE_PNG)
endif ()
# dependency checking
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules/")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeTests)
include(FindX11 REQUIRED)
find_package(PkgConfig REQUIRED)
# Include bundled CMake modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/externals/cmake-modules")
find_package(OpenGL REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
# corefoundation is required only on OSX
IF (APPLE)
FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
ENDIF (APPLE)
#external includes
include_directories(${GLFW_INCLUDE_DIRS})
include_directories(${OPENGL_INCLUDE_DIR})
# workaround for GLFW linking on OSX
link_directories(${GLFW_LIBRARY_DIRS})
option(DISABLE_QT "Disable Qt GUI" OFF)
option(USE_QT5 "Use Qt5 when available" ON)
if (NOT DISABLE_QT)
if(USE_QT5)
find_package(Qt5Gui)
find_package(Qt5Widgets)
find_package(Qt5OpenGL)
if(NOT Qt5Gui_FOUND OR NOT Qt5Widgets_FOUND OR NOT Qt5OpenGL_FOUND)
message("Qt5 libraries not found! Using Qt4 instead.")
set(USE_QT5 OFF)
endif()
endif()
if(NOT USE_QT5)
include(FindQt4)
find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL)
if(QT4_FOUND AND QT_QTCORE_FOUND AND QT_QTGUI_FOUND AND QT_QTOPENGL_FOUND)
include(${QT_USE_FILE})
include_directories(${QT_INCLUDES})
option(ENABLE_GLFW "Enable the GLFW frontend" ON)
if (ENABLE_GLFW)
if (WIN32)
# Detect toolchain and platform
if (MSVC)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(TMP_ARCH "x64")
else()
message("Qt4 libraries not found! Disabling Qt GUI")
set(DISABLE_QT ON)
endif()
set(TMP_ARCH "Win32")
endif()
if (MSVC11) # Visual C++ 2012
set(TMP_TOOLSET "v110")
elseif (MSVC12) # Visual C++ 2013
set(TMP_TOOLSET "v120")
else()
set(TMP_TOOLSET "UNSUPPORTED")
message(SEND_ERROR "We don't supply GLFW binaries for your version of MSVC, you might have to provide them yourself.")
endif()
set(TMP_TOOLSET "msvc_${TMP_TOOLSET}-${TMP_ARCH}")
else()
# Assume mingw
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(TMP_ARCH "x86_64")
else()
set(TMP_ARCH "i686")
endif()
set(TMP_TOOLSET "mingw-${TMP_ARCH}")
endif()
set(GLFW_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/externals/glfw-3.0.4.bin")
set(GLFW_INCLUDE_DIRS "${GLFW_PREFIX}/include" CACHE PATH "Path to GLFW3 headers")
set(GLFW_LIBRARY_DIRS "${GLFW_PREFIX}/lib-${TMP_TOOLSET}" CACHE PATH "Path to GLFW3 libraries")
# Clean up after ourselves
unset(TMP_TOOLSET)
unset(TMP_ARCH)
set(GLFW_LIBRARIES glfw3)
else()
find_package(X11 REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
endif()
include_directories(${GLFW_INCLUDE_DIRS})
link_directories(${GLFW_LIBRARY_DIRS})
endif()
IF (APPLE)
# CoreFoundation is required only on OSX
FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
ENDIF (APPLE)
option(ENABLE_QT "Enable the Qt frontend" ON)
option(CITRA_FORCE_QT4 "Use Qt4 even if Qt5 is available." OFF)
if (ENABLE_QT)
# Set CMAKE_PREFIX_PATH if QTDIR is defined in the environment This allows CMake to
# automatically find the Qt packages on Windows
if (DEFINED ENV{QTDIR})
list(APPEND CMAKE_PREFIX_PATH "$ENV{QTDIR}")
endif()
if (NOT CITRA_FORCE_QT4)
find_package(Qt5 COMPONENTS Widgets OpenGL)
set(CITRA_QT_LIBS Qt5::Widgets Qt5::OpenGL)
endif()
if (CITRA_FORCE_QT4 OR NOT Qt5_FOUND)
# Try to fallback to Qt4
find_package(Qt4 REQUIRED COMPONENTS QtGui QtOpenGL)
set(CITRA_QT_LIBS Qt4::QtGui Qt4::QtOpenGL)
endif()
endif()
# This function should be passed a list of all files in a target. It will automatically generate
# file groups following the directory hierarchy, so that the layout of the files in IDEs matches the
# one in the filesystem.
function(create_directory_groups)
# Place any files that aren't in the source list in a separate group so that they don't get in
# the way.
source_group("Other Files" REGULAR_EXPRESSION ".")
foreach(file_name ${ARGV})
get_filename_component(dir_name "${file_name}" PATH)
# Group names use '\' as a separator even though the entire rest of CMake uses '/'...
string(REPLACE "/" "\\" group_name "${dir_name}")
source_group("${group_name}" FILES "${file_name}")
endforeach()
endfunction()
# generate git revision information
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REF_SPEC GIT_REV)
git_describe(GIT_DESC --always --long --dirty)
git_branch_name(GIT_BRANCH)
# internal includes
include_directories(src)
# process subdirectories
if(NOT DISABLE_QT)
if(ENABLE_QT)
include_directories(externals/qhexedit)
add_subdirectory(externals/qhexedit)
endif()

View file

@ -5,14 +5,17 @@ set(SRCS
commands.cpp
qhexedit.cpp
qhexedit_p.cpp
xbytearray.cpp)
xbytearray.cpp
)
set(HEADERS
commands.h
qhexedit.h
qhexedit_p.h)
qhexedit_p.h
xbytearray.h
)
create_directory_groups(${SRCS} ${HEADERS})
add_library(qhexedit STATIC ${SRCS} ${HEADERS})
if(USE_QT5)
target_link_libraries(qhexedit Qt5::Core Qt5::Widgets)
endif()
target_link_libraries(qhexedit ${CITRA_QT_LIBS})

View file

@ -1,9 +1,12 @@
# Enable modules to include each other's files
include_directories(.)
add_subdirectory(common)
add_subdirectory(core)
add_subdirectory(video_core)
if (ENABLE_GLFW)
add_subdirectory(citra)
add_subdirectory(citra_qt)
if(QT4_FOUND AND QT_QTCORE_FOUND AND QT_QTGUI_FOUND AND QT_QTOPENGL_FOUND AND NOT DISABLE_QT4)
#add_subdirectory(citra_qt)
endif()
if (ENABLE_QT)
add_subdirectory(citra_qt)
endif()

View file

@ -1,6 +1,13 @@
set(SRCS citra.cpp
emu_window/emu_window_glfw.cpp)
set(HEADERS resource.h)
set(SRCS
emu_window/emu_window_glfw.cpp
citra.cpp
)
set(HEADERS
emu_window/emu_window_glfw.h
resource.h
)
create_directory_groups(${SRCS} ${HEADERS})
# NOTE: This is a workaround for CMake bug 0006976 (missing X11_xf86vmode_LIB variable)
if (NOT X11_xf86vmode_LIB)
@ -8,11 +15,16 @@ if (NOT X11_xf86vmode_LIB)
endif()
add_executable(citra ${SRCS} ${HEADERS})
target_link_libraries(citra core common video_core)
target_link_libraries(citra ${OPENGL_gl_LIBRARY} ${GLFW_LIBRARIES})
if (APPLE)
target_link_libraries(citra core common video_core iconv pthread ${COREFOUNDATION_LIBRARY} ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES})
else()
target_link_libraries(citra core common video_core pthread X11 Xxf86vm Xi Xcursor ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} rt ${X11_Xrandr_LIB} ${X11_xv86vmode_LIB} ${PNG_LIBRARIES})
target_link_libraries(citra iconv pthread ${COREFOUNDATION_LIBRARY})
elseif (WIN32)
target_link_libraries(citra winmm)
else() # Unix
target_link_libraries(citra pthread rt)
target_link_libraries(citra ${X11_X11_LIB} ${X11_Xi_LIB} ${X11_Xcursor_LIB} ${X11_Xrandr_LIB} ${X11_xv86vmode_LIB})
endif()
#install(TARGETS citra RUNTIME DESTINATION ${bindir})

View file

@ -2,54 +2,61 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SRCS
bootmanager.cpp
config/controller_config.cpp
config/controller_config_util.cpp
debugger/callstack.cpp
debugger/disassembler.cpp
debugger/graphics.cpp
debugger/graphics_cmdlists.cpp
debugger/ramview.cpp
debugger/registers.cpp
bootmanager.cpp
hotkeys.cpp
main.cpp
config/controller_config.cpp
config/controller_config_util.cpp)
)
set(HEADERS
bootmanager.hxx
config/controller_config.hxx
config/controller_config_util.hxx
debugger/callstack.hxx
debugger/disassembler.hxx
debugger/graphics.hxx
debugger/graphics_cmdlists.hxx
debugger/ramview.hxx
debugger/registers.hxx
bootmanager.hxx
hotkeys.hxx
main.hxx
version.h
config/controller_config.hxx
config/controller_config_util.hxx)
)
set(UIS
config/controller_config.ui
debugger/callstack.ui
debugger/disassembler.ui
debugger/registers.ui
hotkeys.ui
main.ui
config/controller_config.ui)
)
if(USE_QT5)
create_directory_groups(${SRCS} ${HEADERS} ${UIS})
if (Qt5_FOUND)
qt5_wrap_ui(UI_HDRS ${UIS})
else()
qt4_wrap_ui(UI_HDRS ${UIS})
endif()
add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS})
if(APPLE)
set(ICONV_LIBRARY iconv)
else()
set(RT_LIBRARY rt)
endif()
target_link_libraries(citra-qt core common video_core qhexedit)
target_link_libraries(citra-qt ${OPENGL_gl_LIBRARY} ${CITRA_QT_LIBS})
target_link_libraries(citra-qt core common video_core qhexedit ${ICONV_LIBRARY} ${COREFOUNDATION_LIBRARY} ${QT_LIBRARIES} ${OPENGL_LIBRARIES} ${RT_LIBRARY} ${PNG_LIBRARIES})
if(USE_QT5)
target_link_libraries(citra-qt Qt5::Gui Qt5::Widgets Qt5::OpenGL)
if (APPLE)
target_link_libraries(citra-qt iconv ${COREFOUNDATION_LIBRARY})
elseif (WIN32)
target_link_libraries(citra-qt winmm)
else() # Unix
target_link_libraries(citra-qt rt)
endif()
#install(TARGETS citra-qt RUNTIME DESTINATION ${bindir})

View file

@ -1,6 +1,8 @@
# Generate cpp with Git revision from template
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in" "${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp" @ONLY)
set(SRCS break_points.cpp
set(SRCS
break_points.cpp
console_listener.cpp
extended_trace.cpp
file_search.cpp
@ -12,23 +14,25 @@ set(SRCS break_points.cpp
memory_util.cpp
misc.cpp
msg_handler.cpp
string_util.cpp
scm_rev.cpp
string_util.cpp
symbols.cpp
thread.cpp
timer.cpp
utf8.cpp)
utf8.cpp
)
set(HEADERS atomic.h
set(HEADERS
atomic.h
atomic_gcc.h
atomic_win32.h
bit_field.h
break_points.h
chunk_file.h
common.h
common_funcs.h
common_paths.h
common_types.h
common.h
console_listener.h
cpu_detect.h
debug_interface.h
@ -37,10 +41,11 @@ set(HEADERS atomic.h
fifo_queue.h
file_search.h
file_util.h
fixed_size_queue.h
hash.h
linear_disk_cache.h
log_manager.h
log.h
log_manager.h
math_util.h
mem_arena.h
memory_util.h
@ -54,8 +59,12 @@ set(HEADERS atomic.h
swap.h
symbols.h
thread.h
thread_queue_list.h
thunk.h
timer.h
utf8.h)
utf8.h
)
create_directory_groups(${SRCS} ${HEADERS})
add_library(common STATIC ${SRCS} ${HEADERS})

View file

@ -1,14 +1,18 @@
set(SRCS core.cpp
core_timing.cpp
loader/elf.cpp
loader/loader.cpp
loader/ncch.cpp
mem_map.cpp
mem_map_funcs.cpp
system.cpp
set(SRCS
arm/disassembler/arm_disasm.cpp
arm/disassembler/load_symbol_map.cpp
file_sys/archive_romfs.cpp
arm/interpreter/mmu/arm1176jzf_s_mmu.cpp
arm/interpreter/mmu/cache.cpp
arm/interpreter/mmu/maverick.cpp
arm/interpreter/mmu/rb.cpp
arm/interpreter/mmu/sa_mmu.cpp
arm/interpreter/mmu/tlb.cpp
arm/interpreter/mmu/wb.cpp
arm/interpreter/mmu/xscale_copro.cpp
arm/interpreter/vfp/vfp.cpp
arm/interpreter/vfp/vfpdouble.cpp
arm/interpreter/vfp/vfpinstr.cpp
arm/interpreter/vfp/vfpsingle.cpp
arm/interpreter/arm_interpreter.cpp
arm/interpreter/armcopro.cpp
arm/interpreter/armemu.cpp
@ -18,22 +22,7 @@ set(SRCS core.cpp
arm/interpreter/armsupp.cpp
arm/interpreter/armvirt.cpp
arm/interpreter/thumbemu.cpp
arm/interpreter/vfp/vfp.cpp
arm/interpreter/vfp/vfpdouble.cpp
arm/interpreter/vfp/vfpinstr.cpp
arm/interpreter/vfp/vfpsingle.cpp
arm/interpreter/mmu/arm1176jzf_s_mmu.cpp
arm/interpreter/mmu/cache.cpp
arm/interpreter/mmu/maverick.cpp
arm/interpreter/mmu/rb.cpp
arm/interpreter/mmu/sa_mmu.cpp
arm/interpreter/mmu/tlb.cpp
arm/interpreter/mmu/wb.cpp
arm/interpreter/mmu/xscale_copro.cpp
hle/hle.cpp
hle/config_mem.cpp
hle/coprocessor.cpp
hle/svc.cpp
file_sys/archive_romfs.cpp
hle/kernel/address_arbiter.cpp
hle/kernel/archive.cpp
hle/kernel/event.cpp
@ -48,27 +37,26 @@ set(SRCS core.cpp
hle/service/ndm.cpp
hle/service/service.cpp
hle/service/srv.cpp
hle/config_mem.cpp
hle/coprocessor.cpp
hle/hle.cpp
hle/svc.cpp
hw/gpu.cpp
hw/hw.cpp
hw/ndma.cpp)
hw/ndma.cpp
loader/elf.cpp
loader/loader.cpp
loader/ncch.cpp
core.cpp
core_timing.cpp
mem_map.cpp
mem_map_funcs.cpp
system.cpp
)
set(HEADERS core.h
core_timing.h
loader/elf.h
loader/loader.h
loader/ncch.h
mem_map.h
system.h
set(HEADERS
arm/disassembler/arm_disasm.h
arm/disassembler/load_symbol_map.h
arm/interpreter/arm_interpreter.h
arm/interpreter/arm_regformat.h
arm/interpreter/armcpu.h
arm/interpreter/armdefs.h
arm/interpreter/armemu.h
arm/interpreter/armmmu.h
arm/interpreter/armos.h
arm/interpreter/skyeye_defs.h
arm/interpreter/mmu/arm1176jzf_s_mmu.h
arm/interpreter/mmu/cache.h
arm/interpreter/mmu/rb.h
@ -78,27 +66,48 @@ set(HEADERS core.h
arm/interpreter/vfp/asm_vfp.h
arm/interpreter/vfp/vfp.h
arm/interpreter/vfp/vfp_helper.h
arm/interpreter/arm_interpreter.h
arm/interpreter/arm_regformat.h
arm/interpreter/armcpu.h
arm/interpreter/armdefs.h
arm/interpreter/armemu.h
arm/interpreter/armmmu.h
arm/interpreter/armos.h
arm/interpreter/skyeye_defs.h
arm/arm_interface.h
file_sys/archive.h
file_sys/archive_romfs.h
hle/config_mem.h
hle/coprocessor.h
hle/hle.h
hle/svc.h
hle/kernel/address_arbiter.h
hle/kernel/archive.h
hle/kernel/event.h
hle/kernel/kernel.h
hle/kernel/mutex.h
hle/kernel/shared_memory.h
hle/kernel/thread.h
hle/function_wrappers.h
hle/service/apt.h
hle/service/fs.h
hle/service/gsp.h
hle/service/hid.h
hle/service/ndm.h
hle/service/service.h
hle/service/srv.h
hle/config_mem.h
hle/coprocessor.h
hle/function_wrappers.h
hle/hle.h
hle/svc.h
hw/gpu.h
hw/hw.h
hw/ndma.h)
hw/ndma.h
loader/elf.h
loader/loader.h
loader/ncch.h
core.h
core_timing.h
mem_map.h
system.h
)
create_directory_groups(${SRCS} ${HEADERS})
add_library(core STATIC ${SRCS} ${HEADERS})

View file

@ -1,29 +1,42 @@
set(SRCS clipper.cpp
set(SRCS
renderer_opengl/generated/gl_3_2_core.c
renderer_opengl/renderer_opengl.cpp
renderer_opengl/gl_shader_util.cpp
debug_utils/debug_utils.cpp
clipper.cpp
command_processor.cpp
primitive_assembly.cpp
rasterizer.cpp
utils.cpp
vertex_shader.cpp
video_core.cpp
renderer_opengl/generated/gl_3_2_core.c
renderer_opengl/renderer_opengl.cpp
renderer_opengl/gl_shader_util.cpp
debug_utils/debug_utils.cpp)
)
set(HEADERS clipper.h
command_processor.h
math.h
primitive_assembly.h
rasterizer.h
utils.h
video_core.h
renderer_base.h
vertex_shader.h
video_core.h
set(HEADERS
debug_utils/debug_utils.h
renderer_opengl/generated/gl_3_2_core.h
renderer_opengl/renderer_opengl.h
renderer_opengl/gl_shader_util.h
renderer_opengl/gl_shaders.h
debug_utils/debug_utils.h)
renderer_opengl/renderer_opengl.h
clipper.h
command_processor.h
gpu_debugger.h
math.h
pica.h
primitive_assembly.h
rasterizer.h
renderer_base.h
utils.h
vertex_shader.h
video_core.h
)
create_directory_groups(${SRCS} ${HEADERS})
add_library(video_core STATIC ${SRCS} ${HEADERS})
if (PNG_FOUND)
target_link_libraries(video_core ${PNG_LIBRARIES})
include_directories(${PNG_INCLUDE_DIRS})
add_definitions(${PNG_DEFINITIONS})
endif()