project (AsteroGen CXX C)
cmake_minimum_required (VERSION 2.6)
set (CMAKE_CXX_STANDARD 11)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
FIND_PACKAGE(OpenMP)

if(CMAKE_BUILD_TYPE MATCHES DEBUG)
	set(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS}")
endif()

SET(CMAKE_C_FLAGS_RELEASE "-Ofast -msse4 -msse2 -DNDEBUG")
SET(CMAKE_CXX_FLAGS_RELEASE "-Ofast -msse4 -msse2 -DNDEBUG")

if(CMAKE_BUILD_TYPE MATCHES RELEASE)
	set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
	set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
	add_definitions(-DOM_STATIC_BUILD)
endif()

IF(OPENMP_CXX_FOUND)
  SET(CMAKE_C_FLAGS "${OpenMP_C_FLAGS} ${CMAKE_C_FLAGS}")
  SET(CMAKE_CXX_FLAGS "${OpenMP_CXX_FLAGS} ${CMAKE_CXX_FLAGS} ")
ENDIF()
  
FIND_PACKAGE(OpenMesh REQUIRED)
link_directories(${OPENMESH_LIBRARY_DIR})
include_directories(${OPENMESH_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/vendor)

# add executable
add_executable(asteroidgen
	src/main.cpp
	src/Application.cpp
	src/Polygoniser.cpp
	src/TextureMapper.cpp
	src/Mesh.cpp
	src/MarchingCube.cpp
	src/SkyBox.cpp
	src/Shader.cpp
#	src/TexturePainter.cpp
#	src/gen.cpp
	vendor/stb_impl.cpp
	vendor/mersenne-twister.cpp
	vendor/OpenNL_psm.c
	vendor/glad.c
	vendor/logger.cpp
	vendor/imgui.cpp
	vendor/imgui_draw.cpp
	vendor/imgui_impl_glfw_gl3.cpp
)
target_link_libraries(asteroidgen ${OPENMESH_LIBRARIES} dl glfw ${OpenMP_CXX_LIBRARIES})

if(CMAKE_BUILD_TYPE MATCHES RELEASE)
	set_target_properties(asteroidgen PROPERTIES LINK_SEARCH_START_STATIC 1)
	set_target_properties(asteroidgen PROPERTIES LINK_SEARCH_END_STATIC 1)
endif()
