Skip to content

Commit a80e47b

Browse files
committed
Add CMake to example. Update README.
1 parent 939979a commit a80e47b

File tree

2 files changed

+45
-11
lines changed

2 files changed

+45
-11
lines changed

example/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# CXX compiler must match the one used to compiler BLAS++.
2+
# Set it in your environment.
3+
4+
cmake_minimum_required( VERSION 3.8 )
5+
6+
project(
7+
blaspp_example
8+
LANGUAGES CXX
9+
)
10+
11+
add_executable(
12+
example_gemm
13+
example_gemm.cc
14+
)
15+
16+
find_package( OpenMP ) # may be required by blaspp
17+
find_package( blaspp )
18+
19+
target_link_libraries(
20+
example_gemm
21+
blaspp
22+
)

example/README.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,36 @@ or in the Makefile. For the flags, there are two more options:
1414
a. Using pkg-config to get CXXFLAGS and LIBS for BLAS++ (recommended).
1515
pkg-config must be able to locate the blas++ package. If it is installed
1616
outside the default search path (see `pkg-config --variable pc_path pkg-config`),
17-
it should be added to `$PKG_CONFIG_PATH`. For instance:
18-
19-
export PKG_CONFIG_PATH=/usr/local/blaspp/lib/pkgconfig # for sh
20-
setenv PKG_CONFIG_PATH /usr/local/blaspp/lib/pkgconfig # for csh
21-
17+
it should be added to `$PKG_CONFIG_PATH`. For instance, if it is installed
18+
in /opt/slate:
19+
20+
export PKG_CONFIG_PATH=/opt/slate/lib/pkgconfig # for sh
21+
setenv PKG_CONFIG_PATH /opt/slate/lib/pkgconfig # for csh
22+
2223
b. Hard-code CXXFLAGS and LIBS for BLAS++ in the Makefile.
2324

2425
Then, to build `example_gemm` using the Makefile, run:
25-
26+
2627
make
27-
28+
2829
## Option 2: CMake
2930

30-
todo: CMake must know where BLAS++ is installed.
31+
CMake must know the compiler used to compile BLAS++. Set CXX to the
32+
compiler, in your environment.
33+
34+
It's best (but not required) to compile in out-of-source in a build directory:
3135

32-
Then, to build `example_gemm` using the CMakeLists.txt, run:
36+
mkdir build && cd build
37+
38+
If BLAS++ is installed outside the default search path, tell cmake
39+
where, for example, in /opt/slate:
40+
41+
cmake -DCMAKE_PREFIX_PATH=/opt/slate ..
42+
43+
Otherwise, simply run:
3344

34-
mkdir build
35-
cd build
3645
cmake ..
46+
47+
Then, to build `example_gemm` using the resulting Makefile, run:
48+
3749
make

0 commit comments

Comments
 (0)