Skip to content

Commit

Permalink
tom cmake added info about LTO to about command
Browse files Browse the repository at this point in the history
  • Loading branch information
silverqx committed Jun 3, 2024
1 parent b10f3c8 commit 7c12276
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ if(TOM)
if(BUILD_TESTS)
target_compile_definitions(${TinyOrm_target} PUBLIC TINYTOM_TESTS_CODE)
endif()

# Set TINYORM_LTO macro based on the INTERPROCEDURAL_OPTIMIZATION target property
tiny_set_lto_compile_definition(${TinyOrm_target})
endif()

if(TOM_EXAMPLE)
Expand Down
10 changes: 10 additions & 0 deletions cmake/CommonModules/TinyHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ ${TINY_UNPARSED_ARGUMENTS}")

endfunction()

# Set TINYORM_LTO macro based on the INTERPROCEDURAL_OPTIMIZATION target property
# Used by the tom about command to show if the LTO is enabled
function(tiny_set_lto_compile_definition target)

get_target_property(tinyHasLTO ${target} INTERPROCEDURAL_OPTIMIZATION)

target_compile_definitions(${target} PRIVATE -DTINYORM_LTO=${tinyHasLTO})

endfunction()

# Create an empty SQLite database file if it does not exist
function(tiny_create_sqlite_db db_filepath)

Expand Down
4 changes: 4 additions & 0 deletions src/orm/libraryinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ std::map<QString, QString> LibraryInfo::ormCMacrosMap()
#else
{sl("TINYORM_INLINE_CONSTANTS"), OFF},
#endif
// CMake ON/OFF
#ifdef TINYORM_LTO
{sl("TINYORM_LTO"), TINY_CMAKE_BOOL(TINYORM_LTO)},
#endif
#ifdef TINYORM_MYSQL_PING
{sl("TINYORM_MYSQL_PING"), ON},
#else
Expand Down
6 changes: 5 additions & 1 deletion tom/src/tom/commands/aboutcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ QVector<SectionItem> AboutCommand::gatherAllAboutInformation() const
};
}

#ifdef TINYORM_MSVC_RUNTIME_DYNAMIC
#if defined(TINYORM_MSVC_RUNTIME_DYNAMIC) || defined(TINYORM_LTO)
using Orm::Constants::OFF;
using Orm::Constants::ON;

Expand Down Expand Up @@ -331,6 +331,10 @@ QVector<SubSectionItem> AboutCommand::gatherEnvironmentInformation() const
{sl("Link type"), "Static"},
#endif
// CMake ON/OFF
// qmake has bad support for ltcg so it's not handled in qmake (don't do it in future)
#ifdef TINYORM_LTO
{sl("Link Time Optimization"), TINY_CMAKE_BOOL(TINYORM_LTO)},
#endif
#ifdef TINYORM_MSVC_RUNTIME_DYNAMIC
{sl("MSVC Runtime dynamic"),
TINY_CMAKE_BOOL(TINYORM_MSVC_RUNTIME_DYNAMIC)},
Expand Down

0 comments on commit 7c12276

Please sign in to comment.