Commit d7b46f87 authored by Victor Yacovlev's avatar Victor Yacovlev

CMake rework: Work done for Linux

parent 023ffda5

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
project(Kumir2)
cmake_minimum_required(VERSION 3.0)
if(EXISTS custom_variables.cmake)
include(custom_variables.cmake)
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/custom_variables.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/custom_variables.cmake")
endif()
include(kumir2_common.cmake)
if(WIN32)
include(kumir2_win32.cmake)
elseif(APPLE)
include(kumir2_apple.cmake)
else()
include(kumir2_linux.cmake)
endif()
set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/cmake")
find_package(Kumir2 REQUIRED)
include_directories("${CMAKE_SOURCE_DIR}/include")
include_directories("${CMAKE_SOURCE_DIR}/src")
if(WIN32)
......@@ -41,49 +37,59 @@ else()
endif()
add_definitions(-DIDE_LIBRARY_BASENAME="${LIB_BASENAME}")
set(PLUGIN_OUTPUT_PATH
${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${PLUGINS_DIR}
)
set(SHARE_PATH ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${RESOURCES_DIR})
set(LIBRARY_OUTPUT_PATH
${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${LIBS_DIR}
)
set(EXECUTABLE_OUTPUT_PATH
${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${EXEC_DIR}
)
set(LIBEXECS_PATH ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${LIBEXECS_DIR})
add_subdirectory(src)
add_subdirectory(userdocs)
add_subdirectory(share/kumir2/courses)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/share/applications)
file(GLOB_RECURSE icons RELATIVE ${CMAKE_SOURCE_DIR}/app_icons/linux ${CMAKE_SOURCE_DIR}/app_icons/linux/*)
foreach(icon IN ITEMS ${icons})
get_filename_component(subdir ${icon} PATH)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/share/icons/${subdir})
file(COPY ${CMAKE_SOURCE_DIR}/app_icons/linux/${icon} DESTINATION ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/share/icons/${subdir})
install(FILES ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/share/icons/${icon} DESTINATION share/icons/${subdir})
endforeach(icon)
# TODO move into python subproject CMakeLists.txt
if(EXISTS ${CMAKE_SOURCE_DIR}/kumir2-python.desktop)
file(COPY ${CMAKE_SOURCE_DIR}/kumir2-python.desktop DESTINATION ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/share/applications)
install(FILES ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/share/applications/kumir2-python.desktop DESTINATION share/applications)
endif()
# Copy and create install targets for top-level resources
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${KUMIR2_RESOURCES_DIR}/userdocs")
file(GLOB_RECURSE resfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/userdocs ${CMAKE_CURRENT_SOURCE_DIR}/userdocs/*)
foreach(res IN ITEMS ${resfiles})
if(NOT ${res} MATCHES ^[.].*)
get_filename_component(subdir ${res} PATH)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${KUMIR2_RESOURCES_DIR}/userdocs/${subdir}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/userdocs/${res}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/${KUMIR2_RESOURCES_DIR}/userdocs/${subdir}")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/userdocs/${res}" DESTINATION "${KUMIR2_RESOURCES_DIR}/userdocs/${subdir}")
endif()
endforeach(res)
# TODO move the code to function and reuse it
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${KUMIR2_RESOURCES_DIR}/courses")
file(GLOB_RECURSE resfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/courses ${CMAKE_CURRENT_SOURCE_DIR}/courses/*)
foreach(res IN ITEMS ${resfiles})
if(NOT ${res} MATCHES ^[.].*)
get_filename_component(subdir ${res} PATH)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${KUMIR2_RESOURCES_DIR}/courses/${subdir}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/courses/${res}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/${KUMIR2_RESOURCES_DIR}/courses/${subdir}")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/courses/${res}" DESTINATION "${KUMIR2_RESOURCES_DIR}/courses/${subdir}")
endif()
endforeach(res)
file(MAKE_DIRECTORY ${SHARE_PATH}/icons)
file(GLOB_RECURSE icons RELATIVE ${CMAKE_SOURCE_DIR}/share/kumir2/icons ${CMAKE_SOURCE_DIR}/share/kumir2/icons/*)
foreach(icon IN ITEMS ${icons})
get_filename_component(subdir ${icon} PATH)
file(MAKE_DIRECTORY ${SHARE_PATH}/icons/${subdir})
file(COPY ${CMAKE_SOURCE_DIR}/share/kumir2/icons/${icon} DESTINATION ${SHARE_PATH}/icons/${subdir})
install(FILES ${SHARE_PATH}/icons/${icon} DESTINATION ${RESOURCES_DIR}/icons/${subdir})
endforeach(icon)
if(WIN32)
# Do nothing
elseif(APPLE)
# TODO Make package-related stuff
else()
# Create XDG-compliant filesystem structure for applciations and icons
# Application icons
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${KUMIR2_XDG_ICONS_DIR}")
file(GLOB_RECURSE icons RELATIVE ${CMAKE_SOURCE_DIR}/app_icons/linux ${CMAKE_SOURCE_DIR}/app_icons/linux/*)
foreach(icon IN ITEMS ${icons})
get_filename_component(subdir ${icon} PATH)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${KUMIR2_XDG_ICONS_DIR}/${subdir}")
file(COPY "${CMAKE_SOURCE_DIR}/app_icons/linux/${icon}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/${KUMIR2_XDG_ICONS_DIR}/${subdir}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${KUMIR2_XDG_ICONS_DIR}/${icon}" DESTINATION "${KUMIR2_XDG_ICONS_DIR}/${subdir}")
endforeach(icon)
# In-app icons
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${KUMIR2_RESOURCES_DIR}/icons")
file(GLOB_RECURSE icons RELATIVE ${CMAKE_SOURCE_DIR}/share/kumir2/icons ${CMAKE_SOURCE_DIR}/share/kumir2/icons/*)
foreach(icon IN ITEMS ${icons})
get_filename_component(subdir ${icon} PATH)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${KUMIR2_RESOURCES_DIR}/icons/${subdir}")
file(COPY "${CMAKE_SOURCE_DIR}/share/kumir2/icons/${icon}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/${KUMIR2_RESOURCES_DIR}/icons/${subdir}")
install(FILES "${CMAKE_SOURCE_DIR}/${KUMIR2_RESOURCES_DIR}/icons/${icon}" DESTINATION "${KUMIR2_RESOURCES_DIR}/icons/${subdir}")
endforeach(icon)
endif()
if(EXISTS "${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")
elseif(APPLE)
include("${CMAKE_CURRENT_LIST_DIR}/kumir2/kumir2_apple.cmake")
else()
include("${CMAKE_CURRENT_LIST_DIR}/kumir2/kumir2_linux.cmake")