Major reorganization of source files into a better source tree

This commit is contained in:
Hugues Delorme 2014-03-13 17:49:39 +01:00
parent c4bb9015d6
commit ab794ded78
42 changed files with 115 additions and 220 deletions

View File

@ -6,18 +6,15 @@ include(CheckCSourceCompiles)
project(fougdatax)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Options
option(BUILD_SHARED_LIBS "Build shared libraries (DLL)" ON)
option(BUILD_STRICT_C90 "Build with strict conformance to C90 standard, if disabled FougDataX can use C99 features (eg. fabsf(), strtof(), ...)" ON)
option(BUILD_WITH_LIBSTL "Build the libSTL module" ON)
option(BUILD_WITH_QT_SUPPORT "Build with Qt support" OFF)
option(BUILD_WITH_QT_SUPPORT_FORCE_QT4 "Build the Qt support with Qt4 instead of Qt5. No effect if option BUILD_WITH_QT_SUPPORT is disabled" OFF)
option(BUILD_WITH_OCC_SUPPORT "Build with OpenCascade support" OFF)
# Add core source files
file(GLOB ALL_SRC_FILES src/* src/internal/*)
file(GLOB ALL_SRC_FILES src/datax_core/* src/datax_core/internal/*)
set(ALL_SRC_FILES ${ALL_SRC_FILES})
# Have <stdint.h> ?
@ -42,7 +39,7 @@ elseif(MSVC)
FOUG_HAVE_MSVC_BUILTIN_BSWAP_FUNC)
endif()
configure_file(src/config.h.cmake config.h @ONLY)
configure_file(src/datax_core/config.h.cmake config.h @ONLY)
include_directories(${CMAKE_BINARY_DIR}) # For generated "config.h"
# Specific flags for GCC
@ -52,6 +49,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic-errors -fstrict-aliasing")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Winline -Wextra -Wstrict-aliasing -Wcast-align -Wlogical-op -Wfloat-equal")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
# Specific flags for Visual C++
@ -66,105 +64,36 @@ if(BUILD_SHARED_LIBS)
endif()
# Declare installs
install(FILES ${CMAKE_BINARY_DIR}/config.h DESTINATION include/datax)
install(FILES ${CMAKE_BINARY_DIR}/config.h DESTINATION include/datax_core)
file(GLOB C_GLOBAL_HEADERS src/*.h)
install(FILES ${C_GLOBAL_HEADERS} DESTINATION include/datax)
file(GLOB C_CORE_HEADERS src/datax_core/*.h)
install(FILES ${C_CORE_HEADERS} DESTINATION include/datax_core)
# Module libSTL
if(BUILD_WITH_LIBSTL)
add_definitions(-DFOUG_DATAX_LIBSTL_DLL
-DFOUG_DATAX_LIBSTL_MAKE_DLL)
if(BUILD_SHARED_LIBS)
add_definitions(-DFOUG_DATAX_LIBSTL_DLL
-DFOUG_DATAX_LIBSTL_MAKE_DLL)
endif()
file(GLOB ALL_LIBSTL_SRC_FILES src/libstl/* src/internal/libstl/*)
file(GLOB ALL_LIBSTL_SRC_FILES src/datax_stl/* src/datax_stl/internal/*)
set(ALL_SRC_FILES ${ALL_SRC_FILES} ${ALL_LIBSTL_SRC_FILES})
endif()
file(GLOB C_LIBSTL_HEADERS src/libstl/*.h)
install(FILES ${C_LIBSTL_HEADERS} DESTINATION include/datax/libstl)
file(GLOB C_LIBSTL_HEADERS src/datax_stl/*.h)
install(FILES ${C_LIBSTL_HEADERS} DESTINATION include/datax_stl)
# Common for support modules
if(BUILD_WITH_QT_SUPPORT OR BUILD_WITH_OCC_SUPPORT)
if(BUILD_SHARED_LIBS)
add_definitions(-DFOUG_LIBSUPPORT_DLL
-DFOUG_LIBSUPPORT_MAKE_DLL)
endif()
endif()
install(FILES src/support/support_global.h DESTINATION include/datax/support)
install(FILES src/datax_support/support_global.h DESTINATION include/datax_support)
# Qt support
if(BUILD_WITH_QT_SUPPORT)
if(BUILD_WITH_QT_SUPPORT_FORCE_QT4)
find_package(Qt4 REQUIRED)
set(QT_USE_QTCORE TRUE)
set(QT_USE_QTGUI FALSE)
include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
else()
if ("${CMAKE_VERSION}" VERSION_GREATER 2.8.11)
cmake_policy(SET CMP0020 NEW)
endif()
find_package(Qt5Core REQUIRED)
endif()
file(GLOB ALL_QT_SUPPORT_SRC_FILES src/support/qt_*)
set(ALL_SRC_FILES ${ALL_SRC_FILES} ${ALL_QT_SUPPORT_SRC_FILES})
else()
install(FILES src/support/qt_stream.h DESTINATION src/support)
install(FILES src/support/qt_stream.cpp DESTINATION src/support)
endif()
install(FILES src/support/qt_stream.h DESTINATION include/datax/support)
install(FILES src/datax_support/qt_stream.h DESTINATION include/datax_support)
install(FILES src/datax_support/qt_stream.cpp DESTINATION src/datax_support)
# OpenCASCADE support
if(BUILD_WITH_OCC_SUPPORT)
set(CASCADE_ROOT "" CACHE PATH "Root directory of OpenCascade, useful only when option BUILD_WITH_OCC_SUPPORT is enabled")
file(GLOB ALL_OCC_SUPPORT_SRC_FILES src/support/occ_*)
set(ALL_SRC_FILES ${ALL_SRC_FILES} ${ALL_OCC_SUPPORT_SRC_FILES})
include_directories(${CASCADE_ROOT}/inc)
# Defines
if(WIN32)
add_definitions(-DWNT)
elseif("${CMAKE_SYSTEM}" MATCHES "Linux")
add_definitions(-DLIN
-DLININTEL
-DOCC_CONVERT_SIGNALS)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # 64b ?
add_definitions(-D_OCC64)
endif()
if(NOT WIN32)
add_definitions(-DHAVE_CONFIG_H
-DHAVE_FSTREAM
-DHAVE_IOSTREAM
-DHAVE_IOMANIP
-DHAVE_LIMITS_H)
endif()
# Libraries
#set(CASCADE_TOOLKITS TKSTL TKernel TKMath)
#foreach(occToolKit ${CASCADE_TOOLKITS})
# find_library(${occToolKit}_OCCLIB ${occToolKit} ${CASCADE_ROOT}/lib NO_DEFAULT_PATH)
# set(foundOccLib ${${occToolKit}_OCCLIB})
# if(foundOccLib STREQUAL ${occToolKit}_OCCLIB-NOTFOUND)
# message(FATAL_ERROR "Cannot find ${occToolKit} in ${CASCADE_ROOT}/lib")
# endif()
# set(CASCADE_LIBRARIES ${CASCADE_LIBRARIES} ${foundOccLib})
# mark_as_advanced(${occToolKit}_OCCLIB)
#endforeach()
link_directories(${CASCADE_ROOT}/lib)
else()
install(FILES src/support/occ_libstl.h DESTINATION src/support)
install(FILES src/support/occ_libstl.cpp DESTINATION src/support)
endif()
install(FILES src/support/occ_libstl.h DESTINATION include/datax/support)
install(FILES src/datax_support/occ_libstl.h DESTINATION include/datax_support)
install(FILES src/datax_support/occ_libstl.cpp DESTINATION src/datax_support)
# Installs for target
add_library(fougdatax ${ALL_SRC_FILES})
@ -174,22 +103,6 @@ install(TARGETS fougdatax
ARCHIVE DESTINATION lib)
# Qt support link
if(BUILD_WITH_QT_SUPPORT)
if(BUILD_WITH_QT_SUPPORT_FORCE_QT4)
target_link_libraries(fougdatax ${QT_LIBRARIES})
else()
qt5_use_modules(fougdatax Core)
endif()
endif()
# OpenCascade support link
if(BUILD_WITH_OCC_SUPPORT)
#target_link_libraries(fougdatax ${CASCADE_LIBRARIES})
target_link_libraries(fougdatax TKSTL TKernel TKMath)
endif()
# Examples:
# cmake ../.. -DCMAKE_INSTALL_PREFIX=../../gcc-linux64 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_DEBUG_POSTFIX=.debug
# cmake ../.. -DCMAKE_INSTALL_PREFIX=../../gcc-linux64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_RELEASE_POSTFIX=.release
@ -204,8 +117,8 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
add_executable(test_internal EXCLUDE_FROM_ALL tests/stream_buffer.c
tests/test_internal.c
src/stream.c
src/internal/ascii_parse.c)
src/datax_core/stream.c
src/datax_core/internal/ascii_parse.c)
add_executable(test_platform EXCLUDE_FROM_ALL tests/test_platform.c)
add_test(test_internal test_internal)
add_test(test_platform test_platform)

View File

@ -4,4 +4,4 @@ CONFIG(debug, debug|release) {
} else {
TARGET_SUFFIX =
}
CONFIG *= build_all debug_and_release
CONFIG += build_all debug_and_release

View File

@ -17,32 +17,34 @@ DATAX += stl
dll:DEFINES += FOUG_LIB_DLL \
FOUG_LIB_MAKE_DLL
INCLUDEPATH += $$PWD/../src
#*g++*:QMAKE_CXXFLAGS_RELEASE -= -O2
#*g++*:QMAKE_CXXFLAGS_RELEASE += -O3
HEADERS += \
config.h \
../src/endian.h \
../src/error.h \
../src/global.h \
../src/memory.h \
../src/stream.h \
../src/task_control.h \
../src/transfer.h \
../src/datax_core/endian.h \
../src/datax_core/error.h \
../src/datax_core/global.h \
../src/datax_core/memory.h \
../src/datax_core/stream.h \
../src/datax_core/task_control.h \
../src/datax_core/transfer.h \
\
../src/internal/convert.h \
../src/internal/ascii_parse.h \
../src/internal/byte_swap.h \
../src/internal/byte_codec.h
../src/datax_core/internal/convert.h \
../src/datax_core/internal/ascii_parse.h \
../src/datax_core/internal/byte_swap.h \
../src/datax_core/internal/byte_codec.h
SOURCES += \
../src/endian.c \
../src/error.c \
../src/stream.c \
../src/task_control.c \
../src/datax_core/endian.c \
../src/datax_core/error.c \
../src/datax_core/stream.c \
../src/datax_core/task_control.c \
\
../src/internal/convert.c \
../src/internal/ascii_parse.c
../src/datax_core/internal/convert.c \
../src/datax_core/internal/ascii_parse.c
*-g++*:QMAKE_CFLAGS += -ansi -pedantic-errors
*-msvc*:QMAKE_CFLAGS += -TC
@ -58,29 +60,29 @@ contains(DATAX, stl) {
#DEFINES += FOUG_STLB_READWRITE_ALIGNSAFE
HEADERS += \
../src/libstl/stl_error.h \
../src/libstl/stl_format.h \
../src/libstl/stl_geom.h \
../src/libstl/stl_geom_creator.h \
../src/libstl/stl_global.h \
../src/libstl/stl_io.h \
../src/libstl/stl_triangle.h \
../src/datax_stl/stl_error.h \
../src/datax_stl/stl_format.h \
../src/datax_stl/stl_geom.h \
../src/datax_stl/stl_geom_creator.h \
../src/datax_stl/stl_global.h \
../src/datax_stl/stl_io.h \
../src/datax_stl/stl_triangle.h \
\
../src/internal/libstl/stlb_byte_swap.h \
../src/internal/libstl/stl_rw_common.h
../src/datax_stl/internal/stlb_byte_swap.h \
../src/datax_stl/internal/stl_rw_common.h
SOURCES += \
../src/libstl/stl_format.c \
../src/libstl/stla_read.c \
../src/libstl/stla_write.c \
../src/libstl/stlb_read.c \
../src/libstl/stlb_write.c \
../src/datax_stl/stl_format.c \
../src/datax_stl/stla_read.c \
../src/datax_stl/stla_write.c \
../src/datax_stl/stlb_read.c \
../src/datax_stl/stlb_write.c \
\
../src/internal/libstl/stlb_byte_swap.c \
../src/internal/libstl/stl_rw_common.c
../src/datax_stl/internal/stlb_byte_swap.c \
../src/datax_stl/internal/stl_rw_common.c
libstl_inc.path = $$PREFIX_DIR/include/datax/libstl
libstl_inc.files = ../src/libstl/*.h
libstl_inc.path = $$PREFIX_DIR/include/datax_stl
libstl_inc.files = ../src/datax_stl/*.h
INSTALLS += libstl_inc
} # contains(DATAX, stl)
@ -91,46 +93,21 @@ HAS_SUPPORT = $$find(DATAX, support)
dll:DEFINES += FOUG_LIBSUPPORT_DLL \
FOUG_LIBSUPPORT_MAKE_DLL
support_inc.path = $$PREFIX_DIR/include/datax/support
support_inc.files = ../src/support/support_global.h
support_inc.files = ../src/datax_support/support_global.h
INSTALLS += support_inc
} # !isEmpty(HAS_SUPPORT)
# qt_support
contains(DATAX, qt_support) {
HEADERS += ../src/support/qt_stream.h
SOURCES += ../src/support/qt_stream.cpp
QT = core
qt_support_inc.path = $$PREFIX_DIR/include/datax/support
qt_support_inc.files = ../src/support/qt_stream.h
qt_support_inc.path = $$PREFIX_DIR/include/datax_support
qt_support_inc.files = ../src/datax_support/qt_stream.h
INSTALLS += qt_support_inc
} # contains(DATAX, qt_support)
# occ_support
contains(DATAX, occ_support) {
isEmpty(CASCADE_ROOT):error(Variable CASCADE_ROOT is not defined)
INCLUDEPATH += $$CASCADE_ROOT/inc
win32-*:DEFINES += WNT
linux-*:DEFINES += LIN LININTEL OCC_CONVERT_SIGNALS
*-64:DEFINES += _OCC64
!win32:DEFINES += HAVE_CONFIG_H \
HAVE_FSTREAM \
HAVE_IOSTREAM \
HAVE_IOMANIP \
HAVE_LIMITS_H
HEADERS += ../src/support/occ_libstl.h
SOURCES += ../src/support/occ_libstl.cpp
CASCADE_LIBPATH = $$CASCADE_ROOT/lib
LIBS += -L$$CASCADE_LIBPATH -lTKSTL -lTKernel -lTKMath
QMAKE_RPATHDIR += $$CASCADE_LIBPATH
occ_support_inc.path = $$PREFIX_DIR/include/datax/support
occ_support_inc.files = ../src/support/occ_libstl.h
occ_support_inc.path = $$PREFIX_DIR/include/datax_support
occ_support_inc.files = ../src/datax_support/occ_libstl.h
INSTALLS += occ_support_inc
} # contains(DATAX, occ_support)
@ -142,4 +119,4 @@ OTHER_FILES += \
../doc/main_page.cpp \
../doc/Doxyfile \
\
../src/config.h.cmake
../src/datax_core/config.h.cmake

View File

@ -1,7 +1,7 @@
#include "stl_rw_common.h"
#include "../../error.h"
#include "../../libstl/stl_error.h"
#include "../../datax_core/error.h"
#include "../stl_error.h"
foug_bool_t foug_check_transfer(int *error, const foug_transfer_t* trsf)
{

View File

@ -1,11 +1,11 @@
#ifndef FOUG_INTERNAL_STL_RW_COMMON_H
#define FOUG_INTERNAL_STL_RW_COMMON_H
#include "../../global.h"
#include "../../endian.h"
#include "../../transfer.h"
#include "../../libstl/stl_geom.h"
#include "../../libstl/stl_triangle.h"
#include "../../datax_core/global.h"
#include "../../datax_core/endian.h"
#include "../../datax_core/transfer.h"
#include "../stl_geom.h"
#include "../stl_triangle.h"
typedef struct
{

View File

@ -1,6 +1,6 @@
#include "stlb_byte_swap.h"
#include "../byte_swap.h"
#include "../../datax_core/internal/byte_swap.h"
void foug_stl_triangle_bswap(foug_stl_triangle_t* triangle)
{

View File

@ -1,8 +1,8 @@
#ifndef FOUG_INTERNAL_STLB_BYTE_SWAP_H
#define FOUG_INTERNAL_STLB_BYTE_SWAP_H
#include "../../global.h"
#include "../../libstl/stl_triangle.h"
#include "../../datax_core/global.h"
#include "../stl_triangle.h"
void foug_stl_triangle_bswap(foug_stl_triangle_t* triangle);

View File

@ -1,10 +1,11 @@
#include "stl_format.h"
#include "../endian.h"
#include "../internal/byte_codec.h"
#include "../internal/byte_swap.h"
#include "stl_triangle.h"
#include "../datax_core/endian.h"
#include "../datax_core/internal/byte_codec.h"
#include "../datax_core/internal/byte_swap.h"
#include <ctype.h>
#include <string.h>

View File

@ -2,7 +2,7 @@
#define FOUG_LIBSTL_FORMAT_H
#include "stl_global.h"
#include "../stream.h"
#include "../datax_core/stream.h"
FOUG_C_LINKAGE_BEGIN

View File

@ -1,7 +1,7 @@
#ifndef FOUG_DATAX_C_LIBSTL_STLB_GLOBAL_H
#define FOUG_DATAX_C_LIBSTL_STLB_GLOBAL_H
#include "../global.h"
#include "../datax_core/global.h"
#ifdef FOUG_DATAX_LIBSTL_DLL
# ifdef FOUG_DATAX_LIBSTL_MAKE_DLL

View File

@ -4,8 +4,8 @@
#include "stl_global.h"
#include "stl_geom.h"
#include "stl_geom_creator.h"
#include "../endian.h"
#include "../transfer.h"
#include "../datax_core/endian.h"
#include "../datax_core/transfer.h"
FOUG_C_LINKAGE_BEGIN

View File

@ -1,9 +1,10 @@
#include "stl_io.h"
#include "../internal/ascii_parse.h"
#include "../internal/libstl/stl_rw_common.h"
#include "../error.h"
#include "stl_error.h"
#include "internal/stl_rw_common.h"
#include "../datax_core/error.h"
#include "../datax_core/internal/ascii_parse.h"
#include <ctype.h>
#include <stdlib.h>

View File

@ -1,9 +1,10 @@
#include "stl_io.h"
#include "../error.h"
#include "../internal/libstl/stl_rw_common.h"
#include "internal/stl_rw_common.h"
#include "stl_error.h"
#include "../datax_core/error.h"
#include <stdio.h>
#include <string.h>

View File

@ -1,13 +1,13 @@
#include "stl_io.h"
#include "../endian.h"
#include "../error.h"
#include "stl_error.h"
#include "internal/stl_rw_common.h"
#include "internal/stlb_byte_swap.h"
#include "../internal/convert.h"
#include "../internal/byte_swap.h"
#include "../internal/libstl/stl_rw_common.h"
#include "../internal/libstl/stlb_byte_swap.h"
#include "../datax_core/endian.h"
#include "../datax_core/error.h"
#include "../datax_core/internal/convert.h"
#include "../datax_core/internal/byte_swap.h"
#include <string.h>

View File

@ -1,12 +1,12 @@
#include "stl_io.h"
#include "../endian.h"
#include "../error.h"
#include "stl_error.h"
#include "internal/stl_rw_common.h"
#include "internal/stlb_byte_swap.h"
#include "../internal/byte_codec.h"
#include "../internal/libstl/stl_rw_common.h"
#include "../internal/libstl/stlb_byte_swap.h"
#include "../datax_core/endian.h"
#include "../datax_core/error.h"
#include "../datax_core/internal/byte_codec.h"
#include <string.h>

View File

@ -1,4 +1,7 @@
#include "occ_libstl.h"
#include <datax_support/occ_libstl.h>
#include <datax_stl/stl_geom.h>
#include <datax_stl/stl_geom_creator.h>
#include <cstring>
#include <StlMesh_Mesh.hxx>

View File

@ -1,11 +1,10 @@
#ifndef FOUG_SUPPORT_OCC_LIBSTL_H
#define FOUG_SUPPORT_OCC_LIBSTL_H
extern "C" {
#include "support_global.h"
#include "../libstl/stl_io.h"
}
#include <Handle_StlMesh_Mesh.hxx>
struct foug_stl_geom;
struct foug_stl_geom_creator;
class FOUG_LIBSUPPORT_EXPORT foug_OccStlMeshDomain
{
@ -24,11 +23,11 @@ private:
};
FOUG_LIBSUPPORT_EXPORT
void foug_stl_occmesh_geom(foug_stl_geom_t* geom,
void foug_stl_occmesh_geom(foug_stl_geom* geom,
const foug_OccStlMeshDomain& meshCookie);
FOUG_LIBSUPPORT_EXPORT
void foug_stl_occmesh_geom_creator(foug_stl_geom_creator_t* creator,
void foug_stl_occmesh_geom_creator(foug_stl_geom_creator* creator,
const Handle_StlMesh_Mesh& mesh);
#endif /* FOUG_SUPPORT_OCC_LIBSTL_H */

View File

@ -1,4 +1,6 @@
#include "qt_stream.h"
#include <datax_support/qt_stream.h>
#include <datax_core/stream.h>
#include <QtCore/QFile>
#include <QtCore/QIODevice>

View File

@ -1,13 +1,11 @@
#ifndef FOUG_SUPPORT_QT_STREAM_H
#define FOUG_SUPPORT_QT_STREAM_H
extern "C" {
#include "support_global.h"
#include "../stream.h"
}
struct foug_stream;
class QIODevice;
FOUG_LIBSUPPORT_EXPORT
void foug_stream_set_qiodevice(foug_stream_t* stream, QIODevice* device);
void foug_stream_set_qiodevice(struct foug_stream* stream, QIODevice* device);
#endif /* FOUG_SUPPORT_QT_STREAM_H */

View File

@ -1,7 +1,7 @@
#ifndef FOUG_C_SUPPORT_GLOBAL_H
#define FOUG_C_SUPPORT_GLOBAL_H
#include "../global.h"
#include <datax_core/global.h>
#ifdef FOUG_LIBSUPPORT_DLL
# ifdef FOUG_LIBSUPPORT_MAKE_DLL