-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
77 lines (62 loc) · 2.09 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# kindly provided by scivision
cmake_minimum_required(VERSION 3.14...3.25)
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT is_multi_config AND NOT (CMAKE_BUILD_TYPE OR DEFINED ENV{CMAKE_BUILD_TYPE}))
set(CMAKE_BUILD_TYPE Release CACHE STRING "Release default")
endif()
project(PAL-CRT LANGUAGES C)
option(live "live video using PL3D-KC")
include(ExternalProject)
include(GNUInstallDirs)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}" CACHE PATH "default install path" FORCE)
endif()
# --- PL3D-KC
if(live)
if(UNIX)
find_package(X11 REQUIRED)
endif()
set(fw_url https://github.com/LMP88959/PL3D-KC.git)
set(fw_tag main)
set(fw_args
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=Release
-DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
)
set(FW_LIBRARY ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}fw${CMAKE_STATIC_LIBRARY_SUFFIX})
set(FW_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
ExternalProject_Add(fw
GIT_REPOSITORY ${fw_url}
GIT_TAG ${fw_tag}
GIT_SHALLOW true
CMAKE_ARGS ${fw_args}
BUILD_BYPRODUCTS ${FW_LIBRARY}
TLS_VERIFY true
INACTIVITY_TIMEOUT 60
CONFIGURE_HANDLED_BY_BUILD ON
)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include)
add_library(fw::fw INTERFACE IMPORTED)
target_link_libraries(fw::fw INTERFACE ${FW_LIBRARY}
$<$<BOOL:${UNIX}>:X11::Xext>
$<$<BOOL:${WIN32}>:winmm>
)
target_include_directories(fw::fw INTERFACE ${FW_INCLUDE_DIR})
add_dependencies(fw::fw fw)
endif()
# --- PAL program
add_executable(pal pal_core.c pal.c pal_nes.c pal_nesrgb.c pal_main.c ppm_rw.c bmp_rw.c)
target_include_directories(pal PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(pal PRIVATE
CMD_LINE_VERSION=$<NOT:$<BOOL:${live}>>
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
)
target_link_libraries(pal PRIVATE
$<$<BOOL:${live}>:fw::fw>
$<$<BOOL:${WIN32}>:winmm>
)
# --- auto-ignore build directory
if(NOT EXISTS ${PROJECT_BINARY_DIR}/.gitignore)
file(WRITE ${PROJECT_BINARY_DIR}/.gitignore "*")
endif()