From 6899b68adb77a88d8184bb0a584e8d0777c73591 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sat, 15 Oct 2022 14:29:30 +0100 Subject: [PATCH] Update docs --- HelloWorld/CMakeLists.txt | 65 ++---------------------------------- HelloWorld/QXlsx | 1 + HowToSetProject-cmake.md | 70 ++++++++++----------------------------- HowToSetProject.md | 1 + README.md | 2 +- 5 files changed, 23 insertions(+), 116 deletions(-) create mode 120000 HelloWorld/QXlsx diff --git a/HelloWorld/CMakeLists.txt b/HelloWorld/CMakeLists.txt index f982b58..6318006 100644 --- a/HelloWorld/CMakeLists.txt +++ b/HelloWorld/CMakeLists.txt @@ -9,75 +9,16 @@ project(HelloWorld LANGUAGES CXX) # TODO: Set Your C++ version set(CMAKE_CXX_STANDARD 11) # C++ 11 -########################## -# bolier-plate code (1) {{ - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -set(CMAKE_CXX_STANDARD_REQUIRED ON) - find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui REQUIRED) -if(NOT DEFINED ${QXLSX_PARENTPATH}) - set(QXLSX_PARENTPATH ${CMAKE_CURRENT_SOURCE_DIR}/../) -endif(NOT DEFINED ${QXLSX_PARENTPATH}) - -if(NOT DEFINED ${QXLSX_HEADERPATH}) - set(QXLSX_HEADERPATH ${CMAKE_CURRENT_SOURCE_DIR}/../QXlsx/header/) -endif(NOT DEFINED ${QXLSX_HEADERPATH}) - -if(NOT DEFINED ${QXLSX_SOURCEPATH}) - set(QXLSX_SOURCEPATH ${CMAKE_CURRENT_SOURCE_DIR}/../QXlsx/source/) -endif(NOT DEFINED ${QXLSX_SOURCEPATH}) - -message("Current Path of QXlsx") -message(${QXLSX_PARENTPATH}) -message(${QXLSX_HEADERPATH}) -message(${QXLSX_SOURCEPATH}) - -include_directories(${QXLSX_HEADERPATH}) - -file(GLOB QXLSX_CPP "${QXLSX_SOURCEPATH}/*.cpp") -file(GLOB QXLSX_H "${QXLSX_HEADERPATH}/*.h") - -set(SRC_FILES ${QXLSX_CPP}) -list(APPEND SRC_FILES ${QXLSX_H}) - -# bolier-plate code (1) }} -########################### +add_subdirectory(QXlsx) ######################### # Console Application {{ -# TODO: set your source code -set(APP_SRC_FILES - main.cpp) - -list(APPEND SRC_FILES ${APP_SRC_FILES}) -add_executable(${PROJECT_NAME} ${SRC_FILES}) +add_executable(HelloWorld main.cpp) +target_link_libraries(HelloWorld PRIVATE QXlsx::QXlsx) # Console Application }} ######################## - -########################## -# bolier-plate code (2) {{ - -target_include_directories(${PROJECT_NAME} PRIVATE - ${QXLSX_HEADERPATH} - ${CMAKE_CURRENT_SOURCE_DIR} ) - -target_link_libraries(${PROJECT_NAME} - Qt${QT_VERSION_MAJOR}::Core - Qt${QT_VERSION_MAJOR}::GuiPrivate - ) - - set(CMAKE_WIN32_EXECUTABLE OFF) - -# bolier-plate code (2) }} -########################## - diff --git a/HelloWorld/QXlsx b/HelloWorld/QXlsx new file mode 120000 index 0000000..89e25af --- /dev/null +++ b/HelloWorld/QXlsx @@ -0,0 +1 @@ +../QXlsx \ No newline at end of file diff --git a/HowToSetProject-cmake.md b/HowToSetProject-cmake.md index efbca43..85fea35 100644 --- a/HowToSetProject-cmake.md +++ b/HowToSetProject-cmake.md @@ -2,68 +2,32 @@ > *Read this in other languages: [English](HowToSetProject-cmake.md), :kr: [한국어](HowToSetProject-cmake.ko.md)* -- Enter the command as shown below. +### To install QXlsx -:one: Using MingW +Enter the command as shown below. -- QXlsx library - -``` +```sh mkdir build cd build -cmake -G "MinGW Makefiles" ..\QXlsx\ -mingw32-make +cmake ../QXlsx/ -DCMAKE_INSTALL_PREFIX=... -DCMAKE_BUILD_TYPE=Release +cmake --build . +cmake --install . ``` -- HelloWorld +### To use in your application -``` -mkdir build2 -cd build2 -cmake -G "MinGW Makefiles" ..\HelloWorld\ -mingw32-make +In your CMakeLists.txt: + +```cmake +find_package(QXlsxQt5 REQUIRED) # or QXlsxQt6 +target_link_libraries(myapp PRIVATE QXlsx::QXlsx) ``` -:two: Using Visual Studio +### To use in your application without installation -- QXlsx library (Release Build) +In your CMakeLists.txt: +```cmake +add_subdirectory(QXlsx) +target_link_libraries(myapp PRIVATE QXlsx::QXlsx) ``` -mkdir build -cd build -cmake -G "Visual Studio 16 2019" ..\QXlsx\ -MSBuild /nologo /t:Build /p:Configuration=Release QXlsx.vcxproj -``` - -- HelloWorld (Release Build) - -``` -mkdir build2 -cd build2 -cmake -G "Visual Studio 16 2019" ..\HelloWorld\ -MSBuild /nologo /t:Build /p:Configuration=Release HelloWorld.vcxproj -``` - -- Or, You may open *.sln/*.vcxproj files in Visual Studio IDE. - -:three: Using Linux/Mac/Unix - -- QXlsx library - -``` -mkdir build -cd build -cmake -G "Unix Makefiles" ../QXlsx/ -make -``` - -- HelloWorld - -``` -mkdir build2 -cd build2 -cmake -G "Unix Makefiles" ../HelloWorld/ -make -``` - - diff --git a/HowToSetProject.md b/HowToSetProject.md index f052ea4..c8ac944 100644 --- a/HowToSetProject.md +++ b/HowToSetProject.md @@ -4,6 +4,7 @@ > *Read this in other languages: [English](HowToSetProject.md), :kr: [한국어](HowToSetProject.ko.md)* - Here's an easy way to apply QXlsx. +- This works only with qmake, for cmake look at [the other doc](HowToSetProject-cmake.md). - Describes when to apply to Windows. - The method of applying it on Linux or Mac is similar, and I will write help if there is an additional request. - * Hi! I'm j2doll. My native language is not English and my English is not fluent. Please understand. :-) diff --git a/README.md b/README.md index f7f8735..7061a7b 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ ## How to set up (Installation) -- :Recommended: See [how to setup QXlsx project (qmake)](HowToSetProject.md) +- See [how to setup QXlsx project (qmake)](HowToSetProject.md) - See [how to setup QXlsx project (cmake)](HowToSetProject-cmake.md) ## Tested environment