diff options
author | Johannes 'josch' Schauer <josch@debian.org> | 2019-01-27 13:56:24 +0100 |
---|---|---|
committer | Johannes 'josch' Schauer <josch@debian.org> | 2019-01-27 13:56:33 +0100 |
commit | 6ce553563bc795f389f639a3a8cdfe356de71441 (patch) | |
tree | da4c9ede3087ca534d93bc1ac5a14f044f036600 /examples/application | |
parent | bbefa170378553e5a6e0d72e4d52328b61f3e8ac (diff) |
new upstream version 6.0
Diffstat (limited to 'examples/application')
-rw-r--r-- | examples/application/CMakeLists.txt | 140 | ||||
-rwxr-xr-x | examples/application/clean.sh | 1 | ||||
-rw-r--r-- | examples/application/compile.bat | 24 | ||||
-rwxr-xr-x | examples/application/compile.sh | 25 | ||||
-rw-r--r-- | examples/application/src/main.cpp | 16 |
5 files changed, 206 insertions, 0 deletions
diff --git a/examples/application/CMakeLists.txt b/examples/application/CMakeLists.txt new file mode 100644 index 0000000..3ec0869 --- /dev/null +++ b/examples/application/CMakeLists.txt @@ -0,0 +1,140 @@ +cmake_minimum_required(VERSION 2.8.8) + +project(FuzzyLiteDemo CXX) + +#Some default policies and variables +if (APPLE) + cmake_policy(SET CMP0042 NEW) +endif() +if (MSVC) + cmake_policy(SET CMP0054 NEW) +endif() + +if(NOT CMAKE_VERBOSE_MAKEFILE) + set(CMAKE_VERBOSE_MAKEFILE false) +endif() + +if( NOT CMAKE_BUILD_TYPE ) + set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo +MinSizeRel." FORCE ) +endif() + +option(FL_BACKTRACE "Provide backtrace information in case of errors" ON) +option(FL_STATIC "Statically link to fuzzylite libraries" ON) + +set(BacktraceLibrary) + +if (MSVC AND FL_BACKTRACE) + set(BacktraceLibrary dbghelp) +endif() + +if (CMAKE_BUILD_TYPE MATCHES Debug) + set(FL_DEBUG ON) +else() + set(FL_DEBUG OFF) +endif() + + +set(FL_SYSTEM_LIBRARY FALSE) #Finds the library installed in the system +set(FL_LIBRARY_DIR) + +if (NOT FL_SYSTEM_LIBRARY) + #it is possible to find the FuzzyLiteLibrary locally as follows, + #assuming the submodule of fuzzylite is added to the ${PROJECT_SOURCE_DIR}: + set(FL_HOME ${PROJECT_SOURCE_DIR}/../../fuzzylite/) + set(FL_INCLUDE_DIR ${FL_HOME}) + if (FL_DEBUG) + set(FL_LIBRARY_DIR ${FL_HOME}/debug/bin) + else() + set(FL_LIBRARY_DIR ${FL_HOME}/release/bin) + endif() + message("Finding FuzzyLiteLibrary locally at ${FL_LIBRARY_DIR}") + + include_directories(${FL_INCLUDE_DIR}) +endif() + +set(FL_POSTFIX) +if (FL_STATIC) + set(FL_POSTFIX "-static") +endif() +if (FL_DEBUG) + set(FL_POSTFIX "${FL_POSTFIX}-debug") +endif() + +set(FL_LIBRARY_NAME fuzzylite${FL_POSTFIX}) +find_library (FuzzyLiteLibrary ${FL_LIBRARY_NAME} HINTS ${FL_LIBRARY_DIR}) + +if (MSVC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19) +#C++11 not available before Visual Studio 2015 + if (NOT FL_CPP98) + set(FL_CPP98 ON) + endif() +endif() + + +#if building using C++98 +if(FL_CPP98) + add_definitions(-DFL_CPP98) + if(NOT MSVC) + #Set C++98 by default in Clang and others + add_definitions(-std=c++98) + endif() +else() + if(NOT MSVC) + #Set C++11 by default in Clang and others + add_definitions(-std=c++11) + endif() +endif(FL_CPP98) + +#we add the definition of the building path to remove it when using macro FL_LOG +add_definitions(-DFL_BUILD_PATH="${CMAKE_SOURCE_DIR}") #used to determine +#we add the sources +set(sources src/main.cpp) + + + +if(MSVC) +#Set compilation flags in Windows + set(CMAKE_CXX_FLAGS "/W4 /EHsc") + #Wx: Treat warnings as errors. W4: All warnings + #http://msdn.microsoft.com/en-us/library/thxezb7y.aspx + #EHsc: call destructors on __try __catch, and to ignore C4530: C++ exception handler used. Note, unwind semantics are not enabled +endif() + + +#we create the binary +add_executable(binary ${sources}) +if (NOT FL_STATIC) + target_compile_definitions(binary PRIVATE FL_IMPORT_LIBRARY) +endif() +#linking the fuzzylite library +target_link_libraries (binary ${FuzzyLiteLibrary} ${BacktraceLibrary}) +#setting the name of the product +set_target_properties(binary PROPERTIES OUTPUT_NAME FuzzyLiteDemo) +#specially for windows +set_target_properties(binary PROPERTIES OUTPUT_NAME FuzzyLiteDemo IMPORT_PREFIX tmp-) #To prevent LNK1149 in Windows +#in case of building on debug mode +set_target_properties(binary PROPERTIES DEBUG_POSTFIX d) + + + +message("=====================================") +message("FuzzyLite Demo v6.0\n") +message("FL_HOME=${FL_HOME}") +message("FL_LIBRARY_NAME=${FL_LIBRARY_NAME}") +message("FuzzyLiteLibrary=${FuzzyLiteLibrary}") +message("") +message("FL_BACKTRACE=${FL_BACKTRACE}") +message("FL_STATIC=${FL_STATIC}") +message("FL_DEBUG=${FL_DEBUG}") +message("CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") +message("CMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID}") +message("CMAKE_CXX_COMPILER_VERSION=${CMAKE_CXX_COMPILER_VERSION}") +message("CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}") +message("COMPILE_DEFINITIONS:") +get_directory_property(fl-definitions DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS ) +foreach(d ${fl-definitions}) + message( STATUS "Defined: " ${d} ) +endforeach() +message("=====================================\n") + diff --git a/examples/application/clean.sh b/examples/application/clean.sh new file mode 100755 index 0000000..4f4bc9c --- /dev/null +++ b/examples/application/clean.sh @@ -0,0 +1 @@ +rm -rf CMakeCache.txt CMakeFiles Makefile cmake_install.cmake FuzzyLiteDemo
\ No newline at end of file diff --git a/examples/application/compile.bat b/examples/application/compile.bat new file mode 100644 index 0000000..8baf5a3 --- /dev/null +++ b/examples/application/compile.bat @@ -0,0 +1,24 @@ +FL_HOME="../../fuzzylite/" + +rem Static Linking +rem -------------- +rem For C++11 +cl.exe src/main.cpp %FL_HOME%/release/bin/fuzzylite-static.lib /I%FL_HOME% /EHsc /MD + +rem For C++98 +cl.exe src/main.cpp %FL_HOME%/release/bin/fuzzylite-static.lib /I%FL_HOME% /DFL_CPP98=ON /EHsc /MD + + +rem Dynamic Linking +rem --------------- +rem For C++11 +rem For C++11 +cl.exe src/main.cpp %FL_HOME%/release/bin/fuzzylite-static.lib /I%FL_HOME% /DFL_IMPORT_LIBRARY /EHsc /MD + +rem For C++98 +cl.exe src/main.cpp %FL_HOME%/release/bin/fuzzylite-static.lib /I%FL_HOME% /DFL_CPP98=ON /DFL_IMPORT_LIBRARY /EHsc /MD + +rem Note: when using dynamic linking, the path to fuzzylite libraries must be specified. For example, run from console the following: + +set PATH="%FL_HOME%\release\bin;%PATH%" +example-dynamic-11.exe diff --git a/examples/application/compile.sh b/examples/application/compile.sh new file mode 100755 index 0000000..1ea1aa4 --- /dev/null +++ b/examples/application/compile.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +FL_HOME="../../fuzzylite/" + +#Static Linking +#-------------- +#For C++11 +g++ src/main.cpp -oexample-static-11 -I$FL_HOME -L$FL_HOME/release/bin -lfuzzylite-static -std=c++11 + +#For C++98 +g++ src/main.cpp -oexample-static-98 -I$FL_HOME -L$FL_HOME/release/bin -lfuzzylite-static -DFL_CPP98=ON -Wno-non-literal-null-conversion + + +#Dynamic Linking +#--------------- +#For C++11 +g++ src/main.cpp -oexample-dynamic-11 -I$FL_HOME -L$FL_HOME/release/bin -lfuzzylite -std=c++11 + +#For C++98 +g++ src/main.cpp -oexample-dynamic-98 -I$FL_HOME -L$FL_HOME/release/bin -lfuzzylite -DFL_CPP98=ON -Wno-non-literal-null-conversion + +#Note: when using dynamic linking, the path to fuzzylite libraries must be specified. For example, run from console the following: + +LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$FL_HOME/release/bin; +./example-dynamic-11 diff --git a/examples/application/src/main.cpp b/examples/application/src/main.cpp new file mode 100644 index 0000000..d547b72 --- /dev/null +++ b/examples/application/src/main.cpp @@ -0,0 +1,16 @@ + +#include "fl/Headers.h" + +int main(int argc, char** argv){ + FL_IUNUSED(argc); + FL_IUNUSED(argv); + + using namespace fl; + + Engine* hybrid = Console::hybrid(); + FL_LOG("Hybrid Demo: FuzzyLite Dataset"); + FL_LOG("==============================="); + FL_LOG(FldExporter().toString(hybrid)); + delete hybrid; + +}
\ No newline at end of file |