Skip to content
Snippets Groups Projects
Commit e288a371 authored by Martin Beseda's avatar Martin Beseda
Browse files

FIX: Fixed compilation for external dependencies installed in the system on Linux.

parent ff1461e0
No related branches found
No related tags found
No related merge requests found
......@@ -100,18 +100,11 @@ set(SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/src)
set(PROJECT_BINARY_DIR ${CMAKE_CURRENT_LIST_DIR}/build)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
#----------------------------------------#
# Dependencies for the lib4neuro library #
#----------------------------------------#
#if(WIN32)
# set(LINK_DEP_LIB4NEURO libboost_serialization libboost_system libboost_random libboost_unit_test libexprtk)
#else()
# set(LINK_DEP_LIB4NEURO boost_serialization boost_system boost_random boost_unit_test exprtk)
#endif()
message("Running CMake in: ${SRC_DIR} ${PROJECT_BINARY_DIR}")
add_subdirectory(${SRC_DIR} ${PROJECT_BINARY_DIR})
......
......@@ -9,6 +9,10 @@
# * BOOST_LIBRARYDIR - The path to the folder containing Boost libraries
# * BOOST_INCLUDEDIR - The path to the folder containing Boost header files
# "External" used variables
#
# * DEPENDENCIES_LINK_TYPE - TODO
# "Output" variables set after running this script
# * Boost_FOUND - TODO
# * Boost_INCLUDE_DIRS - TODO
......@@ -53,9 +57,20 @@ if(NOT Boost_INCLUDE_DIRS)
endif()
# Create a list of requested Boost libraries with "system" names
if(NOT DEPENDENCIES_LINK_TYPE)
message(FATAL_ERROR "Variable DEPENDENCIES_LINK_TYPE is not set! Set it to 'static' or 'shared'.")
endif()
set(LIB_SUFFIX "a")
if("${DEPENDENCIES_LINK_TYPE}" STREQUAL "shared" AND WIN32)
set(LIB_SUFFIX "dll")
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 "libboost_${COMPONENT}.a")
list(APPEND REQUESTED_BOOST_LIBS "libboost_${COMPONENT}.${LIB_SUFFIX}")
endforeach()
# Look for libraries specified by COMPONENTS flag
......
......@@ -10,6 +10,7 @@
BUILD_TESTS=yes
BUILD_EXAMPLES=yes
BUILD_LIB=yes
DEPENDENCIES_LINK_TYPE=shared # shared/static
# Build type (Release/Debug)
BUILD_TYPE=Debug
......@@ -31,5 +32,5 @@ $(pwd)/clean.sh
git submodule init
git submodule update --remote
cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} -DCMAKE_C_COMPILER=${C_COMPILER} -DBUILD_TESTS=${BUILD_TESTS} -DBUILD_EXAMPLES=${BUILD_EXAMPLES} -DBUILD_LIB=${BUILD_LIB} -DLIB4NEURO_DIR=$(pwd)/build/lib .
cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} -DCMAKE_C_COMPILER=${C_COMPILER} -DBUILD_TESTS=${BUILD_TESTS} -DBUILD_EXAMPLES=${BUILD_EXAMPLES} -DBUILD_LIB=${BUILD_LIB} -DLIB4NEURO_DIR=$(pwd)/build/lib -DDEPENDENCIES_LINK_TYPE=${DEPENDENCIES_LINK_TYPE} .
cmake --build . --config ${BUILD_TYPE} -- -j${N_CORES} && (tput setaf 2; echo "Build complete."; echo "For examples have a look at the folder build/bin/examples."; tput sgr 0; ) || (tput setaf 1; echo "Build finished with errors!"; tput sgr 0; exit 1;)
......@@ -29,16 +29,22 @@ if ("${BUILD_LIB}" STREQUAL "yes")
PROPERTIES
INCLUDE_DIRECTORIES "${ROOT_DIR}/include;${SRC_DIR};${Boost_INCLUDE_DIRS}"
LINK_LIBRARIES "${BOOST_LIBRARIES}"
ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin"
)
if(WIN32)
if(WIN32 AND "${DEPENDENCIES_LINK_TYPE}" STREQUAL "static")
add_library(libboost_unit_test STATIC boost_test_lib_dummy.cpp)
add_library(libexprtk STATIC exprtk.cpp)
#target_link_libraries(lib4neuro ${LINK_DEP_LIB4NEURO})
else()
elseif(WIN32 AND "${DEPENDENCIES_LINK_TYPE}" STREQUAL "static")
message(FATAL_ERROR "Only static linking of external dependencies is supported for Windows systems now!")
elseif("${DEPENDENCIES_LINK_TYPE}" STREQUAL "static")
add_library(boost_unit_test STATIC boost_test_lib_dummy.cpp)
add_library(exprtk STATIC exprtk.cpp)
#target_link_libraries(lib4neuro ${LINK_DEP_LIB4NEURO})
elseif("${DEPENDENCIES_LINK_TYPE}" STREQUAL "shared")
add_library(boost_unit_test SHARED boost_test_lib_dummy.cpp)
add_library(exprtk SHARED exprtk.cpp)
endif()
endif ()
......@@ -22,4 +22,7 @@ set_target_properties(
PROPERTIES
INCLUDE_DIRECTORIES "${ROOT_DIR}/include"
LINK_LIBRARIES "lib4neuro"
ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/"
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/examples"
)
......@@ -34,5 +34,8 @@ set_target_properties(
PROPERTIES
INCLUDE_DIRECTORIES "${ROOT_DIR}/include;${SRC_DIR};${Boost_INCLUDE_DIRS}"
LINK_LIBRARIES "lib4neuro;boost_unit_test;${BOOST_LIBRARIES}"
ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/tests"
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment