Skip to content

Commit 57c8933

Browse files
committed
basic transition to cmake build + some reorganization of files
1 parent 1ed571e commit 57c8933

28 files changed

+81
-238
lines changed

.gitignore

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,12 @@ DerivedData
6060

6161
# -- project specific ignores --
6262
lib*
63+
build
6364
config.sh
6465
*exe*
6566
vgcore*
6667

67-
src/*.o
68-
69-
debug/*.o
70-
debug/*.txt
71-
72-
debug/unittests/ut*/*.o
73-
debug/unittests/ut*/*.sh
74-
75-
examples/*/a.out
76-
examples/*/*.o
68+
test/*.txt
7769

7870
doc/*.aux
7971
doc/*.dvi

CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cmake_minimum_required (VERSION 3.5)
2+
include(FindPackageHandleStandardArgs)
3+
4+
project (mci LANGUAGES CXX VERSION 0.0.1)
5+
6+
set(CMAKE_CXX_STANDARD 11)
7+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
8+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
9+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${USER_CXX_FLAGS}")
10+
11+
# find packages
12+
message(STATUS "Configured CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
13+
14+
find_package(MPI)
15+
message(STATUS "MPI_INCLUDE_PATH: ${MPI_INCLUDE_PATH}")
16+
message(STATUS "MPI_CXX_LIBRARIES: ${MPI_CXX_LIBRARIES}")
17+
18+
# set header / library paths
19+
include_directories(include/) # headers
20+
include_directories(SYSTEM ${MPI_INCLUDE_PATH})
21+
22+
enable_testing()
23+
24+
# continue with subdirectories
25+
add_subdirectory(src)
26+
add_subdirectory(test)
27+
add_subdirectory(examples)
28+

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ Some basic tools for finding the average and standard deviation of an array of d
66

77
In `doc/` there is a user manual in pdf.
88

9-
In `examples/` there are several examples (STILL TO BE DONE).
9+
In `examples/` there are examples.
1010

1111

1212

1313
# Build the library
1414

15-
Insert the system parameters in a file named `config.sh` (use `config_template.sh` as template) and then simply execute the command
15+
We use the CMake build system, so you need to have it on your system to build the library out of the box.
16+
Then copy the file `config_template.sh` to `config.sh`, edit it to your liking and then simply execute the command
1617

1718
`./build.sh`
19+
20+
Note that we build out-of-tree, so the compiled library and executable files can be found in the directories under `./build/`.

build.sh

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,8 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

3-
OS_NAME=$(uname)
4-
echo "The Operating System is: "${OS_NAME} # here we consider only Linux and Darwin (Mac Os X)
5-
6-
source config.sh
7-
ACTUAL_FOLDER=$(pwd)
8-
9-
\rm -f *.so
10-
cd src/
11-
\rm -f *.o *.so
12-
echo "$CC $FLAGS $OPTFLAGS -fpic -c *.cpp"
13-
$CC $FLAGS $OPTFLAGS -fpic -c *.cpp
14-
15-
case ${OS_NAME} in
16-
"Linux")
17-
echo "$CC $FLAGS $OPTFLAGS -shared -o lib${LIBNAME}.so *.o"
18-
$CC $FLAGS $OPTFLAGS -shared -o lib${LIBNAME}.so *.o
19-
;;
20-
"Darwin")
21-
ROOT_FOLDER=$(dirname $(pwd))
22-
echo "$CC $FLAGS $OPTFLAGS -shared -install_name ${ROOT_FOLDER}/lib${LIBNAME}.so -o lib${LIBNAME}.so *.o"
23-
$CC $FLAGS $OPTFLAGS -shared -install_name ${ROOT_FOLDER}/lib${LIBNAME}.so -o lib${LIBNAME}.so *.o
24-
;;
25-
*)
26-
echo "The detected operating system is not between the known ones (Linux and Darwin)"
27-
;;
28-
esac
29-
30-
mv lib${LIBNAME}.so ../
3+
source ./config.sh
4+
mkdir -p build
5+
cd build
6+
cmake -DUSER_CXX_FLAGS="${CXX_FLAGS}" ..
7+
make
318
cd ..
32-
33-
34-
echo
35-
echo "Library ready!"
36-
echo
37-
echo "Help, how can I use it?"
38-
case ${OS_NAME} in
39-
"Linux")
40-
echo "1) $CC $FLAGS -I$(pwd)/src/ -c example.cpp"
41-
echo " $CC $FLAGS -L$(pwd) example.o -l${LIBNAME}"
42-
echo "2) $CC $FLAGS -I$(pwd)/src/ -L$(pwd) example.cpp -l${LIBNAME}"
43-
;;
44-
"Darwin")
45-
echo "1) $CC $FLAGS -I$(pwd)/src/ -c example.cpp"
46-
echo " $CC $FLAGS -I$(pwd)/src/ -L$(pwd) example.o -l${LIBNAME}"
47-
echo "2) $CC $FLAGS -I$(pwd)/src/ -L$(pwd) example.cpp -l${LIBNAME}"
48-
;;
49-
esac

build_debug_library.sh

Lines changed: 0 additions & 49 deletions
This file was deleted.

config_template.sh

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

3-
# Library name
4-
LIBNAME="mci"
3+
# C++ flags
4+
CXX_FLAGS="-O3 -flto -Wall"
55

6+
# currently unused:
67
# C++ compiler
7-
CC="g++"
8-
8+
#CC="g++"
99
# MPI compiler wrapper
10-
MPICC="mpic++"
11-
12-
# C++ flags (std=c++11 is necessary)
13-
FLAGS="-std=c++11 -Wall -Werror"
14-
15-
# Optimization flags
16-
OPTFLAGS="-O3 -flto"
10+
#MPICC="mpic++"
1711

18-
# Debuggin flags
19-
DEBUGFLAGS="-g -O0"

debug/run.sh

Lines changed: 0 additions & 53 deletions
This file was deleted.

debug/unittests/run.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

debug/unittests/run_single_unittest.sh

Lines changed: 0 additions & 31 deletions
This file was deleted.

examples/CMakeLists.txt

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

0 commit comments

Comments
 (0)