diff --git a/CMakeLists.txt b/CMakeLists.txt index e1a07f0194ca5252af39c090e9970e821f25d553..c8df40006b989afe2d58de2d3202e4f99eaae21d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,6 +86,20 @@ if(N_CORES GREATER 1) endif() message("Build will be performed on ${N_CORES} cores.") +#----------------------------------------# +# Set prefixes and suffixes of libraries # +#----------------------------------------# +set(LIB_PREFIX "lib") +set(LIB_SUFFIX "a") # suffix for Linux static libraries +if("${DEPENDENCIES_LINK_TYPE}" STREQUAL "shared" AND WIN32) + set(LIB_PREFIX "") + set(LIB_SUFFIX "dll") +elseif("${DEPENDENCIES_LINK_TYPE}" STREQUAL "static" AND WIN32) + set(LIB_SUFFIX "lib") +elseif("${DEPENDENCIES_LINK_TYPE}" STREQUAL "shared") + set(LIB_SUFFIX "so") +endif() + #-------------------------# # Find external libraries # #-------------------------# diff --git a/DownloadArmadillo.cmake b/DownloadArmadillo.cmake index f03b9843ad1ec1fa38c5db2593e78b2482fce735..89e94435299d303469fb23df937ed20ac44792f6 100644 --- a/DownloadArmadillo.cmake +++ b/DownloadArmadillo.cmake @@ -2,9 +2,9 @@ set(ARMADILLO_LOCAL_PATH ${CMAKE_CURRENT_LIST_DIR}/external_dependencies/armadil include(FetchContent) -################### -# Download exprtk # -################### +###################### +# Download Armadillo # +###################### FetchContent_Declare( armadillo SOURCE_DIR ${ARMADILLO_LOCAL_PATH} diff --git a/FindArmadillo.cmake b/FindArmadillo.cmake index 37c55872f1fa8e3cbe8546740b70a0734ccb0bc4..ff8c0dc9340c4a2d2ae656a10aba25df756974aa 100644 --- a/FindArmadillo.cmake +++ b/FindArmadillo.cmake @@ -1,6 +1,6 @@ message("FindArmadillo starting...") -# Find headers and libraries +# Find headers FIND_PATH( ARMADILLO_INCLUDE_DIR @@ -23,29 +23,49 @@ FIND_PATH( armadillo include/armadillo ) -# Set TURTLE_FOUND honoring the QUIET and REQUIRED arguments + +# Find library +set(LIBNAME ${LIB_PREFIX}armadillo.so) +message(${LIBNAME}) +FIND_LIBRARY( + ARMADILLO_LIBRARY_DIR + + NAMES + ${LIBNAME} + + HINTS + external_dependencies/armadillo + + PATHS + /usr/lib + /usr/local/lib +) + +# Set ARMADILLO_FOUND honoring the QUIET and REQUIRED arguments INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS( armadillo "Armadillo was NOT found!" - ARMADILLO_INCLUDE_DIR) + ARMADILLO_INCLUDE_DIR + ARMADILLO_LIBRARY_DIR) # Output variables IF(ARMADILLO_FOUND) # Include dirs SET(ARMADILLO_INCLUDE_DIRS ${ARMADILLO_INCLUDE_DIR}) - set(TMP "") - string(REGEX REPLACE "/include" "" TMP ${ARMADILLO_INCLUDE_DIR}) - add_subdirectory(${TMP} ${TMP}) + # If Armadillo is downloaded as a source code, add it to the project, so the library will be compiled + # automatically + IF(${ARMADILLO_INCLUDE_DIR} MATCHES "^.*external_dependencies.*$") + set(TMP "") + string(REGEX REPLACE "/include" "" TMP ${ARMADILLO_INCLUDE_DIR}) + add_subdirectory(${TMP} ${TMP}) + ENDIF() message("Armadillo was successfully found.") ENDIF() -# Add path only to the 'include' folder -#set(TMP "") -#string(REGEX REPLACE "/turtle$" "" TMP ${TURTLE_INCLUDE_DIR}) -#list(APPEND TURTLE_INCLUDE_DIR ${TMP}) - # Advanced options for not cluttering the cmake UIs: MARK_AS_ADVANCED(ARMADILLO_INCLUDE_DIR) +MARK_AS_ADVANCED(ARMADILLO_LIBRARY_DIR) + diff --git a/FindBoost.cmake b/FindBoost.cmake index 310932412ce8953b7981b2c6caa2a3ef40347835..e23824b37707dde8fe12c0c516c7be94238990b5 100644 --- a/FindBoost.cmake +++ b/FindBoost.cmake @@ -74,17 +74,6 @@ if(NOT DEPENDENCIES_LINK_TYPE) message(FATAL_ERROR "Variable DEPENDENCIES_LINK_TYPE is not set! Set it to 'static' or 'shared'.") endif() -set(LIB_PREFIX "lib") -set(LIB_SUFFIX "a") # suffix for Linux static libraries -if("${DEPENDENCIES_LINK_TYPE}" STREQUAL "shared" AND WIN32) - set(LIB_PREFIX "") - set(LIB_SUFFIX "dll") -elseif("${DEPENDENCIES_LINK_TYPE}" STREQUAL "static" AND WIN32) - set(LIB_SUFFIX "lib") -elseif("${DEPENDENCIES_LINK_TYPE}" STREQUAL "shared") - set(LIB_SUFFIX "so") -endif() - set(REQUESTED_BOOST_LIBS "") foreach(COMPONENT ${Boost_FIND_COMPONENTS}) list(APPEND REQUESTED_BOOST_LIBS "${LIB_PREFIX}boost_${COMPONENT}.${LIB_SUFFIX}") diff --git a/src/ErrorFunction/ErrorFunctions.h b/src/ErrorFunction/ErrorFunctions.h index a8de729805d2977838ab54629c209b76d6e03983..2a5d556cf5fe27b7e7df0eba424e0b8753b1110a 100644 --- a/src/ErrorFunction/ErrorFunctions.h +++ b/src/ErrorFunction/ErrorFunctions.h @@ -171,7 +171,7 @@ namespace lib4neuro { */ DataSet* ds_test = nullptr; }; - + class MSE : public ErrorFunction{ public: