author | koda |
Tue, 18 Jun 2013 22:39:57 +0200 | |
branch | webgl |
changeset 9259 | 872dd30deb7b |
parent 9256 | 5a2e94a4c2d0 |
child 9267 | dbd18257be8f |
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) |
8029 | 4 |
find_package(SDL REQUIRED) |
5 |
find_package(SDL_mixer REQUIRED) |
|
6 |
find_package(SDL_net REQUIRED) |
|
7 |
find_package(SDL_image REQUIRED) |
|
8 |
find_package(SDL_ttf REQUIRED) |
|
8004 | 9 |
|
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
10 |
#compile our rtl implementation |
9201 | 11 |
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
|
12 |
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/rtl) |
8047
25a4daa6473c
cleanup headers, remove -I . from rtl lib to save a few warnings
koda
parents:
8044
diff
changeset
|
13 |
add_subdirectory(rtl) |
7999 | 14 |
|
8044 | 15 |
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
|
16 |
|
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
17 |
#get the list of pas files that are going to be converted and compiled |
8044 | 18 |
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
|
19 |
#TODO: temporary until cmake can configure itself accordingly |
8044 | 20 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uWeb.pas") |
21 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uVideoRec.pas") |
|
22 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uTouch.pas") |
|
23 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/PNGh.pas") |
|
24 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/pas2cSystem.pas") |
|
25 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/pas2cRedo.pas") |
|
26 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/hwLibrary.pas") |
|
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
27 |
|
9259
872dd30deb7b
compile hwengine first, so that all other files are compiled too and don't call pas2c again
koda
parents:
9256
diff
changeset
|
28 |
#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
|
29 |
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
|
30 |
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
|
31 |
|
872dd30deb7b
compile hwengine first, so that all other files are compiled too and don't call pas2c again
koda
parents:
9256
diff
changeset
|
32 |
#process files .pas -> .c |
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
33 |
foreach(sourcefile ${engine_sources_pas}) |
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
34 |
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
|
35 |
list(APPEND engine_sources "${CMAKE_CURRENT_BINARY_DIR}/${sourcename}.c") |
5a2e94a4c2d0
set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents:
9252
diff
changeset
|
36 |
|
5a2e94a4c2d0
set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents:
9252
diff
changeset
|
37 |
#invoke pas2c on each pas files |
5a2e94a4c2d0
set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents:
9252
diff
changeset
|
38 |
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${sourcename}.c" |
5a2e94a4c2d0
set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents:
9252
diff
changeset
|
39 |
COMMAND "${EXECUTABLE_OUTPUT_PATH}/pas2c${CMAKE_EXECUTABLE_SUFFIX}" |
5a2e94a4c2d0
set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents:
9252
diff
changeset
|
40 |
ARGS -n "${sourcename}" |
5a2e94a4c2d0
set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents:
9252
diff
changeset
|
41 |
-i "${CMAKE_SOURCE_DIR}/hedgewars" |
5a2e94a4c2d0
set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents:
9252
diff
changeset
|
42 |
-o "${CMAKE_CURRENT_BINARY_DIR}" |
5a2e94a4c2d0
set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents:
9252
diff
changeset
|
43 |
-a "${CMAKE_CURRENT_BINARY_DIR}" |
5a2e94a4c2d0
set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents:
9252
diff
changeset
|
44 |
DEPENDS pas2c #converter tool |
5a2e94a4c2d0
set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents:
9252
diff
changeset
|
45 |
${sourcefile} #original pascal file |
5a2e94a4c2d0
set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents:
9252
diff
changeset
|
46 |
${CMAKE_SOURCE_DIR}/hedgewars/pas2cSystem.pas #special, external functions |
5a2e94a4c2d0
set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents:
9252
diff
changeset
|
47 |
${CMAKE_SOURCE_DIR}/hedgewars/pas2cRedo.pas #special, fpcrtl_ functions |
5a2e94a4c2d0
set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents:
9252
diff
changeset
|
48 |
) |
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
49 |
endforeach() |
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
50 |
|
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
|
51 |
#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
|
52 |
add_custom_target(engine_c DEPENDS ${engine_sources}) |
7999 | 53 |
|
8006 | 54 |
|
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
55 |
#compile the c files |
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
56 |
add_executable(hwengine WIN32 ${engine_sources}) |
8029 | 57 |
|
58 |
target_link_libraries(hwengine fpcrtl |
|
59 |
${LUA_LIBRARY} |
|
60 |
${OPENGL_LIBRARY} |
|
61 |
${SDL_LIBRARY} |
|
62 |
${SDLMIXER_LIBRARY} |
|
63 |
${SDLNET_LIBRARY} |
|
64 |
${SDLIMAGE_LIBRARY} |
|
65 |
${SDLTTF_LIBRARY} |
|
8853
ef59a44a9f08
and now engine in c links too (with more manual intervention as of issue 596)
koda
parents:
8448
diff
changeset
|
66 |
${GLEW_LIBRARY} |
ef59a44a9f08
and now engine in c links too (with more manual intervention as of issue 596)
koda
parents:
8448
diff
changeset
|
67 |
physfs |
ef59a44a9f08
and now engine in c links too (with more manual intervention as of issue 596)
koda
parents:
8448
diff
changeset
|
68 |
physlayer |
8038 | 69 |
#TODO: add other libraries |
8029 | 70 |
) |
8853
ef59a44a9f08
and now engine in c links too (with more manual intervention as of issue 596)
koda
parents:
8448
diff
changeset
|
71 |
if(APPLE) |
9130
4f4b71da3559
move sdlmain_osx aside in its own folder so its include path is not contaminated
koda
parents:
8853
diff
changeset
|
72 |
target_link_libraries(hwengine IOKit SDLmain) |
8853
ef59a44a9f08
and now engine in c links too (with more manual intervention as of issue 596)
koda
parents:
8448
diff
changeset
|
73 |
endif() |
8029 | 74 |
|
8332
9333216f2054
fix hwc install and pas2c preprocessing (but not total conversion)
koda
parents:
8108
diff
changeset
|
75 |
install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_binary_install_dir}) |
8038 | 76 |