Skip to content

Commit 17fa9c5

Browse files
committed
CMakify the lib in order to be use as an external project
1 parent aa5bc56 commit 17fa9c5

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

CMake/QXlsxConfig.cmake.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include("${CMAKE_CURRENT_LIST_DIR}/QXlsxTargets.cmake")

CMakeLists.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
3+
project(QXlsx)
4+
5+
#------------------------------------------------------------------------------
6+
# Qt
7+
#------------------------------------------------------------------------------
8+
find_package(Qt5 REQUIRED QUIET COMPONENTS Core Gui)
9+
find_package(Qt5Gui CONFIG REQUIRED Private)
10+
set(CMAKE_AUTOMOC ON)
11+
12+
#------------------------------------------------------------------------------
13+
# Library
14+
#------------------------------------------------------------------------------
15+
add_library(QXlsx)
16+
17+
#------------------------------------------------------------------------------
18+
# Target
19+
#------------------------------------------------------------------------------
20+
# Define target sources
21+
file(GLOB_RECURSE files ${CMAKE_SOURCE_DIR}/QXlsx/source/*.cpp ${CMAKE_SOURCE_DIR}/QXlsx/header/*.h)
22+
23+
target_sources(QXlsx PRIVATE
24+
${files}
25+
)
26+
27+
target_link_libraries(QXlsx PUBLIC Qt5::Core Qt5::Gui Qt5::GuiPrivate)
28+
target_include_directories(QXlsx PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/QXlsx/header)
29+
30+
configure_file(
31+
${CMAKE_SOURCE_DIR}/CMake/QXlsxConfig.cmake.in
32+
"${CMAKE_BINARY_DIR}/QXlsxConfig.cmake" @ONLY)
33+
34+
export(TARGETS QXlsx
35+
FILE "${CMAKE_BINARY_DIR}/QXlsxTargets.cmake")

0 commit comments

Comments
 (0)