Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

Serialise empty model to XML #49

Open
wants to merge 47 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
45aaaa9
Use case: Empty, nameless model. Test fail intended.
Mar 27, 2015
9c4f117
Fixed implementation code to pass test.
Mar 27, 2015
37f2601
Enabled MSVC exceptions.
Mar 27, 2015
a357443
Renamed cellml_1_2.* to start with lowercase letter
Mar 29, 2015
2154983
Changed from using auto to explicitly stating type
Mar 29, 2015
4b12cc5
Eliminated `using namespace` as per Google style.
Mar 29, 2015
c4431f0
Made use of full stop at end of comments consistent.
Mar 29, 2015
cf391bb
Removed unneeded scope resolution.
Mar 29, 2015
89b2f09
Using `version.h`'s technique for exporting symbols
Mar 29, 2015
00e7344
Faking Cmake required version.
Mar 29, 2015
799e632
Used `sstream` instead of deprecated `strstream`.
Mar 30, 2015
54de041
Refactored common cmake settings.
Mar 30, 2015
2c6df65
Actually call the macro defined in cmake common.
Mar 30, 2015
357be47
Eliminated unused variable.
Mar 30, 2015
2461bad
Minor refactoring of Cmake: reduce duplication.
Mar 30, 2015
c5aef13
Added Cmake flag to control whether warnings=errors.
Mar 30, 2015
ce41908
Removed unneeded conditional.
Mar 30, 2015
d1cba61
Bumped required version.
Mar 30, 2015
bcbb61b
Changed include guard name convention for API headers.
Mar 30, 2015
867166b
Made condition compiler dependent.
Mar 30, 2015
7dcbb9b
Renamed Cmake macro.
Mar 30, 2015
d86fdc5
Using `CMAKE_MODULE_PATH` to specify include location.
Mar 31, 2015
b95c119
For 3rd-party code, warnings are not deemed errors.
Mar 31, 2015
c3f756c
Correct conditional statement.
hsorby Mar 31, 2015
3be776a
Show how you use the CMAKE_MODULE_PATH. Set the include directories …
hsorby Mar 31, 2015
891d2a1
This is how you create a reusable function to set compiler flags per …
hsorby Mar 31, 2015
9ad1400
Merge pull request #8 from hsorby/empty-model-01
Mar 31, 2015
4017ed0
Added "AppleClang" condition for warnings-as-errors
Apr 1, 2015
7483eb7
Cmake: used elseif, as suggested by @agarny
Apr 1, 2015
b603ca1
Refactored cmake, more grouping similar compilers.
Apr 1, 2015
0d16eae
Fixed indentation
Apr 1, 2015
dfbff0f
Use a list to group compilers that use the same flags.
hsorby Apr 2, 2015
d855b08
Merge remote-tracking branch 'coworker/empty-model-01' into empty-mod…
hsorby Apr 2, 2015
6896bff
Removed header that is private from api headers.
Apr 2, 2015
f7bcb5b
Removed redundant path prefix.
Apr 2, 2015
b85989f
Make use of generator expressions to simplify the configuration.
hsorby Apr 2, 2015
4d9a4a2
Merge remote-tracking branch 'coworker/empty-model-01' into empty-mod…
hsorby Apr 2, 2015
114bfce
Correct documentation string for CMAKE_CODEBLOCKS_EXECUTABLE
hsorby Apr 2, 2015
f334ce0
Don't need to add gtest as a target_link_library
hsorby Apr 2, 2015
5126e94
Change out-of-date comment in tests/CMakeLists.txt
hsorby Apr 2, 2015
17e077b
Merge pull request #10 from hsorby/empty-model-01
Apr 2, 2015
b5b46d7
Got a bit carried away with my deletions, reinstating required gtest …
hsorby Apr 2, 2015
89515bf
Fix typo
hsorby Apr 2, 2015
4451c98
Merge pull request #11 from hsorby/empty-model-01
Apr 2, 2015
49051a6
Moved XSD generated code, script and options.
Apr 2, 2015
3677047
Merge branch 'empty-model-01' of https://github.com/codecurve/libcell…
Apr 2, 2015
075fac3
Specified `generated` header path in include.
Apr 3, 2015
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ build/
# Qt Creator generated files
CMakeLists.txt.user

html
35 changes: 25 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,57 @@
# See the License for the specific language governing permissions and
# limitations under the License.cmake_minimum_required (VERSION 3.1)

cmake_minimum_required (VERSION 3.1)

cmake_minimum_required(VERSION 3.2)

set(PROJECT_NAME libCellML)
project(${PROJECT_NAME} CXX)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(common)

# Use the following variables when configuring the build from the command line to
# set the corresponding cache variables.
# TESTS ==> LIBCELLML_TESTS
set( LIBCELLML_TESTS OFF CACHE BOOL "Enable build of automated LibCellML tests." )
set(_PARAM_ANNOTATION "Enable build of automated LibCellML tests.")
set( LIBCELLML_TESTS OFF CACHE BOOL ${_PARAM_ANNOTATION} )
if( TESTS )
set( LIBCELLML_TESTS "${TESTS}" CACHE BOOL "Enable build of automated LibCellML tests." FORCE )
set( LIBCELLML_TESTS "${TESTS}" CACHE BOOL ${_PARAM_ANNOTATION} FORCE )
endif()

# WARNINGS_TREATED_AS_ERRORS ==> LIBCELLML_WARNINGS_TREATED_AS_ERRORS -- Note: This excludes third party code, where warnings are never treated as errors.
set(_PARAM_ANNOTATION "Treat warnings as errors (note: warnings in 3rd party code are never treated as errors)")
set( LIBCELLML_WARNINGS_TREATED_AS_ERRORS OFF CACHE BOOL ${_PARAM_ANNOTATION} )
if( WARNINGS_TREATED_AS_ERRORS )
set( LIBCELLML_WARNINGS_TREATED_AS_ERRORS "${WARNINGS_TREATED_AS_ERRORS}" CACHE BOOL ${_PARAM_ANNOTATION} FORCE )
endif()

# BUILD_TYPE ==> LIBCELLML_BUILD_TYPE
set( LIBCELLML_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." )
set(_PARAM_ANNOTATION "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
set( LIBCELLML_BUILD_TYPE "Release" CACHE STRING ${_PARAM_ANNOTATION} )
if( BUILD_TYPE )
set( LIBCELLML_BUILD_TYPE ${BUILD_TYPE} CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE )
set( LIBCELLML_BUILD_TYPE ${BUILD_TYPE} CACHE STRING ${_PARAM_ANNOTATION} FORCE )
endif()

# INSTALL_PREFIX ==> LIBCELLML_INSTALL_PREFIX
set( LIBCELLML_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE STRING "Install path prefix, prepended onto install directories." )
set(_PARAM_ANNOTATION "Install path prefix, prepended onto install directories.")
set( LIBCELLML_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE STRING ${_PARAM_ANNOTATION} )
if( INSTALL_PREFIX )
set( LIBCELLML_INSTALL_PREFIX ${INSTALL_PREFIX} CACHE STRING "Install path prefix, prepended onto install directories." FORCE )
set( LIBCELLML_INSTALL_PREFIX ${INSTALL_PREFIX} CACHE STRING ${_PARAM_ANNOTATION} FORCE )
endif()

# BUILD_SHARED ==> LIBCELLML_BUILD_SHARED
set( LIBCELLML_BUILD_SHARED OFF CACHE BOOL "Build shared libraries (so, dylib, DLLs)." )
set(_PARAM_ANNOTATION "Build shared libraries (so, dylib, DLLs).")
set( LIBCELLML_BUILD_SHARED OFF CACHE BOOL ${_PARAM_ANNOTATION} )
if( BUILD_SHARED )
set( LIBCELLML_BUILD_SHARED ${BUILD_SHARED} CACHE BOOL "Build shared libraries (so, dylib, DLLs)." FORCE )
set( LIBCELLML_BUILD_SHARED ${BUILD_SHARED} CACHE BOOL ${_PARAM_ANNOTATION} FORCE )
endif()

# internalise some CMake variables
set( CMAKE_INSTALL_PREFIX ${LIBCELLML_INSTALL_PREFIX} CACHE INTERNAL "Internalise CMAKE_INSTALL_PREFIX, manipulate via LIBCELLML_INSTALL_PREFIX" FORCE )
set( CMAKE_BUILD_TYPE ${LIBCELLML_BUILD_TYPE} CACHE INTERNAL "Internalise CMAKE_BUILD_TYPE, manipulate via LIBCELLML_BUILD_TYPE" FORCE )
set( BUILD_SHARED_LIBS ${LIBCELLML_BUILD_SHARED} CACHE INTERNAL "Internalise BUILD_SHARED_LIBS, manipulate via LIBCELLML_BUILD_SHARED" FORCE )
set( CMAKE_CODEBLOCKS_EXECUTABLE "" CACHE INTERNAL "Internalise BUILD_SHARED_LIBS" FORCE )
set( CMAKE_CODEBLOCKS_EXECUTABLE "" CACHE INTERNAL "The CodeBlocks executable" FORCE )

# The version number.
set(LIBCELLML_VERSION_MAJOR 0)
Expand Down
32 changes: 32 additions & 0 deletions cmake/common.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2015 University of Auckland
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.cmake_minimum_required (VERSION 3.1)

function(TARGET_WARNINGS_AS_ERRORS _TARGET)
set(_COMPILER_WAE)

set(_GNU_FLAGS_COMPILER_COMPAT "GNU" "AppleClang" "Clang")
list(FIND _GNU_FLAGS_COMPILER_COMPAT "${CMAKE_CXX_COMPILER_ID}" _INDEX)
if(${_INDEX} GREATER -1)
set(_COMPILER_WAE -Wall -W -Werror)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(_COMPILER_WAE /W3)
endif()


if(_COMPILER_WAE)
target_compile_options(${_TARGET} PRIVATE ${_COMPILER_WAE})
endif()
unset(_COMPILER_WAE)
endfunction()

59 changes: 44 additions & 15 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,78 @@
# See the License for the specific language governing permissions and
# limitations under the License.cmake_minimum_required (VERSION 3.1)


set(CELLML_EXPORT_H "${CMAKE_CURRENT_BINARY_DIR}/api/libcellml/libcellml_export.h")
set(LIBCELLML_CONFIG_H "${CMAKE_CURRENT_BINARY_DIR}/libcellml_config.h")
configure_file (
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/libcellml_config.h.in"
${LIBCELLML_CONFIG_H}
)

set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/version.cpp
${CMAKE_CURRENT_SOURCE_DIR}/model.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xml_serialisation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/generated/cellml_1_2.cpp
)

set(API_HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/api/libcellml/version.h
${CMAKE_CURRENT_SOURCE_DIR}/api/libcellml/model.h
${CMAKE_CURRENT_SOURCE_DIR}/api/libcellml/xml_serialisation.h
${CELLML_EXPORT_H}
)

set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/generated/cellml_1_2.h
${LIBCELLML_CONFIG_H}
)

include_directories(
${CMAKE_CURRENT_BINARY_DIR}/api
${CMAKE_CURRENT_SOURCE_DIR}/api
${CMAKE_CURRENT_BINARY_DIR}
)

include(GenerateExportHeader)

add_compiler_export_flags()

add_library(cellml
${SOURCE_FILES}
${HEADER_FILES}
${API_HEADER_FILES}
)
generate_export_header(cellml EXPORT_FILE_NAME ${CELLML_EXPORT_H} BASE_NAME LIBCELLML)

set_source_files_properties(${CELLML_EXPORT_H} PROPERTIES GENERATED TRUE)
target_include_directories(cellml
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/api>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/api>
$<INSTALL_INTERFACE:include/>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../extdep/libxsd
${CMAKE_CURRENT_BINARY_DIR}
)

# To work around a bug conditionally set the CXX_STANDARD property
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set_target_properties(cellml PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON)
if(LIBCELLML_WARNINGS_TREATED_AS_ERRORS)
target_warnings_as_errors(cellml)
endif()

generate_export_header(cellml EXPORT_FILE_NAME ${CELLML_EXPORT_H} BASE_NAME LIBCELLML)

set(XercesC_ROOT "${XercesC_ROOT}" CACHE PATH "Location of Xerces-C")
set(BOOST_ROOT "${BOOST_ROOT}" CACHE PATH "Location of Boost")

set(CMAKE_INCLUDE_PATH "${XercesC_ROOT}/include")
set(CMAKE_LIBRARY_PATH "${XercesC_ROOT}/lib")
find_package (XercesC)
if (XercesC_FOUND)
target_include_directories(cellml PRIVATE ${XercesC_INCLUDE_DIR})
target_link_libraries (cellml ${XercesC_LIBRARY})
endif (XercesC_FOUND)


find_package (Boost)
if (Boost_FOUND)
target_include_directories(cellml PRIVATE ${Boost_INCLUDE_DIRS})
target_link_libraries (cellml ${Boost_LIBRARIES})
endif (Boost_FOUND)


set_source_files_properties(${CELLML_EXPORT_H} PROPERTIES GENERATED TRUE)

export(TARGETS cellml FILE libcellml-exports.cmake)

install(TARGETS cellml EXPORT libcellml-targets
Expand All @@ -66,8 +94,9 @@ install(TARGETS cellml EXPORT libcellml-targets

install(FILES
${API_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/libcellml
DESTINATION include/libcellml
)

install(EXPORT libcellml-targets DESTINATION lib/cmake)

set_target_properties(cellml PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON)
38 changes: 38 additions & 0 deletions src/api/libcellml/model.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Copyright 2015 University of Auckland

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.Some license of other
*/

#ifndef LIBCELLML_LIBCELLML_MODEL_H_
#define LIBCELLML_LIBCELLML_MODEL_H_

#include <string>

#include "libcellml/libcellml_export.h"

//! Everything in LibCellML is in this namespace.
namespace libcellml {

//! In-memory representation of a CellML model.
class LIBCELLML_EXPORT Model {
public:
/**
* Default constructor.
*/
Model();
};

} // namespace libcellml

#endif // LIBCELLML_LIBCELLML_MODEL_H_
10 changes: 5 additions & 5 deletions src/api/libcellml/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.Some license of other
*/

#ifndef LIBCELLML_VERSION_H
#define LIBCELLML_VERSION_H
#ifndef LIBCELLML_LIBCELLML_VERSION_H_
#define LIBCELLML_LIBCELLML_VERSION_H_

#include <string>

Expand All @@ -28,10 +28,10 @@ namespace libcellml {
* Get the version string.
* The version string is in the format x.y.z, where the "."s are literal, and x,y and z represent counting numbers,
* in which case x is the major version, y the minor version, and z the patch level.
* @return a string to represent the version
* @return a string to represent the version.
*/
LIBCELLML_EXPORT const std::string getVersion();

} // namespace libcellml
} // namespace libcellml

#endif /* LIBCELLML_VERSION_H */
#endif // LIBCELLML_LIBCELLML_VERSION_H_
36 changes: 36 additions & 0 deletions src/api/libcellml/xml_serialisation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright 2015 University of Auckland

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.Some license of other
*/

#ifndef LIBCELLML_LIBCELLML_XML_SERIALISATION_H_
#define LIBCELLML_LIBCELLML_XML_SERIALISATION_H_

#include "model.h"
#include "libcellml/libcellml_export.h"

#include <string>

namespace libcellml {

/**
Serialise the Model.
\param model The model to be serialised.
\return XML representation.
*/
std::string LIBCELLML_EXPORT createXml(const Model& model);

}

#endif // LIBCELLML_LIBCELLML_XML_SERIALISATION_H_
13 changes: 13 additions & 0 deletions src/cellml_1_2.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version='1.0'?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:cellml="http://www.cellml.org/cellml/1.2#"
elementFormDefault="qualified"
targetNamespace="http://www.cellml.org/cellml/1.2#">

<element name="model" type="cellml:model">
</element>
<complexType name="model">
<anyAttribute namespace="##other" processContents="lax"/>
</complexType>

</schema>
Loading