-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixing errors in documentation * Initial commit creating shared library * Adding pkg-config file * Adding shared library example * Removing fprofile-arcs from shared library * Expanding README.md * Setting LD LIBRARY PATH * Incrementing CMake version
- Loading branch information
Showing
10 changed files
with
252 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ build/* | |
CHGCAR* | ||
*.png | ||
src/config.h | ||
src/den2obj.pc | ||
|
||
# do not save doc build | ||
docs/_build/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Examples | ||
|
||
This folder contains a number of scripts how to use Den2Obj as a (shared) | ||
library in your own programs and applications. | ||
|
||
## Requirements | ||
|
||
To use Den2Obj as a shared library in your applications, you need to dynamically | ||
link against `libden2obj.so` as well as against a number of required libraries: | ||
|
||
* Boost (regex, iostreams and filesystem) | ||
* GZIP | ||
* LZMA | ||
* BZ2 | ||
|
||
Besides these libraries, there is also a header-only dependency on the Eigen3 | ||
library. | ||
|
||
A convenient way to ensure this in your application is by making use of | ||
`CMake` and using the following settings in your `CmakeLists.txt file` | ||
|
||
```cmake | ||
# use Boost | ||
SET(BOOST_INCLUDEDIR "/usr/include") | ||
SET(BOOST_LIBRARYDIR "/usr/lib/x86_64-linux-gnu") | ||
# set Boost | ||
set (Boost_NO_SYSTEM_PATHS ON) | ||
set (Boost_USE_MULTITHREADED ON) | ||
set (Boost_USE_STATIC_LIBS OFF) | ||
set (Boost_USE_STATIC_RUNTIME OFF) | ||
set (BOOST_ALL_DYN_LINK OFF) | ||
# use OpenMP | ||
find_package(OpenMP) | ||
if (OPENMP_FOUND) | ||
option(HAS_OPENMP "OpenMP enabled" ON) | ||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") | ||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") | ||
endif() | ||
# include libraries | ||
find_package(PkgConfig REQUIRED) | ||
find_package(Boost COMPONENTS regex iostreams filesystem REQUIRED) | ||
find_package(LibLZMA REQUIRED) | ||
find_package(ZLIB REQUIRED) | ||
find_package(BZip2 REQUIRED) | ||
pkg_check_modules(DEN2OBJ den2obj REQUIRED) | ||
pkg_check_modules(EIGEN eigen3 REQUIRED) | ||
``` | ||
|
||
and finally add the required libraries to your executable | ||
|
||
```cmake | ||
target_link_libraries(den2obj-shared-example | ||
${DEN2OBJ_LIBRARIES} | ||
${Boost_LIBRARIES} | ||
${LIBLZMA_LIBRARIES} | ||
${ZLIB_LIBRARIES} | ||
${BZIP2_LIBRARIES}) | ||
``` | ||
|
||
An example of this is provided in [shared/CMakeLists.txt](shared/CMakeLists.txt). | ||
|
||
## Compilation instructions | ||
|
||
```bash | ||
mkdir build && cd build | ||
cmake ../shared | ||
make -j | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#************************************************************************* | ||
# CMakeLists.txt -- This file is part of DEN2OBJ. * | ||
# * | ||
# Author: Ivo Filot <i.a.w.filot@tue.nl> * | ||
# * | ||
# DEN2OBJ 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. * | ||
# * | ||
# DEN2OBJ 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/. * | ||
# * | ||
#*************************************************************************/ | ||
|
||
# set minimum cmake requirements | ||
cmake_minimum_required(VERSION 3.5) | ||
project (den2obj-shared-example) | ||
|
||
# add custom directory to look for .cmake files | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules ) | ||
|
||
# Enable release build | ||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
message(STATUS "Setting build type to 'Release' as none was specified.") | ||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) | ||
# Set the possible values of build type for cmake-gui | ||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") | ||
endif() | ||
|
||
# add OS specific | ||
SET(BOOST_INCLUDEDIR "/usr/include") | ||
SET(BOOST_LIBRARYDIR "/usr/lib/x86_64-linux-gnu") | ||
|
||
# set Boost | ||
set (Boost_NO_SYSTEM_PATHS ON) | ||
set (Boost_USE_MULTITHREADED ON) | ||
set (Boost_USE_STATIC_LIBS OFF) | ||
set (Boost_USE_STATIC_RUNTIME OFF) | ||
set (BOOST_ALL_DYN_LINK OFF) | ||
|
||
# use OpenMP | ||
find_package(OpenMP) | ||
if (OPENMP_FOUND) | ||
option(HAS_OPENMP "OpenMP enabled" ON) | ||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") | ||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") | ||
endif() | ||
|
||
# include libraries | ||
find_package(PkgConfig REQUIRED) | ||
find_package(Boost COMPONENTS regex iostreams filesystem REQUIRED) | ||
find_package(LibLZMA REQUIRED) | ||
find_package(ZLIB REQUIRED) | ||
find_package(BZip2 REQUIRED) | ||
pkg_check_modules(DEN2OBJ den2obj REQUIRED) | ||
pkg_check_modules(EIGEN eigen3 REQUIRED) | ||
|
||
# Set include folders | ||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} | ||
${CMAKE_BINARY_DIR} | ||
${EIGEN_INCLUDE_DIRS} | ||
${DEN2OBJ_INCLUDE_DIR} | ||
${Boost_INCLUDE_DIRS}) | ||
|
||
# Add sources | ||
file(GLOB SOURCES "*.cpp") | ||
add_executable(den2obj-shared-example ${SOURCES}) | ||
|
||
# Set C++17 | ||
add_definitions(-std=c++17 -march=native) | ||
|
||
# Link libraries | ||
target_link_libraries(den2obj-shared-example | ||
${DEN2OBJ_LIBRARIES} | ||
${Boost_LIBRARIES} | ||
${LIBLZMA_LIBRARIES} | ||
${ZLIB_LIBRARIES} | ||
${BZIP2_LIBRARIES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <den2obj/scalar_field.h> | ||
#include <den2obj/generator.h> | ||
#include <memory> | ||
#include <string> | ||
|
||
int main() { | ||
// construct scalar field | ||
Generator gen; | ||
const std::string filename = "genus2.d2o"; | ||
gen.build_dataset("genus2", filename, D2OFormat::CompressionAlgo::BZIP2); | ||
|
||
auto sf = std::make_unique<ScalarField>(filename, | ||
ScalarFieldInputFileType::SFF_D2O); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
prefix=@CMAKE_INSTALL_PREFIX@ | ||
exec_prefix=@CMAKE_INSTALL_PREFIX@ | ||
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ | ||
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ | ||
|
||
Name: @PROJECT_NAME@ | ||
Description: @PROJECT_DESCRIPTION@ | ||
Version: @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_MICRO@ | ||
|
||
Requires: | ||
Libs: -L${libdir} -lden2obj | ||
Cflags: -I${includedir} |