Empty shell, just to set up CMake.

This commit is contained in:
vincent 2015-12-18 10:42:46 +01:00
parent 8edf499999
commit 2eee6da544
7 changed files with 170 additions and 0 deletions

48
CMakeLists.txt Normal file

@ -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()

21
src/CMakeLists.txt Normal file

@ -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)

17
src/qcron.cpp Normal file

@ -0,0 +1,17 @@
#include "qcron.hpp"
/******************************************************************************/
QCron::
QCron()
{
}
/******************************************************************************/
QCron::
~QCron()
{
}
/******************************************************************************/

15
src/qcron.hpp Normal file

@ -0,0 +1,15 @@
#ifndef _QCRON_HPP
#define _QCRON_HPP
#include <QObject>
class QCron : public QObject
{
Q_OBJECT
public:
QCron();
~QCron();
};
#endif

39
test/CMakeLists.txt Normal file

@ -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()

16
test/qcron_test.cpp Normal file

@ -0,0 +1,16 @@
#include "qcron_test.hpp"
#include <QTest>
/******************************************************************************/
void
QCronTest::
basics()
{
QFAIL("Nothing here.");
}
/******************************************************************************/
QTEST_MAIN(QCronTest)

14
test/qcron_test.hpp Normal file

@ -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