forked from msikma/allegro-4.2.2-xc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
114 lines (98 loc) · 4.23 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
103
104
105
106
107
108
109
110
111
112
113
114
# A extremely ugly hack shoddy CMakeLists build system.
# To build Allegro 4.x using OpenWatcom without relying of the unreliable DJGPP Make.
# Still needs DJGPP as assembler tool.
#
# Doesn't need a virtual machine but needs a valid installation of DOSBox-x (not tested in ordinary DOSBox or DOSBox-Staging)
# Because i need to run asmdef to generate the C layout memory offset sizes needed, if it was native it would give very inaccurate
# results.
#
# To build:
# - Have the latest OpenWatcom v2 installed and located in your PATH.
# - Update the DOSBOX-X_PATH and DOSBOX-X_DEFPATH to your local DOSBox-x executable and location.
# - Update the DJGPP_AS cmake variables to your location of your DJGPP crosscompiling toolchain for your host target NOT the DOS version
# i'm using the DJGPP toolchain generated in this GitHub repository: https://github.com/andrewwutw/build-djgpp
# - Make sure CMake is configured to use Watcom WMake generator.
# - First build the ASM.Process target first, then reconfigure again in CMake.
# - Build the target allegro, then the demo, it should work in a DOS system.
cmake_minimum_required(VERSION 3.9)
set(CMAKE_VERBOSE_MAKEFILE ON)
project(Allegro)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
#NOTE: This CMakeList.txt is OpenWatcom centric!
#add_compile_definitions(/dALLEGRO_WATCOM)
string(REPLACE "-bt=dos" "-bt=dos4g" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
add_compile_options(-fr=nul)
add_compile_options(-zq)
add_compile_options(-wcd=202 -wcd=303 -wcd=138 -wcd=201)
set(ALLEGRO_ROOT ${CMAKE_SOURCE_DIR})
include_directories(./ ./include/)
set(DOSBOX-X_PATH "C:\\DOSBox-X\\dosbox-x.exe")
set(DOSBOX-X_DEFPATH "C:\\DOSBox-X\\")
#Prepare the alplatf.h first
file(WRITE ${ALLEGRO_ROOT}/include/allegro/platform/alplatf.h
"/* generated by CMakeLists.txt */\n"
"#define ALLEGRO_WATCOM\n")
option(OPT_WARNMODE "Set WARNMODE" OFF)
option(OPT_PROFILEMODE "Set PROFILEMODE" OFF)
#@TODO: We should replace '-bt=dos' to '-bt=dos4g'?
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -5s -s -d2")
include(${CMAKE_SOURCE_DIR}/cmake/SourcesList.cmake)
add_executable(asmdef src/i386/asmdef.c)
set_target_properties(asmdef PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}")
add_custom_command(TARGET asmdef POST_BUILD COMMAND ${DOSBOX-X_PATH} -silent -defaultdir "${DOSBOX-X_DEFPATH}" -c "asmdef obj\\watcom\\asmdef.inc & exit" "${CMAKE_SOURCE_DIR}")
add_custom_target(ASM.Process COMMAND ${CMAKE_COMMAND} -DROOT_DIR=${CMAKE_SOURCE_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/process-asm.cmake WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} DEPENDS asmdef)
set(OBJ_FILES
obj/watcom/asmcapa.o
obj/watcom/djirqs.o
obj/watcom/gripfnc.o
obj/watcom/iblit16.o
obj/watcom/iblit24.o
obj/watcom/iblit32.o
obj/watcom/iblit8.o
obj/watcom/icolconv.o
obj/watcom/icpus.o
obj/watcom/igfx15.o
obj/watcom/igfx16.o
obj/watcom/igfx24.o
obj/watcom/igfx32.o
obj/watcom/igfx8.o
obj/watcom/imisc.o
obj/watcom/iscan.o
obj/watcom/iscanmmx.o
obj/watcom/ispr15.o
obj/watcom/ispr16.o
obj/watcom/ispr24.o
obj/watcom/ispr32.o
obj/watcom/ispr8.o
obj/watcom/izbuf.o
obj/watcom/modexgfx.o
obj/watcom/swpps.o
obj/watcom/vbeafs.o
obj/watcom/vesas.o
)
file(GLOB OBJ_ASM ./obj/watcom/*.o)
if(EXISTS objList.txt)
file(REMOVE objList.txt)
endif()
set(REAL_OBJ_ASM)
set(LIST_OBJ)
foreach(F IN LISTS OBJ_ASM)
file(RELATIVE_PATH F ${CMAKE_SOURCE_DIR} ${F})
#message(${F})
#file(APPEND objList.txt "${F}\n")
#list(APPEND LIST_OBJ ${F})
file(REAL_PATH ${F} F)
file(TO_NATIVE_PATH ${F} F)
#message(${F})
list(APPEND REAL_OBJ_ASM ${F})
endforeach()
add_custom_target(genasmlib COMMAND wlib ${CMAKE_BINARY_DIR}\\asmlib.lib ${REAL_OBJ_ASM})
add_library(allegro STATIC ${ALLEGRO_SRC_FILES} ${ALLEGRO_SRC_DOS_FILES} ${ALLEGRO_SRC_I386_FILES} src/dos/wat.c)
add_dependencies(allegro ASM.Process genasmlib)
add_custom_command(TARGET allegro POST_BUILD COMMAND wlib /q /c $<TARGET_FILE:allegro> +${CMAKE_BINARY_DIR}\\asmlib.lib WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_executable(demo ${ALLEGRO_DEMO_SOURCES})
target_link_libraries(demo allegro)
file(GLOB SETUP_SRC setup/*.c)
add_executable(setup ${SETUP_SRC})
target_include_directories(setup PRIVATE setup/)
target_link_libraries(setup allegro)