CMakeLists.txt
author Ryan C. Gordon <icculus@icculus.org>
Tue, 03 Feb 2009 17:16:56 -0500
changeset 549 13714d3b3fa2
parent 473 78c418bde2d2
child 555 940821555fda
permissions -rw-r--r--
Handle out of memory error better.

CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
PROJECT(MojoShader)

EXECUTE_PROCESS(
    COMMAND hg tip --template {rev}
    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
    RESULT_VARIABLE HGVERSION_RC
    OUTPUT_VARIABLE MOJOSHADER_VERSION
    ERROR_QUIET
    OUTPUT_STRIP_TRAILING_WHITESPACE
)
EXECUTE_PROCESS(
    COMMAND hg tip --template hg-{rev}:{node|short}
    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
    RESULT_VARIABLE HGVERSION_RC
    OUTPUT_VARIABLE MOJOSHADER_CHANGESET
    ERROR_QUIET
    OUTPUT_STRIP_TRAILING_WHITESPACE
)

WRITE_FILE(
    "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_version.h"
    "/* This file was autogenerated. Do not edit! */\n"
    "#ifndef _INCL_MOJOSHADER_VERSION_H_\n"
    "#define _INCL_MOJOSHADER_VERSION_H_\n"
    "#define MOJOSHADER_VERSION ${MOJOSHADER_VERSION}\n"
    "#define MOJOSHADER_CHANGESET \"${MOJOSHADER_CHANGESET}\"\n"
    "#endif\n"
)

IF(CMAKE_COMPILER_IS_GNUCC)
    ADD_DEFINITIONS(-Wall -ggdb3)
ENDIF(CMAKE_COMPILER_IS_GNUCC)

# testparse uses this when I'm looking at memory usage patterns.
#ADD_DEFINITIONS(-DMOJOSHADER_DEBUG_MALLOC=1)

IF(MSVC)
    ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS=1)
    ADD_DEFINITIONS(-TP)  # force .c files to compile as C++.
ENDIF(MSVC)

ADD_LIBRARY(mojoshader STATIC
    mojoshader.c
    mojoshader_assembler.c
    mojoshader_opengl.c
)

FIND_PACKAGE(SDL)
IF(SDL_FOUND)
    INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
    ADD_DEFINITIONS(-DFINDERRORS_COMPILE_SHADERS=1)
    ADD_EXECUTABLE(glcaps glcaps.c)
    TARGET_LINK_LIBRARIES(glcaps ${SDL_LIBRARY})
    ADD_EXECUTABLE(bestprofile bestprofile.c)
    TARGET_LINK_LIBRARIES(bestprofile mojoshader ${SDL_LIBRARY})
    ADD_EXECUTABLE(availableprofiles availableprofiles.c)
    TARGET_LINK_LIBRARIES(availableprofiles mojoshader ${SDL_LIBRARY})
ENDIF(SDL_FOUND)

ADD_EXECUTABLE(testparse testparse.c)
TARGET_LINK_LIBRARIES(testparse mojoshader)
ADD_EXECUTABLE(testoutput testoutput.c)
TARGET_LINK_LIBRARIES(testoutput mojoshader)
ADD_EXECUTABLE(finderrors finderrors.c)
TARGET_LINK_LIBRARIES(finderrors mojoshader ${SDL_LIBRARY})
ADD_EXECUTABLE(assemble assemble.c)
TARGET_LINK_LIBRARIES(assemble mojoshader)

# End of CMakeLists.txt ...