CMakeLists.txt
changeset 569 117d6e606c4e
parent 563 d22551643fcb
child 588 ef3d2efa822d
equal deleted inserted replaced
568:647b13e64468 569:117d6e606c4e
     1 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
     1 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
     2 PROJECT(MojoShader)
     2 PROJECT(MojoShader)
     3 
     3 
     4 EXECUTE_PROCESS(
     4 FIND_PROGRAM(HG hg DOC "Path to hg command line app: http://www.selenic.com/mercurial/")
     5     COMMAND hg tip --template {rev}
     5 IF(NOT HG)
     6     WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
     6     MESSAGE(STATUS "Mercurial (hg) not found. You can go on, but version info will be wrong.")
     7     RESULT_VARIABLE HGVERSION_RC
     7     SET(MOJOSHADER_VERSION -1)
     8     OUTPUT_VARIABLE MOJOSHADER_VERSION
     8     SET(MOJOSHADER_CHANGESET "???")
     9     ERROR_QUIET
     9 ELSE(NOT HG)
    10     OUTPUT_STRIP_TRAILING_WHITESPACE
    10     MARK_AS_ADVANCED(HG)
    11 )
    11     EXECUTE_PROCESS(
    12 EXECUTE_PROCESS(
    12         COMMAND hg tip --template {rev}
    13     COMMAND hg tip --template hg-{rev}:{node|short}
    13         WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
    14     WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
    14         RESULT_VARIABLE HGVERSION_RC
    15     RESULT_VARIABLE HGVERSION_RC
    15         OUTPUT_VARIABLE MOJOSHADER_VERSION
    16     OUTPUT_VARIABLE MOJOSHADER_CHANGESET
    16         ERROR_QUIET
    17     ERROR_QUIET
    17         OUTPUT_STRIP_TRAILING_WHITESPACE
    18     OUTPUT_STRIP_TRAILING_WHITESPACE
    18     )
    19 )
    19     EXECUTE_PROCESS(
       
    20         COMMAND hg tip --template hg-{rev}:{node|short}
       
    21         WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
       
    22         RESULT_VARIABLE HGVERSION_RC
       
    23         OUTPUT_VARIABLE MOJOSHADER_CHANGESET
       
    24         ERROR_QUIET
       
    25         OUTPUT_STRIP_TRAILING_WHITESPACE
       
    26     )
       
    27 ENDIF(NOT HG)
    20 
    28 
    21 WRITE_FILE(
    29 WRITE_FILE(
    22     "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_version.h"
    30     "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_version.h"
    23     "/* This file was autogenerated. Do not edit! */\n"
    31     "/* This file was autogenerated. Do not edit! */\n"
    24     "#ifndef _INCL_MOJOSHADER_VERSION_H_\n"
    32     "#ifndef _INCL_MOJOSHADER_VERSION_H_\n"
    46     mojoshader_lexer.c
    54     mojoshader_lexer.c
    47     mojoshader_assembler.c
    55     mojoshader_assembler.c
    48     mojoshader_opengl.c
    56     mojoshader_opengl.c
    49 )
    57 )
    50 
    58 
    51 ADD_CUSTOM_COMMAND(
    59 FIND_PROGRAM(RE2C re2c DOC "Path to re2c command line app: http://re2c.org/")
    52     OUTPUT mojoshader_lexer.c
    60 IF(NOT RE2C)
    53     DEPENDS mojoshader_lexer.re
    61     MESSAGE(STATUS "re2c missing. You can go on, but can't rebuild the lexer.")
    54     COMMAND re2c
    62 ELSE(NOT RE2C)
    55     ARGS -s -o ${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_lexer.c ${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_lexer.re
    63     MARK_AS_ADVANCED(RE2C)
    56 )
    64     ADD_CUSTOM_COMMAND(
       
    65         OUTPUT mojoshader_lexer.c
       
    66         DEPENDS mojoshader_lexer.re
       
    67         COMMAND ${RE2C}
       
    68         ARGS -s -o ${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_lexer.c ${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_lexer.re
       
    69     )
       
    70 ENDIF(NOT RE2C)
    57 
    71 
    58 FIND_PACKAGE(SDL)
    72 FIND_PACKAGE(SDL)
    59 IF(SDL_FOUND)
    73 IF(SDL_FOUND)
    60     INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
    74     INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
    61     ADD_DEFINITIONS(-DFINDERRORS_COMPILE_SHADERS=1)
    75     ADD_DEFINITIONS(-DFINDERRORS_COMPILE_SHADERS=1)