CMakeLists.txt
changeset 1150 02c0f0afb39a
parent 1134 be31bd0ee0a2
child 1166 ba0794ea4172
equal deleted inserted replaced
1149:265ab4117525 1150:02c0f0afb39a
     1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
     1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
     2 PROJECT(MojoShader)
     2 PROJECT(MojoShader)
       
     3 
       
     4 OPTION(BUILD_SHARED "Build MojoShader as a shared library" OFF)
       
     5 OPTION(PROFILE_D3D "Build MojoShader with support for the D3D profile" ON)
       
     6 OPTION(PROFILE_BYTECODE "Build MojoShader with support for the BYTECODE profile" ON)
       
     7 OPTION(PROFILE_GLSL120 "Build MojoShader with support for the GLSL120 profile" ON)
       
     8 OPTION(PROFILE_GLSL "Build MojoShader with support for the GLSL profile" ON)
       
     9 OPTION(PROFILE_ARB1 "Build MojoShader with support for the ARB1 profile" ON)
       
    10 OPTION(PROFILE_ARB1_NV "Build MojoShader with support for the ARB1_NV profile" ON)
       
    11 OPTION(EFFECT_SUPPORT "Build MojoShader with support for Effect framework files" OFF)
       
    12 OPTION(FLIP_VIEWPORT "Build MojoShader with the ability to flip the GL viewport" OFF)
       
    13 OPTION(DEPTH_CLIPPING "Build MojoShader with the ability to simulate [0, 1] depth clipping" OFF)
       
    14 OPTION(XNA4_VERTEXTEXTURE "Build MojoShader with XNA4 vertex texturing behavior" OFF)
     3 
    15 
     4 INCLUDE_DIRECTORIES(.)
    16 INCLUDE_DIRECTORIES(.)
     5 
    17 
     6 FIND_PROGRAM(HG hg DOC "Path to hg command line app: http://www.selenic.com/mercurial/")
    18 FIND_PROGRAM(HG hg DOC "Path to hg command line app: http://www.selenic.com/mercurial/")
     7 IF(NOT HG)
    19 IF(NOT HG)
    59     DEPENDS lemon "${CMAKE_CURRENT_SOURCE_DIR}/misc/lempar.c"
    71     DEPENDS lemon "${CMAKE_CURRENT_SOURCE_DIR}/misc/lempar.c"
    60     COMMAND "${LEMON}"
    72     COMMAND "${LEMON}"
    61     ARGS -q "-T${CMAKE_CURRENT_SOURCE_DIR}/misc/lempar.c" "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.lemon"
    73     ARGS -q "-T${CMAKE_CURRENT_SOURCE_DIR}/misc/lempar.c" "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.lemon"
    62 )
    74 )
    63 
    75 
    64 ADD_LIBRARY(mojoshader STATIC
    76 IF(APPLE)
       
    77     find_library(CARBON_FRAMEWORK Carbon)  # Stupid Gestalt.
       
    78 ENDIF(APPLE)
       
    79 
       
    80 IF(NOT PROFILE_D3D)
       
    81     ADD_DEFINITIONS(-DSUPPORT_PROFILE_D3D=0)
       
    82 ENDIF(NOT PROFILE_D3D)
       
    83 IF(NOT PROFILE_BYTECODE)
       
    84     ADD_DEFINITIONS(-DSUPPORT_PROFILE_BYTECODE=0)
       
    85 ENDIF(NOT PROFILE_BYTECODE)
       
    86 IF(NOT PROFILE_GLSL120)
       
    87     ADD_DEFINITIONS(-DSUPPORT_PROFILE_GLSL120=0)
       
    88 ENDIF(NOT PROFILE_GLSL120)
       
    89 IF(NOT PROFILE_GLSL)
       
    90     ADD_DEFINITIONS(-DSUPPORT_PROFILE_GLSL=0)
       
    91 ENDIF(NOT PROFILE_GLSL)
       
    92 IF(NOT PROFILE_ARB1)
       
    93     ADD_DEFINITIONS(-DSUPPORT_PROFILE_ARB1=0)
       
    94 ENDIF(NOT PROFILE_ARB1)
       
    95 IF(NOT PROFILE_ARB1_NV)
       
    96     ADD_DEFINITIONS(-DSUPPORT_PROFILE_ARB1_NV=0)
       
    97 ENDIF(NOT PROFILE_ARB1_NV)
       
    98 
       
    99 IF(EFFECT_SUPPORT)
       
   100     IF(UNIX)
       
   101         SET(LIBM -lm)
       
   102     ENDIF(UNIX)
       
   103     ADD_DEFINITIONS(-DMOJOSHADER_EFFECT_SUPPORT)
       
   104 ENDIF(EFFECT_SUPPORT)
       
   105 
       
   106 IF(FLIP_VIEWPORT)
       
   107     ADD_DEFINITIONS(-DMOJOSHADER_FLIP_RENDERTARGET)
       
   108 ENDIF(FLIP_VIEWPORT)
       
   109 
       
   110 IF(DEPTH_CLIPPING)
       
   111     ADD_DEFINITIONS(-DMOJOSHADER_DEPTH_CLIPPING)
       
   112 ENDIF(DEPTH_CLIPPING)
       
   113 
       
   114 IF(XNA4_VERTEXTEXTURE)
       
   115     ADD_DEFINITIONS(-DMOJOSHADER_XNA4_VERTEX_TEXTURES)
       
   116 ENDIF(XNA4_VERTEXTEXTURE)
       
   117 
       
   118 IF(BUILD_SHARED)
       
   119     SET(LIBRARY_FORMAT SHARED)
       
   120 ELSE(BUILD_SHARED)
       
   121     SET(LIBRARY_FORMAT STATIC)
       
   122 ENDIF(BUILD_SHARED)
       
   123 
       
   124 ADD_LIBRARY(mojoshader ${LIBRARY_FORMAT}
    65     mojoshader.c
   125     mojoshader.c
    66     mojoshader_common.c
   126     mojoshader_common.c
    67     mojoshader_effects.c
   127     mojoshader_effects.c
    68     mojoshader_compiler.c
   128     mojoshader_compiler.c
    69     mojoshader_preprocessor.c
   129     mojoshader_preprocessor.c
    70     mojoshader_lexer.c
   130     mojoshader_lexer.c
    71     mojoshader_assembler.c
   131     mojoshader_assembler.c
    72     mojoshader_opengl.c
   132     mojoshader_opengl.c
    73 )
   133 )
    74 
   134 IF(BUILD_SHARED)
    75 IF(UNIX)
   135     TARGET_LINK_LIBRARIES(mojoshader ${LIBM} ${CARBON_FRAMEWORK})
    76     SET(LIBM -lm)
   136 ENDIF(BUILD_SHARED)
    77 ENDIF(UNIX)
       
    78 
   137 
    79 SET_SOURCE_FILES_PROPERTIES(
   138 SET_SOURCE_FILES_PROPERTIES(
    80     mojoshader_compiler.c
   139     mojoshader_compiler.c
    81     PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.h"
   140     PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.h"
    82 )
   141 )
    91         DEPENDS mojoshader_lexer.re
   150         DEPENDS mojoshader_lexer.re
    92         COMMAND "${RE2C}"
   151         COMMAND "${RE2C}"
    93         ARGS -is --no-generation-date -o "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_lexer.c" "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_lexer.re"
   152         ARGS -is --no-generation-date -o "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_lexer.c" "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_lexer.re"
    94     )
   153     )
    95 ENDIF(NOT RE2C)
   154 ENDIF(NOT RE2C)
    96 
       
    97 IF(APPLE)
       
    98     find_library(CARBON_FRAMEWORK Carbon)  # Stupid Gestalt.
       
    99 ENDIF(APPLE)
       
   100 
   155 
   101 find_path(SDL2_INCLUDE_DIR SDL.h PATH_SUFFIXES include/SDL2)
   156 find_path(SDL2_INCLUDE_DIR SDL.h PATH_SUFFIXES include/SDL2)
   102 find_library(SDL2 NAMES SDL2 PATH_SUFFIXES lib)
   157 find_library(SDL2 NAMES SDL2 PATH_SUFFIXES lib)
   103 IF(SDL2)
   158 IF(SDL2)
   104     INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR})
   159     INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR})