# CMakeList.txt : Top-level CMake project file, do global configuration
# and include sub-projects here.
#
cmake_minimum_required (VERSION 3.8)

cmake_policy(SET CMP0074 NEW)
cmake_policy(SET CMP0077 NEW)


set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(lib/glfw-3.3.8)


set(PNG_BUILD_ZLIB ON)
set(PNG_SHARED OFF)
set(PNG_STATIC ON)
set(PNG_EXECUTABLES OFF)
set(PNG_TESTS OFF)
set(BUILD_SHARED_LIBS OFF)
set(SKIP_INSTALL_ALL ON)
set(ZLIB_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/lib/zlib-1.2.13" "${CMAKE_BINARY_DIR}/lib/zlib-1.2.13")
add_subdirectory(lib/zlib-1.2.13)
#set(ZLIB_LIBRARY zlib)
add_subdirectory(lib/lpng1639)

project ("glew")

add_library(glew STATIC "lib/glew-2.1.0/src/glew.c" "lib/glew-2.1.0/include/GL/glew.h")
if(WIN32)
	target_link_libraries(glew opengl32)
else()
	target_link_libraries(glew GL)
endif()
target_include_directories(glew PRIVATE lib/glew-2.1.0/include)
set_target_properties(glew PROPERTIES C_STANDARD 11 C_STANDARD_REQUIRED YES C_EXTENSIONS YES)
set_target_properties(glew PROPERTIES COMPILE_FLAGS "-Wno-everything")
target_compile_definitions(glew PUBLIC GLEW_STATIC)

project ("skunkworks")
set(SOURCE
	src/gl.h
	src/skunkworks.c
	src/skunkworks.h
	src/test.c
	src/vec2i.c
	src/window.c

	include/vec2i.h
	include/window.h
)

add_executable (skunkworks ${SOURCE})
target_link_libraries(skunkworks glfw glew png_static zlibstatic)
target_include_directories(skunkworks PRIVATE
    lib/glfw-3.8.8/include
	lib/glew-2.1.0/include
	lib/lpng1639
	build/lib/lpng1639
	include
)

set_target_properties(skunkworks PROPERTIES C_STANDARD 90 C_STANDARD_REQUIRED YES C_EXTENSIONS NO)
set_target_properties(skunkworks PROPERTIES COMPILE_FLAGS "-Wall -Werror -pedantic")
add_custom_command(TARGET skunkworks POST_BUILD
    COMMAND $<$<CONFIG:release>:llvm-strip>
	ARGS --strip-all $<TARGET_FILE:skunkworks>)
