From 7ce4328601a5f218a11617b0da434c15504b699c Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 27 Oct 2020 00:41:07 +0100 Subject: [PATCH 1/2] Add cmake config file Big thanks for @madebr who made all work --- CMakeCPack.cmake | 15 ++ CMakeLists.txt | 57 +++++++ cmake/CMakeDSMCompiler.cmake.in | 16 ++ cmake/CMakeDSMInformation.cmake | 79 ++++++++++ cmake/CMakeDetermineDSMCompiler.cmake | 87 +++++++++++ cmake/CMakeTestDSMCompiler.cmake | 7 + cmake/ee.cmake | 2 + cmake/toolchain_ps2_ee.cmake | 64 ++++++++ librw-config.cmake.in | 12 ++ skeleton/CMakeLists.txt | 46 ++++++ skeleton/imgui/CMakeLists.txt | 46 ++++++ src/CMakeLists.txt | 217 ++++++++++++++++++++++++++ tools/CMakeLists.txt | 11 ++ tools/dumprwtree/CMakeLists.txt | 14 ++ tools/imguitest/CMakeLists.txt | 15 ++ 15 files changed, 688 insertions(+) create mode 100644 CMakeCPack.cmake create mode 100644 CMakeLists.txt create mode 100644 cmake/CMakeDSMCompiler.cmake.in create mode 100644 cmake/CMakeDSMInformation.cmake create mode 100644 cmake/CMakeDetermineDSMCompiler.cmake create mode 100644 cmake/CMakeTestDSMCompiler.cmake create mode 100644 cmake/ee.cmake create mode 100644 cmake/toolchain_ps2_ee.cmake create mode 100644 librw-config.cmake.in create mode 100644 skeleton/CMakeLists.txt create mode 100644 skeleton/imgui/CMakeLists.txt create mode 100644 src/CMakeLists.txt create mode 100644 tools/CMakeLists.txt create mode 100644 tools/dumprwtree/CMakeLists.txt create mode 100644 tools/imguitest/CMakeLists.txt diff --git a/CMakeCPack.cmake b/CMakeCPack.cmake new file mode 100644 index 0000000..80654aa --- /dev/null +++ b/CMakeCPack.cmake @@ -0,0 +1,15 @@ +set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A (partial) re-implementation of RenderWare Graphics") +set(CPACK_PACKAGE_VENDOR "librw") + +# FIXME: better description of the project +set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/LICENSE") +set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") +set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}") +set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}") + +set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}") + +# set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/CMakeCPackOptions.cmake") + +include(CPack) diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..d6caa5f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,57 @@ +cmake_minimum_required(VERSION 3.8) + +project(librw C CXX) + +if(PS2DEV AND EE) + include("${CMAKE_CURRENT_LIST_DIR}/cmake/ee.cmake") +endif() + +if(WIN32) + set(LIBRW_PLATFORMS "NULL" "GL3" "D3D9") +else() + set(LIBRW_PLATFORMS "NULL" "GL3" "PS2") +endif() +set(LIBRW_PLATFORM "NULL" CACHE STRING "Platform") +set_property(CACHE LIBRW_PLATFORM PROPERTY STRINGS ${LIBRW_PLATFORMS}) +message(STATUS "LIBRW_PLATFORM = ${LIBRW_PLATFORM} (choices=${LIBRW_PLATFORMS})") +set("LIBRW_PLATFORM_${LIBRW_PLATFORM}" ON) +if(NOT LIBRW_PLATFORM IN_LIST LIBRW_PLATFORMS) + message(FATAL_ERROR "Illegal LIBRW_PLATFORM=${LIBRW_PLATFORM}") +endif() + +if(LIBRW_PLATFORM_PS2) + enable_language(DSM) +endif() + +option(LIBRW_TOOLS "Build librw tools" ON) +option(LIBRW_INSTALL "Install librw files" OFF) + +if(LIBRW_INSTALL) + include(GNUInstallDirs) + set(LIBRW_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/librw") +endif() + +add_subdirectory(src) + +if(LIBRW_TOOLS) + add_subdirectory(skeleton) + + add_subdirectory(tools) +endif() + +if(LIBRW_INSTALL) + include(CMakePackageConfigHelpers) + configure_package_config_file(librw-config.cmake.in librw-config.cmake + INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}" + ) + install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/librw-config.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" + ) + install( + EXPORT librw-targets + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}" + ) + + include(CMakeCPack.cmake) +endif() diff --git a/cmake/CMakeDSMCompiler.cmake.in b/cmake/CMakeDSMCompiler.cmake.in new file mode 100644 index 0000000..9a55d4c --- /dev/null +++ b/cmake/CMakeDSMCompiler.cmake.in @@ -0,0 +1,16 @@ +set(CMAKE_DSM_COMPILER "@_CMAKE_DSM_COMPILER@") +set(CMAKE_DSM_COMPILER_ARG1 "@_CMAKE_DSM_COMPILER_ARG1@") +set(CMAKE_DSM_COMPILER_AR "@_CMAKE_DSM_COMPILER_AR@") +set(CMAKE_RANLIB "@CMAKE_RANLIB@") +set(CMAKE_DSM_COMPILER_RANLIB "@_CMAKE_DSM_COMPILER_RANLIB@") +set(CMAKE_LINKER "@CMAKE_LINKER@") +set(CMAKE_DSM_COMPILER_LOADED 1) +set(CMAKE_DSM_COMPILER_ID "@_CMAKE_DSM_COMPILER_ID@") +set(CMAKE_DSM_COMPILER_VERSION "@_CMAKE_DSM_COMPILER_VERSION@") +set(CMAKE_DSM_COMPILER_ENV_VAR "@_CMAKE_DSM_COMPILER_ENV_VAR@") +@_SET_CMAKE_DSM_COMPILER_ARCHITECTURE_ID@ + +set(CMAKE_DSM_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) +set(CMAKE_DSM_LINKER_PREFERENCE 0) + +@CMAKE_DSM_COMPILER_CUSTOM_CODE@ diff --git a/cmake/CMakeDSMInformation.cmake b/cmake/CMakeDSMInformation.cmake new file mode 100644 index 0000000..27b56d6 --- /dev/null +++ b/cmake/CMakeDSMInformation.cmake @@ -0,0 +1,79 @@ +if(UNIX) + set(CMAKE_DSM_OUTPUT_EXTENSION .o) +else() + set(CMAKE_DSM_OUTPUT_EXTENSION .obj) +endif() + +set(CMAKE_INCLUDE_FLAG_DSM "-I") + +set(CMAKE_DSM_FLAGS_INIT "$ENV{DSMFLAGS} ${CMAKE_DSM_FLAGS_INIT}") + +# replace for CMake >= 3.11 +foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO) + string(STRIP "${CMAKE_DSM_FLAGS${c}_INIT}" CMAKE_DSM_FLAGS${c}_INIT) +endforeach() + +set (CMAKE_DSM_FLAGS "${CMAKE_DSM_FLAGS_INIT}" CACHE STRING + "Flags used by the assembler during all build types.") + +if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) + get_property(_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + # default build type is none + if(NOT _GENERATOR_IS_MULTI_CONFIG AND NOT CMAKE_NO_BUILD_TYPE) + set (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_INIT} CACHE STRING + "Choose the type of build, options are: None, Debug Release RelWithDebInfo MinSizeRel.") + endif() + unset(_GENERATOR_IS_MULTI_CONFIG) + set (CMAKE_DSM_FLAGS_DEBUG "${CMAKE_DSM_FLAGS_DEBUG_INIT}" CACHE STRING + "Flags used by the assembler during debug builds.") + set (CMAKE_DSM_FLAGS_MINSIZEREL "${CMAKE_DSM_FLAGS_MINSIZEREL_INIT}" CACHE STRING + "Flags used by the assembler during release minsize builds.") + set (CMAKE_DSM_FLAGS_RELEASE "${CMAKE_DSM_FLAGS_RELEASE_INIT}" CACHE STRING + "Flags used by the assembler during release builds.") + set (CMAKE_DSM_FLAGS_RELWITHDEBINFO "${CMAKE_DSM_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING + "Flags used by the assembler during Release with Debug Info builds.") +endif() + +mark_as_advanced(CMAKE_DSM_FLAGS + CMAKE_DSM_FLAGS_DEBUG + CMAKE_DSM_FLAGS_MINSIZEREL + CMAKE_DSM_FLAGS_RELEASE + CMAKE_DSM_FLAGS_RELWITHDEBINFO + ) +# WITH: cmake_initialize_per_config_variable(CMAKE_DSM_FLAGS "Flags used by the DSM compiler") + +if(NOT CMAKE_DSM_COMPILE_OBJECT) + set(CMAKE_DSM_COMPILE_OBJECT " -o ") +endif() + +if(NOT CMAKE_DSM_CREATE_STATIC_LIBRARY) + set(CMAKE_DSM_CREATE_STATIC_LIBRARY + " cr " + " ") +endif() + +if(NOT CMAKE_DSM_LINK_EXECUTABLE) + set(CMAKE_DSM_LINK_EXECUTABLE + " -o ") +endif() + +if(NOT CMAKE_EXECUTABLE_RUNTIME_DSM_FLAG) + set(CMAKE_EXECUTABLE_RUNTIME_DSM_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_DSM_FLAG}) +endif() + +if(NOT CMAKE_EXECUTABLE_RUNTIME_DSM_FLAG_SEP) + set(CMAKE_EXECUTABLE_RUNTIME_DSM_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_DSM_FLAG_SEP}) +endif() + +if(NOT CMAKE_EXECUTABLE_RPATH_LINK_DSM_FLAG) + set(CMAKE_EXECUTABLE_RPATH_LINK_DSM_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_DSM_FLAG}) +endif() + +# to be done +if(NOT CMAKE_DSM_CREATE_SHARED_LIBRARY) + set(CMAKE_DSM_CREATE_SHARED_LIBRARY) +endif() + +if(NOT CMAKE_DSM_CREATE_SHARED_MODULE) + set(CMAKE_DSM_CREATE_SHARED_MODULE) +endif() diff --git a/cmake/CMakeDetermineDSMCompiler.cmake b/cmake/CMakeDetermineDSMCompiler.cmake new file mode 100644 index 0000000..d3bda8b --- /dev/null +++ b/cmake/CMakeDetermineDSMCompiler.cmake @@ -0,0 +1,87 @@ +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake) + +if (NOT CMAKE_DSM_COMPILER) + message(FATAL_ERROR "Need CMAKE_DSM_COMPILER set") +endif() + +_cmake_find_compiler_path(DSM) +mark_as_advanced(CMAKE_DSM_COMPILER) + +if (NOT CMAKE_DSM_COMPILER_ID) + # Table of per-vendor compiler id flags with expected output. + list(APPEND CMAKE_DSM_COMPILER_ID_VENDORS GNU ) + set(CMAKE_DSM_COMPILER_ID_VENDOR_FLAGS_GNU "--version") + set(CMAKE_DSM_COMPILER_ID_VENDOR_REGEX_GNU "(GNU assembler)|(GCC)|(Free Software Foundation)") + + include(CMakeDetermineCompilerId) + cmake_determine_compiler_id_vendor(DSM "") + +endif() + +if (NOT _CMAKE_TOOLCHAIN_LOCATION) + get_filename_component(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_DSM_COMPILER}" PATH) +endif() + +if (CMAKE_DSM_COMPILER_ID) + if (CMAKE_DSM_COMPILER_VERSION) + set(_version " ${CMAKE_DSM_COMPILER_VERSION}") + else() + set(_version "") + endif() + message(STATUS "The DSM compiler identification is ${CMAKE_DSM_COMPILER_ID}${_version}") + unset(_version) +else() + message(STATUS "The DSM compiler identification is unknown") +endif() + +if (NOT _CMAKE_TOOLCHAIN_PREFIX) + get_filename_component(COMPILER_BASENAME "${CMAKE_DSM_COMPILER}" NAME) + if (COMPILER_BASENAME MATCHES "^(.+1)g?as(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + endif() + +endif() + +set(_CMAKE_PROCESSING_LANGUAGE "DSM") +find_program(CMAKE_DSM_COMPILER_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) +find_program(CMAKE_DSM_COMPILER_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) +find_program(CMAKE_DSM_COMPILER_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) +find_program(CMAKE_DSM_COMPILER_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) +find_program(CMAKE_DSM_COMPILER_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) +find_program(CMAKE_DSM_COMPILER_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + +unset(_CMAKE_PROCESSING_LANGUAGE) + +set(CMAKE_DSM_COMPILER_ENV_VAR "DSM") + +if (CMAKE_DSM_COMPILER) + message(STATUS "Found DSM assembler: ${CMAKE_DSM_COMPILER}") +else() + message(STATUS "Didn't find assembler") +endif() + +foreach(_var + COMPILER + COMPILER_ID + COMPILER_ARG1 + COMPILER_ENV_VAR + COMPILER_AR + COMPILER_RANLIB + COMPILER_VERSION + ) + set(_CMAKE_DSM_${_var} "${CMAKE_DSM_${_var}}") +endforeach() + +configure_file("${CMAKE_CURRENT_LIST_DIR}/CMakeDSMCompiler.cmake.in" + "${CMAKE_PLATFORM_INFO_DIR}/CMakeDSMCompiler.cmake" @ONLY) + +foreach(_var + COMPILER + COMPILER_ID + COMPILER_ARG1 + COMPILER_ENV_VAR + COMPILER_AR + COMPILER_VERSION + ) + unset(_CMAKE_DSM_${_var}) +endforeach() diff --git a/cmake/CMakeTestDSMCompiler.cmake b/cmake/CMakeTestDSMCompiler.cmake new file mode 100644 index 0000000..5c514ea --- /dev/null +++ b/cmake/CMakeTestDSMCompiler.cmake @@ -0,0 +1,7 @@ +set(_ASM_COMPILER_WORKS 0) + +if(CMAKE_DSM_COMPILER) + set(_DSM_COMPILER_WORKS) +endif() + +set(CMAKE_DSM_COMPILER_WORKS ${_DSM_COMPILER_WORKS} CACHE INTERNAL "") diff --git a/cmake/ee.cmake b/cmake/ee.cmake new file mode 100644 index 0000000..4a75ab2 --- /dev/null +++ b/cmake/ee.cmake @@ -0,0 +1,2 @@ +include_directories(SYSTEM "${PS2SDK}/common/include") +include_directories(SYSTEM "${PS2SDK}/ee/include") diff --git a/cmake/toolchain_ps2_ee.cmake b/cmake/toolchain_ps2_ee.cmake new file mode 100644 index 0000000..1f28073 --- /dev/null +++ b/cmake/toolchain_ps2_ee.cmake @@ -0,0 +1,64 @@ +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") + +set(CMAKE_SYSTEM_NAME "Generic") +set(CMAKE_SYSTEM_PROCESSOR "ee") +set(CMAKE_SYSTEM_VERSION 1) + +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON) + +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +if(NOT DEFINED ENV{PS2DEV}) + message(FATAL_ERROR "Need environment variable PS2DEV set") +endif() +if(NOT DEFINED ENV{PS2SDK}) + message(FATAL_ERROR "Need environment variable PS2SDK set") +endif() +set(PS2DEV "$ENV{PS2DEV}") +set(PS2SDK "$ENV{PS2SDK}") + +#set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS "asm;dsm") + +set(CMAKE_DSM_SOURCE_FILE_EXTENSIONS "dsm") + +set(CMAKE_SHARED_LIBRARY_SUFFIX ".erl") +set(CMAKE_EXECUTABLE_SUFFIX ".elf") + +set(CMAKE_C_COMPILER "${PS2DEV}/ee/bin/ee-gcc") +set(CMAKE_CXX_COMPILER "${PS2DEV}/ee/bin/ee-g++") +set(CMAKE_ASM_COMPILER "${PS2DEV}/ee/bin/ee-g++") +set(CMAKE_DSM_COMPILER "${PS2DEV}/dvp/bin/dvp-as") +set(CMAKE_AR "${PS2DEV}/ee/bin/ee-ar" CACHE FILEPATH "archiver") +set(CMAKE_LINKER "${PS2DEV}/ee/bin/ee-ld") +set(CMAKE_RANLIB "${PS2DEV}/ee/bin/ee-ranlib" CACHE FILEPATH "ranlib") +set(CMAKE_STRIP "${PS2DEV}/ee/bin/ee-strip" CACHE FILEPATH "strip") + +set(EE_LDFLAGS "" CACHE STRING "EE linker flags") +set(EE_ASFLAGS "-G0" CACHE STRING "EE assembler flags") + +set(EE_CRT0 "${PS2SDK}/ee/startup/crt0.o" CACHE FILEPATH "EE crt0 file") +set_source_files_properties("${EE_CRT0}" PROPERTIES EXTERNAL_OBJECT ON) + +set(EE_LINKSCRIPT "${PS2SDK}/ee/startup/linkfile" CACHE FILEPATH "EE link script") + +#set(EE_CFLAGS " -nostdlib -fno-common -D_EE" CACHE STRING "EE C/CXX compiler flags") +set(EE_CFLAGS "-D_EE") +set(CMAKE_C_FLAGS_INIT "${EE_CFLAGS}") +set(CMAKE_CXX_FLAGS_INIT "${EE_CFLAGS}") +#set(CMAKE_ASM_FLAGS_INIT "${EE_CFLAGS}") + +set(CMAKE_C_CREATE_STATIC_LIBRARY " cru ") +set(CMAKE_CXX_CREATE_STATIC_LIBRARY "${CMAKE_C_CREATE_STATIC_LIBRARY}") +set(CMAKE_ASM_CREATE_STATIC_LIBRARY "${CMAKE_C_CREATE_STATIC_LIBRARY}") + +set(CMAKE_EXE_LINKER_FLAGS_INIT "-mno-crt0 -T\"${PS2SDK}/ee/startup/linkfile\" \"${EE_CRT0}\" -L\"${PS2SDK}/ee/lib\"") + +set(CMAKE_FIND_ROOT_PATH "${PS2DEV}/ee;${PS2SDK}/ee") +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +set(PS2 1) +set(EE 1) diff --git a/librw-config.cmake.in b/librw-config.cmake.in new file mode 100644 index 0000000..668ce5f --- /dev/null +++ b/librw-config.cmake.in @@ -0,0 +1,12 @@ +include("${CMAKE_CURRENT_LIST_DIR}/librw-targets.cmake") + +set(LIBRW_PLATFORM "@LIBRW_PLATFORM@") +set(LIBRW_PLATFORMS "@LIBRW_PLATFORMS@") +set(LIBRW_PLATFORM_@LIBRW_PLATFORM@ ON) + +if(LIBRW_PLATFORM_GL3) + set(OpenGL_GL_PREFERENCE GLVND) + find_package(OpenGL REQUIRED) + find_package(GLEW REQUIRED) + find_package(glfw3 REQUIRED) +endif() diff --git a/skeleton/CMakeLists.txt b/skeleton/CMakeLists.txt new file mode 100644 index 0000000..14cbba7 --- /dev/null +++ b/skeleton/CMakeLists.txt @@ -0,0 +1,46 @@ +add_library(librw_skeleton + glfw.cpp + skeleton.cpp + skeleton.h + win.cpp + ) + +set_target_properties(librw_skeleton + PROPERTIES + PREFIX "" + ) + +target_link_libraries(librw_skeleton + PUBLIC + librw + ) + +target_include_directories(librw_skeleton + INTERFACE + $ + ) + +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( + TARGETS librw_skeleton + EXPORT librw-targets + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/skeleton/imgui/CMakeLists.txt b/skeleton/imgui/CMakeLists.txt new file mode 100644 index 0000000..e61a7db --- /dev/null +++ b/skeleton/imgui/CMakeLists.txt @@ -0,0 +1,46 @@ +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 new file mode 100644 index 0000000..361a620 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,217 @@ +if(LIBRW_PLATFORM_GL3) + set(OpenGL_GL_PREFERENCE GLVND) + find_package(OpenGL REQUIRED) + find_package(GLEW REQUIRED) + find_package(glfw3 REQUIRED) +endif() + +add_library(librw + "${PROJECT_SOURCE_DIR}/args.h" + "${PROJECT_SOURCE_DIR}/rw.h" + + anim.cpp + base.cpp + bmp.cpp + camera.cpp + charset.cpp + clump.cpp + engine.cpp + error.cpp + frame.cpp + geometry.cpp + geoplg.cpp + hanim.cpp + image.cpp + light.cpp + matfx.cpp + pipeline.cpp + plg.cpp + png.cpp + prim.cpp + raster.cpp + render.cpp + rwanim.h + rwengine.h + rwerror.h + rwobjects.h + rwpipeline.h + rwplg.h + rwplugins.h + rwrender.h + rwuserdata.h + skin.cpp + texture.cpp + tga.cpp + tristrip.cpp + userdata.cpp + uvanim.cpp + world.cpp + + d3d/d3d8.cpp + d3d/d3d8matfx.cpp + d3d/d3d8render.cpp + d3d/d3d8skin.cpp + d3d/d3d9.cpp + d3d/d3d9matfx.cpp + d3d/d3d9render.cpp + d3d/d3d9skin.cpp + d3d/d3d.cpp + d3d/d3ddevice.cpp + d3d/d3dimmed.cpp + d3d/d3drender.cpp + d3d/rwd3d8.h + d3d/rwd3d9.h + d3d/rwd3d.h + d3d/rwd3dimpl.h + d3d/rwxbox.h + d3d/rwxboximpl.h + d3d/xbox.cpp + d3d/xboxmatfx.cpp + d3d/xboxskin.cpp + d3d/xboxvfmt.cpp + + gl/gl3.cpp + gl/gl3device.cpp + gl/gl3immed.cpp + gl/gl3matfx.cpp + gl/gl3pipe.cpp + gl/gl3raster.cpp + gl/gl3render.cpp + gl/gl3shader.cpp + gl/gl3skin.cpp + gl/rwgl3.h + gl/rwgl3impl.h + gl/rwgl3plg.h + gl/rwgl3shader.h + gl/rwwdgl.h + gl/wdgl.cpp + + lodepng/lodepng.h + lodepng/lodepng.cpp + + ps2/pds.cpp + ps2/ps2.cpp + ps2/ps2device.cpp + ps2/ps2matfx.cpp + ps2/ps2raster.cpp + ps2/ps2skin.cpp + ps2/rwps2.h + ps2/rwps2impl.h + ps2/rwps2plg.h + ) + +target_include_directories(librw + INTERFACE + $ + ) + +target_compile_definitions(librw + PRIVATE + "$,DEBUG,NDEBUG>" + PUBLIC + "RW_${LIBRW_PLATFORM}" + ) + +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + target_compile_options(librw + PRIVATE + "-Wall" + ) + if (NOT LIBRW_PLATFORM_PS2) + target_compile_options(librw + PRIVATE + "-Wextra" + "-Wdouble-promotion" + "-Wpedantic" + ) + endif() +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + target_compile_options(librw + PUBLIC + /wd4996 /wd4244 + ) +endif() + +set_target_properties(librw + PROPERTIES + C_STANDARD 11 + C_EXTENSIONS OFF + C_STANDARD_REQUIRED ON + CXX_STANDARD 11 + CXX_EXTENSIONS OFF + CXX_STANDARD_REQUIRED ON + PREFIX "" + ) + +if(LIBRW_PLATFORM_GL3) + target_link_libraries(librw + PUBLIC + glfw + GLEW::GLEW + OpenGL::GL + ) +elseif(LIBRW_PLATFORM_D3D9) + target_link_libraries(librw + PUBLIC + d3d9 + xinput + ) +endif() + +if(LIBRW_INSTALL) + target_include_directories(librw + INTERFACE + $ + ) + + install( + FILES + "${PROJECT_SOURCE_DIR}/args.h" + "${PROJECT_SOURCE_DIR}/rw.h" + DESTINATION "${LIBRW_INSTALL_INCLUDEDIR}" + ) + install( + FILES + base.err + rwbase.h + rwerror.h + rwplg.h + rwrender.h + rwengine.h + rwpipeline.h + rwobjects.h + rwanim.h + rwplugins.h + rwuserdata.h + DESTINATION "${LIBRW_INSTALL_INCLUDEDIR}/src" + ) + install( + FILES + d3d/rwxbox.h + d3d/rwd3d.h + d3d/rwd3d8.h + d3d/rwd3d9.h + DESTINATION "${LIBRW_INSTALL_INCLUDEDIR}/src/d3d" + ) + install( + FILES + ps2/rwps2.h + ps2/rwps2plg.h + DESTINATION "${LIBRW_INSTALL_INCLUDEDIR}/src/ps2" + ) + install( + FILES + gl/rwwdgl.h + gl/rwgl3.h + gl/rwgl3shader.h + DESTINATION "${LIBRW_INSTALL_INCLUDEDIR}/src/gl" + ) + + install( + TARGETS librw + EXPORT librw-targets + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt new file mode 100644 index 0000000..1d06544 --- /dev/null +++ b/tools/CMakeLists.txt @@ -0,0 +1,11 @@ +if(NOT LIBRW_PLATFORM_PS2) + add_subdirectory(dumprwtree) +endif() + +if(TARGET librw_skeleton_imgui) + add_subdirectory(imguitest) +endif() + +if(LIBRW_PLATFORM_PS2) + add_subdirectory(ps2test) +endif() diff --git a/tools/dumprwtree/CMakeLists.txt b/tools/dumprwtree/CMakeLists.txt new file mode 100644 index 0000000..fffb737 --- /dev/null +++ b/tools/dumprwtree/CMakeLists.txt @@ -0,0 +1,14 @@ +add_executable(dumprwtree + dumprwtree.cpp + ) + +target_link_libraries(dumprwtree + PUBLIC + librw + ) + +if(LIBRW_INSTALL) + install(TARGETS dumprwtree + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ) +endif() diff --git a/tools/imguitest/CMakeLists.txt b/tools/imguitest/CMakeLists.txt new file mode 100644 index 0000000..0cf413a --- /dev/null +++ b/tools/imguitest/CMakeLists.txt @@ -0,0 +1,15 @@ +add_executable(imguitest WIN32 + main.cpp + ) + +target_link_libraries(imguitest + PUBLIC + librw + librw_skeleton_imgui + ) + +if(LIBRW_INSTALL) + install(TARGETS imguitest + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ) +endif() From 7e1eaaaf434b83e75a341aa4ef49e0bd157ef8b5 Mon Sep 17 00:00:00 2001 From: shfil Date: Tue, 27 Oct 2020 01:26:26 +0100 Subject: [PATCH 2/2] Update CMakeLists.txt Co-authored-by: Anonymous Maarten --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6caa5f..f94dfc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,7 +50,7 @@ if(LIBRW_INSTALL) ) install( EXPORT librw-targets - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" ) include(CMakeCPack.cmake)