首页 > 数据库 >cmakelist 源码生成so 文件 orthanc mysql

cmakelist 源码生成so 文件 orthanc mysql

时间:2024-10-12 11:50:27浏览次数:7  
标签:cmakelist VERSION set CMAKE 源码 so ORTHANC Plugins DIR

cmakelist.txt

# Orthanc - A Lightweight, RESTful DICOM Store
# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
# Department, University Hospital of Liege, Belgium
# Copyright (C) 2017-2023 Osimis S.A., Belgium
# Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
# Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Affero General Public License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0058 NEW)
project(Orthanc)

set(ORTHANC_PLUGIN_VERSION "5.2")
set(ALLOW_DOWNLOADS ON)
set(CMAKE_BUILD_TYPE "Release")

# This is the preferred version of the Orthanc SDK for this plugin
set(ORTHANC_SDK_DEFAULT_VERSION "1.12.0")

# This is the list of the versions of the Orthanc SDK against which
# this plugin will compile
set(ORTHANC_SDK_COMPATIBLE_VERSIONS "0.9.5" "1.4.0" "1.5.2" "1.5.4" "1.9.2" "1.12.0" "1.12.3" "1.12.4")

# This is the minimal version of the Orthanc runtime that will provide
# best performance. If the version of the Orthanc runtime is below
# this minimal version, a warning message will be printed (but the
# plugin will still start).
set(ORTHANC_OPTIMAL_VERSION_MAJOR    1)
set(ORTHANC_OPTIMAL_VERSION_MINOR    12)
set(ORTHANC_OPTIMAL_VERSION_REVISION 4)
set(USE_SYSTEM_ORTHANC_SDK ON)

if (ORTHANC_PLUGIN_VERSION STREQUAL "mainline")
    set(ORTHANC_FRAMEWORK_VERSION "mainline")
    set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg")
else()
    set(ORTHANC_FRAMEWORK_VERSION "1.12.4")
    set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "path")
endif()
set(ORTHANC_FRAMEWORK_SOURCE "path")
set(ORTHANC_SDK_DEFAULT_VERSION "1.12.4")
set(ORTHANC_SDK_ROOT ${CMAKE_CURRENT_LIST_DIR}/../OrthancFramework/Resources/Orthanc/Sdk-1.12.4)
set(ORTHANC_FRAMEWORK_ROOT ${CMAKE_CURRENT_LIST_DIR}/../OrthancFramework/Sources)


include(${ORTHANC_FRAMEWORK_ROOT}/../Resources/CMake/DatabasesPluginParameters.cmake)

set(ENABLE_MYSQL_BACKEND ON)
set(OPENSSL_STATIC_VERSION "3.0" CACHE STRING "Force the use of OpenSSL 3.0.x" FORCE)

include(${ORTHANC_FRAMEWORK_ROOT}/../Resources/CMake/DatabasesPluginConfiguration.cmake)


if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
    execute_process(
            COMMAND
            ${PYTHON_EXECUTABLE} ${ORTHANC_FRAMEWORK_ROOT}/../Resources/WindowsResources.py
            ${ORTHANC_PLUGIN_VERSION} "MySQL storage area plugin" OrthancMySQLStorage.dll
            "MySQL as a database back-end to Orthanc (storage area)"
            ERROR_VARIABLE Failure
            OUTPUT_FILE ${AUTOGENERATED_DIR}/StorageVersion.rc
    )

    if (Failure)
        message(FATAL_ERROR "Error while computing the version information: ${Failure}")
    endif()

    execute_process(
            COMMAND
            ${PYTHON_EXECUTABLE} ${ORTHANC_FRAMEWORK_ROOT}/../Resources/WindowsResources.py
            ${ORTHANC_PLUGIN_VERSION} "MySQL index plugin" OrthancMySQLIndex.dll
            "MySQL as a database back-end to Orthanc (index)"
            ERROR_VARIABLE Failure
            OUTPUT_FILE ${AUTOGENERATED_DIR}/IndexVersion.rc
    )

    if (Failure)
        message(FATAL_ERROR "Error while computing the version information: ${Failure}")
    endif()

    set(INDEX_RESOURCES ${AUTOGENERATED_DIR}/IndexVersion.rc)
    set(STORAGE_RESOURCES ${AUTOGENERATED_DIR}/StorageVersion.rc)
endif()


EmbedResources(
        MYSQL_PREPARE_INDEX          ${CMAKE_CURRENT_LIST_DIR}/Plugins/MySQL/Plugins/PrepareIndex.sql
        MYSQL_GET_LAST_CHANGE_INDEX  ${CMAKE_CURRENT_LIST_DIR}/Plugins/MySQL/Plugins/GetLastChangeIndex.sql
        MYSQL_CREATE_INSTANCE        ${CMAKE_CURRENT_LIST_DIR}/Plugins/MySQL/Plugins/CreateInstance.sql
        MYSQL_DELETE_RESOURCES       ${CMAKE_CURRENT_LIST_DIR}/Plugins/MySQL/Plugins/DeleteResources.sql
)

if (EXISTS ${ORTHANC_SDK_ROOT}/orthanc/OrthancDatabasePlugin.proto)
    add_custom_command(
            COMMAND
            ${PROTOC_EXECUTABLE} ${ORTHANC_SDK_ROOT}/orthanc/OrthancDatabasePlugin.proto --cpp_out=${AUTOGENERATED_DIR} -I${ORTHANC_SDK_ROOT}/orthanc/
            DEPENDS
            ProtobufCompiler
            ${ORTHANC_SDK_ROOT}/orthanc/OrthancDatabasePlugin.proto
            OUTPUT
            ${AUTOGENERATED_DIR}/OrthancDatabasePlugin.pb.cc
            ${AUTOGENERATED_DIR}/OrthancDatabasePlugin.pb.h
    )

    list(APPEND AUTOGENERATED_SOURCES
            ${AUTOGENERATED_DIR}/OrthancDatabasePlugin.pb.cc
    )
endif()


add_custom_target(
        AutogeneratedTarget
        DEPENDS
        ${AUTOGENERATED_SOURCES}
)

add_library(FrameworkForPlugins STATIC
        ${AUTOGENERATED_SOURCES}
        ${DATABASES_SOURCES}
        ${ORTHANC_DATABASES_ROOT}/Sources/Plugins/PluginInitialization.cpp
        ${CMAKE_CURRENT_LIST_DIR}/Plugins/MySQL/Plugins/MySQLIndex.cpp
        ${CMAKE_CURRENT_LIST_DIR}/Plugins/MySQL/Plugins/MySQLStorageArea.cpp
)

set_target_properties(FrameworkForPlugins PROPERTIES
        POSITION_INDEPENDENT_CODE ON
        COMPILE_FLAGS -DORTHANC_ENABLE_LOGGING_PLUGIN=1
)

add_library(OrthancMySQLIndex SHARED
        ${INDEX_RESOURCES}
        ${CMAKE_CURRENT_LIST_DIR}/Plugins/MySQL/Plugins/IndexPlugin.cpp
)

add_library(OrthancMySQLStorage SHARED
        ${STORAGE_RESOURCES}
        ${CMAKE_CURRENT_LIST_DIR}/Plugins/MySQL/Plugins/StoragePlugin.cpp
)

add_dependencies(FrameworkForPlugins AutogeneratedTarget)

target_link_libraries(OrthancMySQLIndex FrameworkForPlugins)
target_link_libraries(OrthancMySQLStorage FrameworkForPlugins)

message("Setting the version of the libraries to ${ORTHANC_PLUGIN_VERSION}")

add_definitions(
        -DORTHANC_PLUGIN_VERSION="${ORTHANC_PLUGIN_VERSION}"
)

set_target_properties(OrthancMySQLStorage PROPERTIES
        VERSION ${ORTHANC_PLUGIN_VERSION}
        SOVERSION ${ORTHANC_PLUGIN_VERSION}
        COMPILE_FLAGS -DORTHANC_ENABLE_LOGGING_PLUGIN=1
)

set_target_properties(OrthancMySQLIndex PROPERTIES
        VERSION ${ORTHANC_PLUGIN_VERSION}
        SOVERSION ${ORTHANC_PLUGIN_VERSION}
        COMPILE_FLAGS -DORTHANC_ENABLE_LOGGING_PLUGIN=1
)

install(
        TARGETS OrthancMySQLIndex OrthancMySQLStorage
        RUNTIME DESTINATION lib    # Destination for Windows
        LIBRARY DESTINATION share/orthanc/plugins    # Destination for Linux
)

message(STATUS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/share/orthanc/plugins")

add_executable(UnitTests
        ${CMAKE_CURRENT_LIST_DIR}/Plugins/MySQL/Plugins/MySQLIndex.cpp
        ${CMAKE_CURRENT_LIST_DIR}/Plugins/MySQL/Plugins/MySQLStorageArea.cpp
        ${CMAKE_CURRENT_LIST_DIR}/Plugins/MySQL/UnitTests/UnitTestsMain.cpp

        ${DATABASES_SOURCES}
        ${GOOGLE_TEST_SOURCES}
        ${AUTOGENERATED_SOURCES}
)

add_dependencies(UnitTests AutogeneratedTarget)

target_link_libraries(UnitTests ${GOOGLE_TEST_LIBRARIES})
set_target_properties(UnitTests PROPERTIES
        COMPILE_FLAGS -DORTHANC_ENABLE_LOGGING_PLUGIN=0
)

if (COMMAND DefineSourceBasenameForTarget)
    DefineSourceBasenameForTarget(FrameworkForPlugins)
    DefineSourceBasenameForTarget(OrthancMySQLIndex)
    DefineSourceBasenameForTarget(OrthancMySQLStorage)
    DefineSourceBasenameForTarget(UnitTests)
endif()

build

  • 目录下会有一个 cmake_install.cmake
  • 可以看到有install 命令
  • clion 默认不会执行 make --build
  • make .. 编译该目录
  • make --build .. 执行编译 可以到so文件再build 目录下
  • make --install .. 执行 cmakelist 中的 install 移动到 /usr/local/share

运行时加载 so 文件 可以动态引入模块

  • 比如插件机制 再配置文件指定路径
  • 读取文件 通过dlopen 载入动态库

标签:cmakelist,VERSION,set,CMAKE,源码,so,ORTHANC,Plugins,DIR
From: https://www.cnblogs.com/guanchaoguo/p/18460223

相关文章

  • POLIR-Society-Organization-Psychology-Values:价值
    https://www.verywellmind.com/speaking-about-values-in-your-relationship-5191152SkiptocontentSearchRelationshipsStrengtheningRelationshipsHowtoTalkAboutYourValuesinaRelationshipByElizabethPlumptreUpdatedonFebruary19,2024Reviewedb......
  • C# 后端回传的Json数据转换为实体对象转换器JsonConverter的使用
    publicclassJsonDateTimeConverter:JsonConverter<DateTime?>{privatereadonlystring_dateTimeFormat;publicJsonDateTimeConverter(stringdateTimeFormat){_dateTimeFormat=dateTimeFormat;}publicoverridevoidWri......
  • springboot空巢老人健康管理系统小程序-计算机毕业设计源码29889
    摘 要随着社会老龄化程度不断加剧,空巢老人群体的健康管理问题日益引起人们的关注。为了更好地满足空巢老人群体的健康管理需求,本研究致力于设计并实现一款基于SpringBoot框架的空巢老人健康管理系统。该系统旨在为管理员用户、老人用户和医生用户提供全方位的健康管理服务,......
  • java.util.Arrays#sort
    基本数据类型数组/***java.util.Arrays#sort(int[])*publicstaticvoidsort(int[]a){*DualPivotQuicksort.sort(a,0,a.length-1,null,0,0);//DualPivotQuicksort*}*/Obje......
  • 基于JSP本科生毕业设计选题系统的设计与实现<免费开题>全套源码+文章lw+毕业设计+课程设
    基于JSP本科生毕业设计选题系统的设计与实现<免费开题>全套源码+文章lw+毕业设计+课程设计+数据库+ppt摘要随着高校信息化管理系统平台的广泛应用,文件信息的传递不再受到时间和空间的制约,毕业设计是高校教学管理的重要工作内容之一,随着高校毕业设计数量的逐年递增,毕业设计......
  • java.util.Collections#sort(java.util.List<T>)
    java.util.ArrayList/java.util.LinkedList/***java.util.Collections#sort(java.util.List)*publicstatic<TextendsComparable<?superT>>voidsort(List<T>list){*list.sort(null);*......
  • 基于Anaconda搭建深度学习环境,安装Tensorflow、Keras和Pytorch
    1、Anaconda安装(一款可以同时创建跟管理多个python环境的软件)https://blog.csdn.net/run_success/article/details/134656460安装好Anaconda之后,我们可以接着配置一个用于人工智能开发的Python环境。一、创建新的Python环境1、打开AnacondaPrompt2、创建一个名为badou的Py......
  • POLIR-Society-Organization-Psychology-Attitude-Life: $\large \bm{Attitude} :
    POLIR-Society-Organization-Life:对待社会生活环境的正确态度Question:我认为对待社会生活环境的正确态度是:ImplywhenfacingNon-BeneficialorNeutralSocialEnvironment:*生活环境如何,都要努力奋斗,无愧一生*尽量利用生活环境的有利因素发展自己*遇到不良社......
  • 圈子社交系统源码PHP前后端开源二次可扩展
    一、开源概述开源的圈子系统源码允许开发者自由下载、使用和修改,这有助于降低开发成本,提高开发效率,并促进技术的交流和共享。许多开源项目都提供了详细的文档和教程,以帮助开发者更好地理解和使用源码。二、具体实例基于Vue.js和uni-app的圈子系统技术栈:前端采用Vue.js和un......
  • 多客最新游戏陪玩源码APP开源提供独特丝滑陪玩体验
    多客最新游戏陪玩源码APP开源提供独特丝滑陪玩体验系统基于TP6+Uni-app框架开发;客户移动端采用uni-app开发,管理后台TH6开发。系统支持微信公众号端、微信小程序端、H5端、PC端多端账号同步,可快速打包生成APP;优秀全面功能和独立完善个性功能,非常适合陪玩、技能服务等领域使用......