added simple CMake project file
This commit is contained in:
parent
d437126760
commit
47b96df17b
|
@ -0,0 +1,53 @@
|
||||||
|
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
||||||
|
|
||||||
|
# meta data
|
||||||
|
set(META_PROJECT_NAME c++utilities)
|
||||||
|
set(META_APP_NAME "C++ Utilities")
|
||||||
|
set(META_APP_AUTHOR "Martchus")
|
||||||
|
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
||||||
|
set(META APP_DESCRIPTION "Common C++ classes and routines used by my applications such as argument parser, IO and conversion utilities.")
|
||||||
|
set(META_VERSION_MAJOR 3)
|
||||||
|
set(META_VERSION_MINOR 0)
|
||||||
|
set(META_VERSION_PATCH 0)
|
||||||
|
|
||||||
|
# define project
|
||||||
|
project(${META_PROJECT_NAME})
|
||||||
|
|
||||||
|
# stringification of meta data
|
||||||
|
set(META_PROJECT_NAME_STR "\"${META_PROJECT_NAME}\"")
|
||||||
|
set(META_APP_NAME_STR "\"${META_APP_NAME}\"")
|
||||||
|
set(META_APP_AUTHOR_STR "\"${META_APP_AUTHOR}\"")
|
||||||
|
set(META_APP_URL_STR "\"${META_APP_URL}\"")
|
||||||
|
set(APP_DESCRIPTION_STR "\"${APP_DESCRIPTION}\"")
|
||||||
|
set(META_APP_VERSION_STR "\"${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}\"")
|
||||||
|
|
||||||
|
# add configuration header
|
||||||
|
configure_file (
|
||||||
|
"${PROJECT_SOURCE_DIR}/config.h.in"
|
||||||
|
"${PROJECT_BINARY_DIR}/config.h"
|
||||||
|
)
|
||||||
|
include_directories("${PROJECT_BINARY_DIR}")
|
||||||
|
|
||||||
|
# add source and header files
|
||||||
|
file(GLOB_RECURSE SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp" "*.c")
|
||||||
|
file(GLOB_RECURSE HEADER_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
|
||||||
|
|
||||||
|
# executable and linking
|
||||||
|
add_library(${META_PROJECT_NAME} SHARED ${HEADER_FILES} ${SRC_FILES})
|
||||||
|
target_link_libraries(${META_PROJECT_NAME})
|
||||||
|
set_target_properties(${META_PROJECT_NAME} PROPERTIES VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH} SOVERSION ${META_VERSION_MAJOR})
|
||||||
|
|
||||||
|
# enable C++11
|
||||||
|
set_property(TARGET ${META_PROJECT_NAME} PROPERTY CXX_STANDARD 11)
|
||||||
|
|
||||||
|
# add install target
|
||||||
|
install(TARGETS ${META_PROJECT_NAME}
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
)
|
||||||
|
foreach(HEADER_FILE ${HEADER_FILES})
|
||||||
|
get_filename_component(HEADER_DIR ${HEADER_FILE} DIRECTORY)
|
||||||
|
install(FILES ${HEADER_FILE} DESTINATION include/${META_PROJECT_NAME}/${HEADER_DIR})
|
||||||
|
endforeach()
|
||||||
|
|
10
README.md
10
README.md
|
@ -4,9 +4,17 @@ Common C++ classes and routines used by my applications such as argument parser,
|
||||||
## Build instructions
|
## Build instructions
|
||||||
Building the library is simple:
|
Building the library is simple:
|
||||||
```
|
```
|
||||||
INSTALL_ROOT=/where/you/want/to/install qmake-qt5 "c++utilities.pro" -r -spec linux-g++
|
INSTALL_ROOT=/where/you/want/to/install qmake-qt5 c++utilities.pro
|
||||||
make && make install
|
make && make install
|
||||||
```
|
```
|
||||||
As you can see, the qmake build system is used. However the library itself does *not* depend on Qt.
|
As you can see, the qmake build system is used. However the library itself does *not* depend on Qt.
|
||||||
|
|
||||||
|
It is also possible to build the library using CMake:
|
||||||
|
```
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/where/you/want/to/install project/directory
|
||||||
|
make && make install
|
||||||
|
```
|
||||||
|
|
||||||
|
In any case, the make option *-j* might be used to compile multiple files in parallel.
|
||||||
|
|
||||||
The repository PKGBUILDs (also on GitHub) contains files for building Arch Linux packages. A PKGBUILD file to build for Windows using the Mingw-w64 compiler is also included.
|
The repository PKGBUILDs (also on GitHub) contains files for building Arch Linux packages. A PKGBUILD file to build for Windows using the Mingw-w64 compiler is also included.
|
||||||
|
|
|
@ -564,9 +564,9 @@ void ArgumentParser::parseArgs(int argc, char *argv[])
|
||||||
if(valuesToRead == 0) {
|
if(valuesToRead == 0) {
|
||||||
throw Failure("Invalid extra information \"" + givenArg + "\" for the argument \"" + currentArg->name() + "\" given.");
|
throw Failure("Invalid extra information \"" + givenArg + "\" for the argument \"" + currentArg->name() + "\" given.");
|
||||||
} else if(valuesToRead < 0) {
|
} else if(valuesToRead < 0) {
|
||||||
currentArg->m_values.push_back(givenArg);
|
currentArg->m_values.emplace_back(givenArg);
|
||||||
} else {
|
} else {
|
||||||
currentArg->m_values.push_back(givenArg);
|
currentArg->m_values.emplace_back(givenArg);
|
||||||
--valuesToRead; // one value less to be read
|
--valuesToRead; // one value less to be read
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef APP_METADATA_AVAIL
|
||||||
|
#define APP_METADATA_AVAIL
|
||||||
|
#define PROJECT_NAME @META_PROJECT_NAME_STR@
|
||||||
|
#define APP_NAME @META_APP_NAME_STR@
|
||||||
|
#define APP_VERSION @META_APP_VERSION_STR@
|
||||||
|
#define APP_AUTHOR @META_APP_AUTHOR_STR@
|
||||||
|
#define APP_URL @META_APP_URL_STR@
|
||||||
|
#define APP_DESCRIPTION @META_APP_DESCRIPTION_STR@
|
||||||
|
#endif // APP_METADATA_AVAIL
|
|
@ -1,5 +1,4 @@
|
||||||
#dirs
|
#dirs
|
||||||
UI_DIR = ./gui
|
|
||||||
MOC_DIR = ./moc
|
MOC_DIR = ./moc
|
||||||
OBJECTS_DIR = ./obj
|
OBJECTS_DIR = ./obj
|
||||||
RCC_DIR = ./res
|
RCC_DIR = ./res
|
||||||
|
@ -18,6 +17,7 @@ CONFIG(debug, debug|release) {
|
||||||
TARGET = $${targetprefix}$${projectname}
|
TARGET = $${targetprefix}$${projectname}
|
||||||
}
|
}
|
||||||
# add defines
|
# add defines
|
||||||
|
DEFINES += "APP_METADATA_AVAIL"
|
||||||
DEFINES += "'PROJECT_NAME=\"$${projectname}\"'"
|
DEFINES += "'PROJECT_NAME=\"$${projectname}\"'"
|
||||||
DEFINES += "'APP_NAME=\"$${appname}\"'"
|
DEFINES += "'APP_NAME=\"$${appname}\"'"
|
||||||
DEFINES += "'APP_AUTHOR=\"$${appauthor}\"'"
|
DEFINES += "'APP_AUTHOR=\"$${appauthor}\"'"
|
||||||
|
|
Loading…
Reference in New Issue