IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> C++知识库 -> Windows下编译PureMVC-C++ -> 正文阅读

[C++知识库]Windows下编译PureMVC-C++

PureMVC是一套轻量级的MVC开发框架,最初支持ActionScript 3语言,目前已经移植到18种编程语言,PureMVC包括两个版本:标准版和多核版。

由于PureMVC对应的VS构建项目仅支持到VS 2010,同时考虑到目前CMake已然成为跨平台软件构建的首选方案。因此,本文探讨在WIndows下使用CMake构建VS 2019项目。

一、下载代码

从GitHub上拉取puremvc-cpp-multicore-framework代码,

git clone https://github.com/PureMVC/puremvc-cpp-multicore-framework.git
git checkout -b 1.1.0 1.1.0

二、编译PureMVC

在puremvc-cpp-multicore-framework目录下新建CMakeLists.txt文件,添加以下内容,

# Helper to create filters in VS
macro(source_group_by_dir source_files)
    if(MSVC)
        set(sgbd_cur_dir ${CMAKE_CURRENT_SOURCE_DIR})
        foreach(sgbd_file ${${source_files}})
            string(REGEX REPLACE ${sgbd_cur_dir}/\(.*\) \\1 sgbd_fpath ${sgbd_file})
            string(REGEX REPLACE "\(.*\)/.*" \\1 sgbd_group_name ${sgbd_fpath})
            string(COMPARE EQUAL ${sgbd_fpath} ${sgbd_group_name} sgbd_nogroup)
            string(REPLACE "/" "\\" sgbd_group_name ${sgbd_group_name})
            if(sgbd_nogroup)
                set(sgbd_group_name "\\")
            endif(sgbd_nogroup)
            source_group(${sgbd_group_name} FILES ${sgbd_file})
        endforeach(sgbd_file)
    endif(MSVC)
endmacro(source_group_by_dir)

# PureMVC
SET(LIB_NAME PureMVC)

# The include/PureMVC directory
SET(PureMVC_INCLUDE_DIR
	"include/PureMVC"
)

# The src/PureMVC directory
SET(PureMVC_SRC_DIR
	"src/PureMVC"
)

INCLUDE_DIRECTORIES(
	${CMAKE_CURRENT_SOURCE_DIR}
	${CMAKE_CURRENT_BINARY_DIR}
	"${CMAKE_CURRENT_SOURCE_DIR}/include"
)

LINK_DIRECTORIES(
	${CMAKE_LIBRARY_PATH}
	${PROJECT_BINARY_DIR}/lib
)

SET(PureMVC_LIBS
)

# Core
SET(PureMVC_Core_SRCS
	${PureMVC_INCLUDE_DIR}/Core/Controller.hpp
	${PureMVC_INCLUDE_DIR}/Core/Model.hpp
	${PureMVC_INCLUDE_DIR}/Core/View.hpp
	${PureMVC_SRC_DIR}/Core/Controller.cpp
	${PureMVC_SRC_DIR}/Core/Model.cpp
	${PureMVC_SRC_DIR}/Core/View.cpp		
)

# Interfaces
SET(PureMVC_Interfaces_SRCS
	${PureMVC_INCLUDE_DIR}/Interfaces/IAggregate.hpp
	${PureMVC_INCLUDE_DIR}/Interfaces/ICommand.hpp
	${PureMVC_INCLUDE_DIR}/Interfaces/IController.hpp
	${PureMVC_INCLUDE_DIR}/Interfaces/IFacade.hpp
	${PureMVC_INCLUDE_DIR}/Interfaces/IIterator.hpp
	${PureMVC_INCLUDE_DIR}/Interfaces/IMediator.hpp
	${PureMVC_INCLUDE_DIR}/Interfaces/IModel.hpp
	${PureMVC_INCLUDE_DIR}/Interfaces/INotification.hpp	
	${PureMVC_INCLUDE_DIR}/Interfaces/INotifier.hpp
	${PureMVC_INCLUDE_DIR}/Interfaces/IObserver.hpp
	${PureMVC_INCLUDE_DIR}/Interfaces/IProxy.hpp	
	${PureMVC_INCLUDE_DIR}/Interfaces/IView.hpp		
)

# Patterns
SET(PureMVC_Patterns_Command_SRCS
	${PureMVC_INCLUDE_DIR}/Patterns/Command/DelegateCommand.hpp
	${PureMVC_INCLUDE_DIR}/Patterns/Command/MacroCommand.hpp
	${PureMVC_INCLUDE_DIR}/Patterns/Command/SimpleCommand.hpp
	${PureMVC_SRC_DIR}/Patterns/Command/MacroCommand.cpp
	${PureMVC_SRC_DIR}/Patterns/Command/SimpleCommand.cpp	
)

SET(PureMVC_Patterns_Facade_SRCS
	${PureMVC_INCLUDE_DIR}/Patterns/Facade/Facade.hpp
	${PureMVC_SRC_DIR}/Patterns/Facade/Facade.cpp	
)

SET(PureMVC_Patterns_Iterator_SRCS
	${PureMVC_INCLUDE_DIR}/Patterns/Iterator/Iterator.hpp	
)

SET(PureMVC_Patterns_Mediator_SRCS	
	${PureMVC_INCLUDE_DIR}/Patterns/Mediator/Mediator.hpp		
	${PureMVC_SRC_DIR}/Patterns/Mediator/Mediator.cpp
)

SET(PureMVC_Patterns_Observer_SRCS
	${PureMVC_INCLUDE_DIR}/Patterns/Observer/Notification.hpp
	${PureMVC_INCLUDE_DIR}/Patterns/Observer/Notifier.hpp	
	${PureMVC_INCLUDE_DIR}/Patterns/Observer/Observer.hpp
	${PureMVC_SRC_DIR}/Patterns/Observer/Notification.cpp	
	${PureMVC_SRC_DIR}/Patterns/Observer/Notifier.cpp
)

SET(PureMVC_Patterns_Proxy_SRCS
	${PureMVC_INCLUDE_DIR}/Patterns/Proxy/Proxy.hpp
	${PureMVC_SRC_DIR}/Patterns/Proxy/Proxy.cpp
)

SET(PureMVC_Patterns_SRCS
	${PureMVC_Patterns_Command_SRCS}	
	${PureMVC_Patterns_Facade_SRCS}
	${PureMVC_Patterns_Iterator_SRCS}
	${PureMVC_Patterns_Mediator_SRCS}
	${PureMVC_Patterns_Observer_SRCS}	
	${PureMVC_Patterns_Proxy_SRCS}
)

# Resource Files
SET(PureMVC_RES_SRCS
	${PureMVC_SRC_DIR}/Resource/PureMVC.rc
)

SET(PureMVC_SRCS
	${PureMVC_Core_SRCS}
	${PureMVC_Interfaces_SRCS}
	${PureMVC_Patterns_SRCS}
	${PureMVC_RES_SRCS}
	${PureMVC_INCLUDE_DIR}/PureMVC.hpp
	${PureMVC_SRC_DIR}/PureMVC.cpp
	${PureMVC_SRC_DIR}/Common.hpp
)

source_group_by_dir(PureMVC_SRCS)


IF (MSVC)
    # Turn off deprecation warnings
    ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
    ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNINGS)
	# Export PureMVC class symbols
	ADD_DEFINITIONS(-DPUREMVC_API_EXPORT)
ENDIF(MSVC)

ADD_LIBRARY(${LIB_NAME} STATIC ${PureMVC_SRCS})
TARGET_LINK_LIBRARIES(${LIB_NAME} ${PureMVC_LIBS})

IF (MSVC)
	# Runtime Library: -DMDd, -DMD
	ADD_LIBRARY(${LIB_NAME}dll SHARED ${PureMVC_SRCS})
	TARGET_LINK_LIBRARIES(${LIB_NAME}dll ${PureMVC_LIBS})

	SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES DEBUG_OUTPUT_NAME PureMVCd.dll  RELEASE_OUTPUT_NAME PureMVC.dll)
	SET_TARGET_PROPERTIES(${LIB_NAME}dll PROPERTIES DEBUG_OUTPUT_NAME PureMVCddll.dll  RELEASE_OUTPUT_NAME PureMVCdll.dll)
ENDIF(MSVC)

# Install
SET(INSTALL_INCDIR include)
SET(INSTALL_BINDIR bin)
IF(WIN32)
    SET(INSTALL_LIBDIR bin)
    SET(INSTALL_ARCHIVEDIR lib)
ELSE(WIN32)
    SET(INSTALL_LIBDIR lib${LIB_POSTFIX})
    SET(INSTALL_ARCHIVEDIR lib${LIB_POSTFIX})
ENDIF(WIN32)

INSTALL(
    TARGETS ${LIB_NAME}
    RUNTIME DESTINATION ${INSTALL_BINDIR}
    LIBRARY DESTINATION ${INSTALL_LIBDIR}
    ARCHIVE DESTINATION ${INSTALL_ARCHIVEDIR}
)

INSTALL(
    FILES       ${HEADERS}
    DESTINATION ${INSTALL_INCDIR}/${LIB_NAME}
)

然后,使用CMake完成PureMVC的构建,在VS 2019中编译即可。

三、生成文档

下载并安装DoxgenMikTex,按照下述CMakeLists.txt构建PureMVC Doc项目,从而生成PureMVC文档。

# add a target to generate API documentation with Doxygen
#FIND_PACKAGE(Doxygen)
#OPTION(BUILD_DOCUMENTATION "Create and install the HTML based API documentation (requires Doxygen)" ${DOXYGEN_FOUND})

IF(BUILD_DOCUMENTATION)
	FIND_PACKAGE(Doxygen)
    IF(NOT DOXYGEN_FOUND)
        MESSAGE(FATAL_ERROR "Doxygen is needed to build the documentation.")
    ENDIF()

    SET(DOXYGEN_IN ${CMAKE_CURRENT_LIST_DIR}/Doxyfile.in)
    SET(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

    # request to configure the file
    CONFIGURE_FILE(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)

    # note the option ALL which allows to build the docs together with the application
    ADD_CUSTOM_TARGET(Doc ALL
        COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
        COMMENT "Generating API documentation with Doxygen"
        VERBATIM)

    #INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc)
	INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION doc)
ENDIF()

参考资料

PureMVChttp://puremvc.org/

puremvc-cpp-multicore-frameworkhttps://github.com/PureMVC/puremvc-cpp-multicore-framework

?Doxygenhttps://www.doxygen.org/

MikTex?http://www.miktex.org

  C++知识库 最新文章
【C++】友元、嵌套类、异常、RTTI、类型转换
通讯录的思路与实现(C语言)
C++PrimerPlus 第七章 函数-C++的编程模块(
Problem C: 算法9-9~9-12:平衡二叉树的基本
MSVC C++ UTF-8编程
C++进阶 多态原理
简单string类c++实现
我的年度总结
【C语言】以深厚地基筑伟岸高楼-基础篇(六
c语言常见错误合集
上一篇文章      下一篇文章      查看所有文章
加:2022-05-05 10:59:30  更:2022-05-05 11:00:40 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/23 21:56:56-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码