Skip to content

Commit

Permalink
Merge branch 'refactor/config.h' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
HuguesDelorme committed Mar 7, 2024
2 parents 74c5873 + c9dd206 commit be1087f
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 24 deletions.
23 changes: 15 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ if(Git_FOUND)
endif()
endif()

configure_file(${PROJECT_SOURCE_DIR}/src/app/version.h.cmake app/version.h @ONLY)

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

# Find bit size of the target machine
Expand Down Expand Up @@ -204,7 +202,7 @@ set(
Mayo_IncludeDirectories
src/app
src/3rdparty
${CMAKE_BINARY_DIR}/app
${CMAKE_BINARY_DIR}
)

##########
Expand Down Expand Up @@ -276,7 +274,7 @@ if(Mayo_BuildTests)
list(APPEND Mayo_HeaderFiles ${MayoTests_HeaderFiles})
list(APPEND Mayo_SourceFiles ${MayoTests_SourceFiles})

list(APPEND Mayo_CompileDefinitions MAYO_WITH_TESTS)
set(MAYO_WITH_TESTS 1)
list(APPEND Mayo_LinkLibraries Qt${QT_VERSION_MAJOR}::Test)

file(GLOB MayoTests_InputFiles ${PROJECT_SOURCE_DIR}/tests/inputs/*.*)
Expand Down Expand Up @@ -426,12 +424,13 @@ if(assimp_FOUND)
list(APPEND Mayo_SourceFiles ${MayoPluginAssimp_SourceFiles})

list(APPEND Mayo_LinkLibraries ${ASSIMP_LIBRARIES})
list(APPEND Mayo_CompileDefinitions HAVE_ASSIMP)
set(MAYO_HAVE_ASSIMP 1)

list(GET ASSIMP_INCLUDE_DIRS 0 assimp_IncludeDir)
file(READ "${assimp_IncludeDir}/assimp/version.h" assimp_FileVersionH)
if(NOT assimp_FileVersionH MATCHES "aiGetVersionPatch")
list(APPEND Mayo_CompileDefinitions NO_ASSIMP_aiGetVersionPatch)
if(assimp_FileVersionH MATCHES "aiGetVersionPatch")
set(MAYO_HAVE_ASSIMP_aiGetVersionPatch 1)
else()
message(STATUS "Assimp function aiGetVersionPatch() not available")
endif()
endif()
Expand All @@ -443,6 +442,13 @@ endif()
# TODO


##########
# Configure files
##########

configure_file(${PROJECT_SOURCE_DIR}/src/mayo_config.h.cmake common/mayo_config.h @ONLY)
configure_file(${PROJECT_SOURCE_DIR}/src/mayo_version.h.cmake common/mayo_version.h @ONLY)

##########
# Targets
##########
Expand Down Expand Up @@ -491,7 +497,8 @@ add_custom_target(
images/credits.txt
scripts/bump-version.rb
scripts/gen-cmake-opencascade-vars.bat
src/app/version.h.cmake
src/mayo_config.h.cmake
src/mayo_version.h.cmake
README.md
)

Expand Down
2 changes: 1 addition & 1 deletion src/app/command_system_information.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#include "command_system_information_occopengl.h"
#include "qstring_conv.h"
#include "qtwidgets_utils.h"
#include "version.h"
#include "../base/meta_enum.h"
#include "../base/filepath.h"
#include "../base/io_system.h"
#include <common/mayo_version.h>

#include <QtCore/QDir>
#include <QtCore/QFileSelector>
Expand Down
3 changes: 2 additions & 1 deletion src/app/dialog_about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

#include "ui_dialog_about.h"
#include "qstring_conv.h"
#include "version.h"
#include <common/mayo_version.h>

#include <Standard_Version.hxx>

namespace Mayo {
Expand Down
2 changes: 1 addition & 1 deletion src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
#include "qstring_conv.h"
#include "qtgui_utils.h"
#include "theme.h"
#include "version.h"
#include "widget_model_tree.h"
#include "widget_model_tree_builder_mesh.h"
#include "widget_model_tree_builder_xde.h"
#include "widget_occ_view.h"
#include <common/mayo_version.h>

#include <QtCore/QtDebug>
#include <QtCore/QCommandLineParser>
Expand Down
6 changes: 2 additions & 4 deletions src/io_assimp/io_assimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
#include "io_assimp.h"
#include "io_assimp_reader.h"

#ifdef HAVE_ASSIMP
# include <assimp/version.h>
#endif
#include <assimp/version.h>

namespace Mayo {
namespace IO {
Expand Down Expand Up @@ -47,7 +45,7 @@ std::string_view AssimpLib::strVersion()
if (str.empty()) {
str += std::to_string(aiGetVersionMajor())
+ "." + std::to_string(aiGetVersionMinor())
#ifndef NO_ASSIMP_aiGetVersionPatch
#ifdef MAYO_HAVE_ASSIMP_aiGetVersionPatch
+ "." + std::to_string(aiGetVersionPatch())
#else
+ ".?"
Expand Down
6 changes: 4 additions & 2 deletions src/io_assimp/io_assimp.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "../base/io_reader.h"
#include "../base/property.h"
#include <common/mayo_config.h>

#include <memory>

namespace Mayo {
Expand All @@ -19,7 +21,7 @@ class AssimpFactoryReader : public FactoryReader {
std::unique_ptr<PropertyGroup> createProperties(Format format, PropertyGroup* parentGroup) const override;

static std::unique_ptr<FactoryReader> create() {
#ifdef HAVE_ASSIMP
#ifdef MAYO_HAVE_ASSIMP
return std::make_unique<AssimpFactoryReader>();
#else
return {};
Expand All @@ -29,7 +31,7 @@ class AssimpFactoryReader : public FactoryReader {

struct AssimpLib {
static std::string_view strName() { return "Assimp"; }
#ifdef HAVE_ASSIMP
#ifdef MAYO_HAVE_ASSIMP
static std::string_view strVersion();
static std::string_view strVersionDetails();
#else
Expand Down
5 changes: 3 additions & 2 deletions src/io_gmio/io_gmio.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "../base/io_writer.h"
#include "../base/property.h"
#include <common/mayo_config.h>

#include <memory>

Expand All @@ -22,7 +23,7 @@ class GmioFactoryWriter : public FactoryWriter {
std::unique_ptr<PropertyGroup> createProperties(Format format, PropertyGroup* parentGroup) const override;

static std::unique_ptr<FactoryWriter> create() {
#ifdef HAVE_GMIO
#ifdef MAYO_HAVE_GMIO
return std::make_unique<GmioFactoryWriter>();
#else
return {};
Expand All @@ -32,7 +33,7 @@ class GmioFactoryWriter : public FactoryWriter {

struct GmioLib {
static std::string_view strName() { return "gmio"; }
#ifdef HAVE_GMIO
#ifdef MAYO_HAVE_GMIO
static std::string_view strVersion();
static std::string_view strVersionDetails() { return "(build)"; }
#else
Expand Down
6 changes: 3 additions & 3 deletions src/io_gmio/io_gmio_amf_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ gmio_task_iface gmio_createTask(TaskProgress* progress)
return task;
}

//#ifdef HAVE_GMIO
//#ifdef MAYO_HAVE_GMIO
#if 0
Format System::probeFormat(const QString& filepath) const
{
QFile file(filepath);
if (file.open(QIODevice::ReadOnly)) {
//#ifdef HAVE_GMIO
//#ifdef MAYO_HAVE_GMIO
gmio_stream qtstream = gmio_stream_qiodevice(&file);
const gmio_stl_format stlFormat = gmio_stl_format_probe(&qtstream);
if (stlFormat != GMIO_STL_FORMAT_UNKNOWN)
Expand Down Expand Up @@ -119,7 +119,7 @@ IO::Result IO::exportStl_gmio(ExportData data)

return Result::error(file.errorString());
}
#endif // HAVE_GMIO
#endif // MAYO_HAVE_GMIO

} // namespace

Expand Down
16 changes: 16 additions & 0 deletions src/mayo_config.h.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/****************************************************************************
** Copyright (c) 2024, Fougue Ltd. <https://www.fougue.pro>
** All rights reserved.
** See license at https://github.com/fougue/mayo/blob/master/LICENSE.txt
****************************************************************************/

#pragma once

#cmakedefine MAYO_WITH_TESTS
#cmakedefine MAYO_HAVE_ASSIMP
#cmakedefine MAYO_HAVE_ASSIMP_aiGetVersionPatch
#cmakedefine MAYO_HAVE_GMIO

#ifdef HAVE_RAPIDJSON
# define OPENCASCADE_HAVE_RAPIDJSON
#endif
6 changes: 6 additions & 0 deletions src/app/version.h.cmake → src/mayo_version.h.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/****************************************************************************
** Copyright (c) 2024, Fougue Ltd. <https://www.fougue.pro>
** All rights reserved.
** See license at https://github.com/fougue/mayo/blob/master/LICENSE.txt
****************************************************************************/

#pragma once

namespace Mayo {
Expand Down
5 changes: 3 additions & 2 deletions tests/test_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "../src/io_off/io_off_writer.h"
#include "../src/io_ply/io_ply_reader.h"
#include "../src/io_ply/io_ply_writer.h"
#include <common/mayo_config.h>

#include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx>
Expand Down Expand Up @@ -608,7 +609,7 @@ void TestBase::IO_bugGitHub166_test_data()
#if OCC_VERSION_HEX >= 0x070400
QTest::newRow("OBJ->PLY") << "tests/inputs/cube.obj" << "tests/outputs/cube.ply" << IO::Format_PLY;
QTest::newRow("OBJ->STL") << "tests/inputs/cube.obj" << "tests/outputs/cube.stl" << IO::Format_STL;
# ifdef HAVE_RAPIDJSON
# ifdef OPENCASCADE_HAVE_RAPIDJSON
QTest::newRow("glTF->PLY") << "tests/inputs/cube.gltf" << "tests/outputs/cube.ply" << IO::Format_PLY;
QTest::newRow("glTF->STL") << "tests/inputs/cube.gltf" << "tests/outputs/cube.stl" << IO::Format_STL;
# endif
Expand All @@ -617,7 +618,7 @@ void TestBase::IO_bugGitHub166_test_data()
#if OCC_VERSION_HEX >= 0x070600
QTest::newRow("PLY->OBJ") << "tests/inputs/cube.ply" << "tests/outputs/cube.obj" << IO::Format_OBJ;
QTest::newRow("STL->OBJ") << "tests/inputs/cube.stla" << "tests/outputs/cube.obj" << IO::Format_OBJ;
# ifdef HAVE_RAPIDJSON
# ifdef OPENCASCADE_HAVE_RAPIDJSON
QTest::newRow("glTF->OBJ") << "tests/inputs/cube.gltf" << "tests/outputs/cube.obj" << IO::Format_OBJ;
QTest::newRow("OBJ->glTF") << "tests/inputs/cube.obj" << "tests/outputs/cube.glTF" << IO::Format_GLTF;
# endif
Expand Down

0 comments on commit be1087f

Please sign in to comment.