Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cmake build scripts #22

Merged
merged 10 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Diagnostics:
MissingIncludes: None
UnusedIncludes: Strict
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
env:
CC: ${{matrix.compiler.pkg}}-${{matrix.compiler.version}}
CXX: ${{matrix.compiler.exe}}-${{matrix.compiler.version}}
run: cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DFLUX_GRAPHICS=OpenGL -DFLUX_ENABLE_LTO=NO -B ${{github.workspace}}/build/${{matrix.os}}-${{env.BUILD_TYPE}} -G Ninja
run: cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DFLUX_GRAPHICS_API=OpenGL -B ${{github.workspace}}/build/${{matrix.os}}-${{env.BUILD_TYPE}} -G Ninja

- name: Build
# Build your program with the given configuration
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
env:
CC: ${{ matrix.compiler.pkg }}
CXX: ${{ matrix.compiler.exe }}
run: cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DFLUX_GRAPHICS=OpenGL -DFLUX_ENABLE_LTO=NO -B ${{github.workspace}}/build/${{matrix.os}}-${{env.BUILD_TYPE}} -G Ninja
run: cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DFLUX_GRAPHICS_API=OpenGL -DFLUX_ENABLE_LTO=NO -B ${{github.workspace}}/build/${{matrix.os}}-${{env.BUILD_TYPE}} -G Ninja

- name: Build
# Build your program with the given configuration
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
env:
CC: ${{matrix.compiler.pkg}}-${{matrix.compiler.version}}
CXX: ${{matrix.compiler.exe}}-${{matrix.compiler.version}}
run: cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DFLUX_GRAPHICS=OpenGL -DFLUX_ENABLE_COVERAGE=ON -B ${{github.workspace}}/build/${{matrix.os}}-${{env.BUILD_TYPE}} -G Ninja
run: cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DFLUX_GRAPHICS_API=OpenGL -DFLUX_ENABLE_COVERAGE=ON -B ${{github.workspace}}/build/${{matrix.os}}-${{env.BUILD_TYPE}} -G Ninja

- name: Build
# Build your program with the given configuration
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#=======================================================================================================================

# MacOS files
.DS_Store

# The clangd compilation database. This is a soft link, it's generated automatically during the build.
compile_commands.json

Expand Down Expand Up @@ -95,6 +98,9 @@ fabric.properties
# Prerequisites
*.d

# Python
__pycache__

# Compiled Object files
*.slo
*.lo
Expand Down
24 changes: 11 additions & 13 deletions cmake/bootstrap.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -198,23 +198,21 @@ set(GLAD_SOURCES_DIR "${GLAD_ROOT}")
add_subdirectory("${GLAD_SOURCES_DIR}/cmake" cmake)

# This target is OpenGL-specific.
if(FLUX_TARGET_GRAPHICS STREQUAL "OpenGL")
if(FLUX_GRAPHICS_API STREQUAL "OpenGL")
set(GLAD_SPEC gl)
set(GLAD_PROFILE core)
set(GLAD_ARGS MX API ${GLAD_SPEC}:${GLAD_PROFILE}=${FLUX_API_VERSION_MAJOR}.${FLUX_API_VERSION_MINOR})
set(GLAD_ARGS MX API ${GLAD_SPEC}:${GLAD_PROFILE}=${FLUX_GAPI_VERSION_MAJOR}.${FLUX_GAPI_VERSION_MINOR})
# This target is Vulkan-specific.
elseif(FLUX_TARGET_GRAPHICS STREQUAL "Vulkan")
elseif(FLUX_GRAPHICS_API STREQUAL "Vulkan")
set(GLAD_SPEC vulkan)
set(GLAD_PROFILE core)
set(GLAD_ARGS API ${GLAD_SPEC}=${FLUX_API_VERSION_MAJOR}.${FLUX_API_VERSION_MINOR})
endif()

if(FLUX_TARGET_GRAPHICS STREQUAL "Metal")
message(STATUS "Glad2 with Metal backend is not supported. Skipping...")
set(GLAD_ARGS API ${GLAD_SPEC}=${FLUX_GAPI_VERSION_MAJOR}.${FLUX_GAPI_VERSION_MINOR})
else()
glad_add_library(glad STATIC REPRODUCIBLE LOCATION ${CMAKE_INSTALL_PREFIX} ${GLAD_ARGS})
install(TARGETS glad)
message(STATUS "Glad2 with ${FLUX_GRAPHICS_API} backend is not supported. Skipping...")
endif()

glad_add_library(glad STATIC REPRODUCIBLE LOCATION ${CMAKE_INSTALL_PREFIX} ${GLAD_ARGS})
install(TARGETS glad)
]])
message(STATUS "GLAD project generation successfully finished.")

Expand All @@ -226,9 +224,9 @@ execute_process(COMMAND ${CMAKE_COMMAND}
-S${CMAKE_BINARY_DIR}/generated/external/glad2
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/output/external/glad
-DGLAD_ROOT=${CMAKE_SOURCE_DIR}/external/glad
-DFLUX_TARGET_GRAPHICS=${FLUX_TARGET_GRAPHICS}
-DFLUX_API_VERSION_MAJOR=${FLUX_API_VERSION_MAJOR}
-DFLUX_API_VERSION_MINOR=${FLUX_API_VERSION_MINOR}
-DFLUX_GRAPHICS_API=${FLUX_GRAPHICS_API}
-DFLUX_GAPI_VERSION_MAJOR=${FLUX_GAPI_VERSION_MAJOR}
-DFLUX_GAPI_VERSION_MINOR=${FLUX_GAPI_VERSION_MINOR}
${FLUX_CONFIG_ARGUMENTS}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE COMMAND_RESULT
Expand Down
8 changes: 6 additions & 2 deletions cmake/modules/Findglfw.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ if(FLUX_TARGET_GRAPHICS STREQUAL "OpenGL")
target_link_libraries(glfw::glfw
INTERFACE "${CMAKE_BINARY_DIR}/output/external/glfw/lib/glfw3.lib")
elseif(FLUX_TARGET_OS STREQUAL "MacOSX")
target_link_libraries(glfw::glfw INTERFACE "-framework Cocoa" "-framework IOKit")
target_link_libraries(glfw::glfw
INTERFACE "-framework Cocoa"
"-framework OpenGL"
"-framework IOKit"
"-framework QuartzCore")
target_link_libraries(glfw::glfw
INTERFACE "${CMAKE_BINARY_DIR}/output/external/glfw/lib/libglfw3.a")
elseif(FLUX_TARGET_OS STREQUAL "Linux")
target_link_libraries(glfw::glfw
INTERFACE "${CMAKE_BINARY_DIR}/output/external/glfw/lib/libglfw3.a")
INTERFACE "${CMAKE_BINARY_DIR}/output/external/glfw/lib/libglfw3.a")
endif()
target_link_libraries(glfw::glfw INTERFACE ${GLFW_LIBRARIES})
target_include_directories(glfw::glfw INTERFACE "${CMAKE_BINARY_DIR}/output/external/glfw/include")
Expand Down
Loading