Skip to content

Commit

Permalink
refactor: migrate build system from QMake to CMake
Browse files Browse the repository at this point in the history
- Remove all QMake project files (.pro and .pri)
- Add CMakeLists.txt for CMake build system
- Update include paths in source files
- Update .gitignore for CMake related directories
- Add cmake as build dependency in debian/control

Log:
  • Loading branch information
Johnson-zs committed Jan 2, 2025
1 parent 4068c07 commit 1ebc2a7
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 195 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
*.user
build/
.vscode/
.idea/
cmake-build-*/
5 changes: 0 additions & 5 deletions 3rdparty/3rdparty.pri

This file was deleted.

1 change: 0 additions & 1 deletion 3rdparty/libs/encoding/encoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @author dmryutov ([email protected])
* @date 22.08.2017 -- 29.10.2017
*/
#pragma once
#include <codecvt>
#include <iostream>
#include <sstream>
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/libs/fileext/cfb/cfb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <iomanip>
#include <sstream>

#include "encoding/encoding.cpp"
#include "encoding/encoding.hpp"
#include "tools.hpp"

#include "cfb.hpp"
Expand Down
56 changes: 0 additions & 56 deletions 3rdparty/libs/libs.pri

This file was deleted.

18 changes: 9 additions & 9 deletions 3rdparty/utils/libofd/ofd/Color.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace ofd{
uint64_t GetRefID() const {return m_refID;};
void SetRefID(uint64_t refID){m_refID = refID;};
private:
uint64_t m_refID; // 资源引用ID。缺省值0,指向文档设定的颜色空间。
uint64_t m_refID; // 资源引用ID。缺省值0,指向文档设定的颜色空间。

}; // class ColorSpace

Expand All @@ -78,7 +78,7 @@ namespace ofd{
ColorRGB() : Red(0), Green(0), Blue(0){
}
ColorRGB(uint32_t r, uint32_t g, uint32_t b):
Red(r), Green(g), Blue(b){
Red(r), Green(g), Blue(b){
}

std::tuple<double, double, double> GetRGB() const{
Expand Down Expand Up @@ -217,7 +217,7 @@ namespace ofd{
// 取出相应索引的预定义颜色用来绘制。索引从0开始。
uint32_t Alpha; // 颜色透明度,在0-255之间取值。默认值为255,表示完全不透明。

// TODO
// TODO
// Pattern; // 底纹 标准 P34 页,Page.xsd。
// AxialShd; // 轴向渐变 标准 P36 页,Page.xsd。
// RadialShd; // 径向渐变 标准 P40 页,Page.xsd。
Expand All @@ -243,20 +243,20 @@ namespace ofd{
bool m_bUsePalette; // 使用颜色空间调色板标志

}; // class Color
#define COLOR_BLACK ofd::Color::Instance(0,0,0)
#define COLOR_WHITE ofd::Color::Instance(255,255,255)
#define COLOR_BLACK ofd::Color::Instance(0,0,0)
#define COLOR_WHITE ofd::Color::Instance(255,255,255)
#define COLOR_TRANSPARENT ofd::Color::Instance(0,0,0,nullptr, 0)
#define COLOR_RED ofd::Color::Instance(255,0,0)
#define COLOR_GREEN ofd::Color::Instance(0,255,0)
#define COLOR_BLUE ofd::Color::Instance(0,0,255)
#define COLOR_RED ofd::Color::Instance(255,0,0)
#define COLOR_GREEN ofd::Color::Instance(0,255,0)
#define COLOR_BLUE ofd::Color::Instance(0,0,255)

// ======== struct ColorStop_t ========
typedef struct _ColorStop {

ColorPtr Color;
double Offset;

_ColorStop(ColorPtr color, double offset) :
_ColorStop(ColorPtr color, double offset) :
Color(color), Offset(offset){
}

Expand Down
56 changes: 0 additions & 56 deletions 3rdparty/utils/utils.pri

This file was deleted.

32 changes: 32 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
cmake_minimum_required(VERSION 3.13)
project(docparser VERSION 1.0.0 LANGUAGES CXX)

# 设置C++标准
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 在顶层CMakeLists.txt中添加
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)

# 安全编译选项
add_compile_options(-fstack-protector-strong -D_FORTITY_SOURCE=1 -fvisibility=hidden)
add_link_options(-z noexecstack -pie -fPIC)

# 设置安装路径
include(GNUInstallDirs)

# 查找依赖包
find_package(PkgConfig REQUIRED)
pkg_check_modules(DEPS REQUIRED
poppler-cpp
libzip
pugixml
freetype2
libxml-2.0
uuid
tinyxml2
)

# 添加子目录
add_subdirectory(src)
1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Section: libdevel
Priority: optional
Maintainer: deepin <[email protected]>
Build-Depends:
cmake,
debhelper (>= 11),
qtbase5-dev,
qt5-qmake,
Expand Down
3 changes: 0 additions & 3 deletions docparser.pro

This file was deleted.

82 changes: 82 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# 收集源文件
file(GLOB_RECURSE SRC_FILES_MAIN
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
)

file(GLOB_RECURSE SRC_FILES_3RDPARTY_LIBS
"${CMAKE_SOURCE_DIR}/3rdparty/libs/*.cpp"
"${CMAKE_SOURCE_DIR}/3rdparty/libs/*.hpp"
"${CMAKE_SOURCE_DIR}/3rdparty/libs/*.h"

)

file(GLOB_RECURSE SRC_FILES_3RDPARTY_UTILS
"${CMAKE_SOURCE_DIR}/3rdparty/utils/*.cpp"
"${CMAKE_SOURCE_DIR}/3rdparty/utils/*.cc"
"${CMAKE_SOURCE_DIR}/3rdparty/utils/*.h"
)

# 创建源文件列表
set(SRC_FILES
${SRC_FILES_MAIN}
${SRC_FILES_3RDPARTY_LIBS}
${SRC_FILES_3RDPARTY_UTILS}
)

# 移除重复的源文件
list(REMOVE_DUPLICATES SRC_FILES)

# 打印源文件列表,用于调试
message(STATUS "Source files:")
foreach(SOURCE_FILE ${SRC_FILES})
message(STATUS " ${SOURCE_FILE}")
endforeach()

# 创建库目标
add_library(docparser SHARED
${SRC_FILES}
)

# 设置目标属性
target_include_directories(docparser
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/docparser>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/3rdparty/libs
${CMAKE_SOURCE_DIR}/3rdparty/utils/libofd
${DEPS_INCLUDE_DIRS}
)

target_link_libraries(docparser
PRIVATE
${DEPS_LIBRARIES}
)

# 安装目标
install(TARGETS docparser
EXPORT docparser-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# 安装头文件
install(FILES
docparser.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/docparser
)

# 生成并安装 pkg-config 文件
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/docparser.pc.in
${CMAKE_CURRENT_BINARY_DIR}/docparser.pc
@ONLY
)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/docparser.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
10 changes: 10 additions & 0 deletions src/docparser.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@

Name: docparser
Description: document parse library
Version: @PROJECT_VERSION@
Libs: -L${libdir} -ldocparser
Cflags: -I${includedir}
Loading

0 comments on commit 1ebc2a7

Please sign in to comment.