2017-11-22 05:24:51 +00:00
|
|
|
cmake_minimum_required(VERSION 3.9)
|
|
|
|
|
2017-12-06 22:07:36 +00:00
|
|
|
project(erc-test)
|
2017-11-22 05:24:51 +00:00
|
|
|
|
2017-12-02 19:05:53 +00:00
|
|
|
set(CMAKE_BUILD_TYPE Debug)
|
2018-03-02 22:43:00 +00:00
|
|
|
set(CMAKE_COLOR_MAKEFILE OFF)
|
2017-12-02 19:05:53 +00:00
|
|
|
|
2018-02-07 05:38:15 +00:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHEADLESS -DTESTING")
|
2017-12-26 23:06:08 +00:00
|
|
|
|
2017-12-19 07:02:48 +00:00
|
|
|
if(DEFINED ENV{STATIC_ANALYSIS})
|
2018-03-14 05:12:00 +00:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --analyze -g -O3")
|
2017-12-19 07:02:48 +00:00
|
|
|
endif()
|
2017-12-18 20:26:53 +00:00
|
|
|
|
|
|
|
if(CMAKE_C_FLAGS MATCHES "--analyze")
|
2018-03-13 05:27:10 +00:00
|
|
|
set(CMAKE_C_LINK_EXECUTABLE "echo 'Will not execute binary when running static analysis'; rm -f ./erc-test")
|
2017-12-18 20:26:53 +00:00
|
|
|
endif()
|
|
|
|
|
2017-12-17 05:38:59 +00:00
|
|
|
if(APPLE)
|
2017-12-18 20:46:40 +00:00
|
|
|
set(sdl_library /Library/Frameworks/SDL2.framework)
|
|
|
|
set(sdl_headers /Library/Frameworks/SDL2.framework/Headers)
|
2017-12-17 05:38:59 +00:00
|
|
|
endif()
|
|
|
|
|
2017-12-18 20:46:40 +00:00
|
|
|
if(NOT sdl_library)
|
|
|
|
message(FATAL_ERROR "This CMake file is not yet educated as to where SDL2 resides on your platform. Sorry!")
|
2017-12-17 05:38:59 +00:00
|
|
|
endif()
|
|
|
|
|
2017-12-18 20:46:40 +00:00
|
|
|
include_directories(../include /usr/local/include ${sdl_headers})
|
2017-11-22 05:24:51 +00:00
|
|
|
|
|
|
|
link_directories(/usr/local/lib)
|
|
|
|
|
|
|
|
include(../sources.cmake)
|
|
|
|
|
2017-12-06 22:07:36 +00:00
|
|
|
foreach(src ${erc_sources})
|
2017-11-22 05:24:51 +00:00
|
|
|
string(CONCAT relsrc ../src/ ${src})
|
|
|
|
list(APPEND sources ${relsrc})
|
|
|
|
endforeach(src)
|
|
|
|
|
2017-12-02 19:05:53 +00:00
|
|
|
# test_sources should also include the main source file, so we don't need to
|
|
|
|
# make any particular effort to include it in add_executable().
|
|
|
|
file(GLOB test_sources "*.c")
|
2018-04-14 00:09:23 +00:00
|
|
|
file(GLOB_RECURSE mos6502_sources "mos6502/*.c")
|
|
|
|
file(GLOB_RECURSE apple2_sources "apple2/*.c")
|
2017-12-02 19:05:53 +00:00
|
|
|
|
2017-12-20 03:50:50 +00:00
|
|
|
add_definitions(-DINSTALL_PATH="../../")
|
|
|
|
|
2018-04-14 00:09:23 +00:00
|
|
|
add_executable(erc-test ${sources} ${test_sources} ${mos6502_sources} ${apple2_sources})
|
2017-11-22 05:24:51 +00:00
|
|
|
|
2017-12-02 19:05:53 +00:00
|
|
|
# Our unit-testing library
|
2017-12-06 22:07:36 +00:00
|
|
|
target_link_libraries(erc-test criterion)
|
2017-12-17 04:45:39 +00:00
|
|
|
|
|
|
|
# Graphics
|
2017-12-18 20:46:40 +00:00
|
|
|
target_link_libraries(erc-test ${sdl_library})
|