Skip to content

Commit b527385

Browse files
committed
Update CMake file for plugin system.
- Change plugin directory structure. - Change plugin dll name. - Add cmake file for render pipeline setting.
1 parent d64069b commit b527385

File tree

301 files changed

+113
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

301 files changed

+113
-93
lines changed

CMakeLists.txt

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,27 @@ if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION)
1313
endif()
1414

1515
# version
16-
set(RENDER_PIPELINE_VERSION 0)
17-
file(STRINGS "${PROJECT_SOURCE_DIR}/render_pipeline/rpcore/version.hpp" _RENDER_PIPELINE_VERSION_HPP REGEX "#define RENDER_PIPELINE_VERSION ")
18-
if("${_RENDER_PIPELINE_VERSION_HPP}" MATCHES "#define RENDER_PIPELINE_VERSION ([0-9]+)")
19-
set(RENDER_PIPELINE_VERSION "${CMAKE_MATCH_1}")
16+
file(STRINGS "${PROJECT_SOURCE_DIR}/render_pipeline/rpcore/version.hpp" _render_pipeline_VERSION_HPP REGEX "#define RENDER_PIPELINE_VERSION ")
17+
if("${_render_pipeline_VERSION_HPP}" MATCHES "#define RENDER_PIPELINE_VERSION ([0-9]+)")
18+
set(render_pipeline_VERSION "${CMAKE_MATCH_1}")
2019
endif()
21-
unset(_RENDER_PIPELINE_VERSION_HPP)
20+
unset(_render_pipeline_VERSION_HPP)
2221

23-
math(EXPR RENDER_PIPELINE_VERSION_MAJOR "${RENDER_PIPELINE_VERSION} / 10000")
24-
math(EXPR RENDER_PIPELINE_VERSION_MINOR "${RENDER_PIPELINE_VERSION} / 100 % 100")
25-
math(EXPR RENDER_PIPELINE_VERSION_PATCH "${RENDER_PIPELINE_VERSION} % 100")
26-
set(RENDER_PIPELINE_VERSION_TAG "")
22+
math(EXPR render_pipeline_VERSION_MAJOR "${render_pipeline_VERSION} / 10000")
23+
math(EXPR render_pipeline_VERSION_MINOR "${render_pipeline_VERSION} / 100 % 100")
24+
math(EXPR render_pipeline_VERSION_PATCH "${render_pipeline_VERSION} % 100")
25+
set(render_pipeline_VERSION_TAG "")
2726

28-
set(RENDER_PIPELINE_VERSION "${RENDER_PIPELINE_VERSION_MAJOR}.${RENDER_PIPELINE_VERSION_MINOR}.${RENDER_PIPELINE_VERSION_PATCH}${RENDER_PIPELINE_VERSION_TAG}")
29-
set(PROJECT_VERSION "${RENDER_PIPELINE_VERSION}")
27+
set(render_pipeline_VERSION "${render_pipeline_VERSION_MAJOR}.${render_pipeline_VERSION_MINOR}.${render_pipeline_VERSION_PATCH}${render_pipeline_VERSION_TAG}")
28+
set(PROJECT_VERSION "${render_pipeline_VERSION}")
3029

31-
message("Render Pipeline building version: ${RENDER_PIPELINE_VERSION}")
30+
message("Render Pipeline building version: ${render_pipeline_VERSION}")
3231

3332
# configure project package
3433
include(FindPackages)
3534

36-
set(RENDER_PIPELINE_CONFIG_DIR "etc/${PROJECT_NAME}")
37-
set(RENDER_PIPELINE_DATA_DIR "share/${PROJECT_NAME}")
38-
set(RENDER_PIPELINE_PLUGIN_DIR "${RENDER_PIPELINE_DATA_DIR}/rpplugins")
35+
set(render_pipeline_SETTING_CMAKE_FILE "${PROJECT_SOURCE_DIR}/cmake/render_pipeline-setting.cmake")
36+
include(${render_pipeline_SETTING_CMAKE_FILE})
3937

4038
# subdirectory
4139
add_subdirectory("${PROJECT_SOURCE_DIR}/src/rpplugins")
@@ -101,20 +99,20 @@ set(PACKAGE_CONFIG_FILE "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake")
10199
set(TARGET_EXPORT_NAME "${PACKAGE_NAME}-targets")
102100
set(PACKAGE_CMAKE_INSTALL_DIR "lib/${PROJECT_NAME}/cmake")
103101
file(RELATIVE_PATH PACKAGE_CMAKE_INSTALL_DIR2ROOT_DIR "${CMAKE_INSTALL_PREFIX}/${PACKAGE_CMAKE_INSTALL_DIR}" "${CMAKE_INSTALL_PREFIX}")
102+
get_filename_component(PACKAGE_CMAKE_INSTALL_DIR2ROOT_DIR "${PACKAGE_CMAKE_INSTALL_DIR2ROOT_DIR}/." DIRECTORY)
104103

105104
include(CMakePackageConfigHelpers)
106105
write_basic_package_version_file(${PACKAGE_VERSION_CONFIG_FILE}
107106
VERSION ${PACKAGE_VERSION}
108107
COMPATIBILITY SameMajorVersion
109108
)
110-
configure_package_config_file("${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}-config.cmake.in"
109+
110+
configure_package_config_file("${PROJECT_SOURCE_DIR}/cmake/${PACKAGE_NAME}-config.cmake.in"
111111
${PACKAGE_CONFIG_FILE}
112112
INSTALL_DESTINATION ${PACKAGE_CMAKE_INSTALL_DIR}
113113
)
114114

115-
export(TARGETS ${PROJECT_NAME}
116-
FILE ${PROJECT_BINARY_DIR}/${TARGET_EXPORT_NAME}.cmake
117-
)
115+
export(TARGETS ${PROJECT_NAME} FILE ${PROJECT_BINARY_DIR}/${TARGET_EXPORT_NAME}.cmake)
118116
export(PACKAGE ${PACKAGE_NAME})
119117
# ==================================================================================================
120118

@@ -134,12 +132,14 @@ install(FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.pdb"
134132
)
135133

136134
install(DIRECTORY "${PROJECT_SOURCE_DIR}/${PROJECT_NAME}" DESTINATION "include/")
137-
install(DIRECTORY "${PROJECT_SOURCE_DIR}/resources/config/" DESTINATION "${RENDER_PIPELINE_CONFIG_DIR}/")
138-
install(DIRECTORY "${PROJECT_SOURCE_DIR}/resources/data" DESTINATION "${RENDER_PIPELINE_DATA_DIR}/")
139-
install(DIRECTORY "${PROJECT_SOURCE_DIR}/resources/effects" DESTINATION "${RENDER_PIPELINE_DATA_DIR}/")
140-
install(DIRECTORY "${PROJECT_SOURCE_DIR}/resources/rpcore" DESTINATION "${RENDER_PIPELINE_DATA_DIR}/")
135+
install(DIRECTORY "${PROJECT_SOURCE_DIR}/resources/config/" DESTINATION "${render_pipeline_CONFIG_DIR}/")
136+
install(DIRECTORY "${PROJECT_SOURCE_DIR}/resources/data" DESTINATION "${render_pipeline_DATA_DIR}/")
137+
install(DIRECTORY "${PROJECT_SOURCE_DIR}/resources/effects" DESTINATION "${render_pipeline_DATA_DIR}/")
138+
install(DIRECTORY "${PROJECT_SOURCE_DIR}/resources/rpcore" DESTINATION "${render_pipeline_DATA_DIR}/")
141139

142-
install(FILES ${PACKAGE_CONFIG_FILE} ${PACKAGE_VERSION_CONFIG_FILE} DESTINATION ${PACKAGE_CMAKE_INSTALL_DIR})
140+
install(FILES ${PACKAGE_CONFIG_FILE} ${PACKAGE_VERSION_CONFIG_FILE} ${render_pipeline_SETTING_CMAKE_FILE}
141+
DESTINATION ${PACKAGE_CMAKE_INSTALL_DIR}
142+
)
143143
install(EXPORT ${TARGET_EXPORT_NAME} DESTINATION ${PACKAGE_CMAKE_INSTALL_DIR})
144144

145145
# documents

cmake/FindPackages.cmake

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,40 @@
11
# Author: Younguk Kim (bluekyu)
22
# Date : 2016-08-02
33

4-
# find boost
5-
option(Boost_USE_STATIC_LIBS "Boost uses static libraries" OFF)
6-
option(Boost_USE_MULTITHREADED "Boost uses multithreaded" ON)
7-
option(Boost_USE_STATIC_RUNTIME "Boost uses static runtime" OFF)
8-
9-
set(BOOST_ROOT "" CACHE PATH "Hint for finding boost root directory")
10-
set(BOOST_INCLUDEDIR "" CACHE PATH "Hint for finding boost include directory")
11-
set(BOOST_LIBRARYDIR "" CACHE PATH "Hint for finding boost library directory")
12-
find_package(Boost 1.62.0 REQUIRED COMPONENTS filesystem system)
13-
14-
# find panda3d
15-
set(PANDA3D_ROOT "" CACHE PATH "Hint for finding panda3d root directory")
16-
find_package(panda3d REQUIRED)
4+
function(_find_boost required_component)
5+
if(NOT TARGET Boost::boost)
6+
option(Boost_USE_STATIC_LIBS "Boost uses static libraries" OFF)
7+
option(Boost_USE_MULTITHREADED "Boost uses multithreaded" ON)
8+
option(Boost_USE_STATIC_RUNTIME "Boost uses static runtime" OFF)
9+
10+
set(BOOST_ROOT "" CACHE PATH "Hint for finding boost root directory")
11+
set(BOOST_INCLUDEDIR "" CACHE PATH "Hint for finding boost include directory")
12+
set(BOOST_LIBRARYDIR "" CACHE PATH "Hint for finding boost library directory")
13+
endif()
14+
15+
set(missed_component "")
16+
foreach(component ${required_component})
17+
if(NOT TARGET Boost::${component})
18+
list(APPEND missed_component ${component})
19+
endif()
20+
endforeach()
21+
22+
if(missed_component)
23+
find_package(Boost 1.62.0 REQUIRED ${missed_component})
24+
endif()
25+
26+
if(NOT TARGET Boost::boost)
27+
find_package(Boost 1.62.0 REQUIRED)
28+
endif()
29+
endfunction()
30+
31+
_find_boost("filesystem")
32+
33+
if(NOT TARGET panda3d::panda3d)
34+
# find panda3d
35+
set(PANDA3D_ROOT "" CACHE PATH "Hint for finding panda3d root directory")
36+
find_package(panda3d REQUIRED)
37+
endif()
1738

1839
# find doxygen
1940
option(RENDER_PIPELINE_BUILD_DOCUMENTS "Build doxygen documents" OFF)

cmake/plugin_install.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
install(TARGETS ${PROJECT_NAME} DESTINATION ${RPPLUGIN_INSTALL_DIR})
22
install(TARGETS ${RPPLUGIN_ID} EXPORT ${TARGET_EXPORT_NAME})
33

4-
install(DIRECTORY "${PROJECT_SOURCE_DIR}/resources/" DESTINATION ${RPPLUGIN_INSTALL_DIR})
5-
if(EXISTS "${PROJECT_SOURCE_DIR}/include")
6-
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include" DESTINATION ${RPPLUGIN_INSTALL_DIR})
7-
endif()
4+
install(FILES "${PROJECT_SOURCE_DIR}/config.yaml" DESTINATION ${RPPLUGIN_INSTALL_DIR})
5+
foreach(directory_name "include" "resources" "shader")
6+
if(EXISTS "${PROJECT_SOURCE_DIR}/${directory_name}")
7+
install(DIRECTORY "${PROJECT_SOURCE_DIR}/${directory_name}" DESTINATION ${RPPLUGIN_INSTALL_DIR})
8+
endif()
9+
endforeach()
810

911
install(FILES ${PACKAGE_CONFIG_FILE} ${PACKAGE_VERSION_CONFIG_FILE} DESTINATION ${PACKAGE_CMAKE_INSTALL_DIR})
1012
install(EXPORT ${TARGET_EXPORT_NAME} NAMESPACE ${TARGET_NAMESPACE} DESTINATION ${PACKAGE_CMAKE_INSTALL_DIR})

cmake/render_pipeline-config.cmake.in

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,10 @@
33
set (@PACKAGE_NAME@_VERSION "@PACKAGE_VERSION@")
44

55
include(${CMAKE_CURRENT_LIST_DIR}/@TARGET_EXPORT_NAME@.cmake)
6+
include(${CMAKE_CURRENT_LIST_DIR}/@PACKAGE_NAME@-setting.cmake)
67

78
set(@PACKAGE_NAME@_INSTALL_DIR "${CMAKE_CURRENT_LIST_DIR}/@PACKAGE_CMAKE_INSTALL_DIR2ROOT_DIR@")
8-
set(@PACKAGE_NAME@_CONFIG_DIR "${@PACKAGE_NAME@_INSTALL_DIR}/@RENDER_PIPELINE_CONFIG_DIR@")
9-
set(@PACKAGE_NAME@_DATA_DIR "${@PACKAGE_NAME@_INSTALL_DIR}/@RENDER_PIPELINE_DATA_DIR@")
10-
set(@PACKAGE_NAME@_PLUGIN_DIR "${@PACKAGE_NAME@_INSTALL_DIR}/@RENDER_PIPELINE_PLUGIN_DIR@")
119

1210
message(STATUS "@PACKAGE_NAME@ version: ${@PACKAGE_NAME@_VERSION}")
1311

14-
# help function to find plugin
15-
function(@PACKAGE_NAME@_FIND_PLUGINS plugin_id_list)
16-
foreach(plugin_id ${plugin_id_list})
17-
if(NOT TARGET rpplugin::${plugin_id})
18-
find_package(rpplugin_${plugin_id} REQUIRED HINTS "${@PACKAGE_NAME@_DATA_DIR}/rpplugins/${plugin_id}")
19-
endif()
20-
endforeach()
21-
22-
message(STATUS "Found the following Render Pipeline plugins:")
23-
foreach(plugin_id ${plugin_id_list})
24-
message(STATUS " ${plugin_id}")
25-
endforeach()
26-
endfunction()
27-
2812
check_required_components(@PACKAGE_NAME@)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
set(render_pipeline_CONFIG_DIR "etc/render_pipeline")
2+
set(render_pipeline_DATA_DIR "share/render_pipeline")
3+
set(render_pipeline_PLUGIN_DIR "${render_pipeline_DATA_DIR}/rpplugins")
4+
5+
# help function to find plugin
6+
function(render_pipeline_FIND_PLUGINS plugin_id_list)
7+
set(missed_plugin_id_list "")
8+
foreach(plugin_id ${plugin_id_list})
9+
if(NOT TARGET rpplugin::${plugin_id})
10+
list(APPEND missed_plugin_id_list ${plugin_id})
11+
endif()
12+
endforeach()
13+
14+
if(missed_plugin_id_list)
15+
if(render_pipeline_INSTALL_DIR)
16+
set(PLUGIN_DIR_HINT "${render_pipeline_INSTALL_DIR}/${render_pipeline_PLUGIN_DIR}")
17+
else()
18+
message(WARNING "render_pipeline_INSTALL_DIR is NOT set.")
19+
endif()
20+
21+
foreach(plugin_id ${missed_plugin_id_list})
22+
find_package(rpplugin_${plugin_id} REQUIRED HINTS "${PLUGIN_DIR_HINT}/${plugin_id}")
23+
endforeach()
24+
endif()
25+
26+
message(STATUS "Found the following Render Pipeline plugins:")
27+
foreach(plugin_id ${plugin_id_list})
28+
message(STATUS " ${plugin_id}")
29+
endforeach()
30+
endfunction()

src/rpcore/pluginbase/manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ std::shared_ptr<BasePlugin> PluginManager::Impl::load_plugin(const std::string&
8686
{
8787
boost::filesystem::path plugin_path(plugin_dir_);
8888

89-
plugin_path = boost::filesystem::absolute(plugin_path / plugin_id / "plugin");
89+
plugin_path = boost::filesystem::absolute(plugin_path / plugin_id / ("rpplugin_" + plugin_id));
9090

9191
self_.trace(fmt::format("Importing shared library file ({}) from {}{}", plugin_id, plugin_path.string(), boost::dll::shared_library::suffix().string()));
9292

src/rpplugins/ao/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ project(rpplugin_${RPPLUGIN_ID})
99
# === configure ====================================================================================
1010
set_property(GLOBAL PROPERTY USE_FOLDERS ON) # Project Grouping
1111

12-
set(RPPLUGIN_INSTALL_DIR "${RENDER_PIPELINE_PLUGIN_DIR}/${RPPLUGIN_ID}")
12+
set(RPPLUGIN_INSTALL_DIR "${render_pipeline_PLUGIN_DIR}/${RPPLUGIN_ID}")
1313

1414
set(PROJECT_VERSION_MAJOR "0")
1515
set(PROJECT_VERSION_MINOR "1")
@@ -49,7 +49,6 @@ target_link_libraries(${PROJECT_NAME}
4949

5050
set_target_properties(${PROJECT_NAME} PROPERTIES
5151
FOLDER "render_pipeline/rpplugins"
52-
OUTPUT_NAME "plugin"
5352
)
5453

5554
# create plugin interface target
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)