Skip to content

Commit

Permalink
Made build.sh more portable and fixed OpenMP build
Browse files Browse the repository at this point in the history
  • Loading branch information
Ithanil committed Feb 21, 2019
1 parent 1f91f37 commit 6e51a9e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ message(STATUS "Configured GSL_ROOT_DIR: ${GSL_ROOT_DIR}")

if (USE_OPENMP)
find_package(OpenMP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOPENMP=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -DOPENMP=1")
message(STATUS "OPENMP_LIBRARY_PATHS: ${OpenMP_CXX_LIBRARY}")
message(STATUS "OPENMP_LIBRARIES: ${OpenMP_CXX_LIBRARIES}")
endif()
Expand Down
12 changes: 8 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#!/bin/sh

. ./config.sh
mkdir -p build
cd build
cmake -DCMAKE_CXX_COMPILER="${CXX_COMPILER}" -DUSER_CXX_FLAGS="${CXX_FLAGS}" -DUSE_COVERAGE="${USE_COVERAGE}" -DGSL_ROOT_DIR="${GSL_ROOT}" ..
make -j$(nproc)
mkdir -p build && cd build
cmake -DCMAKE_CXX_COMPILER="${CXX_COMPILER}" -DUSER_CXX_FLAGS="${CXX_FLAGS}" -DUSE_COVERAGE="${USE_COVERAGE}" -DUSE_OPENMP="${USE_OPENMP}" -DGSL_ROOT_DIR="${GSL_ROOT}" ..

if [ "$1" == "" ]; then
make -j$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null)
else
make -j$1
fi
2 changes: 1 addition & 1 deletion config_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CXX_FLAGS="-O3 -flto -Wall -Wno-unused-function"
# add coverage flags
USE_COVERAGE=0

# use MPI for integration
# use OpenMP for parallel propagation
USE_OPENMP=0

# GNU Scientific Library
Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
file(GLOB SOURCES "*/*.cpp")
add_library(ffnn SHARED ${SOURCES})
target_link_libraries(ffnn "${GSL_LIBRARIES}") # shared libs
target_link_libraries(ffnn "${GSL_LIBRARIES}" "${OpenMP_CXX_LIBRARIES}") # shared libs
add_library(ffnn_static STATIC ${SOURCES})
target_link_libraries(ffnn_static "{$GSL_LIBRARIES}") # static (+ some shared) libs
target_link_libraries(ffnn_static "{$GSL_LIBRARIES}" "${OpenMP_CXX_LIBRARIES}") # static (+ some shared) libs

0 comments on commit 6e51a9e

Please sign in to comment.