diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cbe800..35b2873 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,60 +1,25 @@ -project(PROGRESSBAR_FOR_A_MORE_CIVILIZED_AGE) -cmake_minimum_required(VERSION 2.8.5) +project(elegant-progressbars-dev) +cmake_minimum_required(VERSION 3.0.2) ############################################################################### -# Using Clang is awesome -# code based on http://stackoverflow.com/q/7031126 +# Compiler flags ############################################################################### -option(USE_CLANG "build application with clang" ON) # OFF is the default option(CMAKE_BUILD_TYPE "build type" Slow) # to show the progress -if(USE_CLANG) - SET (CMAKE_C_COMPILER "/usr/bin/clang") - SET (CMAKE_C_FLAGS "-Wall -Wextra -std=c99") - SET (CMAKE_C_FLAGS_DEBUG "-g") - SET (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG") - SET (CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") - SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") - SET (CMAKE_C_FLAGS_SLOW "-O0") - - SET (CMAKE_CXX_COMPILER "/usr/bin/clang++") - SET (CMAKE_CXX_FLAGS "-Wall -Wextra -std=c++11") - SET (CMAKE_CXX_FLAGS_DEBUG "-g") - SET (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG") - SET (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") - SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") - SET (CMAKE_CXX_FLAGS_SLOW "-O0") -else(USE_CLANG) - SET (CMAKE_C_COMPILER "/usr/bin/gcc") - SET (CMAKE_C_FLAGS "-Wall -Wextra -std=c99") - SET (CMAKE_C_FLAGS_DEBUG "-g") - SET (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG") - SET (CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") - SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") - SET (CMAKE_C_FLAGS_SLOW "-O0") - - SET (CMAKE_CXX_COMPILER "/usr/bin/g++") - SET (CMAKE_CXX_FLAGS "-Wall -Wextra -std=c++11") - SET (CMAKE_CXX_FLAGS_DEBUG "-g") - SET (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG") - SET (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") - SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") - SET (CMAKE_CXX_FLAGS_SLOW "-O0") -endif(USE_CLANG) - +SET (CMAKE_CXX_FLAGS "-Wall -Wextra -std=c++11") +SET (CMAKE_CXX_FLAGS_SLOW "-O0") ############################################################################### -# Headers +# Progressbar for a More Civilized Age Config ############################################################################### -# for header-only libraries, this is enough :) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) +find_package(elegant-progressbars 1.0.0 REQUIRED PATHS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") ############################################################################### # Build executables ############################################################################### -add_executable(ProgressBarExample examples/progressbar_example.cc) +add_executable(ProgressBarExample examples/progressbar_example.cpp) ############################################################################### # Custom targets diff --git a/README.md b/README.md index 7c7463b..28e3448 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ offer a legacy-variant, which is very nice of them). Installation ------------ + +###Manual### Just put the folder ./lib/elegantProgressbars in a place where your compiler will find it when searching for libraries to include. @@ -19,6 +21,13 @@ doxygen Doxyfile firefox doc/html/index.html ``` +###CMake Supported### + +Clone the project to some local path and add the following line to your `CMakeLists.txt`: + + find_package(elegant-progressbars PATHS "/cmake") + + Example ------- There is an example which can be compiled and tested: diff --git a/cmake/elegant-progressbarsConfig.cmake b/cmake/elegant-progressbarsConfig.cmake new file mode 100644 index 0000000..5c9dabd --- /dev/null +++ b/cmake/elegant-progressbarsConfig.cmake @@ -0,0 +1,5 @@ +# - Config file for the progressbar-for-a-more-civilized-age package +cmake_minimum_required(VERSION 3.0.2) +project(elegant-progressbars) + +include_directories("${elegant-progressbars_DIR}/../include") diff --git a/cmake/elegant-progressbarsConfigVersion.cmake b/cmake/elegant-progressbarsConfigVersion.cmake new file mode 100644 index 0000000..d840be2 --- /dev/null +++ b/cmake/elegant-progressbarsConfigVersion.cmake @@ -0,0 +1,26 @@ +file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/../include/elegantProgressbars/version.hpp" elegantProgressbars_VERSION_MAJOR_HPP REGEX "#define ELEGANTPROGRESSBARS_VERSION_MAJOR ") +file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/../include/elegantProgressbars/version.hpp" elegantProgressbars_VERSION_MINOR_HPP REGEX "#define ELEGANTPROGRESSBARS_VERSION_MINOR ") +file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/../include/elegantProgressbars/version.hpp" elegantProgressbars_VERSION_PATCH_HPP REGEX "#define ELEGANTPROGRESSBARS_VERSION_PATCH ") + +string(REGEX MATCH "([0-9]+)" elegantProgressbars_VERSION_MAJOR ${elegantProgressbars_VERSION_MAJOR_HPP}) +string(REGEX MATCH "([0-9]+)" elegantProgressbars_VERSION_MINOR ${elegantProgressbars_VERSION_MINOR_HPP}) +string(REGEX MATCH "([0-9]+)" elegantProgressbars_VERSION_PATCH ${elegantProgressbars_VERSION_PATCH_HPP}) + +set(PACKAGE_VERSION "${elegantProgressbars_VERSION_MAJOR}.${elegantProgressbars_VERSION_MINOR}.${elegantProgressbars_VERSION_PATCH}") + +# Check whether the requested PACKAGE_FIND_VERSION is exactly the one requested +if("${PACKAGE_VERSION}" EQUAL "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) +else() + set(PACKAGE_VERSION_EXACT FALSE) +endif() + +# Check whether the requested PACKAGE_FIND_VERSION is compatible +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/examples/progressbar_example.cc b/examples/progressbar_example.cpp similarity index 100% rename from examples/progressbar_example.cc rename to examples/progressbar_example.cpp diff --git a/include/elegantProgressbars/version.hpp b/include/elegantProgressbars/version.hpp new file mode 100644 index 0000000..85e5ebb --- /dev/null +++ b/include/elegantProgressbars/version.hpp @@ -0,0 +1,5 @@ +#pragma once + +#define ELEGANTPROGRESSBARS_VERSION_MAJOR 1 +#define ELEGANTPROGRESSBARS_VERSION_MINOR 0 +#define ELEGANTPROGRESSBARS_VERSION_PATCH 0 diff --git a/include/version.hpp b/include/version.hpp deleted file mode 100644 index 360d6b3..0000000 --- a/include/version.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#define ELEGANT_PROGRESSBARS_VERSION 000100 - -// ELEGANT_PROGRESSBARS_VERSION % 100 is the sub-minor version -// ELEGANT_PROGRESSBARS_VERSION / 100 % 1000 is the minor version -// ELEGANT_PROGRESSBARS_VERSION / 100000 is the major version