Skip to content

Instantly share code, notes, and snippets.

@MatyasKriz
Created March 22, 2018 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MatyasKriz/a1d36339891c65da63f4da6dd850de87 to your computer and use it in GitHub Desktop.
Save MatyasKriz/a1d36339891c65da63f4da6dd850de87 to your computer and use it in GitHub Desktop.
IZG projekt 2017/18
cmake_minimum_required(VERSION 3.1.0)
project(IzgProjekt2017)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(APPLE TRUE)
endif()
set(APPLICATION_NAME izgProjekt2017)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
if(MSVC)
set(USE_PREBUILD_LIB_PACKAGE ON CACHE BOOL "Use prebuild lib package.")
if(USE_PREBUILD_LIB_PACKAGE)
set(SDL2_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs/VisualStudio/SDL2/include CACHE STRING "" FORCE)
set(SDL2_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/libs/VisualStudio/SDL2/lib/SDL2.lib CACHE STRING "" FORCE)
set(SDL2MAIN_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/libs/VisualStudio/SDL2/lib/SDL2main.lib CACHE STRING "" FORCE)
set(SDL2_LIBRARY_PATH ${CMAKE_CURRENT_SOURCE_DIR}/libs/VisualStudio/SDL2/lib/SDL2.lib CACHE STRING "" FORCE)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/bin/SDL2.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endif()
endif()
find_package(SDL2 REQUIRED)
set(GPU_SOURCES
gpu/gpu.cpp)
set(GPU_INCLUDES)
set(STUDENT_SOURCES
student/student_cpu.c
student/student_pipeline.c
student/student_shader.c
student/linearAlgebra.c
student/main.c
student/camera.c
student/bunny.c
student/mouseCamera.c
student/swapBuffers.c
student/globals.c)
set(STUDENT_INCLUDES
student/student_cpu.h
student/student_pipeline.h
student/student_shader.h
student/gpu.h
student/uniforms.h
student/buffer.h
student/vertexPuller.h
student/program.h
student/camera.h
student/bunny.h
student/mouseCamera.h
student/swapBuffers.h
student/globals.h)
set(TESTS_SOURCES
tests/conformanceTests.cpp
tests/performanceTest.cpp)
set(TESTS_INCLUDES
tests/conformanceTests.h
tests/performanceTest.h)
set(EXAMPLE_SOURCES
examples/triangleExample.c)
set(EXAMPLE_HEADERS
examples/triangleExample.h)
set(3RDPARTY_SOURCES)
set(3RDPARTY_INCLUDES
3rdParty/catch.hpp)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_C_STANDARD 99)
if(CMAKE_COMPILER_IS_GNUCXX)
add_compile_options(-W)
add_compile_options(-Wall)
add_compile_options(-pedantic)
add_compile_options(-Wconversion)
endif()
if(CMAKE_COMPILER_IS_GNUCC)
add_compile_options(-W)
add_compile_options(-Wall)
add_compile_options(-pedantic)
add_compile_options(-Wconversion)
endif()
# defines DEBUG macro when building in CLion in Debug configuration (not when you run it in debug)
#if(CMAKE_BUILD_TYPE MATCHES Debug)
# add_definitions(-DDEBUG)
# set(CMAKE_VERBOSE_MAKEFILE ON)
#endif()
if(APPLE)
execute_process(COMMAND sdl2-config --libs OUTPUT_VARIABLE SDL_LIBS)
string(STRIP "${SDL_LIBS}" SDL_LIBS)
execute_process(COMMAND sdl2-config --cflags OUTPUT_VARIABLE SDL_CFLAGS)
add_definitions(${SDL_CFLAGS})
else()
set(SDL_LIBS SDL2::SDL2 SDL2::SDL2main)
endif()
add_executable(${APPLICATION_NAME} ${GPU_SOURCES} ${GPU_INCLUDES} ${STUDENT_SOURCES} ${STUDENT_INCLUDES} ${TESTS_SOURCES} ${TESTS_INCLUDES} ${3RDPARTY_SOURCES} ${3RDPARTY_INCLUDES} ${EXAMPLE_SOURCES} ${EXAMPLE_HEADERS})
target_link_libraries(${APPLICATION_NAME} ${SDL_LIBS})
target_include_directories(${APPLICATION_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment