2016-07-12 13:25:33 +01:00
|
|
|
cmake_minimum_required(VERSION 3.4.1)
|
2016-07-01 14:01:06 +01:00
|
|
|
project(dynarmic)
|
|
|
|
|
|
|
|
# Dynarmic project options
|
|
|
|
option(DYNARMIC_USE_SYSTEM_BOOST "Use the system boost libraries" ON)
|
|
|
|
|
|
|
|
# Compiler flags
|
2016-07-12 13:25:33 +01:00
|
|
|
if (NOT MSVC)
|
2016-08-01 19:54:31 +01:00
|
|
|
add_compile_options(--std=c++14)
|
|
|
|
add_compile_options(-Wall -Werror -Wextra -pedantic -pedantic-errors -Wfatal-errors
|
|
|
|
-Wno-unused-parameter -Wno-missing-braces)
|
2016-07-23 05:37:07 +01:00
|
|
|
add_compile_options(-DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_POOL_NO_MT)
|
2016-07-12 13:25:33 +01:00
|
|
|
if (ARCHITECTURE_x86_64)
|
|
|
|
add_compile_options(-msse4.1)
|
|
|
|
endif()
|
|
|
|
else()
|
2016-07-18 10:28:17 +01:00
|
|
|
add_compile_options(/W3 /MP /Zi /Zo /EHsc /WX)
|
2016-07-23 05:37:07 +01:00
|
|
|
add_compile_options(/DBOOST_SYSTEM_NO_DEPRECATED /DBOOST_POOL_NO_MT)
|
2016-07-12 13:25:33 +01:00
|
|
|
endif()
|
2016-07-01 14:01:06 +01:00
|
|
|
|
2016-07-18 10:28:17 +01:00
|
|
|
# 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()
|
|
|
|
|
2016-07-01 14:01:06 +01:00
|
|
|
# Arch detection
|
|
|
|
include(CheckSymbolExists)
|
|
|
|
function(detect_architecture symbol arch)
|
|
|
|
if (NOT DEFINED ARCHITECTURE)
|
|
|
|
set(CMAKE_REQUIRED_QUIET 1)
|
|
|
|
check_symbol_exists("${symbol}" "" ARCHITECTURE_${arch})
|
|
|
|
unset(CMAKE_REQUIRED_QUIET)
|
|
|
|
|
|
|
|
# The output variable needs to be unique across invocations otherwise
|
|
|
|
# CMake's crazy scope rules will keep it defined
|
|
|
|
if (ARCHITECTURE_${arch})
|
|
|
|
set(ARCHITECTURE "${arch}" PARENT_SCOPE)
|
|
|
|
set(ARCHITECTURE_${arch} 1 PARENT_SCOPE)
|
|
|
|
add_definitions(-DARCHITECTURE_${arch}=1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
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.
|
|
|
|
|
|
|
|
# Dynarmic project files
|
|
|
|
add_subdirectory(src)
|
2016-07-04 10:22:11 +01:00
|
|
|
add_subdirectory(tests)
|