CMakeLists.txt
author Ryan C. Gordon <icculus@icculus.org>
Mon, 20 Jul 2020 20:07:06 -0400
changeset 1296 9b3b01f2a9b7
parent 1295 f592791e062e
child 1307 f7efdb215d49
permissions -rw-r--r--
d3d11: Only build the D3D11 glue code on Windows.
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
1233
e3bd5f116e38 Use CMake built-in BUILD_SHARED_LIBS
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1230
diff changeset
     4
OPTION(BUILD_SHARED_LIBS "Build MojoShader as a shared library" OFF)
1150
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)
1255
0135d797e287 Implement HLSL emitter, MOJOSHADER_d3d11 API
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1233
diff changeset
     7
OPTION(PROFILE_HLSL "Build MojoShader with support for the HLSL profile" ON)
1150
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
     8
OPTION(PROFILE_GLSL120 "Build MojoShader with support for the GLSL120 profile" ON)
1194
3948d7f5b4ff Add PROFILE_GLSLES CMake option
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1192
diff changeset
     9
OPTION(PROFILE_GLSLES "Build MojoShader with support for the GLSLES profile" ON)
1150
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    10
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
    11
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
    12
OPTION(PROFILE_ARB1_NV "Build MojoShader with support for the ARB1_NV profile" ON)
1172
55700e64bd8c Make Metal profile optional in the CMake project.
Ryan C. Gordon <icculus@icculus.org>
parents: 1166
diff changeset
    13
OPTION(PROFILE_METAL "Build MojoShader with support for the Metal profile" ON)
1224
21cd84f1aa0a Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents: 1202
diff changeset
    14
OPTION(PROFILE_SPIRV "Build MojoShader with support for the SPIR-V profile" ON)
1225
50b8dd7e0b1a Add GLSPIRV profile, to allow for both GL- and VK-friendly SPIR-V output
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1224
diff changeset
    15
OPTION(PROFILE_GLSPIRV "Build MojoShader with support for the ARB_gl_spirv profile" ON)
1166
ba0794ea4172 Default to building with Effects framework support enabled.
Ryan C. Gordon <icculus@icculus.org>
parents: 1150
diff changeset
    16
OPTION(EFFECT_SUPPORT "Build MojoShader with support for Effect framework files" ON)
1295
f592791e062e cmake: build the HLSL profile by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 1272
diff changeset
    17
OPTION(COMPILER_SUPPORT "Build MojoShader with support for HLSL source files" ON)
1150
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
    18
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
    19
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
    20
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
    21
588
ef3d2efa822d Moved all the test and utility programs to a "utils" directory.
Ryan C. Gordon <icculus@icculus.org>
parents: 569
diff changeset
    22
INCLUDE_DIRECTORIES(.)
ef3d2efa822d Moved all the test and utility programs to a "utils" directory.
Ryan C. Gordon <icculus@icculus.org>
parents: 569
diff changeset
    23
1191
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    24
# If Mercurial is installed and we are in a mercurial repository, include the rev# and changeset as version information.
569
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    25
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
    26
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
    27
    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
    28
    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
    29
    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
    30
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
    31
    MARK_AS_ADVANCED(HG)
1191
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    32
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    33
    # See if we are in an hg repository.
569
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    34
    EXECUTE_PROCESS(
1191
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    35
        COMMAND hg root
569
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    36
        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
    37
        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
    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
    )
1191
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    40
    IF(NOT HGVERSION_RC EQUAL 0)
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    41
        MESSAGE(STATUS "Mercurial (hg) repository not found. You can go on, but version info will be wrong.")
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    42
        SET(MOJOSHADER_VERSION -1)
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    43
        SET(MOJOSHADER_CHANGESET "???")
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    44
    ELSE(NOT HGVERSION_RC EQUAL 0)
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    45
        # Query the rev and changeset.
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    46
        EXECUTE_PROCESS(
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    47
            COMMAND hg tip --template {rev}
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    48
            WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    49
            RESULT_VARIABLE HGVERSION_RC
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    50
            OUTPUT_VARIABLE MOJOSHADER_VERSION
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    51
            ERROR_QUIET
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    52
            OUTPUT_STRIP_TRAILING_WHITESPACE
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    53
        )
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    54
        EXECUTE_PROCESS(
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    55
            COMMAND hg tip --template hg-{rev}:{node|short}
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    56
            WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    57
            RESULT_VARIABLE HGVERSION_RC
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    58
            OUTPUT_VARIABLE MOJOSHADER_CHANGESET
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    59
            ERROR_QUIET
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    60
            OUTPUT_STRIP_TRAILING_WHITESPACE
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    61
        )
f2ecd5032ffe CMake: Make Hg dependency optional (thanks Chad!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1187
diff changeset
    62
    ENDIF(NOT HGVERSION_RC EQUAL 0)
569
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
    63
ENDIF(NOT HG)
455
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    64
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    65
WRITE_FILE(
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    66
    "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_version.h"
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    67
    "/* This file was autogenerated. Do not edit! */\n"
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    68
    "#ifndef _INCL_MOJOSHADER_VERSION_H_\n"
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    69
    "#define _INCL_MOJOSHADER_VERSION_H_\n"
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    70
    "#define MOJOSHADER_VERSION ${MOJOSHADER_VERSION}\n"
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    71
    "#define MOJOSHADER_CHANGESET \"${MOJOSHADER_CHANGESET}\"\n"
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    72
    "#endif\n"
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    73
)
d99f47386d51 Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    74
48
86dc2c772d26 [svn] Enabled -Wall, found some bugs.
icculus
parents: 35
diff changeset
    75
IF(CMAKE_COMPILER_IS_GNUCC)
86dc2c772d26 [svn] Enabled -Wall, found some bugs.
icculus
parents: 35
diff changeset
    76
    ADD_DEFINITIONS(-Wall -ggdb3)
86dc2c772d26 [svn] Enabled -Wall, found some bugs.
icculus
parents: 35
diff changeset
    77
ENDIF(CMAKE_COMPILER_IS_GNUCC)
86dc2c772d26 [svn] Enabled -Wall, found some bugs.
icculus
parents: 35
diff changeset
    78
52
305ddf21d660 [svn] Okay, done with memory profiling for now.
icculus
parents: 48
diff changeset
    79
# 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
    80
#ADD_DEFINITIONS(-DMOJOSHADER_DEBUG_MALLOC=1)
48
86dc2c772d26 [svn] Enabled -Wall, found some bugs.
icculus
parents: 35
diff changeset
    81
254
13184ff204b9 More Windows patches.
Ryan C. Gordon <icculus@icculus.org>
parents: 225
diff changeset
    82
IF(MSVC)
13184ff204b9 More Windows patches.
Ryan C. Gordon <icculus@icculus.org>
parents: 225
diff changeset
    83
    ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS=1)
13184ff204b9 More Windows patches.
Ryan C. Gordon <icculus@icculus.org>
parents: 225
diff changeset
    84
    ADD_DEFINITIONS(-TP)  # force .c files to compile as C++.
13184ff204b9 More Windows patches.
Ryan C. Gordon <icculus@icculus.org>
parents: 225
diff changeset
    85
ENDIF(MSVC)
13184ff204b9 More Windows patches.
Ryan C. Gordon <icculus@icculus.org>
parents: 225
diff changeset
    86
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
    87
# We build lemon, then use it to generate parser C code.
1187
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
    88
IF(COMPILER_SUPPORT)
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
    89
    ADD_EXECUTABLE(lemon "misc/lemon.c")
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
    90
    GET_TARGET_PROPERTY(LEMON lemon LOCATION)
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
    91
    ADD_CUSTOM_COMMAND(
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
    92
        OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.h"
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
    93
        MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.lemon"
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
    94
        DEPENDS lemon "${CMAKE_CURRENT_SOURCE_DIR}/misc/lempar.c"
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
    95
        COMMAND "${LEMON}"
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
    96
        ARGS -q "-T${CMAKE_CURRENT_SOURCE_DIR}/misc/lempar.c" "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_parser_hlsl.lemon"
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
    97
    )
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
    98
ENDIF(COMPILER_SUPPORT)
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
    99
1150
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   100
IF(APPLE)
1192
706e4d246ca1 iOS support (thanks Caleb!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1191
diff changeset
   101
    IF(NOT IOS)
706e4d246ca1 iOS support (thanks Caleb!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1191
diff changeset
   102
        find_library(CARBON_FRAMEWORK Carbon)  # Stupid Gestalt.
706e4d246ca1 iOS support (thanks Caleb!)
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1191
diff changeset
   103
    ENDIF(NOT IOS)
1150
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   104
ENDIF(APPLE)
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(NOT PROFILE_D3D)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   107
    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
   108
ENDIF(NOT PROFILE_D3D)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   109
IF(NOT PROFILE_BYTECODE)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   110
    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
   111
ENDIF(NOT PROFILE_BYTECODE)
1255
0135d797e287 Implement HLSL emitter, MOJOSHADER_d3d11 API
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1233
diff changeset
   112
IF(NOT PROFILE_HLSL)
0135d797e287 Implement HLSL emitter, MOJOSHADER_d3d11 API
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1233
diff changeset
   113
    ADD_DEFINITIONS(-DSUPPORT_PROFILE_HLSL=0)
0135d797e287 Implement HLSL emitter, MOJOSHADER_d3d11 API
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1233
diff changeset
   114
ENDIF(NOT PROFILE_HLSL)
1150
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   115
IF(NOT PROFILE_GLSL120)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   116
    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
   117
ENDIF(NOT PROFILE_GLSL120)
1194
3948d7f5b4ff Add PROFILE_GLSLES CMake option
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1192
diff changeset
   118
IF(NOT PROFILE_GLSLES)
3948d7f5b4ff Add PROFILE_GLSLES CMake option
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1192
diff changeset
   119
    ADD_DEFINITIONS(-DSUPPORT_PROFILE_GLSLES=0)
3948d7f5b4ff Add PROFILE_GLSLES CMake option
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1192
diff changeset
   120
ENDIF(NOT PROFILE_GLSLES)
1150
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   121
IF(NOT PROFILE_GLSL)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   122
    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
   123
ENDIF(NOT PROFILE_GLSL)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   124
IF(NOT PROFILE_ARB1)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   125
    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
   126
ENDIF(NOT PROFILE_ARB1)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   127
IF(NOT PROFILE_ARB1_NV)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   128
    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
   129
ENDIF(NOT PROFILE_ARB1_NV)
1172
55700e64bd8c Make Metal profile optional in the CMake project.
Ryan C. Gordon <icculus@icculus.org>
parents: 1166
diff changeset
   130
IF(NOT PROFILE_METAL)
55700e64bd8c Make Metal profile optional in the CMake project.
Ryan C. Gordon <icculus@icculus.org>
parents: 1166
diff changeset
   131
    ADD_DEFINITIONS(-DSUPPORT_PROFILE_METAL=0)
1230
600d972bbd57 -lobjc for Metal support
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1229
diff changeset
   132
ELSE(NOT PROFILE_METAL)
600d972bbd57 -lobjc for Metal support
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1229
diff changeset
   133
    SET(LOBJC -lobjc)
1187
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   134
ENDIF(NOT PROFILE_METAL)
1224
21cd84f1aa0a Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents: 1202
diff changeset
   135
IF(NOT PROFILE_SPIRV)
21cd84f1aa0a Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents: 1202
diff changeset
   136
    ADD_DEFINITIONS(-DSUPPORT_PROFILE_SPIRV=0)
21cd84f1aa0a Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents: 1202
diff changeset
   137
ENDIF(NOT PROFILE_SPIRV)
1225
50b8dd7e0b1a Add GLSPIRV profile, to allow for both GL- and VK-friendly SPIR-V output
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1224
diff changeset
   138
IF(NOT PROFILE_GLSPIRV)
50b8dd7e0b1a Add GLSPIRV profile, to allow for both GL- and VK-friendly SPIR-V output
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1224
diff changeset
   139
    ADD_DEFINITIONS(-DSUPPORT_PROFILE_GLSPIRV=0)
50b8dd7e0b1a Add GLSPIRV profile, to allow for both GL- and VK-friendly SPIR-V output
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1224
diff changeset
   140
ENDIF(NOT PROFILE_GLSPIRV)
1150
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   141
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   142
IF(EFFECT_SUPPORT)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   143
    IF(UNIX)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   144
        SET(LIBM -lm)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   145
    ENDIF(UNIX)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   146
    ADD_DEFINITIONS(-DMOJOSHADER_EFFECT_SUPPORT)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   147
ENDIF(EFFECT_SUPPORT)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   148
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   149
IF(FLIP_VIEWPORT)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   150
    ADD_DEFINITIONS(-DMOJOSHADER_FLIP_RENDERTARGET)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   151
ENDIF(FLIP_VIEWPORT)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   152
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   153
IF(DEPTH_CLIPPING)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   154
    ADD_DEFINITIONS(-DMOJOSHADER_DEPTH_CLIPPING)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   155
ENDIF(DEPTH_CLIPPING)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   156
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   157
IF(XNA4_VERTEXTEXTURE)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   158
    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
   159
ENDIF(XNA4_VERTEXTEXTURE)
02c0f0afb39a - Add ability to build MojoShader as a shared library
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1134
diff changeset
   160
1233
e3bd5f116e38 Use CMake built-in BUILD_SHARED_LIBS
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1230
diff changeset
   161
ADD_LIBRARY(mojoshader
465
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 455
diff changeset
   162
    mojoshader.c
732
e070fea1f8c7 Added mojoshader_common.c with first shot at generic hashtable.
Ryan C. Gordon <icculus@icculus.org>
parents: 714
diff changeset
   163
    mojoshader_common.c
465
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 455
diff changeset
   164
    mojoshader_opengl.c
1229
3ecd29a50d9d Metal Effect support!
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1225
diff changeset
   165
    mojoshader_metal.c
1255
0135d797e287 Implement HLSL emitter, MOJOSHADER_d3d11 API
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1233
diff changeset
   166
    mojoshader_d3d11.c
1271
5a67d082c55f Add support for Vulkan rendering.
Evan Hemsley <evan@moonside.games>
parents: 1255
diff changeset
   167
    mojoshader_vulkan.c
1199
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1194
diff changeset
   168
    profiles/mojoshader_profile_arb1.c
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1194
diff changeset
   169
    profiles/mojoshader_profile_bytecode.c
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1194
diff changeset
   170
    profiles/mojoshader_profile_d3d.c
1255
0135d797e287 Implement HLSL emitter, MOJOSHADER_d3d11 API
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1233
diff changeset
   171
    profiles/mojoshader_profile_hlsl.c
1199
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1194
diff changeset
   172
    profiles/mojoshader_profile_glsl.c
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1194
diff changeset
   173
    profiles/mojoshader_profile_metal.c
1224
21cd84f1aa0a Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents: 1202
diff changeset
   174
    profiles/mojoshader_profile_spirv.c
1199
b8ece252a201 Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents: 1194
diff changeset
   175
    profiles/mojoshader_profile_common.c
465
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 455
diff changeset
   176
)
1187
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   177
IF(EFFECT_SUPPORT)
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   178
    TARGET_SOURCES(mojoshader PRIVATE
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   179
        mojoshader_effects.c
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   180
    )
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   181
ENDIF(EFFECT_SUPPORT)
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   182
IF(COMPILER_SUPPORT)
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   183
    TARGET_SOURCES(mojoshader PRIVATE
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   184
        mojoshader_compiler.c
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   185
        mojoshader_preprocessor.c
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   186
        mojoshader_lexer.c
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   187
        mojoshader_assembler.c
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   188
    )
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   189
ENDIF(COMPILER_SUPPORT)
1233
e3bd5f116e38 Use CMake built-in BUILD_SHARED_LIBS
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1230
diff changeset
   190
IF(BUILD_SHARED_LIBS)
1230
600d972bbd57 -lobjc for Metal support
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1229
diff changeset
   191
    TARGET_LINK_LIBRARIES(mojoshader ${LIBM} ${LOBJC} ${CARBON_FRAMEWORK})
1233
e3bd5f116e38 Use CMake built-in BUILD_SHARED_LIBS
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1230
diff changeset
   192
ENDIF(BUILD_SHARED_LIBS)
1036
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1019
diff changeset
   193
1271
5a67d082c55f Add support for Vulkan rendering.
Evan Hemsley <evan@moonside.games>
parents: 1255
diff changeset
   194
TARGET_INCLUDE_DIRECTORIES(mojoshader PUBLIC
1272
cddbd25553fe Fix include path for vulkan.h
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1271
diff changeset
   195
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../Vulkan-Headers/include>
1271
5a67d082c55f Add support for Vulkan rendering.
Evan Hemsley <evan@moonside.games>
parents: 1255
diff changeset
   196
)
5a67d082c55f Add support for Vulkan rendering.
Evan Hemsley <evan@moonside.games>
parents: 1255
diff changeset
   197
711
d547597e81de Cleaned up some CMake issues.
Ryan C. Gordon <icculus@icculus.org>
parents: 710
diff changeset
   198
SET_SOURCE_FILES_PROPERTIES(
d547597e81de Cleaned up some CMake issues.
Ryan C. Gordon <icculus@icculus.org>
parents: 710
diff changeset
   199
    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
   200
    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
   201
)
d547597e81de Cleaned up some CMake issues.
Ryan C. Gordon <icculus@icculus.org>
parents: 710
diff changeset
   202
569
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
   203
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
   204
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
   205
    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
   206
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
   207
    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
   208
    ADD_CUSTOM_COMMAND(
705
7ea12a852213 Throw some quotes around strings in CMakeLists.txt ...
Ryan C. Gordon <icculus@icculus.org>
parents: 669
diff changeset
   209
        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
   210
        DEPENDS mojoshader_lexer.re
705
7ea12a852213 Throw some quotes around strings in CMakeLists.txt ...
Ryan C. Gordon <icculus@icculus.org>
parents: 669
diff changeset
   211
        COMMAND "${RE2C}"
7ea12a852213 Throw some quotes around strings in CMakeLists.txt ...
Ryan C. Gordon <icculus@icculus.org>
parents: 669
diff changeset
   212
        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
   213
    )
117d6e606c4e Cleaned up CMakeLists.txt to work in the absence of external tools.
Ryan C. Gordon <icculus@icculus.org>
parents: 563
diff changeset
   214
ENDIF(NOT RE2C)
563
d22551643fcb Added re2c step to build.
Ryan C. Gordon <icculus@icculus.org>
parents: 555
diff changeset
   215
1134
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   216
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
   217
find_library(SDL2 NAMES SDL2 PATH_SUFFIXES lib)
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   218
IF(SDL2)
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   219
    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
   220
    ADD_EXECUTABLE(glcaps utils/glcaps.c)
1230
600d972bbd57 -lobjc for Metal support
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1229
diff changeset
   221
    TARGET_LINK_LIBRARIES(glcaps ${SDL2} ${LIBM} ${LOBJC} ${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
   222
    ADD_EXECUTABLE(bestprofile utils/bestprofile.c)
1230
600d972bbd57 -lobjc for Metal support
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1229
diff changeset
   223
    TARGET_LINK_LIBRARIES(bestprofile mojoshader ${SDL2} ${LIBM} ${LOBJC} ${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
   224
    ADD_EXECUTABLE(availableprofiles utils/availableprofiles.c)
1230
600d972bbd57 -lobjc for Metal support
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1229
diff changeset
   225
    TARGET_LINK_LIBRARIES(availableprofiles mojoshader ${SDL2} ${LIBM} ${LOBJC} ${CARBON_FRAMEWORK})
1134
be31bd0ee0a2 Moved to SDL2.
Ryan C. Gordon <icculus@icculus.org>
parents: 1036
diff changeset
   226
ENDIF(SDL2)
169
7e9d90724cf8 Push parsed shaders through GLSL compiler to see what breaks.
Ryan C. Gordon <icculus@icculus.org>
parents: 153
diff changeset
   227
1187
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   228
IF(COMPILER_SUPPORT)
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   229
    ADD_EXECUTABLE(finderrors utils/finderrors.c)
1230
600d972bbd57 -lobjc for Metal support
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1229
diff changeset
   230
    TARGET_LINK_LIBRARIES(finderrors mojoshader ${SDL2} ${LIBM} ${LOBJC} ${CARBON_FRAMEWORK})
1187
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   231
    IF(SDL2)
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   232
        SET_SOURCE_FILES_PROPERTIES(
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   233
            utils/finderrors.c
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   234
            PROPERTIES COMPILE_FLAGS "-DFINDERRORS_COMPILE_SHADERS=1"
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   235
        )
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   236
    ENDIF(SDL2)
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   237
ENDIF(COMPILER_SUPPORT)
711
d547597e81de Cleaned up some CMake issues.
Ryan C. Gordon <icculus@icculus.org>
parents: 710
diff changeset
   238
1224
21cd84f1aa0a Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents: 1202
diff changeset
   239
FIND_PATH(SPIRV_TOOLS_INCLUDE_DIR "spirv-tools/libspirv.h" PATH_SUFFIXES "include")
21cd84f1aa0a Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents: 1202
diff changeset
   240
FIND_LIBRARY(SPIRV_TOOLS_LIBRARY NAMES SPIRV-Tools-shared)
21cd84f1aa0a Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents: 1202
diff changeset
   241
IF(SPIRV_TOOLS_INCLUDE_DIR AND SPIRV_TOOLS_LIBRARY)
21cd84f1aa0a Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents: 1202
diff changeset
   242
    INCLUDE_DIRECTORIES(${SPIRV_TOOLS_INCLUDE_DIR})
21cd84f1aa0a Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents: 1202
diff changeset
   243
    ADD_DEFINITIONS(-DMOJOSHADER_HAS_SPIRV_TOOLS)
21cd84f1aa0a Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents: 1202
diff changeset
   244
ENDIF(SPIRV_TOOLS_INCLUDE_DIR AND SPIRV_TOOLS_LIBRARY)
21cd84f1aa0a Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents: 1202
diff changeset
   245
588
ef3d2efa822d Moved all the test and utility programs to a "utils" directory.
Ryan C. Gordon <icculus@icculus.org>
parents: 569
diff changeset
   246
ADD_EXECUTABLE(testparse utils/testparse.c)
1230
600d972bbd57 -lobjc for Metal support
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1229
diff changeset
   247
TARGET_LINK_LIBRARIES(testparse mojoshader ${LIBM} ${LOBJC} ${CARBON_FRAMEWORK})
1224
21cd84f1aa0a Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents: 1202
diff changeset
   248
IF(SPIRV_TOOLS_INCLUDE_DIR AND SPIRV_TOOLS_LIBRARY)
21cd84f1aa0a Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents: 1202
diff changeset
   249
    TARGET_LINK_LIBRARIES(testparse ${SPIRV_TOOLS_LIBRARY})
21cd84f1aa0a Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents: 1202
diff changeset
   250
ENDIF(SPIRV_TOOLS_INCLUDE_DIR AND SPIRV_TOOLS_LIBRARY)
588
ef3d2efa822d Moved all the test and utility programs to a "utils" directory.
Ryan C. Gordon <icculus@icculus.org>
parents: 569
diff changeset
   251
ADD_EXECUTABLE(testoutput utils/testoutput.c)
1230
600d972bbd57 -lobjc for Metal support
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1229
diff changeset
   252
TARGET_LINK_LIBRARIES(testoutput mojoshader ${LIBM} ${LOBJC} ${CARBON_FRAMEWORK})
1187
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   253
IF(COMPILER_SUPPORT)
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   254
    ADD_EXECUTABLE(mojoshader-compiler utils/mojoshader-compiler.c)
1230
600d972bbd57 -lobjc for Metal support
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1229
diff changeset
   255
    TARGET_LINK_LIBRARIES(mojoshader-compiler mojoshader ${LIBM} ${LOBJC} ${CARBON_FRAMEWORK})
1187
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   256
ENDIF(COMPILER_SUPPORT)
1
99ac16070d07 [svn] Initial add.
icculus
parents:
diff changeset
   257
737
d028bf9d8096 Wired up unit tests to CMakefile.
Ryan C. Gordon <icculus@icculus.org>
parents: 732
diff changeset
   258
# Unit tests...
1187
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   259
IF(COMPILER_SUPPORT)
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   260
    ADD_CUSTOM_TARGET(
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   261
        test
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   262
        COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/unit_tests/run_tests.pl"
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   263
        WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   264
        DEPENDS mojoshader-compiler
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   265
        COMMENT "Running unit tests..."
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   266
        VERBATIM
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   267
    )
0687a8d78a54 Add COMPILER_SUPPORT CMake flag, do not build effect/compiler files if disabled
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents: 1172
diff changeset
   268
ENDIF(COMPILER_SUPPORT)
737
d028bf9d8096 Wired up unit tests to CMakefile.
Ryan C. Gordon <icculus@icculus.org>
parents: 732
diff changeset
   269
1
99ac16070d07 [svn] Initial add.
icculus
parents:
diff changeset
   270
# End of CMakeLists.txt ...
99ac16070d07 [svn] Initial add.
icculus
parents:
diff changeset
   271