2021-03-29 08:03:39 +00:00
|
|
|
cmake_minimum_required(VERSION 3.8.2)
|
2020-07-21 11:03:22 +00:00
|
|
|
project(Triangles LANGUAGES CXX VERSION 1.0)
|
|
|
|
|
2021-03-29 08:03:39 +00:00
|
|
|
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/glm/glm/glm.hpp)
|
|
|
|
message(FATAL_ERROR "third_party/glm/glm/glm.hpp is missing!\n \
|
|
|
|
Please update the glm submodule by running 'git submodule init' and \
|
2020-07-22 06:02:38 +00:00
|
|
|
'git submodule update'!")
|
2020-07-21 11:03:22 +00:00
|
|
|
endif()
|
2021-03-29 08:03:39 +00:00
|
|
|
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/raygui/src/raygui.h)
|
|
|
|
message(FATAL_ERROR "third_party/raygui/src/raygui.h is missing!\n \
|
|
|
|
Please update the raygui submodule by running 'git submodule init' and \
|
2020-07-22 06:02:38 +00:00
|
|
|
'git submodule update'!")
|
2020-07-21 11:03:22 +00:00
|
|
|
endif()
|
|
|
|
|
2020-08-04 12:13:17 +00:00
|
|
|
if(NOT DEFINED CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE "Debug")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(Triangles_MAIN_SOURCES
|
2020-07-21 11:03:22 +00:00
|
|
|
src/main.cpp
|
2020-08-04 12:13:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
set(Triangles_LIB_SOURCES
|
2020-07-21 11:34:39 +00:00
|
|
|
src/state.cpp
|
2021-03-29 08:03:39 +00:00
|
|
|
src/shape.cpp
|
|
|
|
src/triangle.cpp
|
|
|
|
src/circle.cpp
|
|
|
|
src/raygui.cpp
|
2020-07-21 11:03:22 +00:00
|
|
|
)
|
|
|
|
|
2020-08-09 07:14:33 +00:00
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "/Od /Zi")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "/O2 /DNDEBUG")
|
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -Wsuggest-override")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -D NDEBUG")
|
|
|
|
endif()
|
2020-07-21 11:03:22 +00:00
|
|
|
|
2020-08-04 12:13:17 +00:00
|
|
|
add_library(TrianglesLib STATIC ${Triangles_LIB_SOURCES})
|
2020-07-21 11:03:22 +00:00
|
|
|
|
2020-08-09 07:14:33 +00:00
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|
|
|
add_executable(Triangles WIN32 ${Triangles_MAIN_SOURCES})
|
|
|
|
else()
|
|
|
|
add_executable(Triangles ${Triangles_MAIN_SOURCES})
|
|
|
|
endif()
|
2020-08-04 12:13:17 +00:00
|
|
|
|
|
|
|
target_link_libraries(Triangles PUBLIC TrianglesLib)
|
|
|
|
|
|
|
|
target_compile_features(TrianglesLib PUBLIC cxx_std_17)
|
2020-07-21 11:03:22 +00:00
|
|
|
|
2020-08-09 07:14:33 +00:00
|
|
|
if(BUILD_SHARED_LIBS OR (UNIX AND NOT CYGWIN) OR (CMAKE_CXX_COMPILER_ID MATCHES "MSVC"))
|
2021-03-29 08:03:39 +00:00
|
|
|
find_package(raylib REQUIRED)
|
2020-07-21 11:03:22 +00:00
|
|
|
else()
|
2021-03-29 08:03:39 +00:00
|
|
|
find_package(raylib REQUIRED)
|
2020-07-21 11:03:22 +00:00
|
|
|
endif()
|
|
|
|
|
2020-08-09 07:14:33 +00:00
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|
|
|
target_link_libraries(TrianglesLib PUBLIC
|
2021-03-29 08:03:39 +00:00
|
|
|
raylib
|
2020-08-09 07:14:33 +00:00
|
|
|
opengl32
|
|
|
|
)
|
|
|
|
else()
|
2020-08-04 12:13:17 +00:00
|
|
|
target_link_libraries(TrianglesLib PUBLIC
|
2021-03-29 08:03:39 +00:00
|
|
|
raylib
|
2020-07-21 11:03:22 +00:00
|
|
|
GL
|
|
|
|
)
|
2020-08-09 07:14:33 +00:00
|
|
|
endif()
|
2020-07-21 11:03:22 +00:00
|
|
|
|
2021-03-29 08:03:39 +00:00
|
|
|
target_include_directories(TrianglesLib PUBLIC
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/third_party/raygui/src
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/third_party/glm
|
|
|
|
)
|
2020-08-04 12:13:17 +00:00
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
|
|
|
set(Triangles_UNIT_TEST_SOURCES
|
|
|
|
src/unittest/test_helpers.cpp
|
2023-03-06 11:12:09 +00:00
|
|
|
third_party/catch/catch_amalgamated.cpp
|
2020-08-04 12:13:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
add_executable(UnitTest_Triangles ${Triangles_UNIT_TEST_SOURCES})
|
|
|
|
target_link_libraries(UnitTest_Triangles TrianglesLib)
|
|
|
|
target_include_directories(UnitTest_Triangles PUBLIC
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/third_party/catch
|
|
|
|
)
|
|
|
|
endif()
|