commit aa873c3330a3282a67008c9d13b57c78b4558b5e parent fa7ceed5addf465bd22181b795c59df86f68037a Author: Vincent Forest <vincent.forest@meso-star.com> Date: Mon, 21 Nov 2016 12:26:05 +0100 Major project refactoring Make the solstice parser a separate CMake project. Diffstat:
18 files changed, 98 insertions(+), 54 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -16,10 +16,10 @@ cmake_minimum_required(VERSION 2.8) project(solstice C CXX) enable_testing() - -set(SOLSTICE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src) option(NO_TEST "Do not build tests" OFF) +set(SOLSTICE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src/) + ################################################################################ # Check dependencies ################################################################################ @@ -27,19 +27,19 @@ get_filename_component(_current_source_dir ${CMAKE_CURRENT_LIST_FILE} PATH) set(LibYAML_DIR ${_current_source_dir}/) find_package(LibYAML REQUIRED) -find_package(RCMake 0.2 REQUIRED) find_package(RCMake 0.2.3 REQUIRED) find_package(RSys 0.3 REQUIRED) -find_package(StarSP 0.4 REQUIRED) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR}) include(rcmake) include(rcmake_runtime) -include_directories( - ${LibYAML_INCLUDE_DIR} - ${RSys_INCLUDE_DIR} - ${StarSP_INCLUDE_DIR}) +include_directories(${RSys_INCLUDE_DIR}) + +################################################################################ +# Build subprojects +################################################################################ +add_subdirectory(parser) ################################################################################ # Configure and define targets @@ -49,14 +49,8 @@ set(VERSION_MINOR 1) set(VERSION_PATCH 0) set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) -set(SOLSTICE_FILES_SRC - solstice_parser.c) -set(SOLSTICE_FILES_INC - solstice_entity.h - solstice_material.h - solstice_parser.h - solstice_shape.h - solstice_sun.h) +set(SOLSTICE_FILES_SRC solstice.c) +set(SOLSTICE_FILES_INC ) set(SOLSTICE_FILES_DOC COPYING README.md) # Prepend each file in the `SOLSTICE_FILES_<SRC|INC>' list by `SOLSTICE_SOURCE_DIR' @@ -68,55 +62,19 @@ if(CMAKE_COMPILER_IS_GNUCC) set(MATH_LIB m) endif() -add_library(solstitium STATIC ${SOLSTICE_FILES_SRC} ${SOLSTICE_FILES_INC}) add_executable(solstice ${SOLSTICE_SOURCE_DIR}/solstice.c) -target_link_libraries(solstice LibYAML RSys StarSP ${MATH_LIB} solstitium) +target_link_libraries(solstice LibYAML RSys ${MATH_LIB} solstice-parser) set_target_properties(solstice PROPERTIES VERSION ${VERSION} SOVERSION ${VERSION_MAJOR}) rcmake_copy_runtime_libraries(solstice) ################################################################################ -# Tests -################################################################################ -if(NOT NO_TEST) - function(build_test _name) - add_executable(${_name} - ${SOLSTICE_SOURCE_DIR}/${_name}.c - ${SOLSTICE_SOURCE_DIR}/test_solstice_utils.h) - target_link_libraries(${_name} LibYAML ${MATH_LIB} RSys solstitium) - endfunction() - - function(new_test _name) - build_test(${_name}) - add_test(${_name} ${_name}) - endfunction() - - new_test(test_solstice_parser2) - - build_test(test_solstice_parser) - add_test(test_solstice_parser_ok_0 test_solstice_parser - ${SOLSTICE_SOURCE_DIR}/yaml/test_ok_0.yaml) - add_test(test_solstice_parser_ok_1 test_solstice_parser - ${SOLSTICE_SOURCE_DIR}/yaml/test_ok_1.yaml) - add_test(test_solstice_parser_ok_2 test_solstice_parser - ${SOLSTICE_SOURCE_DIR}/yaml/test_ok_2.yaml) -# TODO rewrite them wrt the update of the input specification -# add_test(test_solstice_parser_ko_0 test_solstice_parser -e -# ${SOLSTICE_SOURCE_DIR}/yaml/test_ko_0.yaml) -# add_test(test_solstice_parser_ko_1 test_solstice_parser -e -# ${SOLSTICE_SOURCE_DIR}/yaml/test_ko_1.yaml) -# add_test(test_solstice_parser_ko_2 test_solstice_parser -e -# ${SOLSTICE_SOURCE_DIR}/yaml/test_ko_2.yaml) -endif() - -################################################################################ # Define output & install directories ################################################################################ install(TARGETS solstice ARCHIVE DESTINATION bin LIBRARY DESTINATION lib RUNTIME DESTINATION bin) -install(FILES ${SOLSTICE_FILES_INC_API} DESTINATION include/solstice) install(FILES ${SOLSTICE_FILES_DOC} DESTINATION share/doc/solstice) diff --git a/cmake/parser/CMakeLists.txt b/cmake/parser/CMakeLists.txt @@ -0,0 +1,86 @@ +# Copyright (C) CNRS 2016 +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +cmake_minimum_required(VERSION 2.8) +project(solstice-parser C CXX) + +set(PARSER_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../../src/parser) + +################################################################################ +# Define include directories +################################################################################ +include_directories( + ${LibYAML_INCLUDE_DIR} + ${RSys_INCLUDE_DIR} + ${PARSER_SOURCE_DIR}/../) + +################################################################################ +# Configure and define targets +################################################################################ +set(PARSER_FILES_SRC + solstice_parser.c) +set(PARSER_FILES_INC + solstice_entity.h + solstice_material.h + solstice_parser.h + solstice_shape.h + solstice_sun.h) + +# Prepend each file in the `SOLSTICE_FILES_<SRC|INC>' list by `SOLSTICE_SOURCE_DIR' +rcmake_prepend_path(PARSER_FILES_SRC ${PARSER_SOURCE_DIR}) +rcmake_prepend_path(PARSER_FILES_INC ${PARSER_SOURCE_DIR}) +rcmake_prepend_path(SOARSER_FILES_DOC ${PROJECT_SOURCE_DIR}/../) + +if(CMAKE_COMPILER_IS_GNUCC) + set(MATH_LIB m) +endif() + +add_library(solstice-parser STATIC ${PARSER_FILES_SRC} ${PARSER_FILES_INC}) + +################################################################################ +# Tests +################################################################################ +if(NOT NO_TEST) + function(build_test _name) + add_executable(${_name} + ${PARSER_SOURCE_DIR}/${_name}.c + ${PARSER_SOURCE_DIR}/../test_solstice_utils.h) + target_link_libraries(${_name} LibYAML ${MATH_LIB} RSys solstice-parser) + endfunction() + + function(new_test _name) + build_test(${_name}) + add_test(${_name} ${_name}) + endfunction() + + new_test(test_solstice_parser2) + + build_test(test_solstice_parser) + add_test(test_solstice_parser_ok_0 test_solstice_parser + ${PARSER_SOURCE_DIR}/yaml/test_ok_0.yaml) + add_test(test_solstice_parser_ok_1 test_solstice_parser + ${PARSER_SOURCE_DIR}/yaml/test_ok_1.yaml) + add_test(test_solstice_parser_ok_2 test_solstice_parser + ${PARSER_SOURCE_DIR}/yaml/test_ok_2.yaml) +# TODO rewrite them wrt the update of the input specification +# add_test(test_solstice_parser_ko_0 test_solstice_parser -e +# ${SOLSTICE_SOURCE_DIR}/yaml/test_ko_0.yaml) +# add_test(test_solstice_parser_ko_1 test_solstice_parser -e +# ${SOLSTICE_SOURCE_DIR}/yaml/test_ko_1.yaml) +# add_test(test_solstice_parser_ko_2 test_solstice_parser -e +# ${SOLSTICE_SOURCE_DIR}/yaml/test_ko_2.yaml) +endif() + + diff --git a/src/solstice_entity.h b/src/parser/solstice_entity.h diff --git a/src/solstice_geometry.h b/src/parser/solstice_geometry.h diff --git a/src/solstice_material.h b/src/parser/solstice_material.h diff --git a/src/solstice_parser.c b/src/parser/solstice_parser.c diff --git a/src/solstice_parser.h b/src/parser/solstice_parser.h diff --git a/src/solstice_shape.h b/src/parser/solstice_shape.h diff --git a/src/solstice_sun.h b/src/parser/solstice_sun.h diff --git a/src/test_solstice_parser.c b/src/parser/test_solstice_parser.c diff --git a/src/test_solstice_parser2.c b/src/parser/test_solstice_parser2.c diff --git a/src/yaml/test_ko_0.yaml b/src/parser/yaml/test_ko_0.yaml diff --git a/src/yaml/test_ko_1.yaml b/src/parser/yaml/test_ko_1.yaml diff --git a/src/yaml/test_ko_2.yaml b/src/parser/yaml/test_ko_2.yaml diff --git a/src/yaml/test_ok_0.yaml b/src/parser/yaml/test_ok_0.yaml diff --git a/src/yaml/test_ok_1.yaml b/src/parser/yaml/test_ok_1.yaml diff --git a/src/yaml/test_ok_2.yaml b/src/parser/yaml/test_ok_2.yaml diff --git a/src/solstice.c b/src/solstice.c @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "solstice_parser.h" +#include "parser/solstice_parser.h" #include <rsys/rsys.h> int