rpcsx/rpcs3/CMakeLists.txt

212 lines
7 KiB
CMake
Raw Normal View History

cmake_minimum_required(VERSION 2.8.12)
2014-06-06 03:33:24 +02:00
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules")
2014-06-06 03:33:24 +02:00
include(cotire)
2013-11-19 11:30:58 +01:00
project(rpcs3)
2015-01-15 04:03:25 +01:00
# Generate git-version.h at build time.
add_custom_target(GitVersion ALL
DEPENDS something_that_never_exists)
add_custom_command(OUTPUT something_that_never_exists
COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/git-version.cmake)
if(CMAKE_COMPILER_IS_GNUCXX)
2015-11-22 16:30:34 +01:00
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.0) # TODO: the same for (apple) clang
message(FATAL_ERROR "GCC ${CMAKE_CXX_COMPILER_VERSION} is too old.")
endif()
2014-07-10 21:07:46 +02:00
# Warnings
add_compile_options(-Wno-attributes -Wno-enum-compare -Wno-invalid-offsetof)
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
2015-10-13 22:32:25 +02:00
add_compile_options(-ftemplate-depth=1024)
if(APPLE)
add_compile_options(-stdlib=libc++)
endif()
if(WIN32)
add_compile_options(-pthread)
add_compile_options(-D__GXX_ABI_VERSION=1009)
endif()
endif()
if(WIN32)
add_definitions(-DUNICODE)
add_definitions(-D_WIN32_WINNT=0x0601)
endif()
if(NOT MSVC)
add_definitions(-DwxGUI)
if($ENV{CI})
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O1") # fix for travis gcc OoM crash. Might be fixed with the move to containers.
endif()
2015-11-26 09:13:33 +01:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fexceptions")
2016-05-13 16:01:48 +02:00
add_compile_options(-msse -msse2 -mcx16 -mssse3 -march=native)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:throwingNew /D _CRT_SECURE_NO_DEPRECATE=1 /D _CRT_NON_CONFORMING_SWPRINTFS=1 /D _SCL_SECURE_NO_WARNINGS=1")
2013-11-19 11:30:58 +01:00
endif()
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/opt/X11/include")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/opt/X11/include")
2014-07-12 23:10:49 +02:00
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
#on some Linux distros shm_unlink and similar functions are in librt only
set(ADDITIONAL_LIBS "rt" "X11")
2015-11-16 16:04:49 +01:00
elseif(UNIX OR NOT MSVC)
#it seems like glibc includes the iconv functions we use but other libc
#implementations like the one on OSX don't seem implement them
set(ADDITIONAL_LIBS "iconv")
else()
set(ADDITIONAL_LIBS "")
endif()
2015-08-07 23:53:39 +02:00
If(NOT RPCS3_SRC_DIR)
SET(RPCS3_SRC_DIR ${CMAKE_CURRENT_LIST_DIR})
Message("-- Initializing RPCS3_SRC_DIR=${RPCS3_SRC_DIR}")
Else()
Message("-- Using Custom RPCS3_SRC_DIR=${RPCS3_SRC_DIR}")
EndIf()
set(CMAKE_MODULE_PATH "${RPCS3_SRC_DIR}/cmake_modules")
if(NOT WIN32)
add_definitions(-DGL_GLEXT_PROTOTYPES)
add_definitions(-DGLX_GLXEXT_PROTOTYPES)
endif()
2014-02-21 17:13:57 +01:00
2014-03-21 15:07:05 +01:00
find_package(wxWidgets COMPONENTS core base net aui gl xml REQUIRED)
2015-11-16 16:04:49 +01:00
if(NOT MSVC)
if(APPLE)
find_path(GLEW_INCLUDE_DIR GL/glew.h
/usr/include/GL
/usr/openwin/share/include
/usr/openwin/include
/usr/X11R6/include
/usr/include/X11
/opt/graphics/OpenGL/include
/opt/graphics/OpenGL/contrib/libglew
/usr/local/include
)
endif()
find_package(GLEW REQUIRED)
find_package(ZLIB REQUIRED)
endif()
2014-02-21 17:13:57 +01:00
find_package(OpenGL REQUIRED)
2014-03-11 17:36:17 +01:00
find_package(OpenAL REQUIRED)
#find_package(LLVM CONFIG) # TODO
2013-11-19 11:30:58 +01:00
include("${wxWidgets_USE_FILE}")
if(APPLE)
set(PLATFORM_ARCH "macosx/x86_64")
elseif(WIN32)
set(PLATFORM_ARCH "Windows/x86_64")
2014-03-11 17:36:17 +01:00
else()
set(PLATFORM_ARCH "linux/x86_64")
2014-03-11 17:36:17 +01:00
endif()
2013-11-19 11:30:58 +01:00
include_directories(
${GLEW_INCLUDE_DIR}
2013-11-19 11:30:58 +01:00
${wxWidgets_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR}
2014-03-11 17:36:17 +01:00
${OPENAL_INCLUDE_DIR}
${LLVM_INCLUDE_DIRS}
"${RPCS3_SRC_DIR}/../3rdparty/pugixml/src"
2016-03-20 01:05:12 +01:00
"${RPCS3_SRC_DIR}/../3rdparty/ffmpeg/${PLATFORM_ARCH}/include"
"${RPCS3_SRC_DIR}"
"${RPCS3_SRC_DIR}/Loader"
"${RPCS3_SRC_DIR}/Crypto"
"${RPCS3_SRC_DIR}/.."
2016-02-01 22:40:38 +01:00
"${RPCS3_SRC_DIR}/../Utilities/yaml-cpp/include"
"${RPCS3_SRC_DIR}/../asmjit/src/asmjit"
"${RPCS3_SRC_DIR}/../3rdparty/libpng"
"${RPCS3_SRC_DIR}/../3rdparty/GSL/include"
"${RPCS3_SRC_DIR}/../rsx_program_decompiler/rsx_decompiler"
"${RPCS3_SRC_DIR}/../rsx_program_decompiler/shader_code"
2016-02-16 20:23:17 +01:00
"${RPCS3_SRC_DIR}/../Vulkan/Vulkan-LoaderAndValidationLayers/include"
"${RPCS3_SRC_DIR}/../Vulkan/glslang/glslang/Public"
# Includes 3rdparty stuff that isn't included yet
"${RPCS3_SRC_DIR}/../3rdparty/GL"
"${RPCS3_SRC_DIR}/../3rdparty/stblib"
2013-11-19 11:30:58 +01:00
)
2015-08-12 23:34:54 +02:00
if(WIN32)
include_directories(BEFORE "${RPCS3_SRC_DIR}/../3rdparty/XAudio2_7") # Slimmed down version of minidx9 for XAudio2_7 only
include_directories(BEFORE "${RPCS3_SRC_DIR}/../3rdparty/minidx12/Include")
2015-08-12 23:34:54 +02:00
endif()
2013-11-19 11:30:58 +01:00
2015-11-26 09:13:33 +01:00
if(NOT LLVM_FOUND)
Message("LLVM not found! LLVM 3.6 is required. RPCS3 will be compiled without LLVM support.")
elseif(${LLVM_PACKAGE_VERSION} VERSION_LESS "3.6" OR ${LLVM_PACKAGE_VERSION} VERSION_EQUAL "3.7" OR ${LLVM_PACKAGE_VERSION} VERSION_GREATER "3.7")
Message("LLVM ${LLVM_PACKAGE_VERSION} is not supported! LLVM 3.6 is required. RPCS3 will be compiled without LLVM support.")
else()
add_definitions(${LLVM_DEFINITIONS})
add_definitions(-DLLVM_AVAILABLE)
if (CMAKE_BUILD_TYPE STREQUAL "Release")
llvm_map_components_to_libnames(LLVM_LIBS mcjit vectorize x86codegen x86disassembler)
else()
llvm_map_components_to_libnames(LLVM_LIBS mcjit vectorize x86codegen x86disassembler mcdisassembler)
endif()
endif()
2016-02-03 18:34:51 +01:00
link_directories(
"${RPCS3_SRC_DIR}/../3rdparty/minidx12/"
2016-02-03 18:34:51 +01:00
)
2015-11-16 16:04:49 +01:00
if(MSVC OR NOT WIN32)
2016-03-20 01:05:12 +01:00
link_directories("${RPCS3_SRC_DIR}/../3rdparty/ffmpeg/${PLATFORM_ARCH}/lib")
2015-11-16 16:04:49 +01:00
endif()
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
foreach(dir ${dirs})
message(STATUS "dir='${dir}'")
endforeach()
2014-03-11 17:36:17 +01:00
2013-11-19 11:30:58 +01:00
file(
GLOB_RECURSE
RPCS3_SRC
2016-02-01 22:40:38 +01:00
"${RPCS3_SRC_DIR}/*.cpp"
"${RPCS3_SRC_DIR}/../Utilities/*.cpp"
"${RPCS3_SRC_DIR}/../rsx_program_decompiler/rsx_decompiler/*.cpp"
"${RPCS3_SRC_DIR}/../rsx_program_decompiler/shader_code/*.cpp"
"${RPCS3_SRC_DIR}/../asmjit/src/asmjit/*.cpp"
2013-11-19 11:30:58 +01:00
)
if(APPLE OR WIN32 AND NOT MSVC)
set (EXCLUDE_DIR "/RSX/VK/")
foreach (TMP_PATH ${RPCS3_SRC})
string (FIND ${TMP_PATH} ${EXCLUDE_DIR} EXCLUDE_DIR_FOUND)
if (NOT ${EXCLUDE_DIR_FOUND} EQUAL -1)
list (REMOVE_ITEM RPCS3_SRC ${TMP_PATH})
endif ()
endforeach(TMP_PATH)
endif()
2013-11-19 11:30:58 +01:00
add_executable(rpcs3 ${RPCS3_SRC})
2015-11-16 16:04:49 +01:00
if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib")
endif()
if(WIN32)
target_link_libraries(rpcs3 ws2_32.lib Winmm.lib)
2015-11-16 16:04:49 +01:00
if(NOT MSVC)
target_link_libraries(rpcs3 ${OPENGL_LIBRARIES} ${GLEW_LIBRARY} opengl32.lib glu32.lib -lstdc++.dll -lpthread.dll)
else()
target_link_libraries(rpcs3 dxgi.lib d2d1.lib dwrite.lib VKstatic.1 glslang OSDependent OGLCompiler SPIRV)
endif()
target_link_libraries(rpcs3 avformat.lib avcodec.lib avutil.lib swresample.lib swscale.lib png16_static ${wxWidgets_LIBRARIES} ${OPENAL_LIBRARY} ${ADDITIONAL_LIBS})
else()
target_link_libraries(rpcs3 ${wxWidgets_LIBRARIES} ${OPENAL_LIBRARY} ${GLEW_LIBRARY} ${OPENGL_LIBRARIES})
2016-05-08 09:38:40 +02:00
target_link_libraries(rpcs3 libavformat.a libavcodec.a libavutil.a libswresample.a libswscale.a -ldl png16_static ${ZLIB_LIBRARIES} ${ADDITIONAL_LIBS})
if (NOT APPLE)
target_link_libraries(rpcs3 vulkan glslang OSDependent OGLCompiler SPIRV)
endif()
endif()
if(LLVM_FOUND)
target_link_libraries(rpcs3 ${LLVM_LIBS})
endif()
2014-06-06 03:33:24 +02:00
set_target_properties(rpcs3 PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "${RPCS3_SRC_DIR}/stdafx.h")
2016-02-01 22:40:38 +01:00
cotire(rpcs3)