Skip to content

Commit f0a933f

Browse files
committed
cmake polish
1 parent 57c8933 commit f0a933f

File tree

7 files changed

+37
-14
lines changed

7 files changed

+37
-14
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,8 @@ DerivedData
6262
lib*
6363
build
6464
config.sh
65-
*exe*
6665
vgcore*
6766

68-
test/*.txt
69-
7067
doc/*.aux
7168
doc/*.dvi
7269
doc/*.idx

CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${USER_CXX_FLAGS}")
1212
message(STATUS "Configured CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
1313

1414
find_package(MPI)
15-
message(STATUS "MPI_INCLUDE_PATH: ${MPI_INCLUDE_PATH}")
16-
message(STATUS "MPI_CXX_LIBRARIES: ${MPI_CXX_LIBRARIES}")
15+
if (MPI_FOUND)
16+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_MPI=1")
17+
include_directories(SYSTEM ${MPI_INCLUDE_PATH})
18+
message(STATUS "MPI_INCLUDE_PATH: ${MPI_INCLUDE_PATH}")
19+
message(STATUS "MPI_CXX_LIBRARIES: ${MPI_CXX_LIBRARIES}")
20+
endif()
1721

1822
# set header / library paths
1923
include_directories(include/) # headers
20-
include_directories(SYSTEM ${MPI_INCLUDE_PATH})
2124

2225
enable_testing()
2326

config_template.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
#!/bin/bash
22

33
# C++ flags
4-
CXX_FLAGS="-O3 -flto -Wall"
4+
CXX_FLAGS="-O3 -flto -Wall -Wno-unused-function"
55

66
# currently unused:
77
# C++ compiler
8-
#CC="g++"
9-
# MPI compiler wrapper
10-
#MPICC="mpic++"
11-
8+
# CXX="g++"

examples/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
link_libraries(mci)
22
add_executable(ex1.exe ex1/main.cpp)
3-
add_executable(ex2.exe ex2/main.cpp)
4-
target_link_libraries(ex2.exe ${MPI_CXX_LIBRARIES})
3+
if (MPI_FOUND)
4+
add_executable(ex2.exe ex2/main.cpp)
5+
target_link_libraries(ex2.exe ${MPI_CXX_LIBRARIES})
6+
endif()

include/mci/MPIMCI.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if USE_MPI==1
2+
13
#ifndef MPIMCI
24
#define MPIMCI
35

@@ -124,3 +126,5 @@ namespace MPIMCI
124126
};
125127

126128
#endif
129+
130+
#endif

src/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
file(GLOB SOURCES "*.cpp")
2-
add_library(mci STATIC ${SOURCES})
2+
add_library(mci SHARED ${SOURCES})
3+
add_library(mci_static STATIC ${SOURCES})
4+
5+
if (MPI_FOUND)
6+
target_link_libraries(mci ${MPI_CXX_LIBRARIES})
7+
target_link_libraries(mci_static ${MPI_CXX_LIBRARIES})
8+
endif()

test/run.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
VALGRIND="valgrind --leak-check=full --track-origins=yes"
4+
5+
ORIGDIR=$(pwd)
6+
cd ../build/test/
7+
${VALGRIND} ./check
8+
for exe in ./ut*.exe; do
9+
echo
10+
echo "Running test ${exe}..."
11+
${VALGRIND} ${exe}
12+
echo
13+
done
14+
cd ${ORIGDIR}

0 commit comments

Comments
 (0)