mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
Simplify CMake scripts (#1162)
- Simplify CMakeLists to help maintainer lazy to update when source files addition and removing. - relocate cmake include files on top Signed-off-by: Hiroshi Miura <miurahr@linux.com>
This commit is contained in:
parent
cd0f2b1869
commit
6167a91090
@ -1,6 +1,5 @@
|
|||||||
cmake_minimum_required (VERSION 3.12)
|
cmake_minimum_required (VERSION 3.12)
|
||||||
project(VNote
|
project(VNote VERSION 2.2.0
|
||||||
VERSION 2.2.0
|
|
||||||
DESCRIPTION "VNote is a markdown note taking application"
|
DESCRIPTION "VNote is a markdown note taking application"
|
||||||
HOMEPAGE_URL "https://tamlok.github.io/vnote"
|
HOMEPAGE_URL "https://tamlok.github.io/vnote"
|
||||||
LANGUAGES C CXX)
|
LANGUAGES C CXX)
|
||||||
@ -12,25 +11,23 @@ set(CMAKE_AUTOMOC ON)
|
|||||||
set(CMAKE_AUTOUIC ON)
|
set(CMAKE_AUTOUIC ON)
|
||||||
set(CMAKE_AUTORCC ON)
|
set(CMAKE_AUTORCC ON)
|
||||||
|
|
||||||
## Default Qt5 path
|
# find Qt5 installation
|
||||||
set(Qt5_DIR "$ENV{QTDIR}/lib/cmake/Qt5")
|
find_package(Qt5 REQUIRED COMPONENTS Core Gui Network PrintSupport WebChannel WebEngine
|
||||||
if(WIN32)
|
|
||||||
set(Qt5_DIR "c:/Qt/Qt5.9.7/5.9.7/msvc2017_64/lib/cmake/Qt5/" CACHE PATH "directory where Qt5Config.cmake exists.")
|
|
||||||
elseif(APPLE)
|
|
||||||
set(Qt5_DIR "/usr/local/Cellar/qt/5.9.7/clang_64/lib/cmake/Qt5/" CACHE PATH "directory where Qt5Config.cmake exists.")
|
|
||||||
else()
|
|
||||||
set(Qt5_DIR "" CACHE PATH "directory where Qt5Config.cmake exists.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_package(Qt5 COMPONENTS Core Gui Network PrintSupport WebChannel WebEngine
|
|
||||||
WebEngineWidgets Positioning Svg Widgets LinguistTools
|
WebEngineWidgets Positioning Svg Widgets LinguistTools
|
||||||
REQUIRED NO_DEFAULT_PATH)
|
HINTS
|
||||||
|
"/opt/qt59/lib/cmake/Qt5/"
|
||||||
|
"c:/Qt/Qt5.9.8/5.9.8/msvc2017_64/lib/cmake/Qt5/"
|
||||||
|
"c:/Qt/Qt5.9.9/5.9.9/msvc2017_64/lib/cmake/Qt5/"
|
||||||
|
"/usr/local/Cellar/qt/5.9.8/clang_64/lib/cmake/Qt5/"
|
||||||
|
"/usr/local/Cellar/qt/5.9.9/clang_64/lib/cmake/Qt5/")
|
||||||
|
|
||||||
## hoedown library
|
## hoedown library
|
||||||
add_library(hoedown STATIC
|
add_library(hoedown STATIC
|
||||||
hoedown/src/autolink.c hoedown/src/document.c hoedown/src/html.c hoedown/src/html_smartypants.c
|
hoedown/src/autolink.c hoedown/src/document.c hoedown/src/html.c hoedown/src/html_smartypants.c
|
||||||
hoedown/src/version.c hoedown/src/buffer.c hoedown/src/escape.c hoedown/src/html_blocks.c
|
hoedown/src/version.c hoedown/src/buffer.c hoedown/src/escape.c hoedown/src/html_blocks.c
|
||||||
hoedown/src/stack.c )
|
hoedown/src/stack.c )
|
||||||
target_link_libraries(hoedown PRIVATE Qt5::Core Qt5::Gui)
|
target_link_libraries(hoedown PRIVATE Qt5::Core Qt5::Gui)
|
||||||
|
|
||||||
## peg-highlight library
|
## peg-highlight library
|
||||||
add_library(peg-highlight STATIC peg-highlight/pmh_parser.c peg-highlight/pmh_styleparser.c)
|
add_library(peg-highlight STATIC peg-highlight/pmh_parser.c peg-highlight/pmh_styleparser.c)
|
||||||
target_link_libraries(peg-highlight PRIVATE Qt5::Core Qt5::Gui)
|
target_link_libraries(peg-highlight PRIVATE Qt5::Core Qt5::Gui)
|
||||||
@ -38,54 +35,6 @@ target_link_libraries(peg-highlight PRIVATE Qt5::Core Qt5::Gui)
|
|||||||
## project sources
|
## project sources
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
option(CMake_RUN_CLANG_TIDY "Run clang-tidy with the compiler." OFF)
|
include(${CMAKE_CURRENT_LIST_DIR}/Packaging.cmake)
|
||||||
if(CMake_RUN_CLANG_TIDY)
|
|
||||||
if(CMake_SOURCE_DIR STREQUAL CMake_BINARY_DIR)
|
|
||||||
message(FATAL_ERROR "CMake_RUN_CLANG_TIDY requires an out-of-source build!")
|
|
||||||
endif()
|
|
||||||
find_program(CLANG_TIDY_COMMAND NAMES clang-tidy)
|
|
||||||
if(NOT CLANG_TIDY_COMMAND)
|
|
||||||
message(WARNING "CMake_RUN_CLANG_TIDY is ON but clang-tidy is not found!")
|
|
||||||
set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE)
|
|
||||||
else()
|
|
||||||
set(CLANG_TIDY_CHECKS "-*,modernize-*")
|
|
||||||
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND};-checks=${CLANG_TIDY_CHECKS};-header-filter='${CMAKE_SOURCE_DIR}/src/*'")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Create a preprocessor definition that depends on .clang-tidy content so
|
|
||||||
# the compile command will change when .clang-tidy changes. This ensures
|
|
||||||
# that a subsequent build re-runs clang-tidy on all sources even if they
|
|
||||||
# do not otherwise need to be recompiled. Nothing actually uses this
|
|
||||||
# definition. We add it to targets on which we run clang-tidy just to
|
|
||||||
# get the build dependency on the .clang-tidy file.
|
|
||||||
file(SHA1 ${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy clang_tidy_sha1)
|
|
||||||
set(CLANG_TIDY_DEFINITIONS "CLANG_TIDY_SHA1=${clang_tidy_sha1}")
|
|
||||||
unset(clang_tidy_sha1)
|
|
||||||
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(CMake_RUN_IWYU "Run include-what-you-use with the compiler." OFF)
|
|
||||||
if(CMake_RUN_IWYU)
|
|
||||||
find_program(IWYU_COMMAND NAMES include-what-you-use iwyu)
|
|
||||||
if(NOT IWYU_COMMAND)
|
|
||||||
message(WARNING "CMake_RUN_IWYU is ON but include-what-you-use is not found!")
|
|
||||||
else()
|
|
||||||
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE
|
|
||||||
"${IWYU_COMMAND};-Xiwyu;--mapping_file=${CMake_SOURCE_DIR}/Utilities/IWYU/mapping.imp;-w")
|
|
||||||
list(APPEND CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${CMake_IWYU_OPTIONS})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Clazy is a Qt oriented code checker based on clang framework. Krazy's little brother.
|
|
||||||
set(CMake_RUN_CLAZY OFF CACHE BOOL "Add clazy check for builds")
|
|
||||||
if(ENABLE_CLAZY)
|
|
||||||
find_program(CLAZY_EXECUTABLE NAMES clazy PATHS /usr/local/llvm/bin /usr/local/bin /opt/clazy/bin)
|
|
||||||
if(CLAZY_EXECUTABLE)
|
|
||||||
message(STATUS "clazy found: ${CLAZY_EXECUTABLE}")
|
|
||||||
else()
|
|
||||||
message(AUTHOR_WARNING "clazy not found.")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
# vim: ts=2 sw=2 sts=2 et
|
# vim: ts=2 sw=2 sts=2 et
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
],
|
],
|
||||||
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
|
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
|
||||||
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
|
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
|
||||||
"cmakeCommandArgs": "-DQt5_DIR=c:\\Qt\\Qt5.9.7\\5.9.7\\msvc2017_64\\lib\\cmake\\Qt5\\",
|
"cmakeCommandArgs": "",
|
||||||
"buildCommandArgs": "-v",
|
"buildCommandArgs": "-v",
|
||||||
"ctestCommandArgs": ""
|
"ctestCommandArgs": ""
|
||||||
}
|
}
|
||||||
|
@ -84,9 +84,9 @@ set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
|
|||||||
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
|
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
|
||||||
|
|
||||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "vnote")
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "vnote")
|
||||||
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/packaging")
|
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||||
|
|
||||||
# set human names to exetuables
|
# set human names to executables
|
||||||
set(CPACK_PACKAGE_EXECUTABLES "VNote" "VNote")
|
set(CPACK_PACKAGE_EXECUTABLES "VNote" "VNote")
|
||||||
set(CPACK_CREATE_DESKTOP_LINKS "VNote")
|
set(CPACK_CREATE_DESKTOP_LINKS "VNote")
|
||||||
set(CPACK_STRIP_FILES TRUE)
|
set(CPACK_STRIP_FILES TRUE)
|
||||||
@ -168,7 +168,7 @@ elseif(APPLE)
|
|||||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
|
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
|
||||||
list(APPEND CPACK_GENERATOR External)
|
list(APPEND CPACK_GENERATOR External)
|
||||||
message(STATUS " + macdeployqt -dmg YES ")
|
message(STATUS " + macdeployqt -dmg YES ")
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CPackMacDeployQt.cmake.in "${CMAKE_BINARY_DIR}/CPackExternal.cmake")
|
configure_file(${CMAKE_SOURCE_DIR}/CPackMacDeployQt.cmake.in "${CMAKE_BINARY_DIR}/CPackExternal.cmake")
|
||||||
set(CPACK_EXTERNAL_PACKAGE_SCRIPT "${CMAKE_BINARY_DIR}/CPackExternal.cmake")
|
set(CPACK_EXTERNAL_PACKAGE_SCRIPT "${CMAKE_BINARY_DIR}/CPackExternal.cmake")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ else()
|
|||||||
linuxdeployqt("${CPACK_PACKAGE_DIRECTORY}/_CPack_Packages/Linux/AppImage" "share/applications/vnote.desktop")
|
linuxdeployqt("${CPACK_PACKAGE_DIRECTORY}/_CPack_Packages/Linux/AppImage" "share/applications/vnote.desktop")
|
||||||
else()
|
else()
|
||||||
set(CPACK_GENERATOR "External;${CPACK_GENERATOR}")
|
set(CPACK_GENERATOR "External;${CPACK_GENERATOR}")
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CPackLinuxDeployQt.cmake.in "${CMAKE_BINARY_DIR}/CPackExternal.cmake")
|
configure_file(${CMAKE_SOURCE_DIR}/CPackLinuxDeployQt.cmake.in "${CMAKE_BINARY_DIR}/CPackExternal.cmake")
|
||||||
set(CPACK_EXTERNAL_PACKAGE_SCRIPT "${CMAKE_BINARY_DIR}/CPackExternal.cmake")
|
set(CPACK_EXTERNAL_PACKAGE_SCRIPT "${CMAKE_BINARY_DIR}/CPackExternal.cmake")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
@ -1,142 +1,17 @@
|
|||||||
add_executable(VNote main.cpp
|
add_executable(VNote main.cpp)
|
||||||
vmainwindow.cpp
|
|
||||||
vdirectorytree.cpp
|
file(GLOB SRC_FILES *.cpp)
|
||||||
vnote.cpp
|
file(GLOB DIALOG_SRCS dialog/*.cpp)
|
||||||
vnotebook.cpp
|
file(GLOB UTILS_SRCS utils/*.cpp)
|
||||||
dialog/vnewdirdialog.cpp
|
file(GLOB WIDGETS_SRCS widgets/*.cpp)
|
||||||
vconfigmanager.cpp
|
|
||||||
vfilelist.cpp
|
target_sources(VNote PRIVATE ${SRC_FILES})
|
||||||
dialog/vnewfiledialog.cpp
|
target_sources(VNote PRIVATE ${DIALOG_SRCS})
|
||||||
vedit.cpp
|
target_sources(VNote PRIVATE ${UTILS_SRCS})
|
||||||
vdocument.cpp
|
target_sources(VNote PRIVATE ${WIDGETS_SRCS})
|
||||||
utils/vutils.cpp
|
target_sources(VNote PRIVATE vnote.qrc translations.qrc)
|
||||||
vpreviewpage.cpp
|
|
||||||
vstyleparser.cpp
|
include_directories(dialog utils widgets)
|
||||||
dialog/vnewnotebookdialog.cpp
|
|
||||||
vmarkdownconverter.cpp
|
|
||||||
dialog/vnotebookinfodialog.cpp
|
|
||||||
dialog/vdirinfodialog.cpp
|
|
||||||
dialog/vfileinfodialog.cpp
|
|
||||||
veditoperations.cpp
|
|
||||||
vmdeditoperations.cpp
|
|
||||||
dialog/vinsertimagedialog.cpp
|
|
||||||
vdownloader.cpp
|
|
||||||
veditarea.cpp
|
|
||||||
veditwindow.cpp
|
|
||||||
vedittab.cpp
|
|
||||||
voutline.cpp
|
|
||||||
vsingleinstanceguard.cpp
|
|
||||||
vdirectory.cpp
|
|
||||||
vfile.cpp
|
|
||||||
vnotebookselector.cpp
|
|
||||||
vnofocusitemdelegate.cpp
|
|
||||||
vmdedit.cpp
|
|
||||||
dialog/vfindreplacedialog.cpp
|
|
||||||
dialog/vsettingsdialog.cpp
|
|
||||||
dialog/vdeletenotebookdialog.cpp
|
|
||||||
dialog/vselectdialog.cpp
|
|
||||||
vcaptain.cpp
|
|
||||||
vopenedlistmenu.cpp
|
|
||||||
vnavigationmode.cpp
|
|
||||||
vorphanfile.cpp
|
|
||||||
vcodeblockhighlighthelper.cpp
|
|
||||||
vwebview.cpp
|
|
||||||
vmdtab.cpp
|
|
||||||
vhtmltab.cpp
|
|
||||||
utils/vvim.cpp
|
|
||||||
utils/veditutils.cpp
|
|
||||||
vvimindicator.cpp
|
|
||||||
vbuttonwithwidget.cpp
|
|
||||||
vtabindicator.cpp
|
|
||||||
dialog/vupdater.cpp
|
|
||||||
dialog/vorphanfileinfodialog.cpp
|
|
||||||
vtextblockdata.cpp
|
|
||||||
utils/vpreviewutils.cpp
|
|
||||||
dialog/vconfirmdeletiondialog.cpp
|
|
||||||
vnotefile.cpp
|
|
||||||
vattachmentlist.cpp
|
|
||||||
dialog/vsortdialog.cpp
|
|
||||||
vfilesessioninfo.cpp
|
|
||||||
vtableofcontent.cpp
|
|
||||||
utils/vmetawordmanager.cpp
|
|
||||||
vmetawordlineedit.cpp
|
|
||||||
dialog/vinsertlinkdialog.cpp
|
|
||||||
vplaintextedit.cpp
|
|
||||||
vimageresourcemanager.cpp
|
|
||||||
vlinenumberarea.cpp
|
|
||||||
veditor.cpp
|
|
||||||
vmdeditor.cpp
|
|
||||||
veditconfig.cpp
|
|
||||||
vpreviewmanager.cpp
|
|
||||||
vimageresourcemanager2.cpp
|
|
||||||
vtextdocumentlayout.cpp
|
|
||||||
vtextedit.cpp
|
|
||||||
vsnippetlist.cpp
|
|
||||||
vsnippet.cpp
|
|
||||||
dialog/veditsnippetdialog.cpp
|
|
||||||
utils/vimnavigationforwidget.cpp
|
|
||||||
vtoolbox.cpp
|
|
||||||
vinsertselector.cpp
|
|
||||||
utils/vclipboardutils.cpp
|
|
||||||
vpalette.cpp
|
|
||||||
vbuttonmenuitem.cpp
|
|
||||||
utils/viconutils.cpp
|
|
||||||
lineeditdelegate.cpp
|
|
||||||
dialog/vtipsdialog.cpp
|
|
||||||
dialog/vcopytextashtmldialog.cpp
|
|
||||||
vwaitingwidget.cpp
|
|
||||||
utils/vwebutils.cpp
|
|
||||||
vlineedit.cpp
|
|
||||||
vcart.cpp
|
|
||||||
vvimcmdlineedit.cpp
|
|
||||||
vlistwidget.cpp
|
|
||||||
vsimplesearchinput.cpp
|
|
||||||
vstyleditemdelegate.cpp
|
|
||||||
vtreewidget.cpp
|
|
||||||
dialog/vexportdialog.cpp
|
|
||||||
vexporter.cpp
|
|
||||||
vsearcher.cpp
|
|
||||||
vsearch.cpp
|
|
||||||
vsearchresulttree.cpp
|
|
||||||
vsearchengine.cpp
|
|
||||||
vuniversalentry.cpp
|
|
||||||
vlistwidgetdoublerows.cpp
|
|
||||||
vdoublerowitemwidget.cpp
|
|
||||||
vsearchue.cpp
|
|
||||||
voutlineue.cpp
|
|
||||||
vhelpue.cpp
|
|
||||||
vlistfolderue.cpp
|
|
||||||
dialog/vfixnotebookdialog.cpp
|
|
||||||
vplantumlhelper.cpp
|
|
||||||
vgraphvizhelper.cpp
|
|
||||||
vlivepreviewhelper.cpp
|
|
||||||
vmathjaxpreviewhelper.cpp
|
|
||||||
vmathjaxwebdocument.cpp
|
|
||||||
vmathjaxinplacepreviewhelper.cpp
|
|
||||||
vhistorylist.cpp
|
|
||||||
vexplorer.cpp
|
|
||||||
vlistue.cpp
|
|
||||||
vuetitlecontentpanel.cpp
|
|
||||||
utils/vprocessutils.cpp
|
|
||||||
vtagpanel.cpp
|
|
||||||
valltagspanel.cpp
|
|
||||||
vtaglabel.cpp
|
|
||||||
vtagexplorer.cpp
|
|
||||||
pegmarkdownhighlighter.cpp
|
|
||||||
pegparser.cpp
|
|
||||||
peghighlighterresult.cpp
|
|
||||||
vtexteditcompleter.cpp
|
|
||||||
utils/vkeyboardlayoutmanager.cpp
|
|
||||||
dialog/vkeyboardlayoutmappingdialog.cpp
|
|
||||||
vfilelistwidget.cpp
|
|
||||||
widgets/vcombobox.cpp
|
|
||||||
vtablehelper.cpp
|
|
||||||
vtable.cpp
|
|
||||||
dialog/vinserttabledialog.cpp
|
|
||||||
isearchengine.cpp
|
|
||||||
iuniversalentry.cpp
|
|
||||||
vimagehosting.cpp
|
|
||||||
vnote.qrc translations.qrc)
|
|
||||||
|
|
||||||
# Qt5 libraries
|
# Qt5 libraries
|
||||||
target_link_libraries(VNote PRIVATE Qt5::Core Qt5::WebEngine Qt5::WebEngineWidgets
|
target_link_libraries(VNote PRIVATE Qt5::Core Qt5::WebEngine Qt5::WebEngineWidgets
|
||||||
@ -145,7 +20,8 @@ target_link_libraries(VNote PRIVATE Qt5::Core Qt5::WebEngine Qt5::WebEngineWidge
|
|||||||
set_property(TARGET VNote PROPERTY AUTORCC_OPTIONS "--compress;9")
|
set_property(TARGET VNote PROPERTY AUTORCC_OPTIONS "--compress;9")
|
||||||
|
|
||||||
# Thirdparty libraries
|
# Thirdparty libraries
|
||||||
target_include_directories(VNote PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/peg-highlight ${CMAKE_SOURCE_DIR}/hoedown)
|
target_include_directories(VNote PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_SOURCE_DIR}/peg-highlight ${CMAKE_SOURCE_DIR}/hoedown)
|
||||||
target_link_libraries(VNote PRIVATE peg-highlight hoedown)
|
target_link_libraries(VNote PRIVATE peg-highlight hoedown)
|
||||||
|
|
||||||
# Compile options
|
# Compile options
|
||||||
@ -207,4 +83,3 @@ elseif(DARWIN)
|
|||||||
set_source_files_properties(${MACOSX_BUNDLE_ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
|
set_source_files_properties(${MACOSX_BUNDLE_ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/Packaging.cmake)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user