2019-07-06 23:10:32 -07:00
|
|
|
cmake_minimum_required(VERSION 3.1)
|
|
|
|
project(dingusppc)
|
2019-12-16 16:31:33 +01:00
|
|
|
|
2023-06-19 22:36:09 -07:00
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
2019-12-14 12:56:43 -07:00
|
|
|
|
2019-07-06 23:10:32 -07:00
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
2020-05-09 14:29:37 +02:00
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
2020-02-27 21:03:01 -07:00
|
|
|
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
|
2020-05-08 22:32:29 +02:00
|
|
|
|
2020-03-22 20:15:12 -07:00
|
|
|
if (NOT WIN32)
|
2023-01-08 22:27:13 +01:00
|
|
|
find_package(SDL2 REQUIRED)
|
|
|
|
include_directories(${SDL2_INCLUDE_DIRS})
|
|
|
|
if (UNIX AND NOT APPLE)
|
|
|
|
find_package (Threads)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
else() # Windows build relies on vcpkg
|
|
|
|
# pick up system wide vcpkg if exists
|
|
|
|
if (DEFINED ENV{VCPKG_ROOT} AND EXISTS $ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
|
|
|
|
message(STATUS "Using system vcpkg at $ENV{VCPKG_ROOT}")
|
|
|
|
set(vcpkg_toolchain_file $ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
|
|
|
|
|
|
|
|
# check Github Actions vcpkg installation
|
2023-03-19 07:55:26 -07:00
|
|
|
elseif (DEFINED ENV{VCPKG_INSTALLATION_ROOT} AND EXISTS $ENV{VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake)
|
2023-01-08 22:27:13 +01:00
|
|
|
message(STATUS "Using system vcpkg at $ENV{VCPKG_INSTALLATION_ROOT}")
|
|
|
|
set(vcpkg_toolchain_file $ENV{VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake)
|
|
|
|
|
|
|
|
# otherwise, fetch vcpkg from Github
|
|
|
|
else()
|
|
|
|
message(STATUS "Fetching latest vcpkg from Github...")
|
|
|
|
|
|
|
|
include(FetchContent)
|
|
|
|
FetchContent_Declare(vcpkg GIT_REPOSITORY https://github.com/microsoft/vcpkg.git)
|
|
|
|
FetchContent_MakeAvailable(vcpkg)
|
|
|
|
set(vcpkg_toolchain_file ${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CMAKE_TOOLCHAIN_FILE ${vcpkg_toolchain_file})
|
|
|
|
find_package(SDL2 CONFIG REQUIRED)
|
|
|
|
add_compile_definitions(SDL_MAIN_HANDLED)
|
2020-03-22 20:15:12 -07:00
|
|
|
endif()
|
2020-03-19 15:09:24 +01:00
|
|
|
|
2021-01-24 11:45:12 +01:00
|
|
|
option(DPPC_BUILD_PPC_TESTS "Build PowerPC tests" OFF)
|
2021-01-08 20:38:40 +01:00
|
|
|
option(DPPC_BUILD_BENCHMARKS "Build benchmarking programs" OFF)
|
|
|
|
|
2021-10-23 21:51:16 +02:00
|
|
|
option(DPPC_68K_DEBUGGER "Enable 68k debugging" OFF)
|
2020-12-03 02:18:13 +01:00
|
|
|
|
2021-10-23 21:51:16 +02:00
|
|
|
if (DPPC_68K_DEBUGGER)
|
2020-12-03 02:18:13 +01:00
|
|
|
# Turn off anything unnecessary.
|
|
|
|
set(CAPSTONE_BUILD_SHARED OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_BUILD_TESTS OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_BUILD_CSTOOL OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_BUILD_DIET OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_OSXKERNEL_SUPPORT OFF CACHE BOOL "")
|
|
|
|
|
|
|
|
# Disable unused Capstone architectures.
|
|
|
|
set(CAPSTONE_ARM_SUPPORT OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_ARM64_SUPPORT OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_MIPS_SUPPORT OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_PPC_SUPPORT OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_SPARC_SUPPORT OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_SYSZ_SUPPORT OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_XCORE_SUPPORT OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_X86_SUPPORT OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_TMS320C64X_SUPPORT OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_M680X_SUPPORT OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_EVM_SUPPORT OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_MOS65XX_SUPPORT OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_WASM_SUPPORT OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_BPF_SUPPORT OFF CACHE BOOL "")
|
|
|
|
set(CAPSTONE_RISCV_SUPPORT OFF CACHE BOOL "")
|
|
|
|
|
|
|
|
ADD_DEFINITIONS(-DENABLE_68K_DEBUGGER)
|
|
|
|
|
|
|
|
add_subdirectory(thirdparty/capstone EXCLUDE_FROM_ALL)
|
|
|
|
endif()
|
2020-07-13 23:39:31 +02:00
|
|
|
|
2022-01-10 16:36:14 +01:00
|
|
|
add_subdirectory("${PROJECT_SOURCE_DIR}/core")
|
2020-02-03 14:36:30 +01:00
|
|
|
add_subdirectory("${PROJECT_SOURCE_DIR}/cpu/ppc/")
|
2020-04-20 20:32:09 +02:00
|
|
|
add_subdirectory("${PROJECT_SOURCE_DIR}/debugger/")
|
2020-02-03 14:36:30 +01:00
|
|
|
add_subdirectory("${PROJECT_SOURCE_DIR}/devices/")
|
2020-03-13 22:49:58 +01:00
|
|
|
add_subdirectory("${PROJECT_SOURCE_DIR}/machines/")
|
2021-04-14 01:27:07 +02:00
|
|
|
add_subdirectory("${PROJECT_SOURCE_DIR}/utils/")
|
2020-03-22 20:15:12 -07:00
|
|
|
add_subdirectory("${PROJECT_SOURCE_DIR}/thirdparty/loguru/")
|
2020-02-03 14:36:30 +01:00
|
|
|
|
2020-05-15 02:36:40 +02:00
|
|
|
set(BUILD_TESTS OFF CACHE BOOL "Build Cubeb tests")
|
|
|
|
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries")
|
|
|
|
set(BUILD_TOOLS OFF CACHE BOOL "Build Cubeb tools")
|
|
|
|
|
|
|
|
add_subdirectory(thirdparty/cubeb EXCLUDE_FROM_ALL)
|
2020-05-08 22:32:29 +02:00
|
|
|
|
2020-09-20 23:25:29 +02:00
|
|
|
set(CLI11_ROOT ${PROJECT_SOURCE_DIR}/thirdparty/CLI11)
|
|
|
|
|
2021-10-23 20:17:47 +02:00
|
|
|
include_directories("${PROJECT_SOURCE_DIR}"
|
2022-01-10 16:36:14 +01:00
|
|
|
"${PROJECT_SOURCE_DIR}/core"
|
2021-10-23 20:17:47 +02:00
|
|
|
"${PROJECT_SOURCE_DIR}/devices"
|
2020-02-03 14:36:30 +01:00
|
|
|
"${PROJECT_SOURCE_DIR}/cpu/ppc"
|
2020-02-27 21:03:01 -07:00
|
|
|
"${PROJECT_SOURCE_DIR}/debugger"
|
2021-04-14 01:27:07 +02:00
|
|
|
"${PROJECT_SOURCE_DIR}/utils"
|
2020-03-22 20:15:12 -07:00
|
|
|
"${PROJECT_SOURCE_DIR}/thirdparty/loguru/"
|
2021-09-17 13:27:49 +02:00
|
|
|
"${PROJECT_SOURCE_DIR}/thirdparty/CLI11/"
|
2023-01-08 22:27:13 +01:00
|
|
|
"${PROJECT_SOURCE_DIR}/thirdparty/cubeb/include")
|
2020-02-03 14:36:30 +01:00
|
|
|
|
|
|
|
file(GLOB SOURCES "${PROJECT_SOURCE_DIR}/*.cpp"
|
2020-03-22 20:15:12 -07:00
|
|
|
"${PROJECT_SOURCE_DIR}/*.c"
|
|
|
|
"${PROJECT_SOURCE_DIR}/*.hpp"
|
2020-04-20 20:32:09 +02:00
|
|
|
"${PROJECT_SOURCE_DIR}/*.h")
|
2019-12-16 16:31:33 +01:00
|
|
|
|
2020-02-03 14:36:30 +01:00
|
|
|
file(GLOB TEST_SOURCES "${PROJECT_SOURCE_DIR}/cpu/ppc/test/*.cpp")
|
2019-12-16 16:31:33 +01:00
|
|
|
|
2022-01-10 16:36:14 +01:00
|
|
|
add_executable(dingusppc ${SOURCES} $<TARGET_OBJECTS:core>
|
2020-04-20 20:32:09 +02:00
|
|
|
$<TARGET_OBJECTS:cpu_ppc>
|
2022-01-10 16:36:14 +01:00
|
|
|
$<TARGET_OBJECTS:debugger>
|
2020-03-13 22:49:58 +01:00
|
|
|
$<TARGET_OBJECTS:devices>
|
|
|
|
$<TARGET_OBJECTS:machines>
|
2021-04-14 01:27:07 +02:00
|
|
|
$<TARGET_OBJECTS:utils>
|
2020-02-27 21:03:01 -07:00
|
|
|
$<TARGET_OBJECTS:loguru>)
|
2020-05-08 22:32:29 +02:00
|
|
|
|
2020-03-22 20:15:12 -07:00
|
|
|
if (WIN32)
|
2023-01-08 23:29:25 +01:00
|
|
|
target_link_libraries(dingusppc PRIVATE SDL2::SDL2 SDL2::SDL2main cubeb)
|
2020-03-22 20:15:12 -07:00
|
|
|
else()
|
2023-01-08 23:29:25 +01:00
|
|
|
target_link_libraries(dingusppc PRIVATE SDL2::SDL2 SDL2::SDL2main cubeb
|
|
|
|
${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT})
|
2020-03-22 20:15:12 -07:00
|
|
|
endif()
|
|
|
|
|
2021-10-23 21:51:16 +02:00
|
|
|
if (DPPC_68K_DEBUGGER)
|
2023-01-08 23:29:25 +01:00
|
|
|
target_link_libraries(dingusppc PRIVATE capstone)
|
2020-12-03 02:18:13 +01:00
|
|
|
endif()
|
|
|
|
|
2021-01-08 20:38:40 +01:00
|
|
|
if (DPPC_BUILD_PPC_TESTS)
|
2022-01-16 22:45:37 +01:00
|
|
|
add_executable(testppc ${TEST_SOURCES} $<TARGET_OBJECTS:core>
|
2021-01-08 20:38:40 +01:00
|
|
|
$<TARGET_OBJECTS:cpu_ppc>
|
2022-01-16 22:45:37 +01:00
|
|
|
$<TARGET_OBJECTS:debugger>
|
2021-01-08 20:38:40 +01:00
|
|
|
$<TARGET_OBJECTS:devices>
|
|
|
|
$<TARGET_OBJECTS:machines>
|
2021-04-14 01:27:07 +02:00
|
|
|
$<TARGET_OBJECTS:utils>
|
2021-01-08 20:38:40 +01:00
|
|
|
$<TARGET_OBJECTS:loguru>)
|
|
|
|
|
|
|
|
if (WIN32)
|
2023-01-08 23:29:25 +01:00
|
|
|
target_link_libraries(testppc PRIVATE SDL2::SDL2 SDL2::SDL2main cubeb)
|
2021-01-08 20:38:40 +01:00
|
|
|
else()
|
2023-01-08 23:29:25 +01:00
|
|
|
target_link_libraries(testppc PRIVATE SDL2::SDL2 SDL2::SDL2main cubeb
|
|
|
|
${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT})
|
2021-01-08 20:38:40 +01:00
|
|
|
endif()
|
|
|
|
|
2021-10-23 21:51:16 +02:00
|
|
|
if (DPPC_68K_DEBUGGER)
|
2023-01-08 23:29:25 +01:00
|
|
|
target_link_libraries(testppc PRIVATE capstone)
|
2021-01-08 20:38:40 +01:00
|
|
|
endif()
|
2020-03-22 20:15:12 -07:00
|
|
|
endif()
|
2020-03-19 15:09:24 +01:00
|
|
|
|
2021-01-08 20:38:40 +01:00
|
|
|
if (DPPC_BUILD_BENCHMARKS)
|
|
|
|
file(GLOB BENCH_SOURCES "${PROJECT_SOURCE_DIR}/benchmark/*.cpp")
|
2022-01-16 22:45:37 +01:00
|
|
|
add_executable(bench1 ${BENCH_SOURCES} $<TARGET_OBJECTS:core>
|
2021-01-08 20:38:40 +01:00
|
|
|
$<TARGET_OBJECTS:cpu_ppc>
|
2022-01-16 22:45:37 +01:00
|
|
|
$<TARGET_OBJECTS:debugger>
|
2021-01-08 20:38:40 +01:00
|
|
|
$<TARGET_OBJECTS:devices>
|
|
|
|
$<TARGET_OBJECTS:machines>
|
2021-04-14 01:27:07 +02:00
|
|
|
$<TARGET_OBJECTS:utils>
|
2021-01-08 20:38:40 +01:00
|
|
|
$<TARGET_OBJECTS:loguru>)
|
|
|
|
|
2023-01-08 23:29:25 +01:00
|
|
|
target_link_libraries(bench1 PRIVATE cubeb SDL2::SDL2 SDL2::SDL2main ${CMAKE_DL_LIBS}
|
2021-01-08 20:38:40 +01:00
|
|
|
${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
|
2021-10-23 21:51:16 +02:00
|
|
|
if (DPPC_68K_DEBUGGER)
|
2023-01-08 23:29:25 +01:00
|
|
|
target_link_libraries(bench1 PRIVATE capstone)
|
2021-01-08 20:38:40 +01:00
|
|
|
endif()
|
2020-03-22 20:15:12 -07:00
|
|
|
endif()
|
2020-03-19 15:09:24 +01:00
|
|
|
|
2021-01-08 20:38:40 +01:00
|
|
|
if (DPPC_BUILD_PPC_TESTS)
|
|
|
|
add_custom_command(
|
|
|
|
TARGET testppc POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
|
|
|
"${PROJECT_SOURCE_DIR}/cpu/ppc/test/ppcinttests.csv"
|
2021-10-17 23:41:53 +02:00
|
|
|
"${PROJECT_SOURCE_DIR}/cpu/ppc/test/ppcfloattests.csv"
|
2021-01-08 20:38:40 +01:00
|
|
|
"${PROJECT_SOURCE_DIR}/cpu/ppc/test/ppcdisasmtest.csv"
|
|
|
|
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
|
2020-12-03 02:18:13 +01:00
|
|
|
endif()
|
2020-11-28 01:08:34 +01:00
|
|
|
|
2020-10-25 16:23:53 -07:00
|
|
|
install (TARGETS dingusppc DESTINATION ${PROJECT_SOURCE_DIR}/build)
|