Skip to content

Commit

Permalink
merge v2:
Browse files Browse the repository at this point in the history
- closes #40
- closes #35
- closes #36
- closes #37
- closes #34 - about to open standalone issues for missing things
- closes #28
- closes #24
  • Loading branch information
iboB committed Mar 17, 2023
1 parent 6e8f0ab commit cb96f9d
Show file tree
Hide file tree
Showing 380 changed files with 12,094 additions and 28,512 deletions.
240 changes: 40 additions & 200 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,224 +1,64 @@
# DynaMix
# Copyright (c) 2013-2020 Borislav Stanimirov, Zahary Karadjov
# Copyright (c) Borislav Stanimirov
# SPDX-License-Identifier: MIT
#
# Distributed under the MIT Software License
# See accompanying file LICENSE.txt or copy at
# https://opensource.org/licenses/MIT
#
cmake_minimum_required(VERSION 3.2.2)

project(dynamix)

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# is_demo is used below to make life simpler for developers
# it enables some configurations and the defaults for building tests and examples
# which typically wouldn't be built if DynaMix is a subdirectory of another project
set(is_demo ON)
else()
set(is_demo OFF)
endif()
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)

set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${CMAKE_CURRENT_SOURCE_DIR}/cmake
project(dynamix2
LANGUAGES C CXX
)

include(src_group)

option(DYNAMIX_DEMO "DynaMix: build as standalone demo (developer mode)" ${is_demo})

option(DYNAMIX_SHARED_LIB "DynaMix: build as a shared library" ON)

option(DYNAMIX_BUILD_UNIT_TESTS "DynaMix: enable testing and build tests" ${is_demo})

option(DYNAMIX_BUILD_EXAMPLES "DynaMix: build examples" ${is_demo})
# Individual example settings. Only relevant if DYNAMIX_BUILD_EXAMPLES is on
option(DYNAMIX_EXAMPLE_HELLO_WORLD "DynaMix: build hello world example" ${is_demo})
option(DYNAMIX_EXAMPLE_BASIC "DynaMix: build basic example" ${is_demo})
option(DYNAMIX_EXAMPLE_MULTI_DLL "DynaMix: build multi_dll example" ${is_demo})

option(DYNAMIX_BUILD_SCRATCH "DynaMix: build scratch project" ${is_demo})

option(DYNAMIX_BUILD_TUTORIALS "DynaMix: build tutorials" ${is_demo})
# cpm
include(./get_cpm.cmake)

# Off by default since generated.h/cpp needs to be... well... generated for this to work
option(DYNAMIX_BUILD_PERF "DynaMix: build performance tests (requires manual code generation step)" OFF)
#######################################
# cmake lib
CPMAddPackage(gh:iboB/icm@1.4.3)

# Off by default since files need to be generated for this to work
option(DYNAMIX_BUILD_COMPILER_PERF "DynaMix: build compilation performance tests (requires manual code generation step)" OFF)

# Optionally disable this so dynamix doesn't get installed along with other projects which are using it
option(DYNAMIX_CONFIGURE_INSTALL "DynaMix: add install configuration" ON)

# Option to install headers
option(DYNAMIX_CONFIGURE_INSTALL_HEADERS "DynaMix: add install configuration for the headers" ${is_demo})

# demo

if(DYNAMIX_DEMO)
include(demo)
endif()

# sources
list(APPEND CMAKE_MODULE_PATH
"${icm_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
)

set(dynamix_sources) # list to be filled with the source files for the project
set(ICM_DEV_C_STANDARD 11)
set(ICM_DEV_CXX_STANDARD 17)

set(dynamix_include ${CMAKE_CURRENT_SOURCE_DIR}/include)
include(icm_dev_mode)

set(inc_path ${dynamix_include}/dynamix)
set(src_path ${CMAKE_CURRENT_SOURCE_DIR}/src)
#######################################
# options

src_group(public dynamix_sources
${inc_path}/allocators.hpp
${inc_path}/combinators.hpp
${inc_path}/common_mutation_rules.hpp
${inc_path}/config.hpp
${inc_path}/core.hpp
${inc_path}/domain.hpp
${inc_path}/declare_message_opt.hpp
${inc_path}/declare_message.hpp
${inc_path}/declare_message_legacy.hpp
${inc_path}/declare_message_no_arity.hpp
${inc_path}/declare_message_split.hpp
${inc_path}/declare_mixin.hpp
${inc_path}/define_message.hpp
${inc_path}/define_message_split.hpp
${inc_path}/define_mixin.hpp
${inc_path}/dm_this.hpp
${inc_path}/dynamix.hpp
${inc_path}/exception.hpp
${inc_path}/feature.hpp
${inc_path}/features.hpp
${inc_path}/message.hpp
${inc_path}/message_features.hpp
${inc_path}/metrics.hpp
${inc_path}/mixin_collection.hpp
${inc_path}/mixin_id.hpp
${inc_path}/mixin_type_info.hpp
${inc_path}/mutate.hpp
${inc_path}/mutation_rule.hpp
${inc_path}/mutation_rule_id.hpp
${inc_path}/next_bidder.hpp
${inc_path}/object.hpp
${inc_path}/object_mutator.hpp
${inc_path}/object_of.hpp
${inc_path}/object_type_info.hpp
${inc_path}/object_type_mutation.hpp
${inc_path}/object_type_template.hpp
${inc_path}/same_type_mutator.hpp
${inc_path}/single_object_mutator.hpp
${inc_path}/type_class.hpp
${inc_path}/type_class_id.hpp
${inc_path}/version.hpp
)
option(DYNAMIX_STATIC "DynaMix: build as a static library" OFF)
option(DYNAMIX_BUILD_TESTS "DynaMix: enable testing and build tests" ${ICM_DEV_MODE})
option(DYNAMIX_BUILD_EXAMPLES "DynaMix: build examples" ${ICM_DEV_MODE})
option(DYNAMIX_BUILD_SCRATCH "DynaMix: build scratch project (dev experiments)" ${ICM_DEV_MODE})
option(DYNAMIX_BUILD_TUTORIALS "DynaMix: build tutorials" ${ICM_DEV_MODE})
option(DYNAMIX_BUILD_BENCH "DynaMix: build benchmarks" ${ICM_DEV_MODE})

src_group("public~internal" dynamix_sources
${inc_path}/internal/assert.hpp
${inc_path}/internal/feature_parser.hpp
${inc_path}/internal/message_callers.hpp
${inc_path}/internal/mixin_data_in_object.hpp
${inc_path}/internal/mixin_traits.hpp
${inc_path}/internal/message_macros.hpp
${inc_path}/internal/preprocessor.hpp
)

src_group("public~gen" dynamix_sources
${inc_path}/gen/arity_message_macros.ipp
${inc_path}/gen/template_message_macros.ipp
${inc_path}/gen/legacy_message_macros.ipp
${inc_path}/gen/no_arity_message_macros.ipp
${inc_path}/gen/short_message_macros.ipp
${inc_path}/gen/split_message_macros.ipp
${inc_path}/gen/undef_message_macros.ipp
)
# Off by default since it's slow
option(DYNAMIX_BUILD_COMPILER_BENCH "DynaMix: build compilation time benchmarks (requires manual code generation step)" OFF)

src_group("private" dynamix_sources
${src_path}/allocators.cpp
${src_path}/common_mutation_rules.cpp
${src_path}/domain.cpp
${src_path}/export.cpp
${src_path}/internal.hpp
${src_path}/mixin_collection.cpp
${src_path}/mixin_traits.cpp
${src_path}/object.cpp
${src_path}/object_mutator.cpp
${src_path}/object_type_info.cpp
${src_path}/object_type_mutation.cpp
${src_path}/object_type_template.cpp
${src_path}/same_type_mutator.cpp
${src_path}/single_object_mutator.cpp
${src_path}/type_class.cpp
${src_path}/zero_memory.hpp
)

if(DYNAMIX_SHARED_LIB)
add_library(dynamix SHARED ${dynamix_sources})
target_compile_definitions(dynamix PUBLIC
-DDYNAMIX_DYNLIB
)
#######################################
# cfg
if(ICM_STATIC_LIBS OR DYNAMIX_STATIC)
set(DYNAMIX_SHARED FALSE)
else()
add_library(dynamix STATIC ${dynamix_sources})
endif()

if(DYNAMIX_CUSTOM_CONFIG_FILE)
target_compile_definitions(dynamix PUBLIC
-DDYNAMIX_CUSTOM_CONFIG_FILE=${DYNAMIX_CUSTOM_CONFIG_FILE}
)
set(DYNAMIX_SHARED TRUE)
endif()

set_target_properties(dynamix PROPERTIES FOLDER dynamix)
#######################################
# code

target_include_directories(dynamix PUBLIC
${dynamix_include}
)
add_subdirectory(code)

# resolve options
if(DYNAMIX_BUILD_SCRATCH)
add_subdirectory(scratch)
endif()

if(DYNAMIX_BUILD_UNIT_TESTS)
if(DYNAMIX_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()

if(DYNAMIX_BUILD_EXAMPLES)
if(DYNAMIX_EXAMPLE_HELLO_WORLD)
add_subdirectory(example/hello_world)
endif()

if(DYNAMIX_EXAMPLE_BASIC)
add_subdirectory(example/basic)
endif()

# the multi dll example is only valid if DynaMix is a shared library
if(DYNAMIX_SHARED_LIB AND DYNAMIX_EXAMPLE_MULTI_DLL)
add_subdirectory(example/multi_dll)
endif()
endif()

if(DYNAMIX_BUILD_SCRATCH)
add_subdirectory(example/scratch)
endif()

if(DYNAMIX_BUILD_TUTORIALS)
add_subdirectory(tutorial)
endif()

if(DYNAMIX_BUILD_PERF)
add_subdirectory(perf)
endif()

if(DYNAMIX_BUILD_COMPILER_PERF)
add_subdirectory(compiler/perf)
endif()

if(DYNAMIX_CONFIGURE_INSTALL)
include(GNUInstallDirs)
install(TARGETS dynamix
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

if(DYNAMIX_CONFIGURE_INSTALL_HEADERS)
install(DIRECTORY include DESTINATION .)
endif()
add_subdirectory(example)
endif()
12 changes: 6 additions & 6 deletions VSOpenFileFromDirFilters.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"dirs": [
".git",
".vs",
"build",
"out"
]
"dirs": [
".git",
".vs",
"build",
"out"
]
}
1 change: 0 additions & 1 deletion cmake/README.md

This file was deleted.

46 changes: 0 additions & 46 deletions cmake/demo.cmake

This file was deleted.

34 changes: 0 additions & 34 deletions cmake/src_group.cmake

This file was deleted.

32 changes: 32 additions & 0 deletions code/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) Borislav Stanimirov
# SPDX-License-Identifier: MIT
#
include(icm_add_lib)

icm_add_lib(dynamix DYNAMIX)
add_library(dynamix::dynamix ALIAS dynamix)
target_include_directories(dynamix INTERFACE .)

CPMAddPackage("gh:iboB/itlib@1.8.3b#c426d5d27d2121eebacd37de0d2df4ffdf930562")
CPMAddPackage("gh:iboB/splat@1.3.0a#c6e8650c34105e741e3a887f1a944976a9f58261")

target_link_libraries(dynamix PUBLIC
splat::splat
itlib::itlib
)

target_sources(dynamix PRIVATE
dynamix/domain.cpp
dynamix/object.cpp
"dynamix/mixin_allocator-c.cpp"
dynamix/type.cpp
dynamix/exception.cpp
dynamix/type_class.cpp
dynamix/type_mutation.cpp
dynamix/object_mutation.cpp
dynamix/object_mutate_ops.cpp

dynamix/compat/pmr/memory_resource.cpp

"dynamix/domain-c.cpp"
"dnmx/object_handle.h" "dnmx/basic_object.h" "dnmx/object_mixin_data.h" "dynamix/type-c.cpp" "dnmx/object.h" "dynamix/object-c.cpp" "dnmx/mixin_common_funcs.h" "dnmx/bits/noexcept.h" "dnmx/mixin_common_funcs.c" "dnmx/mixin_info_util.h" "dynamix/mixin_info_util.hpp" "dnmx/mutation_rule_info.h" "dnmx/msg/msg_macros.h" "dynamix/mixin_info_data.cpp" "dynamix/define_domain.hpp")
2 changes: 2 additions & 0 deletions code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* `dnmx` - C API
* `dynamix` - C++ API
Loading

0 comments on commit cb96f9d

Please sign in to comment.