author | koda |
Tue, 13 Nov 2012 23:56:50 +0100 | |
branch | webgl |
changeset 8050 | c82b68016c68 |
parent 8047 | 25a4daa6473c |
child 8108 | 39d7a16ce60c |
permissions | -rw-r--r-- |
8004 | 1 |
|
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
2 |
#only Clang is supported |
8004 | 3 |
if(CLANG) |
4 |
set(clang_executable ${CLANG}) |
|
5 |
else() |
|
8023 | 6 |
find_program(clang_executable |
7 |
NAMES clang-mp-3.2 clang-mp-3.1 clang-mp-3.0 clang |
|
8 |
PATHS /opt/local/bin /usr/local/bin /usr/bin) |
|
8004 | 9 |
endif() |
10 |
||
11 |
if (clang_executable) |
|
12 |
exec_program(${clang_executable} ARGS "-v" OUTPUT_VARIABLE clang_version_full) |
|
13 |
string(REGEX MATCH "[0-9]+\\.[0-9]+" clang_version_long "${clang_version_full}") |
|
14 |
string(REGEX REPLACE "([0-9]+\\.[0-9]+)" "\\1" clang_version "${clang_version_long}") |
|
8008 | 15 |
#TODO: check version >= 3.0 |
8004 | 16 |
message(STATUS "Found CLANG: ${clang_executable} (version ${clang_version})") |
17 |
else() |
|
18 |
message(FATAL_ERROR "No LLVM/Clang compiler found (required for engine_c target)") |
|
19 |
endif() |
|
20 |
||
8006 | 21 |
set(CMAKE_C_COMPILER ${clang_executable}) |
22 |
||
8004 | 23 |
|
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
24 |
#the usual set of dependencies |
8041 | 25 |
find_package(OpenGL REQUIRED) |
8004 | 26 |
find_package(GLEW REQUIRED) |
8029 | 27 |
find_package(SDL REQUIRED) |
28 |
find_package(SDL_mixer REQUIRED) |
|
29 |
find_package(SDL_net REQUIRED) |
|
30 |
find_package(SDL_image REQUIRED) |
|
31 |
find_package(SDL_ttf REQUIRED) |
|
8004 | 32 |
|
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
33 |
#compile our rtl implementation |
8047
25a4daa6473c
cleanup headers, remove -I . from rtl lib to save a few warnings
koda
parents:
8044
diff
changeset
|
34 |
add_subdirectory(rtl) |
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
35 |
include_directories("${GLEW_INCLUDE_PATH}") |
8044 | 36 |
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/rtl") |
7999 | 37 |
|
8044 | 38 |
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
|
39 |
|
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
40 |
#get the list of pas files that are going to be converted and compiled |
8044 | 41 |
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
|
42 |
#TODO: temporary until cmake can configure itself accordingly |
8044 | 43 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uWeb.pas") |
44 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uVideoRec.pas") |
|
45 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uTouch.pas") |
|
46 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/PNGh.pas") |
|
47 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/pas2cSystem.pas") |
|
48 |
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/pas2cRedo.pas") |
|
49 |
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
|
50 |
|
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
51 |
foreach(sourcefile ${engine_sources_pas}) |
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
52 |
get_filename_component(sourcename ${sourcefile} NAME_WE) #drops .pas |
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
53 |
set(engine_sources "${CMAKE_CURRENT_BINARY_DIR}/${sourcename}.c" ${engine_sources}) |
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
54 |
endforeach() |
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
55 |
|
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
56 |
#invoke pas2c on our pas files |
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
57 |
add_custom_command(OUTPUT ${engine_sources} |
7999 | 58 |
COMMAND "${EXECUTABLE_OUTPUT_PATH}/pas2c${CMAKE_EXECUTABLE_SUFFIX}" |
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
59 |
ARGS -n "hwengine" |
8044 | 60 |
-i "${CMAKE_SOURCE_DIR}/hedgewars" |
8006 | 61 |
-o "${CMAKE_CURRENT_BINARY_DIR}" |
62 |
-a "${CMAKE_CURRENT_BINARY_DIR}" |
|
7999 | 63 |
DEPENDS pas2c |
8006 | 64 |
) |
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
65 |
add_custom_target(engine_c DEPENDS ${engine_sources}) |
7999 | 66 |
|
8006 | 67 |
|
8035
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
68 |
#compile the c files |
68ec3138c16d
comments and runtime list of files to convert and compile
koda
parents:
8029
diff
changeset
|
69 |
add_executable(hwengine WIN32 ${engine_sources}) |
8029 | 70 |
|
71 |
target_link_libraries(hwengine fpcrtl |
|
72 |
${LUA_LIBRARY} |
|
73 |
${OPENGL_LIBRARY} |
|
74 |
${SDL_LIBRARY} |
|
75 |
${SDLMIXER_LIBRARY} |
|
76 |
${SDLNET_LIBRARY} |
|
77 |
${SDLIMAGE_LIBRARY} |
|
78 |
${SDLTTF_LIBRARY} |
|
8038 | 79 |
#TODO: add other libraries |
8029 | 80 |
) |
81 |
||
8050 | 82 |
#TODO: move this away in its proper findxxx.cmake |
83 |
if(APPLE) |
|
84 |
#let's look for the installed sdlmain file; if it is not found, let's build our own |
|
85 |
find_package(SDL REQUIRED) |
|
86 |
#remove the ";-framework Cocoa" from the SDL_LIBRARY variable |
|
87 |
string(REGEX REPLACE "(.*);-.*" "\\1" sdl_dir "${SDL_LIBRARY}") |
|
88 |
#find libsdmain.a |
|
89 |
find_file(SDLMAIN_LIB libSDLMain.a PATHS ${sdl_dir}/Resources/) |
|
90 |
||
91 |
if(SDLMAIN_LIB MATCHES "SDLMAIN_LIB-NOTFOUND") |
|
92 |
include_directories(${SDL_INCLUDE_DIR}) |
|
93 |
add_library (SDLmain STATIC ${CMAKE_SOURCE_DIR}/hedgewars/sdlmain_osx/SDLMain.m) |
|
94 |
#add a dependency to the hwengine target |
|
95 |
set(SDLMAIN_LIB "${LIBRARY_OUTPUT_PATH}/libSDLmain.a") |
|
96 |
endif() |
|
97 |
||
98 |
target_link_libraries(hwengine ${SDLMAIN_LIB}) |
|
99 |
endif(APPLE) |
|
100 |
||
101 |
||
8038 | 102 |
install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_dir}) |
103 |