Commit 6ed41e52 authored by Alexander A. Maly's avatar Alexander A. Maly

Optimized cmake configuration

parent 58d8d520
Pipeline #2255 passed with stages
in 4 minutes and 5 seconds
......@@ -6,15 +6,9 @@ message(STATUS "Cmake prefix path: ${CMAKE_PREFIX_PATH}")
# Query for version info and pass it as compile definitions
if(EXISTS "${CMAKE_SOURCE_DIR}/version_info.cmake")
include(${CMAKE_SOURCE_DIR}/version_info.cmake)
message(STATUS "File-provided version info: HASH=${GIT_HASH}")
message(STATUS "File-provided version info: TIMESTAMP=${GIT_TIMESTAMP}")
message(STATUS "File-provided version info: TAG=${GIT_TAG}")
message(STATUS "File-provided version info: BRANCH=${GIT_BRANCH}")
message(STATUS "File-provided version info: ")
elseif(PROVIDED_VERSION_INFO)
message(STATUS "Variable-provided version info: HASH=${GIT_HASH}")
message(STATUS "Variable-provided version info: TIMESTAMP=${GIT_TIMESTAMP}")
message(STATUS "Variable-provided version info: TAG=${GIT_TAG}")
message(STATUS "Variable-provided version info: BRANCH=${GIT_BRANCH}")
message(STATUS "Variable-provided version info: ")
else()
execute_process(
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/scripts/query_version_info.py" "--mode=cmake_version_info_tbht"
......@@ -25,12 +19,14 @@ else()
list(GET VERSION_DEFINITIONS 1 GIT_BRANCH)
list(GET VERSION_DEFINITIONS 2 GIT_HASH)
list(GET VERSION_DEFINITIONS 3 GIT_TIMESTAMP)
message(STATUS "Queried version info: HASH=${GIT_HASH}")
message(STATUS "Queried version info: TIMESTAMP=${GIT_TIMESTAMP}")
message(STATUS "Queried version info: TAG=${GIT_TAG}")
message(STATUS "Queried version info: BRANCH=${GIT_BRANCH}")
message(STATUS "Queried version info: ")
endif()
message(STATUS "HASH=${GIT_HASH}")
message(STATUS "TIMESTAMP=${GIT_TIMESTAMP}")
message(STATUS "TAG=${GIT_TAG}")
message(STATUS "BRANCH=${GIT_BRANCH}")
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/custom_variables.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/custom_variables.cmake")
endif()
......
if(DEFINED KUMIR2_CONFIGURED)
return()
endif(DEFINED KUMIR2_CONFIGURED)
set(KUMIR2_CONFIGURED 1)
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/kumir2/distribution_build_config.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/kumir2/distribution_build_config.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/kumir2/distribution_build_config.cmake")
endif()
include("${CMAKE_CURRENT_LIST_DIR}/kumir2/kumir2_common.cmake")
if(WIN32)
include("${CMAKE_CURRENT_LIST_DIR}/kumir2/kumir2_win32.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/kumir2/kumir2_win32.cmake")
elseif(APPLE)
include("${CMAKE_CURRENT_LIST_DIR}/kumir2/kumir2_apple.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/kumir2/kumir2_apple.cmake")
else()
include("${CMAKE_CURRENT_LIST_DIR}/kumir2/kumir2_linux.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/kumir2/kumir2_linux.cmake")
endif()
find_package(PythonInterp 3.2.0 REQUIRED)
include(CMakeParseArguments)
if(NOT DEFINED KUMIR2_INSTALL_PREFIX)
set(KUMIR2_INSTALL_PREFIX "/usr")
endif(NOT DEFINED KUMIR2_INSTALL_PREFIX)
set(MINIMUM_QT4_VERSION 4.8.0)
set(MINIMUM_QT5_VERSION 5.3.0)
if(NOT DEFINED USE_QT)
set(USE_QT 4)
endif(NOT DEFINED USE_QT)
#if(NOT USE_QT GREATER 4)
# message(WARNING "Support for Qt4 will be discontinued soon. Please upgrade to Qt5!")
#endif()
# Find lrelease, moc and uic tools from Qt
if(${USE_QT} GREATER 4)
# Find Qt5
find_package(Qt5 ${MINIMUM_QT5_VERSION} COMPONENTS Core Widgets REQUIRED)
set(QT_LRELEASE_EXECUTABLE "${_qt5Core_install_prefix}/bin/lrelease")
else()
# Find Qt4
set(QT_USE_QTMAIN 1)
find_package(Qt4 ${MINIMUM_QT4_VERSION} COMPONENTS QtCore REQUIRED)
include(${QT_USE_FILE})
endif()
if(DEFINED KUMIR2_DISABLED_SUBDIRS)
# message(STATUS "Explicitly disabled subdirs: ${KUMIR2_DISABLED_SUBDIRS}")
else()
......@@ -16,10 +41,6 @@ else()
endif()
endif()
if(NOT DEFINED KUMIR2_INSTALL_PREFIX)
set(KUMIR2_INSTALL_PREFIX "/usr")
endif(NOT DEFINED KUMIR2_INSTALL_PREFIX)
function(add_opt_subdirectory SUBDIR_NAME)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR_NAME})
string(FIND "${DISABLED_SUBDIRS}" "[${SUBDIR_NAME}]" SubdirDisableIndex)
......@@ -36,28 +57,11 @@ function(add_opt_subdirectory SUBDIR_NAME)
endif()
endfunction(add_opt_subdirectory)
if(NOT DEFINED USE_QT)
set(USE_QT 4)
endif(NOT DEFINED USE_QT)
#if(NOT USE_QT GREATER 4)
# message(WARNING "Support for Qt4 will be discontinued soon. Please upgrade to Qt5!")
#endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
# Find lrelease, moc and uic tools from Qt
if(${USE_QT} GREATER 4)
# Find Qt5
find_package(Qt5 ${MINIMUM_QT5_VERSION} COMPONENTS Core Widgets REQUIRED)
set(QT_LRELEASE_EXECUTABLE "${_qt5Core_install_prefix}/bin/lrelease")
else()
# Find Qt4
find_package(Qt4 4.8.0 COMPONENTS QtCore REQUIRED)
include(${QT_USE_FILE})
endif()
function(include_here)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
endfunction(include_here)
# Finds Qt modules by components name
function(kumir2_use_qt)
......@@ -66,25 +70,23 @@ function(kumir2_use_qt)
set(_QT_INCLUDES)
foreach(component ${ARGN})
if(${USE_QT} GREATER 4)
list(APPEND _QT_COMPONENTS ${component})
if(${component} MATCHES "Gui")
list(APPEND _QT_COMPONENTS "Gui" "Widgets" "PrintSupport")
else()
list(APPEND _QT_COMPONENTS ${component})
list(APPEND _QT_COMPONENTS "Widgets" "PrintSupport")
endif()
else()
list(APPEND _QT_COMPONENTS "Qt${component}")
endif()
endforeach(component)
if(${USE_QT} GREATER 4)
find_package(Qt5 ${MINIMUM_QT5_VERSION} COMPONENTS ${_QT_COMPONENTS} REQUIRED)
if(${USE_QT} GREATER 4)
find_package(Qt5 ${MINIMUM_QT5_VERSION} COMPONENTS ${_QT_COMPONENTS} QUIET REQUIRED)
foreach(component ${_QT_COMPONENTS})
include_directories(${Qt5${component}_INCLUDE_DIRS})
list(APPEND _QT_LIBRARIES ${Qt5${component}_LIBRARIES})
list(APPEND _QT_INCLUDES ${Qt5${component}_INCLUDE_DIRS})
endforeach(component)
else()
set(QT_USE_QTMAIN 1)
find_package(Qt4 4.8.0 COMPONENTS ${_QT_COMPONENTS} REQUIRED)
find_package(Qt4 ${MINIMUM_QT4_VERSION} COMPONENTS ${_QT_COMPONENTS} QUIET REQUIRED)
include(${QT_USE_FILE})
include_directories(${QT_INCLUDE_DIR})
include_directories("${QT_INCLUDE_DIR}/Qt")
......@@ -200,6 +202,7 @@ function(kumir2_copy_resources ComponentName)
endfunction(kumir2_copy_resources)
function(kumir2_add_library)
include_here()
if(KUMIR2_ROOT)
include_directories("${KUMIR2_ROOT}/include")
endif(KUMIR2_ROOT)
......@@ -227,6 +230,7 @@ function(kumir2_add_plugin)
if(KUMIR2_ROOT)
include_directories("${KUMIR2_ROOT}/include")
endif(KUMIR2_ROOT)
include_here()
cmake_parse_arguments(PARSED_ARGS "" "NAME" "SOURCES;LIBRARIES" ${ARGN})
add_library(${PARSED_ARGS_NAME} SHARED ${PARSED_ARGS_SOURCES})
if(PARSED_ARGS_LIBRARIES)
......@@ -472,8 +476,8 @@ function(kumir2_add_launcher)
endfunction(kumir2_add_launcher)
function(kumir2_add_tool)
include_here()
cmake_parse_arguments(PARSED_ARGS "" "NAME" "SOURCES;LIBRARIES;CXXFLAGS" ${ARGN})
kumir2_use_qt(Core Gui)
if(WIN32 AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PARSED_ARGS_NAME}.rc")
list(APPEND PARSED_ARGS_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/${PARSED_ARGS_NAME}.rc")
add_executable(${PARSED_ARGS_NAME} WIN32 ${PARSED_ARGS_SOURCES})
......
......@@ -47,7 +47,7 @@ set(CMAKE_INSTALL_RPATH "")
# Compile flags
set(KUMIR2_CXXFLAGS "-fno-exceptions -std=c++0x -fPIC -Wall -W ")
set(KUMIR2_CXXFLAGS_Release "-O2 -UNDEBUG")
set(KUMIR2_CXXFLAGS_RelWithDebInfo "-O2 -g1 -UNDEBUG -UQT_NO_DEBUG")
set(KUMIR2_CXXFLAGS_RelWithDebInfo "-O2 -g -UNDEBUG -UQT_NO_DEBUG")
set(KUMIR2_CXXFLAGS_Debug "-g -O1")
# Linkage flags
......
......@@ -120,7 +120,7 @@ def get_version_information(top_level_dir):
result["version"] = version_info
result["taggedRelease"] = True
eprint("get_version_information: result=", result)
#eprint("get_version_information: result=", result)
return result
......
project(Actor_Colorer)
cmake_minimum_required(VERSION 3.0)
find_package(Kumir2 REQUIRED)
#cmake_minimum_required(VERSION 3.0)
#find_package(Kumir2 REQUIRED)
kumir2_use_qt(Core Gui)
set(SOURCES _colorermodule.cpp)
set(MOC_HEADERS _colorermodule.h)
kumir2_wrap_cpp(MOC_SOURCES ${MOC_HEADERS})
kumir2_add_actor(
NAME _Colorer
SOURCES ${SOURCES} ${MOC_SOURCES}
LIBRARIES ${QT_LIBRARIES}
NAME _Colorer
SOURCES ${SOURCES} ${MOC_SOURCES}
LIBRARIES ${QT_LIBRARIES}
)
project(ActorComplexNumbers)
cmake_minimum_required(VERSION 3.0)
find_package(Kumir2 REQUIRED)
#cmake_minimum_required(VERSION 3.0)
#find_package(Kumir2 REQUIRED)
kumir2_use_qt(Core Gui)
set(SOURCES complexnumbersmodule.cpp)
......@@ -10,7 +9,7 @@ set(MOC_HEADERS complexnumbersmodule.h)
kumir2_wrap_cpp(MOC_SOURCES ${MOC_HEADERS})
kumir2_add_actor(
NAME ComplexNumbers
SOURCES ${SOURCES} ${MOC_SOURCES}
LIBRARIES ${QT_LIBRARIES} KStdlib
NAME ComplexNumbers
SOURCES ${SOURCES} ${MOC_SOURCES}
LIBRARIES ${QT_LIBRARIES} KStdlib
)
project(ActorDraw)
cmake_minimum_required(VERSION 3.0)
find_package(Kumir2 REQUIRED)
#cmake_minimum_required(VERSION 3.0)
#find_package(Kumir2 REQUIRED)
kumir2_use_qt(Core Gui Xml Svg)
set(SOURCES
drawmodule.cpp
drawmodule.cpp
)
set(MOC_HEADERS
drawmodule.h
drawmodule.h
)
kumir2_wrap_cpp(MOC_SOURCES ${MOC_HEADERS})
kumir2_add_actor(
NAME Draw
SOURCES ${SOURCES} ${MOC_SOURCES}
LIBRARIES ${QT_LIBRARIES}
NAME Draw
SOURCES ${SOURCES} ${MOC_SOURCES}
LIBRARIES ${QT_LIBRARIES}
)
add_dependencies(ActorDraw Actor_Colorer)
project(ActorGrasshopper)
cmake_minimum_required(VERSION 3.0)
find_package(Kumir2 REQUIRED)
#cmake_minimum_required(VERSION 3.0)
#find_package(Kumir2 REQUIRED)
kumir2_use_qt(Core Gui Svg)
set(SOURCES
grasshoppermodule.cpp
kuznec.cpp
pult.cpp
dialog.cpp
grasshoppermodule.cpp
kuznec.cpp
pult.cpp
dialog.cpp
)
set(MOC_HEADERS
grasshoppermodule.h
kuznec.h
dialog.h
pult.h
grasshoppermodule.h
kuznec.h
dialog.h
pult.h
)
set(FORMS
dialog.ui
pult.ui
)
dialog.ui
pult.ui
)
kumir2_wrap_cpp(MOC_SOURCES ${MOC_HEADERS})
kumir2_wrap_ui(UI_SOURCES ${FORMS})
kumir2_add_actor(
NAME Grasshopper
SOURCES ${SOURCES} ${MOC_SOURCES} ${UI_SOURCES}
LIBRARIES ${QT_LIBRARIES}
NAME Grasshopper
SOURCES ${SOURCES} ${MOC_SOURCES} ${UI_SOURCES}
LIBRARIES ${QT_LIBRARIES}
)
project(ActorIsometricRobot)
cmake_minimum_required(VERSION 3.0)
find_package(Kumir2 REQUIRED)
#cmake_minimum_required(VERSION 3.0)
#find_package(Kumir2 REQUIRED)
kumir2_use_qt(Core Gui Svg Script Xml)
set(SOURCES
isometricrobotmodule.cpp
robotview.cpp
util.cpp
sch_task.cpp
sch_program.cpp
sch_game.cpp
sch_environment.cpp
sch_command.cpp
sch_algorithm.cpp
cellgraphicsitem.cpp
graphicsimageitem.cpp
robot25dwindow.cpp
robotitem.cpp
remotecontrol.cpp
robotmodel.cpp
isometricrobotmodule.cpp
robotview.cpp
util.cpp
sch_task.cpp
sch_program.cpp
sch_game.cpp
sch_environment.cpp
sch_command.cpp
sch_algorithm.cpp
cellgraphicsitem.cpp
graphicsimageitem.cpp
robot25dwindow.cpp
robotitem.cpp
remotecontrol.cpp
robotmodel.cpp
)
set(MOC_HEADERS
isometricrobotmodule.h
robotview.h
robot25dwindow.h
robotitem.h
remotecontrol.h
robotmodel.h
isometricrobotmodule.h
robotview.h
robot25dwindow.h
robotitem.h
remotecontrol.h
robotmodel.h
)
set(FORMS
robot25dwindow.ui
robot25dwindow.ui
)
kumir2_wrap_cpp(MOC_SOURCES ${MOC_HEADERS})
kumir2_wrap_ui(UI_SOURCES ${FORMS})
kumir2_add_actor(
NAME IsometricRobot
SOURCES ${SOURCES} ${MOC_SOURCES}
LIBRARIES ${QT_LIBRARIES}
NAME IsometricRobot
SOURCES ${SOURCES} ${MOC_SOURCES}
LIBRARIES ${QT_LIBRARIES}
)
project(ActorKeyboard)
cmake_minimum_required(VERSION 3.0)
find_package(Kumir2 REQUIRED)
#cmake_minimum_required(VERSION 3.0)
#find_package(Kumir2 REQUIRED)
kumir2_use_qt(Core Gui)
set(SOURCES
keyboardmodule.cpp
keyboardmodule.cpp
)
set(MOC_HEADERS
keyboardmodule.h
keyboardmodule.h
)
kumir2_wrap_cpp(MOC_SOURCES ${MOC_HEADERS})
kumir2_add_actor(
NAME Keyboard
SOURCES ${SOURCES} ${MOC_SOURCES}
LIBRARIES ${QT_LIBRARIES}
NAME Keyboard
SOURCES ${SOURCES} ${MOC_SOURCES}
LIBRARIES ${QT_LIBRARIES}
)
project(ActorPainter)
cmake_minimum_required(VERSION 3.0)
find_package(Kumir2 REQUIRED)
#cmake_minimum_required(VERSION 3.0)
#find_package(Kumir2 REQUIRED)
kumir2_use_qt(Core Gui)
set(SOURCES
paintermodule.cpp
painternewimagedialog.cpp
painterruler.cpp
paintertools.cpp
painterview.cpp
painterwindow.cpp
scrollarea.cpp
paintermodule.cpp
painternewimagedialog.cpp
painterruler.cpp
paintertools.cpp
painterview.cpp
painterwindow.cpp
scrollarea.cpp
)
set(MOC_HEADERS
paintermodule.h
painternewimagedialog.h
painterruler.h
painterview.h
painterwindow.h
scrollarea.h
paintermodule.h
painternewimagedialog.h
painterruler.h
painterview.h
painterwindow.h
scrollarea.h
)
set(FORMS
painternewimagedialog.ui
painterwindow.ui
painternewimagedialog.ui
painterwindow.ui
)
kumir2_wrap_cpp(MOC_SOURCES ${MOC_HEADERS})
kumir2_wrap_ui(UI_SOURCES ${FORMS})
kumir2_add_actor(
NAME Painter
SOURCES ${SOURCES} ${MOC_SOURCES} ${UI_SOURCES}
LIBRARIES ${QT_LIBRARIES}
NAME Painter
SOURCES ${SOURCES} ${MOC_SOURCES} ${UI_SOURCES}
LIBRARIES ${QT_LIBRARIES}
)
add_dependencies(ActorPainter Actor_Colorer)
project(ActorRobot)
cmake_minimum_required(VERSION 3.0)
find_package(Kumir2 REQUIRED)
#cmake_minimum_required(VERSION 3.0)
#find_package(Kumir2 REQUIRED)
kumir2_use_qt(Core Gui)
set(SOURCES
......@@ -31,7 +30,7 @@ kumir2_wrap_cpp(MOC_SOURCES ${MOC_HEADERS})
kumir2_wrap_ui(UI_SOURCES ${FORMS})
kumir2_add_actor(
NAME Robot
SOURCES ${SOURCES} ${MOC_SOURCES} ${UI_SOURCES}
LIBRARIES ${QT_LIBRARIES}
NAME Robot
SOURCES ${SOURCES} ${MOC_SOURCES} ${UI_SOURCES}
LIBRARIES ${QT_LIBRARIES}
)
project(ActorTurtle)
cmake_minimum_required(VERSION 3.0)
find_package(Kumir2 REQUIRED)
#cmake_minimum_required(VERSION 3.0)
#find_package(Kumir2 REQUIRED)
kumir2_use_qt(Core Gui Svg)
set(SOURCES
turtlemodule.cpp
turtle.cpp
pult.cpp
turtlemodule.cpp
turtle.cpp
pult.cpp
)
set(FORMS
pult.ui
)
pult.ui
)
set(MOC_HEADERS
turtlemodule.h
turtle.h
pult.h
turtlemodule.h
turtle.h
pult.h
)
......@@ -25,9 +24,9 @@ kumir2_wrap_cpp(MOC_SOURCES ${MOC_HEADERS})
kumir2_wrap_ui(UI_SOURCES ${FORMS})
kumir2_add_actor(
NAME Turtle
SOURCES ${SOURCES} ${MOC_SOURCES} ${UI_SOURCES}
LIBRARIES ${QT_LIBRARIES}
NAME Turtle
SOURCES ${SOURCES} ${MOC_SOURCES} ${UI_SOURCES}
LIBRARIES ${QT_LIBRARIES}
)
add_dependencies(ActorTurtle Actor_Colorer)
project(ActorVodoley)
cmake_minimum_required(VERSION 3.0)
find_package(Kumir2 REQUIRED)
#cmake_minimum_required(VERSION 3.0)
#find_package(Kumir2 REQUIRED)
kumir2_use_qt(Core Gui)
set(SOURCES
vodoleymodule.cpp
vodoley.cpp
pult.cpp
dialog.cpp
vodoleymodule.cpp
vodoley.cpp
pult.cpp
dialog.cpp
)
set(MOC_HEADERS
vodoleymodule.h
vodoley.h
pult.h
dialog.h
vodoleymodule.h
vodoley.h
pult.h
dialog.h
)
set(FORMS
dialog.ui
pult.ui
)