Skip to content

Commit 170a16f

Browse files
authored
Refactor to use mnxdom (#6)
* wip (not working) * fix issues from tests * use main branch for mnxdom FetchContent * latest make file * update the github action with correct test options for windows
1 parent f51689c commit 170a16f

File tree

7 files changed

+148
-222
lines changed

7 files changed

+148
-222
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ jobs:
6969
if: matrix.os == 'windows-latest'
7070
run: cmake --build build --config Release
7171

72-
# Run Tests
73-
- name: Run Tests
72+
- name: Run Tests on Windows
73+
if: runner.os == 'Windows'
74+
run: ctest --test-dir build/tests -C Release --output-on-failure
75+
76+
- name: Run Tests on Linux/macOS
77+
if: runner.os != 'Windows'
7478
run: ctest --test-dir build/tests --output-on-failure
79+

CMakeLists.txt

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ set(GENERATED_DIR "${CMAKE_BINARY_DIR}/generated")
8080

8181
# Set output directory for compiled executable
8282
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIR})
83-
set(BUILD_TESTING OFF CACHE BOOL "Disable testing for external dependencies" FORCE)
8483

8584
# Save the current state and disable deprecation warnings
8685
set(_original_WARN_DEPRECATED ${CMAKE_WARN_DEPRECATED})
@@ -97,30 +96,35 @@ FetchContent_Declare(
9796
)
9897
FetchContent_MakeAvailable(miniz-cpp)
9998

100-
# Disable building tests for nlohmann_json
101-
set(JSON_BuildTests OFF CACHE BOOL "Do not build tests for nlohmann_json")
102-
# Define the version of nlohmann_json to use
103-
set(NLOHMANN_JSON_VERSION v3.11.3)
104-
# Fetch nlohmann_json
105-
FetchContent_Declare(
106-
nlohmann_json
107-
URL https://github.com/nlohmann/json/releases/download/${NLOHMANN_JSON_VERSION}/json.tar.xz
108-
URL_HASH SHA256=d6c65aca6b1ed68e7a182f4757257b107ae403032760ed6ef121c9d55e81757d # Verify the hash matches the tarball
109-
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
110-
)
111-
FetchContent_MakeAvailable(nlohmann_json)
99+
# Define a cache variable for the local MNX C++ DOM path relative to the source directory.
100+
set(MNXDOM_LOCAL_PATH "" CACHE STRING "Path to local MNX C++ DOM checkout relative to the source directory (if provided)")
112101

113-
# Disable building tests for json_schema_validator
114-
set(JSON_VALIDATOR_BUILD_TESTS OFF CACHE BOOL "Do not build tests for json_schema_validator")
115-
# Fetch json_schema_validator from your fork
116-
set(nlohmann_json_VERSION ${NLOHMANN_JSON_VERSION})
102+
if(MNXDOM_LOCAL_PATH)
103+
# Combine the source directory with the relative path to get an absolute path.
104+
get_filename_component(MNXDOM_LOCAL_PATH_ABS "${CMAKE_SOURCE_DIR}/${MNXDOM_LOCAL_PATH}" ABSOLUTE)
105+
if(EXISTS "${MNXDOM_LOCAL_PATH_ABS}/CMakeLists.txt")
106+
message(STATUS "Local MNX C++ DOM found at ${MNXDOM_LOCAL_PATH_ABS}")
107+
# Set the FetchContent source directory to the computed absolute path.
108+
set(FETCHCONTENT_SOURCE_DIR_MNXDOM "${MNXDOM_LOCAL_PATH_ABS}" CACHE INTERNAL "")
109+
else()
110+
message(FATAL_ERROR "Local MNX C++ DOM not found at ${MNXDOM_LOCAL_PATH_ABS}")
111+
endif()
112+
else()
113+
message(STATUS "Using GitHub for MNX C++ DOM")
114+
endif()
115+
116+
option(mnxdom_BUILD_TESTING "Enable testing mnxdom" ON)
117+
# Fetch mnxdom
117118
FetchContent_Declare(
118-
json_schema_validator
119-
GIT_REPOSITORY https://github.com/pboettch/json-schema-validator
120-
GIT_TAG 40af3ec39670e768fc3f01f935140af311d71024
119+
mnxdom
120+
GIT_REPOSITORY https://github.com/rpatters1/mnxdom.git
121+
GIT_TAG main
121122
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
122123
)
123-
FetchContent_MakeAvailable(json_schema_validator)
124+
FetchContent_MakeAvailable(mnxdom)
125+
126+
FetchContent_GetProperties(mnxdom)
127+
message(STATUS "mnxdom Source Directory: ${mnxdom_SOURCE_DIR}")
124128

125129
# Restore the original state
126130
set(CMAKE_WARN_DEPRECATED ${_original_WARN_DEPRECATED} CACHE BOOL "Restore original deprecation warnings setting" FORCE)
@@ -129,7 +133,6 @@ add_custom_target(PrintConfig ALL
129133
COMMAND ${CMAKE_COMMAND} -E echo "Active build configuration: $<CONFIG>"
130134
)
131135

132-
include("${CMAKE_SOURCE_DIR}/cmake/GenerateMnxSchemaXxd.cmake")
133136
include("${CMAKE_SOURCE_DIR}/cmake/GenerateLicenseXxd.cmake")
134137

135138
# Add executable target
@@ -158,16 +161,15 @@ set(MUSX_DISPLAY_NODE_NAMES ON CACHE BOOL "Write node names to std::cout as they
158161
#set(MUSX_THROW_ON_INTEGRITY_CHECK_FAIL ON CACHE BOOL "Enable throwing integrity check failures" FORCE)
159162

160163
# Ensure the include directories are added
161-
add_dependencies(mnxvalidate GenerateMnxSchemaXxd GenerateLicenseXxd)
164+
add_dependencies(mnxvalidate GenerateLicenseXxd)
162165
target_include_directories(mnxvalidate PRIVATE "${FETCHCONTENT_BASE_DIR}/ezgz-src")
163166
target_include_directories(mnxvalidate SYSTEM PRIVATE "${FETCHCONTENT_BASE_DIR}/miniz-cpp-src")
164167
target_include_directories(mnxvalidate PRIVATE ${GENERATED_DIR})
165168
target_include_directories(mnxvalidate PRIVATE ${MUSX_OBJECT_MODEL_DIR})
166169
target_include_directories(mnxvalidate PRIVATE ${CMAKE_SOURCE_DIR}/src)
167170

168171
# Ensure the libraries are added
169-
target_link_libraries(mnxvalidate PRIVATE nlohmann_json::nlohmann_json)
170-
target_link_libraries(mnxvalidate PRIVATE nlohmann_json_schema_validator)
172+
target_link_libraries(mnxvalidate PRIVATE mnxdom)
171173

172174
# Define an interface library for precompiled headers
173175
add_library(mnxvalidate_pch INTERFACE)
@@ -178,6 +180,7 @@ target_precompile_headers(mnxvalidate_pch INTERFACE
178180
<functional>
179181
<string>
180182
<memory>
183+
<mnxdom.h>
181184
)
182185

183186
# Link the interface library to mnxvalidate

cmake/GenerateLicenseXxd.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
set(LICENSE_FILES
66
"${CMAKE_SOURCE_DIR}/LICENSE"
77
"${nlohmann_json_SOURCE_DIR}/LICENSE.MIT"
8-
"${json_schema_validator_SOURCE_DIR}/LICENSE"
8+
"${nlohmann_json_schema_validator_SOURCE_DIR}/LICENSE"
99
"${miniz-cpp_SOURCE_DIR}/LICENSE.md"
1010
)
1111

@@ -29,6 +29,7 @@ foreach(INDEX RANGE 0 ${LAST_INDEX})
2929
list(GET LICENSE_FILES ${INDEX} LICENSE_FILE)
3030
list(GET LICENSE_PREFIXES ${INDEX} SAFE_NAME_PREFIX)
3131

32+
message(STATUS "Processing LICENSE_FILE: ${LICENSE_FILE}")
3233
set(GENERATED_XXD "${GENERATED_DIR}/${SAFE_NAME_PREFIX}_license.xxd")
3334

3435
# Extract the directory of the license file

cmake/GenerateMnxSchemaXxd.cmake

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)