mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2025-12-18 01:55:53 -06:00
Let CMake generate version.h
This commit is contained in:
committed by
Martin Kleusberg
parent
c4ebc208ba
commit
38907ccaea
1
.gitignore
vendored
1
.gitignore
vendored
@@ -16,7 +16,6 @@ src/sqlitebrowser
|
||||
src/Makefile*
|
||||
src/debug
|
||||
src/release
|
||||
src/gen_version.h
|
||||
|
||||
# ignore compiled translation files
|
||||
src/translations/*.qm
|
||||
|
||||
@@ -16,6 +16,31 @@ OPTION(sqlcipher "Build with SQLCipher library" OFF)
|
||||
# used by the nightly version to add the date of the build.
|
||||
string(TIMESTAMP BUILD_VERSION "%Y%m%d")
|
||||
|
||||
add_definitions(-std=c++14)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
if(APPLE)
|
||||
add_executable(${PROJECT_NAME} MACOSX_BUNDLE)
|
||||
elseif(WIN32)
|
||||
add_executable(${PROJECT_NAME} WIN32)
|
||||
else()
|
||||
add_executable(${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_STABLE_VERSION)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE BUILD_VERSION=${BUILD_VERSION})
|
||||
endif()
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")
|
||||
|
||||
# BUILD_VERSION is the current date in YYYYMMDD format. It is only
|
||||
# used by the nightly version to add the date of the build.
|
||||
string(TIMESTAMP BUILD_VERSION "%Y%m%d")
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
@@ -26,10 +51,6 @@ if(NOT BUILD_STABLE_VERSION)
|
||||
add_definitions(-DBUILD_VERSION=${BUILD_VERSION})
|
||||
endif()
|
||||
|
||||
add_definitions(-std=c++14)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
# Fix behavior of CMAKE_CXX_STANDARD when targeting macOS.
|
||||
if(POLICY CMP0025)
|
||||
cmake_policy(SET CMP0025 NEW)
|
||||
@@ -96,7 +117,7 @@ if(FORCE_INTERNAL_QHEXEDIT)
|
||||
else()
|
||||
find_package(QHexEdit)
|
||||
endif()
|
||||
set(JSON_DIR libs/json)
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/libs/json)
|
||||
|
||||
if(NOT QSCINTILLA_FOUND)
|
||||
set(QSCINTILLA_DIR libs/qscintilla/Qt4Qt5)
|
||||
@@ -111,17 +132,18 @@ if(NOT QCustomPlot_FOUND)
|
||||
set(QCustomPlot_DIR libs/qcustomplot-source)
|
||||
add_subdirectory(${QCustomPlot_DIR})
|
||||
endif()
|
||||
add_subdirectory(${JSON_DIR})
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
if(ENABLE_TESTING)
|
||||
enable_testing()
|
||||
endif()
|
||||
|
||||
set(SQLB_HDR
|
||||
src/version.h
|
||||
# generate file with version information
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.h
|
||||
)
|
||||
|
||||
target_sources(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
src/sql/sqlitetypes.h
|
||||
src/sql/Query.h
|
||||
src/sql/ObjectIdentifier.h
|
||||
@@ -135,7 +157,8 @@ set(SQLB_HDR
|
||||
src/sql/parser/sqlite3_parser.hpp
|
||||
)
|
||||
|
||||
set(SQLB_MOC_HDR
|
||||
target_sources(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
src/sqlitedb.h
|
||||
src/AboutDialog.h
|
||||
src/EditIndexDialog.h
|
||||
@@ -190,7 +213,8 @@ set(SQLB_MOC_HDR
|
||||
src/TableBrowserDock.h
|
||||
)
|
||||
|
||||
set(SQLB_SRC
|
||||
target_sources(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
src/AboutDialog.cpp
|
||||
src/EditIndexDialog.cpp
|
||||
src/EditDialog.cpp
|
||||
@@ -367,12 +391,12 @@ if(WIN32)
|
||||
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/sqlbicon.o"
|
||||
COMMAND windres "-I${CMAKE_CURRENT_SOURCE_DIR}" "-i${CMAKE_CURRENT_SOURCE_DIR}/src/winapp.rc" -o "${CMAKE_CURRENT_BINARY_DIR}/sqlbicon.o" VERBATIM
|
||||
)
|
||||
set(SQLB_SRC ${SQLB_SRC} "${CMAKE_CURRENT_BINARY_DIR}/sqlbicon.o")
|
||||
target_sources(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/sqlbicon.o")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-subsystem,windows")
|
||||
set(WIN32_STATIC_LINK -Wl,-Bstatic -lssl -lcrypto -lws2_32)
|
||||
set(ADDITIONAL_LIBS lzma)
|
||||
else()
|
||||
set(SQLB_SRC ${SQLB_SRC} "${CMAKE_CURRENT_SOURCE_DIR}/src/winapp.rc")
|
||||
target_sources(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/winapp.rc")
|
||||
endif()
|
||||
else()
|
||||
set(LPTHREAD pthread)
|
||||
@@ -410,12 +434,11 @@ if(WIN32 AND MSVC)
|
||||
include_directories(${SQLITE3_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}"
|
||||
${JSON_DIR}
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
${ADDITIONAL_INCLUDE_PATHS}
|
||||
src
|
||||
)
|
||||
|
||||
if(QHexEdit_FOUND)
|
||||
include_directories(${QHexEdit_INCLUDE_DIR})
|
||||
else()
|
||||
@@ -432,27 +455,13 @@ else()
|
||||
include_directories(${QSCINTILLA_DIR})
|
||||
endif()
|
||||
|
||||
if(NOT APPLE)
|
||||
add_executable(${PROJECT_NAME}
|
||||
${SQLB_HDR}
|
||||
${SQLB_SRC}
|
||||
${SQLB_FORM_HDR}
|
||||
${SQLB_MOC}
|
||||
${SQLB_MOC_HDR}
|
||||
${SQLB_RESOURCES_RCC}
|
||||
${SQLB_MISC}
|
||||
)
|
||||
else()
|
||||
add_executable(${PROJECT_NAME} MACOSX_BUNDLE
|
||||
${SQLB_HDR}
|
||||
${SQLB_SRC}
|
||||
${SQLB_FORM_HDR}
|
||||
${SQLB_MOC}
|
||||
${SQLB_MOC_HDR}
|
||||
${SQLB_RESOURCES_RCC}
|
||||
${SQLB_MISC}
|
||||
)
|
||||
endif()
|
||||
target_sources(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
${SQLB_FORM_HDR}
|
||||
${SQLB_MOC}
|
||||
${SQLB_RESOURCES_RCC}
|
||||
${SQLB_MISC}
|
||||
)
|
||||
|
||||
# Warnings
|
||||
if(ALL_WARNINGS AND CMAKE_COMPILER_IS_GNUCC)
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#ifndef GEN_VERSION_H
|
||||
#define GEN_VERSION_H
|
||||
#define MAJOR_VERSION 3
|
||||
#define MINOR_VERSION 12
|
||||
#define PATCH_VERSION 99
|
||||
|
||||
#define str(s) #s
|
||||
#define xstr(s) str(s)
|
||||
#define APP_VERSION xstr(MAJOR_VERSION) "." xstr(MINOR_VERSION) "." xstr(PATCH_VERSION)
|
||||
|
||||
// If it is defined by the compiler, then it is a nightly build, and in the YYYYMMDD format.
|
||||
#ifndef BUILD_VERSION
|
||||
#define BUILD_VERSION 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
15
src/version.h.in
Normal file
15
src/version.h.in
Normal file
@@ -0,0 +1,15 @@
|
||||
// version file to be preprocessed by CMake
|
||||
#ifndef GEN_VERSION_H
|
||||
#define GEN_VERSION_H
|
||||
#define MAJOR_VERSION @PROJECT_VERSION_MAJOR@
|
||||
#define MINOR_VERSION @PROJECT_VERSION_MINOR@
|
||||
#define PATCH_VERSION @PROJECT_VERSION_PATCH@
|
||||
|
||||
#define APP_VERSION "@PROJECT_VERSION@"
|
||||
|
||||
// If it is defined by the compiler, then it is a nightly build, and in the YYYYMMDD format.
|
||||
#ifndef BUILD_VERSION
|
||||
#define BUILD_VERSION 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user