Skip to content

Commit

Permalink
ci: try fix linux glew build error
Browse files Browse the repository at this point in the history
  • Loading branch information
tomezpl committed Oct 13, 2024
1 parent 6d2b04a commit 1ae00dc
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 62 deletions.
119 changes: 58 additions & 61 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@
### Be sure to define your system's triplet to ensure correct target architecture (32/64-bit). https://vcpkg.readthedocs.io/en/latest/users/triplets/#additional-remarks

# min. required CMake version
cmake_minimum_required (VERSION 3.26)
cmake_minimum_required(VERSION 3.26)
include(FindOpenGL)
include(CMakePrintHelpers)

set(VCPKG_FEATURE_FLAGS "manifests,registries,versions")

# VCPKG directory
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "")
endif()
if (DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "")
endif ()

# VCPKG triplet to use (architecture, e.g. x86-windows)
if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "")
endif()
if (DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "")
endif ()

# C++ standard
set(CMAKE_CXX_STANDARD 17)

# Ensure correct library bitness if running Windows
if(${CMAKE_HOST_WIN32})
if(ENV{VCPKG_DEFAULT_TRIPLET} STREQUAL "x64-windows")
set(CMAKE_SIZEOF_VOID_P 8)
endif()
endif()
if (${CMAKE_HOST_WIN32})
if (ENV{VCPKG_DEFAULT_TRIPLET} STREQUAL "x64-windows")
set(CMAKE_SIZEOF_VOID_P 8)
endif ()
endif ()

project(Lepus)

Expand Down Expand Up @@ -109,15 +109,12 @@ add_dependencies(LepusDemo LepusGfx)
# Dependency libraries
## LepusGfx: GL3W (core profile loading)
add_library(GL3W
3rdparty/gl3w/src/gl3w.c
3rdparty/gl3w/src/gl3w.c
)
include_directories(3rdparty/gl3w/include)
## LepusGfx: GLFW libraries
find_package(glfw3 CONFIG REQUIRED)

## LepusGfx: GLEW includes
include_directories(LepusGfx ${GLEW_INCLUDES})

## LepusGfx: GLFW includes
include_directories(LepusGfx ${GLFW_INCLUDES})

Expand Down Expand Up @@ -155,11 +152,11 @@ file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/Debug)
# Set working directory for debugger
set_property(TARGET LepusDemo PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}/Debug")

if(OpenGL::GL)
set(GL_LIBRARY OpenGL::GL)
elseif(OpenGL::OpenGL)
set(GL_LIBRARY OpenGL::OpenGL)
endif(OpenGL::GL)
if (OpenGL::GL)
set(GL_LIBRARY OpenGL::GL)
elseif (OpenGL::OpenGL)
set(GL_LIBRARY OpenGL::OpenGL)
endif (OpenGL::GL)
target_link_libraries(LepusGfx PRIVATE GL3W glfw ${GL_LIBRARY} DearImgui LepusEngine LepusUtility LepusSystem)
target_link_libraries(LepusDemo PRIVATE DearImgui LepusGfx LepusUtility LepusEngine)

Expand All @@ -170,9 +167,9 @@ add_custom_command(TARGET LepusDemo POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_
# Unit testing framework
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
Expand All @@ -182,23 +179,23 @@ enable_testing()

# Unit test projects for each library
add_executable(LepusGfx_Tests
tests/L3D/GraphicsEngine/GraphicsApiTests.h
tests/L3D/GraphicsEngine/GraphicsApiTests.cpp
tests/L3D/GraphicsEngine/GraphicsApiOptionsTests.h
tests/L3D/GraphicsEngine/GraphicsApiOptionsTests.cpp
tests/L3D/SceneGraph/SceneGraphTests.h
tests/L3D/SceneGraph/SceneGraphTests.cpp
tests/L3D/GraphicsEngine/GraphicsApiTests.h
tests/L3D/GraphicsEngine/GraphicsApiTests.cpp
tests/L3D/GraphicsEngine/GraphicsApiOptionsTests.h
tests/L3D/GraphicsEngine/GraphicsApiOptionsTests.cpp
tests/L3D/SceneGraph/SceneGraphTests.h
tests/L3D/SceneGraph/SceneGraphTests.cpp
)

add_executable(LepusSystem_Tests
tests/LSystem/IO/FileSystemTests.h
tests/LSystem/IO/FileSystemTests.cpp
tests/LSystem/IO/FileSystemTests.h
tests/LSystem/IO/FileSystemTests.cpp
)

add_executable(LepusUtility_Tests
tests/LUtility/MathTests/MatrixTests.cpp
tests/LUtility/MathTests/VectorTests.cpp
tests/LUtility/MathTests/TransformTests.cpp
tests/LUtility/MathTests/MatrixTests.cpp
tests/LUtility/MathTests/VectorTests.cpp
tests/LUtility/MathTests/TransformTests.cpp
)

add_custom_command(TARGET LepusSystem_Tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/tests/Content" ${CMAKE_BINARY_DIR}/tests/Content)
Expand All @@ -214,28 +211,28 @@ gtest_discover_tests(LepusUtility_Tests)

# Warnings
set(LepusTargets LepusEngine LepusSystem LepusGfx LepusSystem_Tests LepusGfx_Tests LepusUtility_Tests)
if(MSVC)
# Ignore warnings:
# 4100: unreferenced param,
# 4514: unreferenced inline function removed,
# 4464: parent relative include,
# 4820: struct padding,
# 4263: member not overriding base class virtual
# 4265-5027: copy ctor, move ctor, assignment, move assignment implicitly deleted (this messes up gtest projects)
# 5045: "compiler will insert Spectre mitigation for memory load"
# 5262: implicit switch fallback
set(MSVCDisabledWarnings 4100 4514 4464 4820 4263 4625 5026 4626 5027 5045 5262)

set(MSVCDisabledWarningsFormatted "")
foreach(Warning IN LISTS MSVCDisabledWarnings)
set(MSVCDisabledWarningsFormatted ${MSVCDisabledWarningsFormatted} /wd${Warning})
endforeach()

foreach(Target IN LISTS LepusTargets)
target_compile_options(${Target} PRIVATE /Wall ${MSVCDisabledWarningsFormatted} /WX /external:W3)
endforeach()
else()
foreach(Target IN LISTS LepusTargets)
target_compile_options(${Target} PRIVATE -Wall -Wextra -Wpedantic)
endforeach()
endif()
if (MSVC)
# Ignore warnings:
# 4100: unreferenced param,
# 4514: unreferenced inline function removed,
# 4464: parent relative include,
# 4820: struct padding,
# 4263: member not overriding base class virtual
# 4265-5027: copy ctor, move ctor, assignment, move assignment implicitly deleted (this messes up gtest projects)
# 5045: "compiler will insert Spectre mitigation for memory load"
# 5262: implicit switch fallback
set(MSVCDisabledWarnings 4100 4514 4464 4820 4263 4625 5026 4626 5027 5045 5262)

set(MSVCDisabledWarningsFormatted "")
foreach (Warning IN LISTS MSVCDisabledWarnings)
set(MSVCDisabledWarningsFormatted ${MSVCDisabledWarningsFormatted} /wd${Warning})
endforeach ()

foreach (Target IN LISTS LepusTargets)
target_compile_options(${Target} PRIVATE /Wall ${MSVCDisabledWarningsFormatted} /WX /external:W3)
endforeach ()
else ()
foreach (Target IN LISTS LepusTargets)
target_compile_options(${Target} PRIVATE -Wall -Wextra -Wpedantic)
endforeach ()
endif ()
1 change: 0 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "1.0.0",
"dependencies": [
"glfw3",
"glew",
"bullet3"
],
"builtin-baseline": "8dbd66f5a7821ced1ed57696b50375a977006813"
Expand Down

0 comments on commit 1ae00dc

Please sign in to comment.