diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4b0a223 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,48 @@ +cmake_minimum_required(VERSION 3.0) + +# Project name. +set(PROJECT qcron) +project(${PROJECT}) + +set(SOURCE_DIR ${CMAKE_SOURCE_DIR}/src) +set(ARCHIVE_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/lib) +set(LIBRARY_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/lib) +set(PUBLIC_HEADER_DIR ${CMAKE_SOURCE_DIR}/include) + +if (WIN32) + set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install) +endif() + +set(${PROJECT}_INCLUDE_DIR + ${SOURCE_DIR} CACHE STRING "${PROJECT} include directory") + +# -Wmissing-declarations delete because it would not make Qt Resource +# Files compiles +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wredundant-decls \ +-Wcast-align -Wmissing-include-dirs -Wswitch-enum -Wswitch-default \ +-Wextra -Wall -Werror -Winvalid-pch -Wredundant-decls -Wformat=2 \ +-Wmissing-format-attribute -Wformat-nonliteral") + +option(WITH_UNIT_TESTS "enable building unit test executable" OFF) +#option(WITH_BENCHMARK "enable building benchmark executable" OFF) + +# Dependencies +set(QT_COMPONENTS Core Test) + +## Qt5 +if (WIN32) + ### Required because on Windows, FindQt5.cmake is not always available. + set (CMAKE_PREFIX_PATH ${QT_INSTALL_PATH}) +endif() +### Instruct CMake to run moc automatically when needed. +set(CMAKE_AUTOMOC ON) +### Find the Qt components. +find_package(Qt5 COMPONENTS ${QT_COMPONENTS} REQUIRED) + +# Source +add_subdirectory(src) + +if(WITH_UNIT_TESTS) + enable_testing() + add_subdirectory(test) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..cd3564a --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,21 @@ +set(${PROJECT}_SRC_FILES + qcron.cpp + ) + +set(${PROJECT}_HEADERS + qcron.hpp + ) + +# Declaration. + +add_library(${PROJECT} SHARED ${${PROJECT}_SRC_FILES}) +qt5_use_modules(${PROJECT} ${QT_COMPONENTS}) +set_target_properties(${PROJECT} PROPERTIES + PUBLIC_HEADER "${${PROJECT}_HEADERS}" + COMPILE_FLAGS "${EQUILAB_CXX_FLAGS}") + +install(TARGETS ${PROJECT} + LIBRARY DESTINATION ${LIBRARY_OUTPUT_DIR} + RUNTIME DESTINATION ${LIBRARY_OUTPUT_DIR} + PUBLIC_HEADER DESTINATION ${PUBLIC_HEADER_DIR}/${PROJECT} + COMPONENT library) diff --git a/src/qcron.cpp b/src/qcron.cpp new file mode 100644 index 0000000..45165eb --- /dev/null +++ b/src/qcron.cpp @@ -0,0 +1,17 @@ +#include "qcron.hpp" + +/******************************************************************************/ + +QCron:: +QCron() +{ +} + +/******************************************************************************/ + +QCron:: +~QCron() +{ +} + +/******************************************************************************/ diff --git a/src/qcron.hpp b/src/qcron.hpp new file mode 100644 index 0000000..7bcf712 --- /dev/null +++ b/src/qcron.hpp @@ -0,0 +1,15 @@ +#ifndef _QCRON_HPP +#define _QCRON_HPP + +#include <QObject> + +class QCron : public QObject +{ + Q_OBJECT + +public: + QCron(); + ~QCron(); +}; + +#endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..8af8da5 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,39 @@ +# In order to avoid "#include <../" when including headers. +include_directories(${${PROJECT}_INCLUDE_DIR}) + +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/test) + +# Declaration. +set(TESTS + qcron_test + ) + +foreach(test ${TESTS}) + project(${test}) + add_executable(${test} ${test}.cpp) + qt5_use_modules(${test} ${QT_COMPONENTS}) + target_link_libraries(${test} ${PROJECT} qcron) + set_target_properties(${test} PROPERTIES + COMPILE_FLAGS "${CMAKE_CXX_FLAGS}") + + if (WIN32) + set(EXEC ${EXECUTABLE_OUTPUT_PATH}/${test}.exe) + add_test(${test} ${EXEC}) + get_property(qt5_lib_location TARGET ${Qt5Core_LIBRARIES} PROPERTY LOCATION) + get_filename_component(MINGW_PATH ${qt5_lib_location} DIRECTORY) + INSTALL(TARGETS ${test} + ARCHIVE DESTINATION ${ARCHIVE_OUTPUT_DIR} + LIBRARY DESTINATION ${LIBRARY_OUTPUT_DIR} + BUNDLE DESTINATION . + RUNTIME DESTINATION ${EXECUTABLE_OUTPUT_PATH} + COMPONENT runtime) + set(LIBRARY_DIRS ${MINGW_PATH} ${LIBRARY_OUTPUT_DIR}) + INSTALL(CODE " + include(BundleUtilities) + fixup_bundle(\"${EXEC}\" \"\" \"${LIBRARY_DIRS}\") + ") + else() + add_test(${test} ${test}) + endif() + +endforeach() diff --git a/test/qcron_test.cpp b/test/qcron_test.cpp new file mode 100644 index 0000000..a780bbe --- /dev/null +++ b/test/qcron_test.cpp @@ -0,0 +1,16 @@ +#include "qcron_test.hpp" + +#include <QTest> + +/******************************************************************************/ + +void +QCronTest:: +basics() +{ + QFAIL("Nothing here."); +} + +/******************************************************************************/ + +QTEST_MAIN(QCronTest) diff --git a/test/qcron_test.hpp b/test/qcron_test.hpp new file mode 100644 index 0000000..083170b --- /dev/null +++ b/test/qcron_test.hpp @@ -0,0 +1,14 @@ +#ifndef _QCRON_TEST_HPP +#define _QCRON_TEST_HPP + +#include <QObject> + +class QCronTest : public QObject +{ + Q_OBJECT + +private slots: + void basics(); +}; + +#endif