project_files/hwc/CMakeLists.txt
author koda
Fri, 09 Nov 2012 22:56:34 +0100
branchwebgl
changeset 8004 da4c6db6ea6b
parent 7999 bb503cd46516
child 8006 7ca007615b88
permissions -rw-r--r--
correct includes and clang detection
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8004
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
     1
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
     2
if(CLANG)
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
     3
    set(clang_executable ${CLANG})
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
     4
else()
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
     5
    find_program(clang_executable clang)
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
     6
endif()
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
     7
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
     8
if (clang_executable)
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
     9
    exec_program(${clang_executable} ARGS "-v" OUTPUT_VARIABLE clang_version_full)
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    10
    string(REGEX MATCH "[0-9]+\\.[0-9]+" clang_version_long "${clang_version_full}")
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    11
    string(REGEX REPLACE "([0-9]+\\.[0-9]+)" "\\1" clang_version "${clang_version_long}")
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    12
    message(STATUS "Found CLANG: ${clang_executable} (version ${clang_version})")
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    13
else()
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    14
    message(FATAL_ERROR "No LLVM/Clang compiler found (required for engine_c target)")
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    15
endif()
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    16
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    17
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    18
find_package(GLEW REQUIRED)
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    19
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    20
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    21
set(CMAKE_C_COMPILER ${clang_executable})
7999
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    22
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    23
configure_file(${hedgewars_SOURCE_DIR}/hedgewars/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    24
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    25
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/hwengine.c"
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    26
        COMMAND "${EXECUTABLE_OUTPUT_PATH}/pas2c${CMAKE_EXECUTABLE_SUFFIX}"
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    27
        ARGS -n hwengine -i "${hedgewars_SOURCE_DIR}/hedgewars" -o "${CMAKE_CURRENT_BINARY_DIR}" -a ./
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    28
        DEPENDS pas2c
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    29
        )
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    30
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    31
add_custom_target(engine_c ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/hwengine.c")
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    32
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    33
add_subdirectory(rtl)
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    34
8004
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    35
include_directories("${GLEW_INCLUDE_PATH}")
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    36
include_directories(rtl)
7999
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    37
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    38
file(GLOB engine_src *.c)
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    39
add_executable(hwengine WIN32 ${engine_src})
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    40
add_dependencies(hwengine engine_c fpcrtl)