author | koda |
Wed, 20 Apr 2016 14:46:04 -0400 | |
changeset 11654 | 870f22de388b |
parent 11400 | fac466eb0c4d |
child 11659 | 71bdf987e41f |
permissions | -rw-r--r-- |
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
1 |
#the usual set of dependencies |
8041 | 2 |
find_package(OpenGL REQUIRED) |
8004 | 3 |
find_package(GLEW REQUIRED) |
11368
c481d087f653
cmake tweaks. make pas2c build with sdl2 (keycodes or something still missing)
sheepluva
parents:
11157
diff
changeset
|
4 |
find_package(SDL2 REQUIRED) |
c481d087f653
cmake tweaks. make pas2c build with sdl2 (keycodes or something still missing)
sheepluva
parents:
11157
diff
changeset
|
5 |
find_package(SDL2_mixer REQUIRED) |
c481d087f653
cmake tweaks. make pas2c build with sdl2 (keycodes or something still missing)
sheepluva
parents:
11157
diff
changeset
|
6 |
find_package(SDL2_net REQUIRED) |
c481d087f653
cmake tweaks. make pas2c build with sdl2 (keycodes or something still missing)
sheepluva
parents:
11157
diff
changeset
|
7 |
find_package(SDL2_image REQUIRED) |
c481d087f653
cmake tweaks. make pas2c build with sdl2 (keycodes or something still missing)
sheepluva
parents:
11157
diff
changeset
|
8 |
find_package(SDL2_ttf REQUIRED) |
11654 | 9 |
if(BUILD_ENGINE_JS) |
10 |
find_package(Emscripten REQUIRED) |
|
11 |
endif() |
|
8004 | 12 |
|
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
13 |
#compile our rtl implementation |
9201 | 14 |
include_directories(${GLEW_INCLUDE_DIR}) |
8448
14f736ca7eb3
update FindGLEW to use the same variables as in later CMake files and make sure to include its headers before compiling c stuff
koda
parents:
8332
diff
changeset
|
15 |
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/rtl) |
9264 | 16 |
include_directories(${PHYSFS_INCLUDE_DIR}) |
17 |
include_directories(${PHYSLAYER_INCLUDE_DIR}) |
|
10127 | 18 |
include_directories(${LUA_INCLUDE_DIR}) |
11368
c481d087f653
cmake tweaks. make pas2c build with sdl2 (keycodes or something still missing)
sheepluva
parents:
11157
diff
changeset
|
19 |
include_directories(${SDL2_INCLUDE_DIR}) |
8047
25a4daa6473c
cleanup headers, remove -I . from rtl lib to save a few warnings
koda
parents:
8044
diff
changeset
|
20 |
add_subdirectory(rtl) |
7999 | 21 |
|
10747
07ade56c3b4a
backporting some build system fixes and pas2c tweaks
sheepluva
parents:
10131
diff
changeset
|
22 |
# convert list into pascal array |
07ade56c3b4a
backporting some build system fixes and pas2c tweaks
sheepluva
parents:
10131
diff
changeset
|
23 |
if(FONTS_DIRS) |
07ade56c3b4a
backporting some build system fixes and pas2c tweaks
sheepluva
parents:
10131
diff
changeset
|
24 |
list(LENGTH FONTS_DIRS ndirs) |
07ade56c3b4a
backporting some build system fixes and pas2c tweaks
sheepluva
parents:
10131
diff
changeset
|
25 |
set(FONTS_DIRS_ARRAY "array [0..${ndirs}] of PChar = (") |
07ade56c3b4a
backporting some build system fixes and pas2c tweaks
sheepluva
parents:
10131
diff
changeset
|
26 |
foreach(fontdir ${FONTS_DIRS}) |
07ade56c3b4a
backporting some build system fixes and pas2c tweaks
sheepluva
parents:
10131
diff
changeset
|
27 |
set(FONTS_DIRS_ARRAY "${FONTS_DIRS_ARRAY}\n_P'${fontdir}',") |
07ade56c3b4a
backporting some build system fixes and pas2c tweaks
sheepluva
parents:
10131
diff
changeset
|
28 |
endforeach(fontdir) |
07ade56c3b4a
backporting some build system fixes and pas2c tweaks
sheepluva
parents:
10131
diff
changeset
|
29 |
set(FONTS_DIRS_ARRAY "${FONTS_DIRS_ARRAY}\nnil);\n") |
07ade56c3b4a
backporting some build system fixes and pas2c tweaks
sheepluva
parents:
10131
diff
changeset
|
30 |
else(FONTS_DIRS) |
07ade56c3b4a
backporting some build system fixes and pas2c tweaks
sheepluva
parents:
10131
diff
changeset
|
31 |
set(FONTS_DIRS_ARRAY "array [0..1] of PChar = (nil, nil);") |
07ade56c3b4a
backporting some build system fixes and pas2c tweaks
sheepluva
parents:
10131
diff
changeset
|
32 |
endif(FONTS_DIRS) |
07ade56c3b4a
backporting some build system fixes and pas2c tweaks
sheepluva
parents:
10131
diff
changeset
|
33 |
|
8044 | 34 |
configure_file(${CMAKE_SOURCE_DIR}/hedgewars/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc) |
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
35 |
|
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
36 |
#get the list of pas files that are going to be converted and compiled |
8044 | 37 |
file(GLOB engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/*.pas") |
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
38 |
#TODO: temporary until cmake can configure itself accordingly |
8044 | 39 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uWeb.pas") |
40 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uVideoRec.pas") |
|
41 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uTouch.pas") |
|
42 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/PNGh.pas") |
|
43 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/pas2cSystem.pas") |
|
44 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/pas2cRedo.pas") |
|
45 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/hwLibrary.pas") |
|
11157 | 46 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uMatrix.pas") |
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
47 |
|
9259
872dd30deb7b
compile hwengine first, so that all other files are compiled too and don't call pas2c again
koda
parents:
9256
diff
changeset
|
48 |
#remove and readd hwengine so that it is compiled first, compiling every other file in the process |
872dd30deb7b
compile hwengine first, so that all other files are compiled too and don't call pas2c again
koda
parents:
9256
diff
changeset
|
49 |
list(REMOVE_ITEM engine_sources_pas ${CMAKE_SOURCE_DIR}/hedgewars/hwengine.pas) |
872dd30deb7b
compile hwengine first, so that all other files are compiled too and don't call pas2c again
koda
parents:
9256
diff
changeset
|
50 |
list(APPEND engine_sources_pas ${CMAKE_SOURCE_DIR}/hedgewars/hwengine.pas) |
872dd30deb7b
compile hwengine first, so that all other files are compiled too and don't call pas2c again
koda
parents:
9256
diff
changeset
|
51 |
|
872dd30deb7b
compile hwengine first, so that all other files are compiled too and don't call pas2c again
koda
parents:
9256
diff
changeset
|
52 |
#process files .pas -> .c |
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
53 |
foreach(sourcefile ${engine_sources_pas}) |
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
54 |
get_filename_component(sourcename ${sourcefile} NAME_WE) #drops .pas |
9256
5a2e94a4c2d0
set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents:
9252
diff
changeset
|
55 |
list(APPEND engine_sources "${CMAKE_CURRENT_BINARY_DIR}/${sourcename}.c") |
9978 | 56 |
endforeach() |
9256
5a2e94a4c2d0
set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents:
9252
diff
changeset
|
57 |
|
9978 | 58 |
#add again files for external functions and for fpcrtl_ functions |
59 |
list(APPEND engine_sources_pas ${CMAKE_SOURCE_DIR}/hedgewars/pas2cSystem.pas) |
|
60 |
list(APPEND engine_sources_pas ${CMAKE_SOURCE_DIR}/hedgewars/pas2cRedo.pas) |
|
9976 | 61 |
|
62 |
||
9978 | 63 |
#invoke pas2c on main module, it will call all the others |
64 |
add_custom_command(OUTPUT ${engine_sources} |
|
65 |
COMMAND "${EXECUTABLE_OUTPUT_PATH}/pas2c${CMAKE_EXECUTABLE_SUFFIX}" |
|
66 |
ARGS -n "hwengine" |
|
67 |
-i "${CMAKE_SOURCE_DIR}/hedgewars" |
|
68 |
-o "${CMAKE_CURRENT_BINARY_DIR}" |
|
69 |
-a "${CMAKE_CURRENT_BINARY_DIR}" |
|
9982 | 70 |
-d "ENDIAN_LITTLE" |
71 |
-d "DEBUGFILE" |
|
9978 | 72 |
DEPENDS pas2c #converter tool |
73 |
${engine_sources_pas} #original pascal file |
|
74 |
) |
|
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
75 |
|
9256
5a2e94a4c2d0
set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents:
9252
diff
changeset
|
76 |
#wrap conversion for all source in this command |
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
77 |
add_custom_target(engine_c DEPENDS ${engine_sources}) |
7999 | 78 |
|
8006 | 79 |
|
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
80 |
#compile the c files |
10127 | 81 |
add_definitions(-DPAS2C) |
10131
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10129
diff
changeset
|
82 |
add_definitions(-Werror=incompatible-pointer-types) |
10127 | 83 |
|
11654 | 84 |
if(BUILD_ENGINE_JS) |
85 |
#hijack the c compiler with emscripten |
|
86 |
set(CMAKE_C_COMPILER ${EMSCRIPTEN_EXECUTABLE}) |
|
87 |
endif() |
|
88 |
||
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
89 |
add_executable(hwengine WIN32 ${engine_sources}) |
8029 | 90 |
|
91 |
target_link_libraries(hwengine fpcrtl |
|
92 |
${LUA_LIBRARY} |
|
93 |
${OPENGL_LIBRARY} |
|
11368
c481d087f653
cmake tweaks. make pas2c build with sdl2 (keycodes or something still missing)
sheepluva
parents:
11157
diff
changeset
|
94 |
${SDL2_LIBRARY} |
c481d087f653
cmake tweaks. make pas2c build with sdl2 (keycodes or something still missing)
sheepluva
parents:
11157
diff
changeset
|
95 |
${SDL2_MIXER_LIBRARY} |
c481d087f653
cmake tweaks. make pas2c build with sdl2 (keycodes or something still missing)
sheepluva
parents:
11157
diff
changeset
|
96 |
${SDL2_NET_LIBRARY} |
c481d087f653
cmake tweaks. make pas2c build with sdl2 (keycodes or something still missing)
sheepluva
parents:
11157
diff
changeset
|
97 |
${SDL2_IMAGE_LIBRARY} |
c481d087f653
cmake tweaks. make pas2c build with sdl2 (keycodes or something still missing)
sheepluva
parents:
11157
diff
changeset
|
98 |
${SDL2_TTF_LIBRARY} |
8853
ef59a44a9f08
and now engine in c links too (with more manual intervention as of issue 596)
koda
parents:
8448
diff
changeset
|
99 |
${GLEW_LIBRARY} |
ef59a44a9f08
and now engine in c links too (with more manual intervention as of issue 596)
koda
parents:
8448
diff
changeset
|
100 |
physfs |
ef59a44a9f08
and now engine in c links too (with more manual intervention as of issue 596)
koda
parents:
8448
diff
changeset
|
101 |
physlayer |
9984
84835d0ceb64
Fixed build failure to a missing math library linked with BUILD_ENGINE_C=1 and clang
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents:
9982
diff
changeset
|
102 |
m |
8038 | 103 |
#TODO: add other libraries |
8029 | 104 |
) |
8332
9333216f2054
fix hwc install and pas2c preprocessing (but not total conversion)
koda
parents:
8108
diff
changeset
|
105 |
install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_binary_install_dir}) |
8038 | 106 |