-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCMakeLists.txt
102 lines (89 loc) · 3.62 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
cmake_minimum_required(VERSION 2.8...3.22.1)
project(acidwarp C)
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
include_directories("${PROJECT_SOURCE_DIR}")
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
SET(STATIC_DEFAULT ON)
else(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
SET(STATIC_DEFAULT OFF)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
option(SDL2 "Version of SDL to use (1 or 2)" ON)
option(GL "Use OpenGL" OFF)
option(STATIC "Link statically" ${STATIC_DEFAULT})
set(CORE_SOURCES acidwarp.c palinit.c rolnfade.c display.c)
set(IMGGEN_SOURCES bit_map.c lut.c img_int.c img_float.c)
set(SOURCES ${CORE_SOURCES} ${IMGGEN_SOURCES} draw.c)
# Windows icon, built by converting PNG to ICO
# and then embedding using resource file.
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
find_program(ICOTOOL icotool)
if(ICOTOOL)
add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/acidwarp.ico
COMMAND icotool -c -o ${CMAKE_SOURCE_DIR}/acidwarp.ico ${CMAKE_SOURCE_DIR}/acidwarp.png
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/acidwarp.png)
set(SOURCES ${SOURCES} acid_res.rc)
set_source_files_properties(acid_res.rc PROPERTIES OBJECT_DEPENDS ${CMAKE_SOURCE_DIR}/acidwarp.ico)
else(ICOTOOL)
message(WARNING "Not adding icon to executable because icotool not found.")
endif(ICOTOOL)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
# Icon set via SDL
find_program(XXD xxd)
find_program(CONVERT convert)
# TODO Make sure convert is ImageMagick
if(XXD AND CONVERT)
add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/acidwarp.rgb
COMMAND convert ${CMAKE_SOURCE_DIR}/acidwarp.png -sample 64x64 ${CMAKE_SOURCE_DIR}/acidwarp.rgb
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/acidwarp.png)
add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/acid_ico.c
COMMAND xxd -i acidwarp.rgb > acid_ico.c
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/acidwarp.rgb
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_definitions(-DADDICON)
set(SOURCES ${SOURCES} acid_ico.c)
else(XXD AND CONVERT)
if(NOT CONVERT)
message(WARNING "ImageMagick convert is required resize icon for embedding")
endif(NOT CONVERT)
if(NOT XXD)
message(WARNING "xxd is required to embed icon into code")
endif(NOT XXD)
endif(XXD AND CONVERT)
add_executable(acidwarp ${SOURCES})
if(STATIC)
# FIXME depends on GCC
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
endif(STATIC)
if(GL)
if (NOT SDL2)
message(FATAL_ERROR "OpenGL only supported with SDL 2." )
endif (NOT SDL2)
add_definitions(-DWITH_GL)
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if(STATIC)
add_definitions(-DGLEW_STATIC)
endif(STATIC)
target_link_libraries(acidwarp glew32 opengl32)
else(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
find_package(OpenGL REQUIRED)
target_link_libraries(acidwarp ${OPENGL_gl_LIBRARY})
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
endif(GL)
if(SDL2)
# FindSDL2 probably won't be available
include(FindPkgConfig)
pkg_search_module(SDL REQUIRED sdl2)
include_directories(${SDL_INCLUDE_DIRS})
if (STATIC)
target_link_libraries(acidwarp ${SDL_STATIC_LDFLAGS})
else (STATIC)
target_link_libraries(acidwarp ${SDL_LDFLAGS})
endif (STATIC)
else(SDL2)
find_package(SDL REQUIRED)
include_directories(${SDL_INCLUDE_DIR})
target_link_libraries(acidwarp ${SDL_LIBRARY})
endif(SDL2)
# Only needed this in Linux for atan()
target_link_libraries(acidwarp m)