Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ elseif (CMAKE_MAJOR_VERSION STREQUAL "3" AND CMAKE_MINOR_VERSION STREQUAL "27")
endif()

# Allow cmake std module for stdlibc++ or msvc
if (CMAKE_VERSION VERSION_GREATER_EQUAL "4.3.0")
if (CMAKE_VERSION VERSION_GREATER_EQUAL "4.4.0")
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "f35a9ac6-8463-4d38-8eec-5d6008153e7d")
elseif (CMAKE_VERSION VERSION_GREATER_EQUAL "4.3.0")
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "451f2fe2-a8a2-47c3-bc32-94786d8fc91b")
elseif (CMAKE_VERSION VERSION_GREATER_EQUAL "4.0.3")
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "d0edc3af-4c50-42ea-a356-e2862fe7a444")
Expand Down Expand Up @@ -62,7 +64,7 @@ else()
add_compile_options(-fPIC -Wall -Wextra -DNDEBUG)
endif()

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(TEMPLATE_DIR ${PROJECT_SOURCE_DIR}/template)
Expand Down Expand Up @@ -115,6 +117,7 @@ set(LINK_LIBRARIES
view-simulation
view-simulation-internal
model
model-application
config
importer-dxf
importer-dxfplot
Expand All @@ -123,6 +126,8 @@ set(LINK_LIBRARIES
exporter-renderer
geometry
geometry-filter
common
serializer
libdxfrw
fmt::fmt
Qt6::Widgets
Expand All @@ -134,7 +139,10 @@ set(LINK_LIBRARIES
include_directories(${INCLUDE_DIRS})

add_subdirectory(template)
# Third party sources are plain headers and sources, scanning them for modules only costs build time.
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
add_subdirectory(thirdparty EXCLUDE_FROM_ALL)
set(CMAKE_CXX_SCAN_FOR_MODULES ${CMAKE_CXX_MODULE_DYNDEP})

include(cmake/modules.cmake)

Expand All @@ -147,7 +155,7 @@ if (BUILD_TESTING)
endif()

add_executable(dxfplotter src/main.cpp)
target_link_libraries(dxfplotter ${LINK_LIBRARIES} model_module)
target_link_libraries(dxfplotter ${LINK_LIBRARIES})
add_coverage(dxfplotter)

install(TARGETS dxfplotter DESTINATION bin)
Expand Down
9 changes: 9 additions & 0 deletions cmake/modules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,13 @@ function (add_module_library lib_name)

# BASE_DIRS is configured to allow files coming from src and build directory (for instance compile generated sources located in build/).
target_sources(${lib_name} PUBLIC FILE_SET cxx_modules TYPE CXX_MODULES FILES ${sources} BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})

target_compile_features(${lib_name} PUBLIC cxx_std_23)

if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(${lib_name} PRIVATE
-Wno-reserved-module-identifier
-Wno-module-file-config-mismatch
)
endif()
endfunction()
10 changes: 10 additions & 0 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set(SRC
aggregable.cpp
copy.cpp
enumerate.cpp
exception.cpp
function.cpp
)

add_module_library(common ${SRC})
add_coverage(common)
15 changes: 9 additions & 6 deletions src/common/aggregable.h → src/common/aggregable.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#pragma once
module;

#include <vector>
#include <array>
#include <set>
#include <cstddef>
#include <memory>
#include <set>
#include <vector>

export module common.aggregable;

namespace common
export namespace common
{

template<class Item>
Expand All @@ -19,9 +22,9 @@ class Aggregable
using ListCPtr = std::vector<const Item*>;
using ListUPtr = std::vector<UPtr>;

template<size_t Size>
template<std::size_t Size>
using Array = std::array<Item, Size>;
template<size_t Size>
template<std::size_t Size>
using ArrayPtr = std::array<Item*, Size>;

using SetPtr = std::set<Item*>;
Expand Down
10 changes: 6 additions & 4 deletions src/common/copy.h → src/common/copy.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#pragma once
module;

#include <vector>
#include <memory>
#include <algorithm>
#include <memory>
#include <vector>

export module common.copy;

namespace common
export namespace common
{

template<class Item, class ItemUPtr = std::unique_ptr<Item>>
Expand Down
17 changes: 0 additions & 17 deletions src/common/enum.h

This file was deleted.

21 changes: 21 additions & 0 deletions src/common/enumerate.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module;

#include <initializer_list>
#include <string>

// Named common.enumerate and not common.enum: 'enum' is a keyword and cannot be a module name component.
export module common.enumerate;

export namespace common::enumerate
{

template<class EnumType>
std::initializer_list<EnumType> All();

template<class EnumType>
std::string toString(const EnumType& value);

template<class EnumType>
EnumType fromString(const std::string& value);

}
9 changes: 7 additions & 2 deletions src/common/exception.h → src/common/exception.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#pragma once
module;

#include <exception>
#include <sstream>
#include <stdexcept>
#include <string>
#include <utility>

namespace common
export module common.exception;

export namespace common
{

class FileCouldNotOpenException : public std::exception
Expand Down
4 changes: 2 additions & 2 deletions src/common/function.h → src/common/function.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
export module common.function;

namespace common
export namespace common
{

template<typename Func>
Expand Down
29 changes: 13 additions & 16 deletions src/config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
set_property(SOURCE config.h PROPERTY SKIP_AUTOGEN ON)

set(SRC
config.cpp
set(MODULE_SRC
node.cpp

config.h
group.h
list.h
node.h
property.h
group.cpp
list.cpp
utils.cpp
property.cpp
${CMAKE_CURRENT_BINARY_DIR}/configgen.cpp
)

add_library(config ${SRC})
# config.cpp is a module implementation unit of config.config, not an interface unit.
add_module_library(config ${MODULE_SRC} NON_MODULE_SOURCES config.cpp)
add_dependencies(config generate-config)
target_link_libraries(config PUBLIC yaml-cpp::yaml-cpp)
target_link_libraries(config PUBLIC yaml-cpp::yaml-cpp common geometry)

add_custom_command(
OUTPUT config.h
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/config_gen.py ${TEMPLATE_DIR}/config.xml ${CMAKE_CURRENT_SOURCE_DIR} config.h.in config.h
DEPENDS config.h.in ${TEMPLATE_DIR}/config.xml config_gen.py
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/configgen.cpp
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/config_gen.py ${TEMPLATE_DIR}/config.xml ${CMAKE_CURRENT_SOURCE_DIR} configgen.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/configgen.cpp
DEPENDS configgen.cpp.in ${TEMPLATE_DIR}/config.xml config_gen.py
)

add_custom_target(generate-config DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/config.h)
add_custom_target(generate-config DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/configgen.cpp)
8 changes: 6 additions & 2 deletions src/config/config.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#include <config.h>
module;

#include <fstream>

#include <yaml-cpp/yaml.h>

#include <QDebug>

#include <fstream>
module config.config;

namespace config
{
Expand Down
17 changes: 12 additions & 5 deletions src/config/config.h.in → src/config/configgen.cpp.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#pragma once
module;

#include <string>
#include <variant>

#include <config/group.h>
#include <config/list.h>
#include <config/property.h>
#include <yaml-cpp/yaml.h>

namespace config
export module config.config;

import config.group;
import geometry.utils;
import config.list;
import config.node;
import config.property;

export namespace config
{

namespace internal
Expand Down
10 changes: 7 additions & 3 deletions src/config/group.h → src/config/group.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#pragma once
module;

#include <string>
#include <tuple>
#include <utility>

#include <config/node.h>
export module config.group;

namespace config
import config.node;

export namespace config
{

/** @brief A configuration group.
Expand Down
12 changes: 8 additions & 4 deletions src/config/list.h → src/config/list.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#pragma once
module;

#include <vector>
#include <map>
#include <string>
#include <vector>
#include <yaml-cpp/yaml.h>

export module config.list;

#include <config/node.h>
import config.node;

namespace config
export namespace config
{

/** @brief A configuration node list.
Expand Down
37 changes: 23 additions & 14 deletions src/config/node.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
#include <node.h>
module;

#include <algorithm>
#include <string>
#include <yaml-cpp/yaml.h>

namespace config
{
export module config.node;

Node::Node(const std::string& name, const std::string& description)
: m_name(name)
, m_description(description)
export namespace config
{
}

const std::string& Node::name() const
class Node
{
return m_name;
}
private:
std::string m_name;
std::string m_description;

const std::string& Node::description() const
{
return m_description;
}
public:
explicit Node(const std::string& name, const std::string& description)
: m_name(name)
, m_description(description)
{
}

Node() = default;

const std::string& name() const { return m_name; }

const std::string& description() const { return m_description; }
};

}
24 changes: 0 additions & 24 deletions src/config/node.h

This file was deleted.

Loading
Loading