Compare commits
3 Commits
6bcfd52b07
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 5317575aeb | |||
| c0e3c1257d | |||
| 088004d494 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
build/
|
||||||
|
CPM_modules/
|
||||||
@@ -2,33 +2,32 @@ cmake_minimum_required(VERSION 3.21)
|
|||||||
|
|
||||||
project(cyberiadamlpp VERSION 1.0)
|
project(cyberiadamlpp VERSION 1.0)
|
||||||
|
|
||||||
find_package(LibXml2 REQUIRED)
|
include(cmake/CPM.cmake)
|
||||||
if(!LibXml2_FOUND)
|
|
||||||
message(FATAL_ERROR "Cannot find libxml2 library")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(cyberiadaml_DIR /usr/lib/cmake)
|
CPMAddPackage(
|
||||||
find_package(cyberiadaml REQUIRED)
|
NAME libcyberiadaml
|
||||||
if(!cyberiadaml_FOUND)
|
VERSION 1.0.0
|
||||||
message(FATAL_ERROR "Cannot find libcyberiadaml library")
|
URL https://git.gogacoder.com/gogacoder/libcyberiadaml/archive/v1.0.0.zip
|
||||||
endif()
|
)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
add_library(cyberiadamlpp SHARED cyberiadamlpp.cpp)
|
add_library(cyberiadamlpp SHARED src/cyberiadamlpp.cpp)
|
||||||
target_include_directories(cyberiadamlpp PUBLIC
|
target_include_directories(cyberiadamlpp PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
||||||
$<INSTALL_INTERFACE:include/cyberiada>
|
$<INSTALL_INTERFACE:include/cyberiada>
|
||||||
"${cyberiadaml_INCLUDE_DIRS}")
|
"${cyberiadaml_INCLUDE_DIRS}"
|
||||||
|
)
|
||||||
|
|
||||||
target_link_directories(cyberiadamlpp PUBLIC "${cyberiadaml_LIBRARY}")
|
target_link_directories(cyberiadamlpp PUBLIC "${cyberiadaml_LIBRARY}")
|
||||||
target_link_libraries(cyberiadamlpp PUBLIC "${cyberiadaml_LIBRARIES}")
|
target_link_libraries(cyberiadamlpp PUBLIC "${cyberiadaml_LIBRARIES}" cyberiadaml)
|
||||||
|
|
||||||
add_executable(cyberiadapp main.cpp)
|
add_executable(cyberiadapp src/main.cpp)
|
||||||
target_include_directories(cyberiadapp PUBLIC
|
target_include_directories(cyberiadapp PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||||
$<INSTALL_INTERFACE:include/cyberiada>)
|
$<INSTALL_INTERFACE:include/cyberiada>
|
||||||
|
)
|
||||||
target_link_directories(cyberiadapp PUBLIC "${PROJECT_BINARY_DIR}")
|
target_link_directories(cyberiadapp PUBLIC "${PROJECT_BINARY_DIR}")
|
||||||
target_link_libraries(cyberiadapp PUBLIC cyberiadamlpp)
|
target_link_libraries(cyberiadapp PUBLIC cyberiadamlpp)
|
||||||
|
|
||||||
@@ -45,12 +44,12 @@ foreach(source_path ${files})
|
|||||||
add_custom_command(TARGET "${target_name}"
|
add_custom_command(TARGET "${target_name}"
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND copy "${PROJECT_BINARY_DIR}/${target_name}" "${PROJECT_BINARY_DIR}/tests/"
|
COMMAND copy "${PROJECT_BINARY_DIR}/${target_name}" "${PROJECT_BINARY_DIR}/tests/"
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
add_custom_command(TARGET "${target_name}"
|
add_custom_command(TARGET "${target_name}"
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND ln -sf "${PROJECT_BINARY_DIR}/${target_name}" "${PROJECT_BINARY_DIR}/tests/"
|
COMMAND ln -sf "${PROJECT_BINARY_DIR}/${target_name}" "${PROJECT_BINARY_DIR}/tests/"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
@@ -63,7 +62,8 @@ foreach(f ${test_files})
|
|||||||
file(COPY_FILE
|
file(COPY_FILE
|
||||||
"${f}"
|
"${f}"
|
||||||
"${PROJECT_BINARY_DIR}/tests/${fname}"
|
"${PROJECT_BINARY_DIR}/tests/${fname}"
|
||||||
ONLY_IF_DIFFERENT)
|
ONLY_IF_DIFFERENT
|
||||||
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
file(COPY_FILE
|
file(COPY_FILE
|
||||||
@@ -78,8 +78,10 @@ install(EXPORT cyberiadamlpp DESTINATION lib/cmake)
|
|||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
${PROJECT_SOURCE_DIR}/cyberiadamlpp-config.cmake.in
|
${PROJECT_SOURCE_DIR}/cyberiadamlpp-config.cmake.in
|
||||||
${PROJECT_BINARY_DIR}/cyberiadamlpp-config.cmake @ONLY)
|
${PROJECT_BINARY_DIR}/cyberiadamlpp-config.cmake @ONLY
|
||||||
|
)
|
||||||
|
|
||||||
install(FILES
|
install(FILES
|
||||||
${PROJECT_BINARY_DIR}/cyberiadamlpp-config.cmake
|
${PROJECT_BINARY_DIR}/cyberiadamlpp-config.cmake
|
||||||
DESTINATION lib/cmake)
|
DESTINATION lib/cmake
|
||||||
|
)
|
||||||
|
|||||||
59
Makefile.old
59
Makefile.old
@@ -1,59 +0,0 @@
|
|||||||
LIB_TARGET_STATIC := libcyberiadamlpp.a
|
|
||||||
LIB_TARGET_DYNAMIC := libcyberiadamlpp.so
|
|
||||||
|
|
||||||
ifeq ($(DYNAMIC), 1)
|
|
||||||
LIB_TARGET := $(LIB_TARGET_DYNAMIC)
|
|
||||||
else
|
|
||||||
LIB_TARGET := $(LIB_TARGET_STATIC)
|
|
||||||
endif
|
|
||||||
|
|
||||||
TESTS_DIR := tests
|
|
||||||
MAIN_TARGET := cyberiadapp
|
|
||||||
LIB_SOURCES := cyberiadamlpp.cpp
|
|
||||||
MAIN_SOURCES := main.cpp
|
|
||||||
LIB_OBJECTS := $(patsubst %.cpp, %.o, $(LIB_SOURCES))
|
|
||||||
MAIN_OBJECTS := $(patsubst %.cpp, %.o, $(MAIN_SOURCES))
|
|
||||||
TEST_SOURCES := $(wildcard $(addsuffix /*.cpp, $(TESTS_DIR)))
|
|
||||||
TEST_OBJECTS := $(patsubst %.cpp, %.o, $(TEST_SOURCES))
|
|
||||||
TEST_TARGETS := $(patsubst %.cpp, %.test, $(TEST_SOURCES))
|
|
||||||
|
|
||||||
ifeq ($(DEBUG), 1)
|
|
||||||
CFLAGS := -Werror -Wall -Wshadow -Wconversion -fPIC -g3 -D__DEBUG__
|
|
||||||
LFLAGS :=
|
|
||||||
else
|
|
||||||
CFLAGS := -fPIC
|
|
||||||
LFLAGS :=
|
|
||||||
endif
|
|
||||||
|
|
||||||
INCLUDE := -I. -I/usr/include/libxml2 -I./cyberiadaml
|
|
||||||
LIBS := -L/usr/lib -lxml2 -L./cyberiadaml -lcyberiadaml
|
|
||||||
MAIN_LIBS := -L. -lcyberiadamlpp
|
|
||||||
|
|
||||||
$(LIB_TARGET): $(LIB_OBJECTS)
|
|
||||||
ifeq ($(DYNAMIC), 1)
|
|
||||||
g++ -shared $(LIBS) $(LIB_OBJECTS) -o $@
|
|
||||||
else
|
|
||||||
ar rcs $@ $(LIB_OBJECTS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(MAIN_TARGET): $(MAIN_OBJECTS) $(LIB_TARGET) $(LIB_ORJECTS)
|
|
||||||
g++ $(MAIN_OBJECTS) -Wl,-\( $(LIBS) $(MAIN_LIBS) -Wl,-\) -o $@
|
|
||||||
|
|
||||||
%.test: %.o $(LIB_TARGET)
|
|
||||||
g++ $< -Wl,-\( $(LIBS) $(MAIN_LIBS) -Wl,-\) -o $@
|
|
||||||
|
|
||||||
%.o: %.cpp
|
|
||||||
g++ -c $< $(CFLAGS) $(INCLUDE) -o $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *~ *.o $(TARGET) $(MAIN_TARGET) $(LIB_TARGET_STATIC) $(LIB_TARGET_DYNAMIC)
|
|
||||||
rm -f $(TESTS_DIR)/*~ $(TESTS_DIR)/*.o $(TESTS_DIR)/*.test.graphml $(TESTS_DIR)/*.test.txt $(TEST_TARGETS)
|
|
||||||
|
|
||||||
main: $(MAIN_TARGET)
|
|
||||||
|
|
||||||
tests: $(TEST_TARGETS)
|
|
||||||
@echo >/dev/null
|
|
||||||
|
|
||||||
all: $(LIB_TARGET) $(MAIN_TARGET) $(TEST_TARGETS)
|
|
||||||
|
|
||||||
.PHONY: all clean main tests
|
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cyberiada/cyberiadaml.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "cyberiadamlpp.h"
|
#include "cyberiadamlpp.h"
|
||||||
|
|
||||||
@@ -2077,7 +2078,7 @@ void Document::load(const String& path, DocumentFormat f)
|
|||||||
int res = cyberiada_init_sm_document(&doc);
|
int res = cyberiada_init_sm_document(&doc);
|
||||||
CYB_ASSERT(res == CYBERIADA_NO_ERROR);
|
CYB_ASSERT(res == CYBERIADA_NO_ERROR);
|
||||||
|
|
||||||
res = cyberiada_read_sm_document(&doc, path.c_str(), CyberiadaXMLFormat(f));
|
res = cyberiada_read_sm_document(&doc, path.c_str(), CyberiadaXMLFormat(f), CYBERIADA_NO_ERROR);
|
||||||
if (res != CYBERIADA_NO_ERROR) {
|
if (res != CYBERIADA_NO_ERROR) {
|
||||||
cyberiada_cleanup_sm_document(&doc);
|
cyberiada_cleanup_sm_document(&doc);
|
||||||
CYB_CHECK_RESULT(res);
|
CYB_CHECK_RESULT(res);
|
||||||
@@ -2344,7 +2345,7 @@ void Document::save(const String& path, DocumentFormat f) const
|
|||||||
throw AssertException("Internal save error: " + e.str());
|
throw AssertException("Internal save error: " + e.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
res = cyberiada_write_sm_document(&doc, path.c_str(), CyberiadaXMLFormat(f));
|
res = cyberiada_write_sm_document(&doc, path.c_str(), CyberiadaXMLFormat(f), CYBERIADA_NO_ERROR);
|
||||||
if (res != CYBERIADA_NO_ERROR) {
|
if (res != CYBERIADA_NO_ERROR) {
|
||||||
cyberiada_cleanup_sm_document(&doc);
|
cyberiada_cleanup_sm_document(&doc);
|
||||||
CYB_CHECK_RESULT(res);
|
CYB_CHECK_RESULT(res);
|
||||||
Reference in New Issue
Block a user