CMakeLists.txt
author Ethan Lee <flibitijibibo@flibitijibibo.com>
Fri, 01 Jan 2016 02:12:19 -0500
changeset 1150 02c0f0afb39a
parent 1134 be31bd0ee0a2
child 1166 ba0794ea4172
permissions -rw-r--r--
- Add ability to build MojoShader as a shared library - Off by default, turn on BUILD_SHARED in CMake - Add ability to disable shader profiles from CMake - Add MOJOSHADER_glSetVertexAttribDivisor - Behaves like glSetVertexAttribute, but for glVertexAttribDivisor - Add MOJOSHADER_glGetVertexAttribLocation - Allows user to directly call glVertexAttribPointer in their program - Full Effect framework support - API is in a separate header, see mojoshader_effects.h for details - Off by default, turn on EFFECT_SUPPORT in CMake - #define MOJOSHADER_EFFECT_SUPPORT before including mojoshader.h - Add MOJOSHADER_PROFILE_GLSLES shader profile - Basically just GLSL120 without using builtins - Add ability to flip gl_Position via MOJOSHADER_glProgramViewportFlip - You probably shouldn't use this unless you're a project like FNA. - Off by default, turn on FLIP_VIEWPORT in CMake - #define MOJOSHADER_FLIP_RENDERTARGET before including mojoshader.h - Add ability to adjust Z coordinates for [0, 1]-like depth clipping - You probably shouldn't use this unless you're a project like FNA. - Off by default, turn on DEPTH_CLIPPING in CMake - Add ability to build MojoShader with XNA4 vertex texturing behavior - You probably shouldn't use this unless you're reimplementing XNA. - Off by default, turn on XNA4_VERTEXTEXTURE in CMake - Add DECLSPEC/MOJOSHADERCALL to functions/function pointers - This allows for easier interop with other languages, i.e. C# P/Invoke - Fix printing float values for locales where radix is not '.' - Various minor bugfixes, optimizations, Win32 buildfixes, etc.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
711
d547597e81de Cleaned up some CMake issues.
Ryan C. Gordon <icculus@icculus.org>
parents: 710
diff changeset
     1
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
35
5749d174b537 [svn] Might as well keep the tradition alive.
icculus
parents: 10
diff changeset
     2
PROJECT(MojoShader)
48
86dc2c772d26 [svn] Enabled -Wall, found some bugs.
icculus
parents: 35
diff changeset
     3
1150
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
     4
OPTION(BUILD_SHARED "Build MojoShader as a shared library" OFF)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
     5
OPTION(PROFILE_D3D "Build MojoShader with support for the D3D profile" ON)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
     6
OPTION(PROFILE_BYTECODE "Build MojoShader with support for the BYTECODE profile" ON)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
     7
OPTION(PROFILE_GLSL120 "Build MojoShader with support for the GLSL120 profile" ON)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
     8
OPTION(PROFILE_GLSL "Build MojoShader with support for the GLSL profile" ON)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
     9
OPTION(PROFILE_ARB1 "Build MojoShader with support for the ARB1 profile" ON)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    10
OPTION(PROFILE_ARB1_NV "Build MojoShader with support for the ARB1_NV profile" ON)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    11
OPTION(EFFECT_SUPPORT "Build MojoShader with support for Effect framework files" OFF)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    12
OPTION(FLIP_VIEWPORT "Build MojoShader with the ability to flip the GL viewport" OFF)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    13
OPTION(DEPTH_CLIPPING "Build MojoShader with the ability to simulate [0, 1] depth clipping" OFF)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    14
OPTION(XNA4_VERTEXTEXTURE "Build MojoShader with XNA4 vertex texturing behavior" OFF)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    15
588
ef3d2efa822d Moved all the test and utility programs to a "utils" directory.
Ryan C. Gordon <icculus@icculus.org>
parents: 569
diff changeset
    16
INCLUDE_DIRECTORIES(.)
ef3d2efa822d Moved all the test and utility programs to a "utils" directory.
Ryan C. Gordon <icculus@icculus.org>
parents: 569
diff changeset
    17
569
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    18
FIND_PROGRAM(HG hg DOC "Path to hg command line app: http://www.selenic.com/mercurial/")
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    19
IF(NOT HG)
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    20
    MESSAGE(STATUS "Mercurial (hg) not found. You can go on, but version info will be wrong.")
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    21
    SET(MOJOSHADER_VERSION -1)
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    22
    SET(MOJOSHADER_CHANGESET "???")
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    23
ELSE(NOT HG)
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    24
    MARK_AS_ADVANCED(HG)
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    25
    EXECUTE_PROCESS(
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    26
        COMMAND hg tip --template {rev}
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    27
        WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    28
        RESULT_VARIABLE HGVERSION_RC
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    29
        OUTPUT_VARIABLE MOJOSHADER_VERSION
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    30
        ERROR_QUIET
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    31
        OUTPUT_STRIP_TRAILING_WHITESPACE
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    32
    )
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    33
    EXECUTE_PROCESS(
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    34
        COMMAND hg tip --template hg-{rev}:{node|short}
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    35
        WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    36
        RESULT_VARIABLE HGVERSION_RC
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    37
        OUTPUT_VARIABLE MOJOSHADER_CHANGESET
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    38
        ERROR_QUIET
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    39
        OUTPUT_STRIP_TRAILING_WHITESPACE
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    40
    )
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    41
ENDIF(NOT HG)
455
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    42
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    43
WRITE_FILE(
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    44
    "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_version.h"
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    45
    "/* This file was autogenerated. Do not edit! */\n"
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    46
    "#ifndef _INCL_MOJOSHADER_VERSION_H_\n"
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    47
    "#define _INCL_MOJOSHADER_VERSION_H_\n"
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    48
    "#define MOJOSHADER_VERSION ${MOJOSHADER_VERSION}\n"
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    49
    "#define MOJOSHADER_CHANGESET \"${MOJOSHADER_CHANGESET}\"\n"
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    50
    "#endif\n"
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    51
)
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    52
48
86dc2c772d26 [svn] Enabled -Wall, found some bugs.
icculus
parents: 35
diff changeset
    53
IF(CMAKE_COMPILER_IS_GNUCC)
86dc2c772d26 [svn] Enabled -Wall, found some bugs.
icculus
parents: 35
diff changeset
    54
    ADD_DEFINITIONS(-Wall -ggdb3)
86dc2c772d26 [svn] Enabled -Wall, found some bugs.
icculus
parents: 35
diff changeset
    55
ENDIF(CMAKE_COMPILER_IS_GNUCC)
86dc2c772d26 [svn] Enabled -Wall, found some bugs.
icculus
parents: 35
diff changeset
    56
52
305ddf21d660 [svn] Okay, done with memory profiling for now.
icculus
parents: 48
diff changeset
    57
# testparse uses this when I'm looking at memory usage patterns.
305ddf21d660 [svn] Okay, done with memory profiling for now.
icculus
parents: 48
diff changeset
    58
#ADD_DEFINITIONS(-DMOJOSHADER_DEBUG_MALLOC=1)
48
86dc2c772d26 [svn] Enabled -Wall, found some bugs.
icculus
parents: 35
diff changeset
    59
254
13184ff204b9 More Windows patches.
Ryan C. Gordon <icculus@icculus.org>
parents: 225
diff changeset
    60
IF(MSVC)
13184ff204b9 More Windows patches.
Ryan C. Gordon <icculus@icculus.org>
parents: 225
diff changeset
    61
    ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS=1)
13184ff204b9 More Windows patches.
Ryan C. Gordon <icculus@icculus.org>
parents: 225
diff changeset
    62
    ADD_DEFINITIONS(-TP)  # force .c files to compile as C++.
13184ff204b9 More Windows patches.
Ryan C. Gordon <icculus@icculus.org>
parents: 225
diff changeset
    63
ENDIF(MSVC)
13184ff204b9 More Windows patches.
Ryan C. Gordon <icculus@icculus.org>
parents: 225
diff changeset
    64
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents: 705
diff changeset
    65
# We build lemon, then use it to generate parser C code.
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents: 705
diff changeset
    66
ADD_EXECUTABLE(lemon "misc/lemon.c")
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents: 705
diff changeset
    67
GET_TARGET_PROPERTY(LEMON lemon LOCATION)
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents: 705
diff changeset
    68
ADD_CUSTOM_COMMAND(
714
e8ed66bfff18 Make parser generate a header, to avoid external project build confusion.
Ryan C. Gordon <icculus@icculus.org>
parents: 711
diff changeset
    69
    OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.h"
711
d547597e81de Cleaned up some CMake issues.
Ryan C. Gordon <icculus@icculus.org>
parents: 710
diff changeset
    70
    MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.lemon"
d547597e81de Cleaned up some CMake issues.
Ryan C. Gordon <icculus@icculus.org>
parents: 710
diff changeset
    71
    DEPENDS lemon "${CMAKE_CURRENT_SOURCE_DIR}/misc/lempar.c"
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents: 705
diff changeset
    72
    COMMAND "${LEMON}"
810
367f7133bd71 Don't suppress #line directives in lemon output.
Ryan C. Gordon <icculus@icculus.org>
parents: 738
diff changeset
    73
    ARGS -q "-T${CMAKE_CURRENT_SOURCE_DIR}/misc/lempar.c" "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.lemon"
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents: 705
diff changeset
    74
)
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents: 705
diff changeset
    75
1150
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    76
IF(APPLE)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    77
    find_library(CARBON_FRAMEWORK Carbon)  # Stupid Gestalt.
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    78
ENDIF(APPLE)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    79
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    80
IF(NOT PROFILE_D3D)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    81
    ADD_DEFINITIONS(-DSUPPORT_PROFILE_D3D=0)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    82
ENDIF(NOT PROFILE_D3D)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    83
IF(NOT PROFILE_BYTECODE)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    84
    ADD_DEFINITIONS(-DSUPPORT_PROFILE_BYTECODE=0)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    85
ENDIF(NOT PROFILE_BYTECODE)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    86
IF(NOT PROFILE_GLSL120)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    87
    ADD_DEFINITIONS(-DSUPPORT_PROFILE_GLSL120=0)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    88
ENDIF(NOT PROFILE_GLSL120)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    89
IF(NOT PROFILE_GLSL)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    90
    ADD_DEFINITIONS(-DSUPPORT_PROFILE_GLSL=0)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    91
ENDIF(NOT PROFILE_GLSL)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    92
IF(NOT PROFILE_ARB1)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    93
    ADD_DEFINITIONS(-DSUPPORT_PROFILE_ARB1=0)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    94
ENDIF(NOT PROFILE_ARB1)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    95
IF(NOT PROFILE_ARB1_NV)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    96
    ADD_DEFINITIONS(-DSUPPORT_PROFILE_ARB1_NV=0)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    97
ENDIF(NOT PROFILE_ARB1_NV)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    98
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    99
IF(EFFECT_SUPPORT)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   100
    IF(UNIX)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   101
        SET(LIBM -lm)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   102
    ENDIF(UNIX)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   103
    ADD_DEFINITIONS(-DMOJOSHADER_EFFECT_SUPPORT)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   104
ENDIF(EFFECT_SUPPORT)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   105
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   106
IF(FLIP_VIEWPORT)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   107
    ADD_DEFINITIONS(-DMOJOSHADER_FLIP_RENDERTARGET)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   108
ENDIF(FLIP_VIEWPORT)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   109
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   110
IF(DEPTH_CLIPPING)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   111
    ADD_DEFINITIONS(-DMOJOSHADER_DEPTH_CLIPPING)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   112
ENDIF(DEPTH_CLIPPING)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   113
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   114
IF(XNA4_VERTEXTEXTURE)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   115
    ADD_DEFINITIONS(-DMOJOSHADER_XNA4_VERTEX_TEXTURES)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   116
ENDIF(XNA4_VERTEXTEXTURE)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   117
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   118
IF(BUILD_SHARED)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   119
    SET(LIBRARY_FORMAT SHARED)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   120
ELSE(BUILD_SHARED)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   121
    SET(LIBRARY_FORMAT STATIC)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   122
ENDIF(BUILD_SHARED)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   123
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   124
ADD_LIBRARY(mojoshader ${LIBRARY_FORMAT}
465
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 455
diff changeset
   125
    mojoshader.c
732
e070fea1f8c7 Added mojoshader_common.c with first shot at generic hashtable.
Ryan C. Gordon <icculus@icculus.org>
parents: 714
diff changeset
   126
    mojoshader_common.c
1019
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
   127
    mojoshader_effects.c
706
01a92f30b84f Added some basic compiler stub stuff, just to get this building at all.
Ryan C. Gordon <icculus@icculus.org>
parents: 705
diff changeset
   128
    mojoshader_compiler.c
555
940821555fda Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents: 473
diff changeset
   129
    mojoshader_preprocessor.c
940821555fda Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents: 473
diff changeset
   130
    mojoshader_lexer.c
465
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 455
diff changeset
   131
    mojoshader_assembler.c
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 455
diff changeset
   132
    mojoshader_opengl.c
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 455
diff changeset
   133
)
1150
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   134
IF(BUILD_SHARED)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   135
    TARGET_LINK_LIBRARIES(mojoshader ${LIBM} ${CARBON_FRAMEWORK})
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   136
ENDIF(BUILD_SHARED)
1036
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1019
diff changeset
   137
711
d547597e81de Cleaned up some CMake issues.
Ryan C. Gordon <icculus@icculus.org>
parents: 710
diff changeset
   138
SET_SOURCE_FILES_PROPERTIES(
d547597e81de Cleaned up some CMake issues.
Ryan C. Gordon <icculus@icculus.org>
parents: 710
diff changeset
   139
    mojoshader_compiler.c
714
e8ed66bfff18 Make parser generate a header, to avoid external project build confusion.
Ryan C. Gordon <icculus@icculus.org>
parents: 711
diff changeset
   140
    PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.h"
711
d547597e81de Cleaned up some CMake issues.
Ryan C. Gordon <icculus@icculus.org>
parents: 710
diff changeset
   141
)
d547597e81de Cleaned up some CMake issues.
Ryan C. Gordon <icculus@icculus.org>
parents: 710
diff changeset
   142
569
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
   143
FIND_PROGRAM(RE2C re2c DOC "Path to re2c command line app: http://re2c.org/")
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
   144
IF(NOT RE2C)
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
   145
    MESSAGE(STATUS "re2c missing. You can go on, but can't rebuild the lexer.")
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
   146
ELSE(NOT RE2C)
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
   147
    MARK_AS_ADVANCED(RE2C)
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
   148
    ADD_CUSTOM_COMMAND(
705
7ea12a852213 Throw some quotes around strings in CMakeLists.txt ...
Ryan C. Gordon <icculus@icculus.org>
parents: 669
diff changeset
   149
        OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_lexer.c"
569
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
   150
        DEPENDS mojoshader_lexer.re
705
7ea12a852213 Throw some quotes around strings in CMakeLists.txt ...
Ryan C. Gordon <icculus@icculus.org>
parents: 669
diff changeset
   151
        COMMAND "${RE2C}"
7ea12a852213 Throw some quotes around strings in CMakeLists.txt ...
Ryan C. Gordon <icculus@icculus.org>
parents: 669
diff changeset
   152
        ARGS -is --no-generation-date -o "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_lexer.c" "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_lexer.re"
569
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
   153
    )
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
   154
ENDIF(NOT RE2C)
563
d22551643fcb Added re2c step to build.
Ryan C. Gordon <icculus@icculus.org>
parents: 555
diff changeset
   155
1134
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   156
find_path(SDL2_INCLUDE_DIR SDL.h PATH_SUFFIXES include/SDL2)
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   157
find_library(SDL2 NAMES SDL2 PATH_SUFFIXES lib)
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   158
IF(SDL2)
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   159
    INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR})
588
ef3d2efa822d Moved all the test and utility programs to a "utils" directory.
Ryan C. Gordon <icculus@icculus.org>
parents: 569
diff changeset
   160
    ADD_EXECUTABLE(glcaps utils/glcaps.c)
1134
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   161
    TARGET_LINK_LIBRARIES(glcaps ${SDL2} ${LIBM} ${CARBON_FRAMEWORK})
588
ef3d2efa822d Moved all the test and utility programs to a "utils" directory.
Ryan C. Gordon <icculus@icculus.org>
parents: 569
diff changeset
   162
    ADD_EXECUTABLE(bestprofile utils/bestprofile.c)
1134
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   163
    TARGET_LINK_LIBRARIES(bestprofile mojoshader ${SDL2} ${LIBM} ${CARBON_FRAMEWORK})
588
ef3d2efa822d Moved all the test and utility programs to a "utils" directory.
Ryan C. Gordon <icculus@icculus.org>
parents: 569
diff changeset
   164
    ADD_EXECUTABLE(availableprofiles utils/availableprofiles.c)
1134
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   165
    TARGET_LINK_LIBRARIES(availableprofiles mojoshader ${SDL2} ${LIBM} ${CARBON_FRAMEWORK})
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   166
ENDIF(SDL2)
169
7e9d90724cf8 Push parsed shaders through GLSL compiler to see what breaks.
Ryan C. Gordon <icculus@icculus.org>
parents: 153
diff changeset
   167
711
d547597e81de Cleaned up some CMake issues.
Ryan C. Gordon <icculus@icculus.org>
parents: 710
diff changeset
   168
ADD_EXECUTABLE(finderrors utils/finderrors.c)
1134
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   169
TARGET_LINK_LIBRARIES(finderrors mojoshader ${SDL2} ${LIBM} ${CARBON_FRAMEWORK})
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   170
IF(SDL2)
711
d547597e81de Cleaned up some CMake issues.
Ryan C. Gordon <icculus@icculus.org>
parents: 710
diff changeset
   171
    SET_SOURCE_FILES_PROPERTIES(
d547597e81de Cleaned up some CMake issues.
Ryan C. Gordon <icculus@icculus.org>
parents: 710
diff changeset
   172
        utils/finderrors.c
d547597e81de Cleaned up some CMake issues.
Ryan C. Gordon <icculus@icculus.org>
parents: 710
diff changeset
   173
        PROPERTIES COMPILE_FLAGS "-DFINDERRORS_COMPILE_SHADERS=1"
d547597e81de Cleaned up some CMake issues.
Ryan C. Gordon <icculus@icculus.org>
parents: 710
diff changeset
   174
    )
1134
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   175
ENDIF(SDL2)
711
d547597e81de Cleaned up some CMake issues.
Ryan C. Gordon <icculus@icculus.org>
parents: 710
diff changeset
   176
588
ef3d2efa822d Moved all the test and utility programs to a "utils" directory.
Ryan C. Gordon <icculus@icculus.org>
parents: 569
diff changeset
   177
ADD_EXECUTABLE(testparse utils/testparse.c)
1134
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   178
TARGET_LINK_LIBRARIES(testparse mojoshader ${LIBM} ${CARBON_FRAMEWORK})
588
ef3d2efa822d Moved all the test and utility programs to a "utils" directory.
Ryan C. Gordon <icculus@icculus.org>
parents: 569
diff changeset
   179
ADD_EXECUTABLE(testoutput utils/testoutput.c)
1134
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   180
TARGET_LINK_LIBRARIES(testoutput mojoshader ${LIBM} ${CARBON_FRAMEWORK})
669
fd14a7278a95 Merged assemble.c into mojoshader-compiler.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 613
diff changeset
   181
ADD_EXECUTABLE(mojoshader-compiler utils/mojoshader-compiler.c)
1134
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   182
TARGET_LINK_LIBRARIES(mojoshader-compiler mojoshader ${LIBM} ${CARBON_FRAMEWORK})
1
99ac16070d07 [svn] Initial add.
icculus
parents:
diff changeset
   183
737
d028bf9d8096 Wired up unit tests to CMakefile.
Ryan C. Gordon <icculus@icculus.org>
parents: 732
diff changeset
   184
# Unit tests...
d028bf9d8096 Wired up unit tests to CMakefile.
Ryan C. Gordon <icculus@icculus.org>
parents: 732
diff changeset
   185
ADD_CUSTOM_TARGET(
d028bf9d8096 Wired up unit tests to CMakefile.
Ryan C. Gordon <icculus@icculus.org>
parents: 732
diff changeset
   186
    test
d028bf9d8096 Wired up unit tests to CMakefile.
Ryan C. Gordon <icculus@icculus.org>
parents: 732
diff changeset
   187
    COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/unit_tests/run_tests.pl"
d028bf9d8096 Wired up unit tests to CMakefile.
Ryan C. Gordon <icculus@icculus.org>
parents: 732
diff changeset
   188
    WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
738
023189c285f6 test command depends on the compiler tool.
Ryan C. Gordon <icculus@icculus.org>
parents: 737
diff changeset
   189
    DEPENDS mojoshader-compiler
737
d028bf9d8096 Wired up unit tests to CMakefile.
Ryan C. Gordon <icculus@icculus.org>
parents: 732
diff changeset
   190
    COMMENT "Running unit tests..."
738
023189c285f6 test command depends on the compiler tool.
Ryan C. Gordon <icculus@icculus.org>
parents: 737
diff changeset
   191
    VERBATIM
737
d028bf9d8096 Wired up unit tests to CMakefile.
Ryan C. Gordon <icculus@icculus.org>
parents: 732
diff changeset
   192
)
d028bf9d8096 Wired up unit tests to CMakefile.
Ryan C. Gordon <icculus@icculus.org>
parents: 732
diff changeset
   193
1
99ac16070d07 [svn] Initial add.
icculus
parents:
diff changeset
   194
# End of CMakeLists.txt ...
99ac16070d07 [svn] Initial add.
icculus
parents:
diff changeset
   195