-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
60 lines (52 loc) · 2.01 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
cmake_minimum_required(VERSION 3.17)
set(CMAKE_C_STANDARD 99)
project(glsr C)
add_executable(${PROJECT_NAME})
set_target_properties(${PROJECT_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}"
)
# add SDL2
set(SDL2_PATH libs/SDL2 CACHE BOOL "" FORCE)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/sdl2-cmake-modules)
find_package(SDL2 REQUIRED)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libs/SDL2/SDL2.framework/Headers)
target_link_libraries(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/libs/SDL2/SDL2.framework)
# add OpenGL
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES})
# add GLEW
set(GLEW_LIB glew-glew-2.1.0)
if (INSTALL_DEPS)
execute_process(
COMMAND curl -O https://codeload.github.com/nigels-com/glew/tar.gz/glew-2.1.0
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/libs)
execute_process(
COMMAND tar -xzvf glew-2.1.0
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/libs)
execute_process(
COMMAND rm glew-2.1.0
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/libs)
execute_process(
COMMAND make -C auto
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/libs/${GLEW_LIB})
execute_process(
COMMAND make -j4 glew.lib.static
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/libs/${GLEW_LIB})
endif()
add_definitions(-DGLEW_STATIC)
target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/libs/${GLEW_LIB}/include)
target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/libs/${GLEW_LIB}/lib/libGLEW.a)
# add libft
add_subdirectory(libs/libft)
include_directories(${LIBFT_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ft)
# add cJSON
add_subdirectory(libs/cJSON)
include_directories(libs/cJSON)
target_link_libraries(${PROJECT_NAME} cjson)
# project sources
add_subdirectory(srcs)
include_directories(${PROJECT_SOURCE_DIR}/includes)