CMake · 1430 bytes Raw Blame History
1 cmake_minimum_required(VERSION 3.16)
2 project(fortty LANGUAGES Fortran C)
3
4 # C standard for GLAD
5 set(CMAKE_C_STANDARD 11)
6 set(CMAKE_C_STANDARD_REQUIRED ON)
7
8 # Compiler warnings
9 if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
10 add_compile_options(-Wall -Wextra -pedantic)
11 endif()
12
13 # Find dependencies
14 find_package(glfw3 REQUIRED)
15 find_package(OpenGL REQUIRED)
16 find_package(Freetype REQUIRED)
17
18 # C helper libraries (GLAD + FreeType wrappers)
19 add_library(helpers STATIC
20 src/gl/glad.c
21 c_src/gl_loader.c
22 c_src/freetype_helpers.c
23 )
24 target_include_directories(helpers PUBLIC ${CMAKE_SOURCE_DIR}/include)
25 target_include_directories(helpers PRIVATE ${FREETYPE_INCLUDE_DIRS})
26 target_link_libraries(helpers PRIVATE glfw ${FREETYPE_LIBRARIES})
27
28 # Fortran module output directory
29 set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/modules)
30
31 # Fortran sources (order matters for module dependencies)
32 set(FORTRAN_SOURCES
33 src/core/types.f90
34 src/gl/gl_bindings.f90
35 src/text/glyph.f90
36 src/text/font.f90
37 src/window/glfw_bindings.f90
38 src/window/window.f90
39 src/fortty.f90
40 )
41
42 # Main executable
43 add_executable(fortty ${FORTRAN_SOURCES})
44 target_include_directories(fortty PRIVATE ${CMAKE_BINARY_DIR}/modules)
45 target_link_libraries(fortty PRIVATE helpers glfw OpenGL::GL ${FREETYPE_LIBRARIES})
46
47 # For Linux, we need dl for GLAD's dlopen
48 if(UNIX AND NOT APPLE)
49 target_link_libraries(fortty PRIVATE dl)
50 endif()
51