Skip to content

Commit 9c0924f

Browse files
committed
Try to find OpenGL libraries in Linux too
1 parent fc6a808 commit 9c0924f

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

CMakeLists.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ project(lib86cpu)
66
# Suppress build failures caused by deprecation warnings treated as errors. CI seems to be using "-Werror=deprecated" which causes the issue
77
set(CMAKE_ERROR_DEPRECATED FALSE CACHE BOOL "" FORCE)
88

9+
if (POLICY CMP0072)
10+
set(OpenGL_GL_PREFERENCE LEGACY)
11+
endif(POLICY CMP0072)
12+
913
if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
1014
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${lib86cpu_BINARY_DIR}/bin")
1115
endif()
@@ -16,6 +20,11 @@ set(CMAKE_CXX_STANDARD 20)
1620
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1721
set(CMAKE_CXX_EXTENSIONS OFF)
1822

23+
find_package(OpenGL)
24+
if(NOT OpenGL_OpenGL_FOUND)
25+
message(FATAL_ERROR "OpenGL was not found")
26+
endif()
27+
1928
option(LIB86CPU_BUILD_SHARED_LIB
2029
"Build shared library"
2130
OFF)
@@ -217,7 +226,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} \
217226
"
218227
)
219228
elseif (${COMPILER_IS_GNU})
220-
add_compile_options(-m64 -msse2 -fexceptions -funwind-tables -lGL -lGLU -lglut)
229+
add_compile_options(-m64 -msse2 -fexceptions -funwind-tables)
221230
endif()
222231

223232
if (${LIB86CPU_BUILD_SHARED_LIB})
@@ -227,10 +236,7 @@ else ()
227236
add_library(cpu STATIC ${HEADERS} ${SOURCES})
228237
endif()
229238

230-
target_link_libraries(cpu PRIVATE asmjit Zydis glfw imgui)
231-
if (${COMPILER_IS_MSVC})
232-
target_link_libraries(cpu PRIVATE opengl32.lib)
233-
endif()
239+
target_link_libraries(cpu PRIVATE asmjit Zydis glfw imgui ${OPENGL_LIBRARIES})
234240

235241
if (${LIB86CPU_BUILD_TEST})
236242
message("Building test")

0 commit comments

Comments
 (0)