2016-09-02 12:26:47 +01:00
|
|
|
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
|
2016-08-25 18:22:08 +01:00
|
|
|
project(dynarmic CXX)
|
2016-07-01 14:01:06 +01:00
|
|
|
|
|
|
|
# Dynarmic project options
|
|
|
|
option(DYNARMIC_USE_SYSTEM_BOOST "Use the system boost libraries" ON)
|
2016-08-05 01:50:31 +01:00
|
|
|
option(DYNARMIC_USE_LLVM "Support disassembly of jitted x86_64 code using LLVM" OFF)
|
2016-09-02 12:29:19 +01:00
|
|
|
option(DYNARMIC_TESTS "Build tests" ON)
|
2016-07-01 14:01:06 +01:00
|
|
|
|
2016-08-22 14:12:46 +01:00
|
|
|
# Set hard requirements for C++
|
|
|
|
set(CMAKE_CXX_STANDARD 14)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
2016-08-22 14:15:05 +01:00
|
|
|
# Warn on CMake API deprecations
|
|
|
|
set(CMAKE_WARN_DEPRECATED ON)
|
|
|
|
|
2016-08-25 18:22:08 +01:00
|
|
|
# Disable in-source builds
|
|
|
|
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
|
|
|
|
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
|
|
|
|
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
|
|
|
message(SEND_ERROR "In-source builds are not allowed.")
|
|
|
|
endif()
|
|
|
|
|
2016-08-22 14:12:46 +01:00
|
|
|
# Signify where the module directories are
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules)
|
|
|
|
|
2016-07-01 14:01:06 +01:00
|
|
|
# Compiler flags
|
2016-08-22 14:25:30 +01:00
|
|
|
if (MSVC)
|
2016-12-15 20:51:42 +00:00
|
|
|
add_compile_options(/W4
|
2016-12-05 12:45:35 +00:00
|
|
|
/w34263 # Non-virtual member function hides base class virtual function
|
2016-12-15 20:51:42 +00:00
|
|
|
/w44265 # Class has virtual functions, but destructor is not virtual
|
2016-09-04 11:30:57 +01:00
|
|
|
/w34456 # Declaration of 'var' hides previous local declaration
|
|
|
|
/w34457 # Declaration of 'var' hides function parameter
|
|
|
|
/w34458 # Declaration of 'var' hides class member
|
|
|
|
/w34459 # Declaration of 'var' hides global definition
|
2016-12-05 12:45:35 +00:00
|
|
|
/w34946 # Reinterpret-cast between related types
|
2016-12-15 21:06:46 +00:00
|
|
|
/wd4592 # Symbol will be dynamically initialized (implementation limitation)
|
2016-09-04 11:30:57 +01:00
|
|
|
/MP
|
|
|
|
/Zi
|
|
|
|
/Zo
|
|
|
|
/EHsc
|
|
|
|
/WX)
|
2016-08-25 17:37:35 +01:00
|
|
|
add_compile_options(/DNOMINMAX)
|
2016-12-03 16:06:09 +00:00
|
|
|
|
|
|
|
if (CMAKE_VS_PLATFORM_TOOLSET MATCHES "LLVM-vs[0-9]+")
|
|
|
|
add_compile_options(-Qunused-arguments
|
|
|
|
-Wno-unused-parameter
|
|
|
|
-Wno-missing-braces)
|
|
|
|
add_compile_options(-Xclang -fno-operator-names)
|
|
|
|
endif()
|
2016-08-22 14:25:30 +01:00
|
|
|
else()
|
2016-08-22 22:21:00 +01:00
|
|
|
add_compile_options(-Wall
|
|
|
|
-Werror
|
|
|
|
-Wextra
|
|
|
|
-Wcast-qual
|
|
|
|
-pedantic
|
|
|
|
-pedantic-errors
|
|
|
|
-Wfatal-errors
|
|
|
|
-Wno-unused-parameter
|
|
|
|
-Wno-missing-braces)
|
2016-08-24 20:07:08 +01:00
|
|
|
add_compile_options(-fno-operator-names)
|
2016-08-22 22:21:00 +01:00
|
|
|
|
2016-07-12 13:25:33 +01:00
|
|
|
if (ARCHITECTURE_x86_64)
|
2016-09-11 08:38:44 +01:00
|
|
|
add_compile_options(-msse3)
|
2016-07-12 13:25:33 +01:00
|
|
|
endif()
|
|
|
|
endif()
|
2016-07-01 14:01:06 +01:00
|
|
|
|
|
|
|
# Arch detection
|
2016-08-22 14:12:46 +01:00
|
|
|
include(DetectArchitecture)
|
2016-07-01 14:01:06 +01:00
|
|
|
if (MSVC)
|
|
|
|
detect_architecture("_M_AMD64" x86_64)
|
|
|
|
detect_architecture("_M_IX86" x86)
|
|
|
|
detect_architecture("_M_ARM" ARM)
|
|
|
|
else()
|
|
|
|
detect_architecture("__x86_64__" x86_64)
|
|
|
|
detect_architecture("__i386__" x86)
|
|
|
|
detect_architecture("__arm__" ARM)
|
|
|
|
endif()
|
|
|
|
if (NOT DEFINED ARCHITECTURE)
|
|
|
|
set(ARCHITECTURE "GENERIC")
|
|
|
|
set(ARCHITECTURE_GENERIC 1)
|
|
|
|
add_definitions(-DARCHITECTURE_GENERIC=1)
|
|
|
|
endif()
|
|
|
|
message(STATUS "Target architecture: ${ARCHITECTURE}")
|
|
|
|
|
|
|
|
# Include Boost
|
|
|
|
if(DYNARMIC_USE_SYSTEM_BOOST)
|
|
|
|
find_package(Boost 1.57.0 REQUIRED)
|
|
|
|
else()
|
|
|
|
if(NOT Boost_INCLUDE_DIRS)
|
|
|
|
message(FATAL_ERROR "Please provide a path to a boost installation using Boost_INCLUDE_DIRS")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
include_directories(${Boost_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
# Include Catch
|
|
|
|
include_directories(externals/catch)
|
|
|
|
enable_testing(true) # Enables unit-testing.
|
|
|
|
|
2016-08-05 01:50:31 +01:00
|
|
|
# Include LLVM
|
|
|
|
if (DYNARMIC_USE_LLVM)
|
|
|
|
find_package(LLVM REQUIRED CONFIG)
|
|
|
|
include_directories(${LLVM_INCLUDE_DIRS})
|
|
|
|
add_definitions(-DDYNARMIC_USE_LLVM ${LLVM_DEFINITIONS})
|
|
|
|
llvm_map_components_to_libnames(llvm_libs x86desc x86disassembler)
|
|
|
|
endif()
|
|
|
|
|
2016-08-25 22:21:19 +01:00
|
|
|
# Pull in externals CMakeLists for libs where available
|
|
|
|
add_subdirectory(externals)
|
|
|
|
|
2016-07-01 14:01:06 +01:00
|
|
|
# Dynarmic project files
|
|
|
|
add_subdirectory(src)
|
2016-09-02 12:29:19 +01:00
|
|
|
if (DYNARMIC_TESTS)
|
|
|
|
add_subdirectory(tests)
|
|
|
|
endif()
|