Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-22 13:58:55 +01:00
parent 4af19165ec
commit 68073add76
12458 changed files with 12350765 additions and 2 deletions

72
cmake/OmimConfig.cmake Normal file
View file

@ -0,0 +1,72 @@
# Flags for all
set(OMIM_WARNING_FLAGS
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-unused-parameter> # We have a lot of functions with unused parameters
)
set(3PARTY_INCLUDE_DIRS "${OMIM_ROOT}/3party/boost")
set(OMIM_DATA_DIR "${OMIM_ROOT}/data")
set(OMIM_USER_RESOURCES_DIR "${OMIM_ROOT}/data")
# GCC 10.0 is required to support <charconv> header inclusion in base/string_utils.hpp
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0)
message(FATAL_ERROR "Minimum supported g++ version is 10.0, yours is ${CMAKE_CXX_COMPILER_VERSION}")
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(PCH_EXTENSION "pch")
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(PCH_EXTENSION "gch")
endif()
if (NJOBS)
message(STATUS "Number of parallel processes: ${NJOBS}")
set(CMAKE_JOB_POOLS custom=${NJOBS})
set(CMAKE_JOB_POOL_COMPILE custom)
set(CMAKE_JOB_POOL_LINK custom)
set(CMAKE_JOB_POOL_PRECOMPILE_HEADER custom)
endif()
if (USE_ASAN AND USE_TSAN)
message(FATAL_ERROR "Can't use asan and tsan sanitizers together")
elseif (USE_ASAN)
message(STATUS "Address Sanitizer is enabled")
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
elseif (USE_TSAN)
message(STATUS "Thread Sanitizer is enabled")
add_compile_options(-fsanitize=thread -fno-omit-frame-pointer)
endif()
if (USE_LIBFUZZER)
message(STATUS "LibFuzzer is enabled")
add_compile_options(-fsanitize=fuzzer)
endif()
if (USE_PPROF)
message(STATUS "Google Profiler is enabled")
add_definitions(-DUSE_PPROF)
endif()
if (USE_HEAPPROF)
message(STATUS "Heap Profiler is enabled")
endif()
if (ENABLE_VULKAN_DIAGNOSTICS)
message(WARNING "Vulkan diagnostics are enabled. Be aware of performance impact!")
add_definitions(-DENABLE_VULKAN_DIAGNOSTICS)
endif()
if (ENABLE_TRACE)
message(STATUS "Tracing is enabled")
add_definitions(-DENABLE_TRACE)
endif()
if (BUILD_DESIGNER)
message(STATUS "Designer tool building is enabled")
add_definitions(-DBUILD_DESIGNER)
endif()
if (BUILD_STANDALONE)
message(STATUS "Standalone building is enabled")
endif()

41
cmake/OmimCoverage.cmake Normal file
View file

@ -0,0 +1,41 @@
add_compile_options(-O0 --coverage)
add_link_options(--coverage)
set(COVERAGE_REPORT_DIR ${CMAKE_BINARY_DIR}/coverage_report)
find_program(GCOVR_EXECUTABLE_PATH gcovr)
if (NOT GCOVR_EXECUTABLE_PATH)
message(FATAL_ERROR "'gcovr' is required to generate test coverage report. Details: gcovr.com.")
endif ()
if (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU|AppleClang")
set(GCOV_EXECUTABLE "gcov")
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
set(GCOV_EXECUTABLE "llvm-cov")
endif ()
find_program(GCOV_EXECUTABLE_PATH ${GCOV_EXECUTABLE})
if (NOT GCOV_EXECUTABLE_PATH)
message(FATAL_ERROR "'${GCOV_EXECUTABLE}' is required to generate test coverage report.")
endif ()
if (${GCOV_EXECUTABLE_PATH} MATCHES "llvm-cov")
set(GCOV_EXECUTABLE_PATH "${GCOV_EXECUTABLE_PATH} gcov")
endif ()
add_custom_target(omim_coverage
# Remove harfbuzz.cc.* files because they reference .rl files that do not exist and cannot be excluded by gcovr.
COMMAND rm -f ${CMAKE_BINARY_DIR}/3party/harfbuzz/CMakeFiles/harfbuzz.dir/harfbuzz/src/harfbuzz.cc.*
# Recreate coverage_report folder
COMMAND rm -rf ${COVERAGE_REPORT_DIR} && mkdir ${COVERAGE_REPORT_DIR}
# Run gcovr
COMMAND ${GCOVR_EXECUTABLE_PATH}
--config=${OMIM_ROOT}/gcovr.cfg
--root=${OMIM_ROOT}
--object-directory=${CMAKE_BINARY_DIR}
--exclude=${CMAKE_BINARY_DIR} # Exclude autogenerated files from Qt and some 3party libraries.
--gcov-executable=${GCOV_EXECUTABLE_PATH}
--html-nested=${COVERAGE_REPORT_DIR}/html/ >> ${COVERAGE_REPORT_DIR}/summary.txt
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating coverage report..."
)

227
cmake/OmimHelpers.cmake Normal file
View file

@ -0,0 +1,227 @@
# Functions for using in subdirectories
function(omim_add_executable executable)
add_executable(${executable} ${ARGN})
if (PLATFORM_WIN)
target_sources(${executable} PRIVATE "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/windows/OrganicMaps.manifest")
endif()
# Enable warnings for all our binaries.
target_compile_options(${executable} PRIVATE ${OMIM_WARNING_FLAGS})
target_include_directories(${executable} SYSTEM PRIVATE ${3PARTY_INCLUDE_DIRS})
if (USE_ASAN)
target_link_libraries(${executable}
-fsanitize=address
-fno-omit-frame-pointer
)
endif()
if (USE_TSAN)
target_link_libraries(${executable}
-fsanitize=thread
-fno-omit-frame-pointer
)
endif()
if (USE_LIBFUZZER)
target_link_libraries(${executable} -fsanitize=fuzzer)
endif()
if (USE_PPROF)
if (PLATFORM_MAC)
find_library(PPROF_LIBRARY libprofiler.dylib)
target_link_libraries(${executable} ${PPROF_LIBRARY})
else()
target_link_libraries(${executable} -lprofiler)
endif()
endif()
if (USE_HEAPPROF)
if (PLATFORM_MAC)
find_library(HEAPPROF_LIBRARY libtcmalloc.dylib)
if (NOT HEAPPROF_LIBRARY)
message(FATAL_ERROR
"Trying to use -ltcmalloc on MacOS, make sure that you have installed it (https://github.com/mapsme/omim/pull/12671).")
endif()
target_link_libraries(${executable} ${HEAPPROF_LIBRARY})
else()
target_link_libraries(${executable} -ltcmalloc)
endif()
endif()
if (USE_PCH)
add_precompiled_headers_to_target(${executable} ${OMIM_PCH_TARGET_NAME})
endif()
endfunction()
function(omim_add_library library)
add_library(${library} ${ARGN})
# Enable warnings for all our libraries.
target_compile_options(${library} PRIVATE ${OMIM_WARNING_FLAGS})
target_include_directories(${library} SYSTEM PRIVATE ${3PARTY_INCLUDE_DIRS})
if (USE_PPROF AND PLATFORM_MAC)
find_path(PPROF_INCLUDE_DIR NAMES gperftools/profiler.h)
target_include_directories(${library} SYSTEM PUBLIC ${PPROF_INCLUDE_DIR})
endif()
if (USE_PCH)
add_precompiled_headers_to_target(${library} ${OMIM_PCH_TARGET_NAME})
endif()
endfunction()
function(omim_add_tool_subdirectory subdir)
if (NOT SKIP_TOOLS)
add_subdirectory(${subdir})
else()
message("SKIP_TOOLS: Skipping subdirectory ${subdir}")
endif()
endfunction()
function(omim_add_pybindings_subdirectory subdir)
if (PYBINDINGS)
add_subdirectory(${subdir})
else()
message("Skipping pybindings subdirectory ${subdir}")
endif()
endfunction()
function(omim_link_libraries target)
if (TARGET ${target})
target_link_libraries(${target} ${ARGN} ${CMAKE_THREAD_LIBS_INIT})
else()
message("~> Skipping linking the libraries to the target ${target} as it"
" does not exist")
endif()
endfunction()
function(append VAR)
set(${VAR} ${${VAR}} ${ARGN} PARENT_SCOPE)
endfunction()
function(export_directory_flags filename)
get_directory_property(include_directories INCLUDE_DIRECTORIES)
get_directory_property(definitions COMPILE_DEFINITIONS)
get_directory_property(flags COMPILE_FLAGS)
get_directory_property(options COMPILE_OPTIONS)
if (PLATFORM_ANDROID)
set(
include_directories
${include_directories}
${CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES}
)
set(
platform_flags
"${ANDROID_COMPILER_FLAGS} ${ANDROID_COMPILER_FLAGS_CXX}"
)
set(
flags
"--target=${CMAKE_C_COMPILER_TARGET}"
"--sysroot=${CMAKE_SYSROOT}" ${flags}
)
endif()
# Append Release/Debug flags:
string(TOUPPER "${CMAKE_BUILD_TYPE}" upper_build_type)
set(flags ${flags} ${CMAKE_CXX_FLAGS_${upper_build_type}})
set(
include_directories
"$<$<BOOL:${include_directories}>\:-I$<JOIN:${include_directories},\n-I>\n>"
)
set(definitions "$<$<BOOL:${definitions}>:-D$<JOIN:${definitions},\n-D>\n>")
set(flags "$<$<BOOL:${flags}>:$<JOIN:${flags},\n>\n>")
set(options "$<$<BOOL:${options}>:$<JOIN:${options},\n>\n>")
file(
GENERATE OUTPUT
${filename}
CONTENT
"${definitions}${include_directories}${platform_flags}\n${flags}${options}\n"
)
endfunction()
function(add_pic_pch_target header pch_target_name
pch_file_name suffix pic_flag)
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/pch_${suffix}")
file(COPY "${header}" DESTINATION "${CMAKE_BINARY_DIR}/pch_${suffix}")
set(_header "${CMAKE_BINARY_DIR}/pch_${suffix}/${pch_file_name}")
set(
_compiled_header
"${CMAKE_BINARY_DIR}/pch_${suffix}/${pch_file_name}.${PCH_EXTENSION}"
)
add_custom_target(
"${pch_target_name}_${suffix}"
COMMAND
"${CMAKE_CXX_COMPILER}" ${compiler_flags} ${c_standard_flags} ${pic_flag}
-x c++-header
-c "${_header}" -o "${_compiled_header}"
COMMENT "Building precompiled omim CXX ${suffix} header"
)
endfunction()
function(add_precompiled_headers header pch_target_name)
set(pch_flags_file "${CMAKE_BINARY_DIR}/${pch_target_name}_flags_file")
export_directory_flags("${pch_flags_file}")
set(compiler_flags "@${pch_flags_file}")
# CMAKE_CXX_STANDARD 23 flags:
set(c_standard_flags "-std=c++23")
get_filename_component(pch_file_name ${header} NAME)
add_pic_pch_target(${header} ${pch_target_name} ${pch_file_name} lib "-fPIC")
add_pic_pch_target(${header} ${pch_target_name} ${pch_file_name} exe "-fPIE")
add_custom_target(
"${pch_target_name}"
COMMENT "Waiting for both lib and exe precompiled headers to build"
DEPENDS "${pch_target_name}_lib" "${pch_target_name}_exe"
)
set_target_properties(
${pch_target_name}
PROPERTIES
PCH_NAME
"${pch_file_name}"
)
endfunction()
function(add_precompiled_headers_to_target target pch_target)
add_dependencies(${target} "${pch_target}")
get_property(sources TARGET ${target} PROPERTY SOURCES)
get_target_property(target_type ${target} TYPE)
get_target_property(pch_file_name ${pch_target} PCH_NAME)
if (target_type STREQUAL "EXECUTABLE")
set(include_compiled_header_dir "${CMAKE_BINARY_DIR}/pch_exe")
# CMake automatically adds additional compile options after linking.
# For example '-fPIC' flag on skin_generator_tool, because it is linked to Qt libs.
# We force correct flag for executables.
set(additional_clang_flags "-fPIE")
endif()
if (target_type MATCHES "LIBRARY")
set(include_compiled_header_dir "${CMAKE_BINARY_DIR}/pch_lib")
endif()
# Force gcc first search gch header in pch_exe/pch_lib:
target_include_directories(${target}
BEFORE
PUBLIC
${include_compiled_header_dir}
)
foreach(source ${sources})
if(source MATCHES \\.\(cc|cpp|h|hpp\)$)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set_source_files_properties(
${source}
PROPERTIES
COMPILE_FLAGS
"${additional_clang_flags} -include-pch \
${include_compiled_header_dir}/${pch_file_name}.${PCH_EXTENSION}"
)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set_source_files_properties(
${source}
PROPERTIES
COMPILE_FLAGS "-include ${pch_file_name}"
)
endif()
endif()
endforeach()
endfunction()

26
cmake/OmimOptions.cmake Normal file
View file

@ -0,0 +1,26 @@
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif ()
option(CMAKE_UNITY_BUILD "Use unity build" ON)
if (DEFINED ENV{CMAKE_UNITY_BUILD})
set(CMAKE_UNITY_BUILD $ENV{CMAKE_UNITY_BUILD})
endif ()
set(CMAKE_UNITY_BUILD_BATCH_SIZE "24" CACHE STRING "Batch size for unity build")
option(USE_CCACHE "Use ccache" ON)
option(WITH_SYSTEM_PROVIDED_3PARTY "Enable compilation with system provided dependencies" OFF)
option(BUILD_DESIGNER "Build application as design tool" OFF)
option(BUILD_STANDALONE "Build standalone application" OFF)
option(USE_ASAN "Enable Address Sanitizer" OFF)
option(USE_TSAN "Enable Thread Sanitizer" OFF)
option(USE_LIBFUZZER "Enable LibFuzzer" OFF)
option(USE_HEAPPROF "Enable heap profiler" OFF)
option(PYBINDINGS "Create makefiles for building python bindings" OFF)
option(SKIP_QT_GUI "Skip building of Qt GUI" OFF)
option(USE_PCH "Use precompiled headers" OFF)
option(NJOBS "Number of parallel processes" OFF)
option(ENABLE_VULKAN_DIAGNOSTICS "Enable Vulkan diagnostics" OFF)
option(ENABLE_TRACE "Enable Tracing" OFF)
option(USE_PPROF "Enable Google Profiler" OFF)
option(COVERAGE_REPORT "Configure for coverage report" OFF)

23
cmake/OmimPlatform.cmake Normal file
View file

@ -0,0 +1,23 @@
set(PLATFORM_LINUX FALSE)
set(PLATFORM_MAC FALSE)
set(PLATFORM_WIN FALSE)
set(PLATFORM_ANDROID FALSE)
set(PLATFORM_IPHONE FALSE)
set(PLATFORM_DESKTOP FALSE)
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(PLATFORM_LINUX TRUE)
set(PLATFORM_DESKTOP TRUE)
elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(PLATFORM_MAC TRUE)
set(PLATFORM_DESKTOP TRUE)
elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
set(PLATFORM_WIN TRUE)
set(PLATFORM_DESKTOP TRUE)
elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
set(PLATFORM_ANDROID TRUE)
elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "iOS")
set(PLATFORM_IPHONE TRUE)
else ()
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
endif ()

91
cmake/OmimTesting.cmake Normal file
View file

@ -0,0 +1,91 @@
# Tests read files from a data directory.
if (NOT SKIP_TESTS)
if (NOT IS_DIRECTORY ${CMAKE_BINARY_DIR}/data AND NOT IS_SYMLINK ${CMAKE_BINARY_DIR}/data)
file(CREATE_LINK ${OMIM_ROOT}/data ${CMAKE_BINARY_DIR}/data SYMBOLIC)
endif()
endif()
# TestServer fixture configuration
add_test(
NAME OmimStartTestServer
COMMAND start_server.py
WORKING_DIRECTORY ${OMIM_ROOT}/tools/python/test_server
)
add_test(
NAME OmimStopTestServer
COMMAND stop_server.py
WORKING_DIRECTORY ${OMIM_ROOT}/tools/python/test_server
)
set_tests_properties(OmimStartTestServer PROPERTIES FIXTURES_SETUP TestServer)
set_tests_properties(OmimStopTestServer PROPERTIES FIXTURES_CLEANUP TestServer)
set_tests_properties(OmimStartTestServer OmimStopTestServer PROPERTIES LABELS "omim-fixture")
# Options:
# * REQUIRE_QT - requires QT event loop
# * REQUIRE_SERVER - requires test server (TestServer fixture that runs testserver.py)
# * NO_PLATFORM_INIT - test doesn't require platform dependencies
# * BOOST_TEST - test is written with Boost.Test
function(omim_add_test name)
if (SKIP_TESTS)
return()
endif()
set(options REQUIRE_QT REQUIRE_SERVER NO_PLATFORM_INIT BOOST_TEST)
cmake_parse_arguments(TEST "${options}" "" "" ${ARGN})
set(TEST_NAME ${name})
set(TEST_SRC ${TEST_UNPARSED_ARGUMENTS})
omim_add_test_target(${TEST_NAME} "${TEST_SRC}" ${TEST_NO_PLATFORM_INIT} ${TEST_REQUIRE_QT} ${TEST_BOOST_TEST})
omim_add_ctest(${TEST_NAME} ${TEST_REQUIRE_SERVER} ${TEST_BOOST_TEST})
endfunction()
function(omim_add_test_subdirectory subdir)
if (NOT SKIP_TESTS)
add_subdirectory(${subdir})
else()
message(STATUS "SKIP_TESTS: Skipping subdirectory ${subdir}")
endif()
endfunction()
function(omim_add_test_target name src no_platform_init require_qt boost_test)
omim_add_executable(${name}
${src}
$<$<NOT:$<BOOL:${boost_test}>>:${OMIM_ROOT}/libs/testing/testingmain.cpp>
)
target_compile_options(${name} PRIVATE ${OMIM_WARNING_FLAGS})
target_include_directories(${name} PRIVATE ${OMIM_INCLUDE_DIRS})
if(no_platform_init)
target_compile_definitions(${name} PRIVATE OMIM_UNIT_TEST_DISABLE_PLATFORM_INIT)
else()
target_link_libraries(${name} platform)
endif()
if(require_qt)
target_compile_definitions(${name} PRIVATE OMIM_UNIT_TEST_WITH_QT_EVENT_LOOP)
target_link_libraries(${name} Qt6::Widgets)
endif()
if (NOT boost_test)
# testingmain.cpp uses base::HighResTimer::ElapsedNano
target_link_libraries(${name} base)
endif()
endfunction()
function(omim_add_ctest name require_server boost_test)
if (NOT boost_test)
set(test_command ${name} --data_path=${OMIM_DATA_DIR} --user_resource_path=${OMIM_USER_RESOURCES_DIR})
else()
set(test_command ${name})
endif()
add_test(
NAME ${name}
COMMAND ${test_command}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
if (require_server)
set_tests_properties(${name} PROPERTIES FIXTURES_REQUIRED TestServer)
endif()
set_tests_properties(${name} PROPERTIES LABELS "omim-test")
endfunction()

View file

@ -0,0 +1,26 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<assemblyIdentity
name="org.organicmaps.organicmaps"
version="1.0.0.0"
processorArchitecture="*"
type="win32"
/>
<!-- Declare support for various versions of Windows -->
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 and Windows 11 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<!-- Force the current process to use UTF-8 as the process code page -->
<activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
<!-- Enable long paths that exceed MAX_PATH in length -->
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
</assembly>