问题背景
1.插件:https://github.com/IdeGelis/q3D2D
2.Cloudcompare源码:https://github.com/CloudCompare/CloudCompare
3.QT版本5.14.2
4.CMake版本 3.21.6
具体流程参考:[https://blog.csdn.net/baidu_40840693/article/details/112279375]
运行结果及报错内容
在CMake运行的过程中,Configure时,总是显示
CMake Error at plugins/core/Standard/q3D2D/CMakePluginTpl.cmake:85 (install_shared):
Unknown CMake command "install_shared".
Call Stack (most recent call first):
plugins/core/Standard/q3D2D/CMakeLists.txt:24 (include)
CMakePluginTpl.cmake
### DEFAULT CC "STANDARD" PLUGIN CMAKE SCRIPT ###
include( CMakePolicies NO_POLICY_SCOPE )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
include_directories( ${CloudComparePlugins_SOURCE_DIR} )
include_directories( ${GLEW_LIB_SOURCE_DIR}/include )
include_directories( ${CC_FBO_LIB_SOURCE_DIR}/include )
include_directories( ${CC_CORE_LIB_SOURCE_DIR}/include )
include_directories( ${QCC_IO_LIB_SOURCE_DIR} )
include_directories( ${QCC_DB_LIB_SOURCE_DIR} )
if( MSVC )
include_directories( ${QCC_DB_LIB_SOURCE_DIR}/msvc )
endif()
include_directories( ${QCC_GL_LIB_SOURCE_DIR} )
include_directories( ${EXTERNAL_LIBS_INCLUDE_DIR} )
file( GLOB header_list *.h)
file( GLOB source_list *.cpp)
# force the link with ccStdPluginInterface.cpp
list( APPEND source_list ${CloudComparePlugins_SOURCE_DIR}/ccStdPluginInterface.cpp )
file( GLOB ui_list *.ui )
file( GLOB qrc_list *.qrc )
file( GLOB rc_list *.rc )
if ( CC_PLUGIN_CUSTOM_HEADER_LIST )
list( APPEND header_list ${CC_PLUGIN_CUSTOM_HEADER_LIST} )
endif()
if ( CC_PLUGIN_CUSTOM_SOURCE_LIST )
list( APPEND source_list ${CC_PLUGIN_CUSTOM_SOURCE_LIST} )
endif()
if (CC_PLUGIN_CUSTOM_UI_LIST)
list( APPEND ui_list ${CC_PLUGIN_CUSTOM_UI_LIST} )
endif()
qt5_wrap_ui( generated_ui_list ${ui_list} )
qt5_add_resources( generated_qrc_list ${qrc_list} )
add_library( ${PROJECT_NAME} SHARED ${header_list} ${source_list} ${moc_list} ${generated_ui_list} ${generated_qrc_list})
# Add custom default prepocessor definitions
set_property( TARGET ${PROJECT_NAME} APPEND PROPERTY COMPILE_DEFINITIONS USE_GLEW GLEW_STATIC )
if( WIN32 )
set_property( TARGET ${PROJECT_NAME} APPEND PROPERTY COMPILE_DEFINITIONS CC_USE_AS_DLL QCC_DB_USE_AS_DLL QCC_IO_USE_AS_DLL )
endif()
# Plugins need the QT_NO_DEBUG preprocessor in release!
if( NOT CMAKE_CONFIGURATION_TYPES )
set_property( TARGET ${PROJECT_NAME} APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_DEBUG )
else()
set_property( TARGET ${PROJECT_NAME} APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG)
endif()
target_link_libraries( ${PROJECT_NAME} GLEW_LIB )
target_link_libraries( ${PROJECT_NAME} CC_FBO_LIB )
target_link_libraries( ${PROJECT_NAME} CC_CORE_LIB )
target_link_libraries( ${PROJECT_NAME} QCC_DB_LIB )
target_link_libraries( ${PROJECT_NAME} QCC_IO_LIB )
target_link_libraries( ${PROJECT_NAME} QCC_GL_LIB )
if ( USE_QT5 )
qt5_use_modules(${PROJECT_NAME} Core Gui Widgets OpenGL Concurrent)
endif()
if( APPLE )
# put all the plugins we build into one directory
set( PLUGINS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/ccPlugins" )
file( MAKE_DIRECTORY "${PLUGINS_OUTPUT_DIR}" )
set_target_properties( ${PROJECT_NAME}
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${PLUGINS_OUTPUT_DIR}"
)
install( TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CLOUDCOMPARE_MAC_PLUGIN_DIR} COMPONENT Runtime )
set( CLOUDCOMPARE_PLUGINS ${CLOUDCOMPARE_PLUGINS} ${CLOUDCOMPARE_MAC_PLUGIN_DIR}/lib${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} CACHE INTERNAL "CloudCompare plugin list")
elseif( UNIX )
install_shared( ${PROJECT_NAME} ${CMAKE_INSTALL_LIBDIR}/cloudcompare/plugins 0 )
else()
install_shared( ${PROJECT_NAME} ${CLOUDCOMPARE_DEST_FOLDER} 1 /plugins )
endif()
#GL filters and IO plugins also go the the ccViewer 'plugins' sub-folder
if( ${OPTION_BUILD_CCVIEWER} )
if( CC_SHADER_FOLDER OR CC_IS_IO_PLUGIN )
if( APPLE )
install( TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CCVIEWER_MAC_PLUGIN_DIR} COMPONENT Runtime )
set( CCVIEWER_PLUGINS ${CCVIEWER_PLUGINS} ${CCVIEWER_MAC_PLUGIN_DIR}/lib${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} CACHE INTERNAL "ccViewer plugin list")
elseif( UNIX )
install_shared( ${PROJECT_NAME} ${CMAKE_INSTALL_LIBDIR}/cloudcompare/plugins 0 )
else()
install_shared( ${PROJECT_NAME} ${CCVIEWER_DEST_FOLDER} 1 /plugins )
endif()
endif()
endif()
#'GL filter' plugins specifics
if( CC_SHADER_FOLDER )
# copy shader dirs into our shadow build directory
file( COPY shaders DESTINATION "${CMAKE_BINARY_DIR}" )
# install the shader files
file( GLOB shaderFiles shaders/${CC_SHADER_FOLDER}/*.frag shaders/${CC_SHADER_FOLDER}/*.vert )
foreach( filename ${shaderFiles} )
if( APPLE )
install( FILES ${filename} DESTINATION ${CLOUDCOMPARE_MAC_BASE_DIR}/Contents/Shaders/${CC_SHADER_FOLDER} )
if( ${OPTION_BUILD_CCVIEWER} )
install( FILES ${filename} DESTINATION ${CCVIEWER_MAC_BASE_DIR}/Contents/Shaders/${CC_SHADER_FOLDER} )
endif()
elseif ( UNIX )
install( FILES ${filename} DESTINATION share/cloudcompare/shaders/${CC_SHADER_FOLDER} )
else()
install_ext( FILES ${filename} ${CLOUDCOMPARE_DEST_FOLDER} /shaders/${CC_SHADER_FOLDER} )
if( ${OPTION_BUILD_CCVIEWER} )
install_ext( FILES ${filename} ${CCVIEWER_DEST_FOLDER} /shaders/${CC_SHADER_FOLDER} )
endif()
endif()
endforeach()
endif()
### END OF DEFAULT CC PLUGIN CMAKE SCRIPT ###
CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
#REPLACE ALL 'DUMMY' OCCURENCES BY YOUR PLUGIN NAME
#AND ADAPT THE CODE BELOW TO YOUR OWN NEEDS!
option( INSTALL_Q3D2D_PLUGIN "Check to install q3D2D plugin" OFF )
# CloudCompare 'MYPLUGIN' plugin
if (INSTALL_Q3D2D_PLUGIN)
project( Q3D2D_PLUGIN )
#As we are going to re-use several components of the main qCC project
#we define its sources path relatively to the plugin's dir
set(CloudCompare_QCC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../qCC)
#include the whole CC directory (easier)
include_directories( ${CloudCompare_QCC_DIR} )
#load necessary libraries (see qPCV for an example)
#add_subdirectory (LIB1)
#if the plugin is an 'OpenGL filter', uncomment the line below
#set( CC_OPENGL_FILTER ON BOOL)
include( ../CMakePluginTpl.cmake )
#we also need picking hub classes
list( APPEND CC_PLUGIN_CUSTOM_HEADER_LIST ${CloudCompare_QCC_DIR}/ccPickingListener.h )
list( APPEND CC_PLUGIN_CUSTOM_HEADER_LIST ${CloudCompare_QCC_DIR}/ccPickingHub.h )
list( APPEND CC_PLUGIN_CUSTOM_SOURCE_LIST ${CloudCompare_QCC_DIR}/ccPickingHub.cpp )
#set dependencies to necessary libraries (see qPCV for an example)
#target_link_libraries( ${PROJECT_NAME} LIB1 )
#include_directories( ${LIB1_INCLUDE_DIR} )
endif()
找到过其他有关解答:https://blog.csdn.net/baidu_40840693/article/details/112279375
对于CMake了解不多,希望有同学可以帮忙给个方向!