Skip to content

Commit

Permalink
optimize cmake rules
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Nov 26, 2023
1 parent 3910dc9 commit 16609fe
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
12 changes: 5 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,11 @@ add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_include_directories(${PROJECT_NAME} PRIVATE ${INCLUDE_DIRS})
target_link_directories(${PROJECT_NAME} PRIVATE ${MPV_LIBRARY_DIRS})
target_link_libraries(${PROJECT_NAME} PRIVATE ${LINK_LIBS})
target_compile_definitions(${PROJECT_NAME} PRIVATE APP_VERSION="${GIT_VERSION}")
if(USE_OPENGL_ES3)
target_compile_definitions(${PROJECT_NAME} PRIVATE IMGUI_IMPL_OPENGL_ES3)
endif()
if(USE_PATCHED_GLFW)
target_compile_definitions(${PROJECT_NAME} PRIVATE GLFW_PATCHED)
endif()
target_compile_definitions(${PROJECT_NAME} PRIVATE
APP_VERSION="${GIT_VERSION}"
$<$<BOOL:${USE_OPENGL_ES3}>:IMGUI_IMPL_OPENGL_ES3>
$<$<BOOL:${USE_PATCHED_GLFW}>:GLFW_PATCHED>
)
if(USE_MPV_WIN_BUILD)
add_dependencies(${PROJECT_NAME} mpv_dev)
endif()
Expand Down
9 changes: 3 additions & 6 deletions third_party/glad/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
cmake_minimum_required(VERSION 3.13)
project(glad)

if(USE_OPENGL_ES3)
add_library(glad OBJECT src/gles3.c)
else()
add_library(glad OBJECT src/gl.c)
endif()

add_library(glad OBJECT
$<IF:$<BOOL:${USE_OPENGL_ES3}>,src/gles3.c,src/gl.c>
)
target_include_directories(glad PUBLIC include)
13 changes: 8 additions & 5 deletions third_party/imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ add_library(imgui OBJECT
)

target_include_directories(imgui PUBLIC include ${FREETYPE_INCLUDE_DIRS} ${GLFW_INCLUDE_DIRS})
target_link_libraries(imgui PUBLIC ${CMAKE_DL_LIBS} ${FREETYPE_LIBRARIES} ${GLFW_LIBRARIES})
if(USE_OPENGL_ES3)
target_compile_definitions(imgui PRIVATE IMGUI_IMPL_OPENGL_ES3)
target_link_libraries(imgui PUBLIC ${OPENGL_LIBRARIES})
endif()
target_link_libraries(imgui PUBLIC
${CMAKE_DL_LIBS} ${FREETYPE_LIBRARIES} ${GLFW_LIBRARIES}
$<$<BOOL:${USE_OPENGL_ES3}>:${OPENGL_LIBRARIES}>
)
target_compile_definitions(imgui PRIVATE
$<$<BOOL:${USE_OPENGL_ES3}>:IMGUI_IMPL_OPENGL_ES3>
$<$<NOT:$<CONFIG:Debug>>:IMGUI_DISABLE_DEMO_WINDOWS IMGUI_DISABLE_DEBUG_TOOLS>
)
4 changes: 2 additions & 2 deletions third_party/imgui/include/imconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
//---- Disable all of Dear ImGui or don't implement standard windows/tools.
// It is very strongly recommended to NOT disable the demo windows and debug tool during development. They are extremely useful in day to day work. Please read comments in imgui_demo.cpp.
//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty.
#define IMGUI_DISABLE_DEBUG_TOOLS // Disable metrics/debugger and other debug tools: ShowMetricsWindow(), ShowDebugLogWindow() and ShowIDStackToolWindow() will be empty.
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty.
//#define IMGUI_DISABLE_DEBUG_TOOLS // Disable metrics/debugger and other debug tools: ShowMetricsWindow(), ShowDebugLogWindow() and ShowIDStackToolWindow() will be empty.

//---- Don't implement some functions to reduce linkage requirements.
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a)
Expand Down

0 comments on commit 16609fe

Please sign in to comment.