From 60588b7192f54ebd5fbf2ff54dbbe5f567746131 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Tue, 22 Jun 2021 22:51:20 +0200 Subject: [PATCH] cmake: merge librw_skeleton_imgui in librw_skeleton --- CMakeLists.txt | 9 +++-- skeleton/CMakeLists.txt | 58 ++++++++++++++++++++++++--------- skeleton/imgui/CMakeLists.txt | 46 -------------------------- src/CMakeLists.txt | 18 +++------- tools/CMakeLists.txt | 26 ++++++++------- tools/camera/CMakeLists.txt | 11 ++++--- tools/dumprwtree/CMakeLists.txt | 4 +-- tools/im2d/CMakeLists.txt | 13 ++++++-- tools/im3d/CMakeLists.txt | 13 ++++++-- tools/imguitest/CMakeLists.txt | 4 +-- tools/lights/CMakeLists.txt | 8 +++-- tools/playground/CMakeLists.txt | 12 +++++-- tools/ps2test/CMakeLists.txt | 9 ++--- tools/ska2anm/CMakeLists.txt | 10 ++++-- tools/subrast/CMakeLists.txt | 3 +- 15 files changed, 124 insertions(+), 120 deletions(-) delete mode 100644 skeleton/imgui/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c1b40d..80f6b64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,8 +51,11 @@ if(NOT COMMAND librw_platform_target) endfunction() endif() +include(CMakeDependentOption) + option(LIBRW_TOOLS "Build librw tools" ON) option(LIBRW_INSTALL "Install librw files" OFF) +cmake_dependent_option(LIBRW_EXAMPLES "Build librw examples" ON "NOT LIBRW_PLATFORM_PS2;NOT LIBRW_PLATFORM_NULL" OFF) if(LIBRW_INSTALL) include(GNUInstallDirs) @@ -61,12 +64,12 @@ endif() add_subdirectory(src) -if(LIBRW_TOOLS) +if(NOT LIBRW_PLATFORM_PS2 AND NOT LIBRW_PLATFORM_NULL) add_subdirectory(skeleton) - - add_subdirectory(tools) endif() +add_subdirectory(tools) + if(LIBRW_INSTALL) include(CMakePackageConfigHelpers) configure_package_config_file(cmake/librw-config.cmake.in librw-config.cmake diff --git a/skeleton/CMakeLists.txt b/skeleton/CMakeLists.txt index 98970bc..1c7c031 100644 --- a/skeleton/CMakeLists.txt +++ b/skeleton/CMakeLists.txt @@ -1,42 +1,68 @@ add_library(librw_skeleton - glfw.cpp - sdl2.cpp - skeleton.cpp - skeleton.h - win.cpp + glfw.cpp + sdl2.cpp + skeleton.cpp + skeleton.h + win.cpp + + imgui/imconfig.h + imgui/imgui.cpp + imgui/imgui_demo.cpp + imgui/imgui_draw.cpp + imgui/imgui.h + imgui/imgui_impl_rw.cpp + imgui/imgui_impl_rw.h + imgui/imgui_internal.h + imgui/ImGuizmo.cpp + imgui/ImGuizmo.h + imgui/stb_rect_pack.h + imgui/stb_textedit.h + imgui/stb_truetype.h ) +add_library(librw::skeleton ALIAS librw_skeleton) set_target_properties(librw_skeleton PROPERTIES PREFIX "" + EXPORT_NAME skeleton ) target_link_libraries(librw_skeleton - PUBLIC + PRIVATE librw ) target_include_directories(librw_skeleton - INTERFACE + PUBLIC $ + $ ) -if(NOT LIBRW_PLATFORM_PS2 AND NOT LIBRW_PLATFORM_NULL) - add_subdirectory(imgui) -endif() - if(LIBRW_INSTALL) - target_include_directories(librw_skeleton - INTERFACE - $ - ) - install( FILES skeleton.h DESTINATION "${LIBRW_INSTALL_INCLUDEDIR}/skeleton" ) + install( + FILES + imgui/imconfig.h + imgui/imgui.h + imgui/imgui_impl_rw.h + imgui/imgui_internal.h + imgui/ImGuizmo.h + imgui/stb_textedit.h + DESTINATION "${LIBRW_INSTALL_INCLUDEDIR}/skeleton/imgui" + ) + + install( + FILES + imgui/LICENSE_imgui.txt + imgui/LICENSE_imguizmo.txt + DESTINATION "${CMAKE_INSTALL_DOCDIR}" + ) + install( TARGETS librw_skeleton EXPORT librw-targets diff --git a/skeleton/imgui/CMakeLists.txt b/skeleton/imgui/CMakeLists.txt deleted file mode 100644 index cb65dee..0000000 --- a/skeleton/imgui/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -add_library(librw_skeleton_imgui - imconfig.h - imgui.cpp - imgui_demo.cpp - imgui_draw.cpp - imgui.h - imgui_impl_rw.cpp - imgui_impl_rw.h - imgui_internal.h - ImGuizmo.cpp - ImGuizmo.h - stb_rect_pack.h - stb_textedit.h - stb_truetype.h -) - -set_target_properties(librw_skeleton_imgui - PROPERTIES - PREFIX "" -) - -target_link_libraries(librw_skeleton_imgui - PUBLIC - librw_skeleton -) - -if(LIBRW_INSTALL) - install( - FILES - imconfig.h - imgui.h - imgui_impl_rw.h - imgui_internal.h - ImGuizmo.h - stb_textedit.h - DESTINATION "${LIBRW_INSTALL_INCLUDEDIR}/skeleton/imgui" - ) - - install( - TARGETS librw_skeleton_imgui - EXPORT librw-targets - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - ) -endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 423883a..bdfefc7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,6 +100,7 @@ add_library(librw::librw ALIAS librw) target_include_directories(librw INTERFACE $ + $ ) target_compile_definitions(librw @@ -153,7 +154,7 @@ if(LIBRW_PLATFORM_GL3) find_package(OpenGL REQUIRED) target_link_libraries(librw - PUBLIC + PRIVATE OpenGL::GL ) endif() @@ -171,35 +172,24 @@ if(LIBRW_PLATFORM_GL3) PUBLIC SDL2::SDL2 ) - if(TARGET SDL2::SDL2main) - target_link_libraries(librw - PUBLIC - SDL2::SDL2main - ) - endif() endif() if(NINTENDO_SWITCH) find_package(NXGL REQUIRED) target_link_libraries(librw - PUBLIC + PRIVATE NXGL::OpenGL ) endif() elseif(LIBRW_PLATFORM_D3D9) target_link_libraries(librw - PUBLIC + PRIVATE d3d9 xinput ) endif() if(LIBRW_INSTALL) - target_include_directories(librw - INTERFACE - $ - ) - install( FILES "${PROJECT_SOURCE_DIR}/args.h" diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 3709720..be7ea66 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,18 +1,20 @@ -if(NOT LIBRW_PLATFORM_PS2) +if(LIBRW_TOOLS AND NOT LIBRW_PLATFORM_PS2) add_subdirectory(dumprwtree) add_subdirectory(ska2anm) endif() -if(TARGET librw_skeleton_imgui) - add_subdirectory(imguitest) - add_subdirectory(playground) - add_subdirectory(lights) - add_subdirectory(subrast) - add_subdirectory(camera) - add_subdirectory(im2d) - add_subdirectory(im3d) -endif() +if(LIBRW_EXAMPLES) + if(TARGET librw::skeleton) + add_subdirectory(imguitest) + add_subdirectory(playground) + add_subdirectory(lights) + add_subdirectory(subrast) + add_subdirectory(camera) + add_subdirectory(im2d) + add_subdirectory(im3d) + endif() -if(LIBRW_PLATFORM_PS2) - add_subdirectory(ps2test) + if(LIBRW_PLATFORM_PS2) + add_subdirectory(ps2test) + endif() endif() diff --git a/tools/camera/CMakeLists.txt b/tools/camera/CMakeLists.txt index 2c7fcd4..2607441 100644 --- a/tools/camera/CMakeLists.txt +++ b/tools/camera/CMakeLists.txt @@ -1,15 +1,18 @@ add_executable(camera WIN32 - main.cpp camexamp.cpp viewer.cpp + main.cpp + camexamp.cpp + viewer.cpp ) target_link_libraries(camera - PUBLIC - librw librw_skeleton librw_skeleton_imgui + PRIVATE + librw::skeleton + librw::librw ) add_custom_command( TARGET camera POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/files" "$/files" + COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/files" "$/files" ) librw_platform_target(camera) diff --git a/tools/dumprwtree/CMakeLists.txt b/tools/dumprwtree/CMakeLists.txt index 71c2738..fdd0a23 100644 --- a/tools/dumprwtree/CMakeLists.txt +++ b/tools/dumprwtree/CMakeLists.txt @@ -3,8 +3,8 @@ add_executable(dumprwtree ) target_link_libraries(dumprwtree - PUBLIC - librw + PRIVATE + librw::librw ) if(LIBRW_INSTALL) diff --git a/tools/im2d/CMakeLists.txt b/tools/im2d/CMakeLists.txt index 367df76..9c14b03 100644 --- a/tools/im2d/CMakeLists.txt +++ b/tools/im2d/CMakeLists.txt @@ -1,10 +1,17 @@ add_executable(im2d WIN32 - im2d.cpp linelist.cpp main.cpp polyline.cpp trifan.cpp trilist.cpp tristrip.cpp + im2d.cpp + linelist.cpp + main.cpp + polyline.cpp + trifan.cpp + trilist.cpp + tristrip.cpp ) target_link_libraries(im2d - PUBLIC - librw librw_skeleton librw_skeleton_imgui + PRIVATE + librw::skeleton + librw::librw ) add_custom_command( diff --git a/tools/im3d/CMakeLists.txt b/tools/im3d/CMakeLists.txt index d01a4e5..52102f6 100644 --- a/tools/im3d/CMakeLists.txt +++ b/tools/im3d/CMakeLists.txt @@ -1,10 +1,17 @@ add_executable(im3d WIN32 - im3d.cpp linelist.cpp main.cpp polyline.cpp trifan.cpp trilist.cpp tristrip.cpp + im3d.cpp + linelist.cpp + main.cpp + polyline.cpp + trifan.cpp + trilist.cpp + tristrip.cpp ) target_link_libraries(im3d - PUBLIC - librw librw_skeleton librw_skeleton_imgui + PRIVATE + librw::skeleton + librw::librw ) add_custom_command( diff --git a/tools/imguitest/CMakeLists.txt b/tools/imguitest/CMakeLists.txt index d0af911..4f2e31d 100644 --- a/tools/imguitest/CMakeLists.txt +++ b/tools/imguitest/CMakeLists.txt @@ -4,8 +4,8 @@ add_executable(imguitest WIN32 target_link_libraries(imguitest PUBLIC - librw - librw_skeleton_imgui + librw::skeleton + librw::librw ) if(LIBRW_INSTALL) diff --git a/tools/lights/CMakeLists.txt b/tools/lights/CMakeLists.txt index 283c74a..282f30d 100644 --- a/tools/lights/CMakeLists.txt +++ b/tools/lights/CMakeLists.txt @@ -1,10 +1,12 @@ add_executable(lights WIN32 - main.cpp lights.cpp + main.cpp + lights.cpp ) target_link_libraries(lights - PUBLIC - librw librw_skeleton librw_skeleton_imgui + PRIVATE + librw::skeleton + librw::librw ) add_custom_command( diff --git a/tools/playground/CMakeLists.txt b/tools/playground/CMakeLists.txt index 298f0e4..3db9307 100644 --- a/tools/playground/CMakeLists.txt +++ b/tools/playground/CMakeLists.txt @@ -1,10 +1,16 @@ add_executable(playground WIN32 - camera.cpp font.cpp main.cpp ras_test.cpp splines.cpp tl_tests.cpp + camera.cpp + font.cpp + main.cpp + ras_test.cpp + splines.cpp + tl_tests.cpp ) target_link_libraries(playground - PUBLIC - librw librw_skeleton_imgui + PRIVATE + librw::skeleton + librw::librw ) add_custom_command( diff --git a/tools/ps2test/CMakeLists.txt b/tools/ps2test/CMakeLists.txt index 9ed4260..69bcc98 100644 --- a/tools/ps2test/CMakeLists.txt +++ b/tools/ps2test/CMakeLists.txt @@ -8,18 +8,15 @@ add_executable(ps2test ) target_link_libraries(ps2test - PUBLIC - librw + PRIVATE + librw::librw kernel ) -add_erl_executable(PS2TEST_ERL ps2test) +librw_platform_target(ps2test) if(LIBRW_INSTALL) install(TARGETS ps2test RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ) - install(FILES "${PS2TEST_ERL}" - DESTINATION "${CMAKE_INSTALL_BINDIR}" - ) endif() diff --git a/tools/ska2anm/CMakeLists.txt b/tools/ska2anm/CMakeLists.txt index 9dfbb2a..ffd63d5 100644 --- a/tools/ska2anm/CMakeLists.txt +++ b/tools/ska2anm/CMakeLists.txt @@ -4,7 +4,13 @@ add_executable(ska2anm target_link_libraries(ska2anm PUBLIC - librw + librw::librw ) -librw_platform_target(ska2anm) +librw_platform_target(ska2anm INSTALL) + +if(LIBRW_INSTALL) + install(TARGETS ska2anm + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ) +endif() diff --git a/tools/subrast/CMakeLists.txt b/tools/subrast/CMakeLists.txt index cb4d197..1bf1de7 100644 --- a/tools/subrast/CMakeLists.txt +++ b/tools/subrast/CMakeLists.txt @@ -4,7 +4,8 @@ add_executable(subrast WIN32 target_link_libraries(subrast PUBLIC - librw librw_skeleton librw_skeleton_imgui + librw::skeleton + librw::librw ) librw_platform_target(subrast)