Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
loadbalancing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SLMS
loadbalancing
Commits
6b1805ac
Commit
6b1805ac
authored
4 years ago
by
Stephan Schulz
Browse files
Options
Downloads
Patches
Plain Diff
clean CMake files and update example CMake project for VTK and Voronoi
parent
ce848a36
No related branches found
No related tags found
1 merge request
!15
CMake projectconfig
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
example/CMakeProject/CMakeLists.txt
+34
-7
34 additions, 7 deletions
example/CMakeProject/CMakeLists.txt
example/CMakeProject/build_all.sh
+28
-4
28 additions, 4 deletions
example/CMakeProject/build_all.sh
src/CMakeLists.txt
+9
-12
9 additions, 12 deletions
src/CMakeLists.txt
with
71 additions
and
23 deletions
example/CMakeProject/CMakeLists.txt
+
34
−
7
View file @
6b1805ac
# REMEMBER TO SET CC AND CXX! CMake is too dumb to find compiler in your path!
# mkdcd build
# CC=gcc CXX=g++ cmake -DALL_DIR=`pwd`/../../jall_bin/lib/cmake/ALL ../
# REMEMBER TO SET CC AND CXX!
# CC=gcc CXX=g++ cmake -S . -B build -DALL_DIR=`pwd`/../../jall_bin/lib/cmake/ALL
cmake_minimum_required
(
VERSION 3.14
)
project
(
ALL_Staggered
)
...
...
@@ -11,14 +10,42 @@ set(CMAKE_CXX_STANDARD 11)
set
(
CMAKE_CXX_STANDARD_REQUIRED ON
)
set
(
CMAKE_CXX_EXTENSIONS OFF
)
# For cleaner code we should also include MPI here, since this project's source
# also needs MPI. Otherwise, we are free to leave it out, since the parts
# required by ALL are automatically included.
find_package
(
MPI REQUIRED COMPONENTS CXX Fortran
)
# Some variants for testing VTK output and the voronoi method. These are only
# required, so the code used in .this. project has the corresponding features
# enabled and calls the respective functions from the library. This is not
# required for the library itself. Although the library needs have been built
# with the respective features enabled.
add_compile_definitions
(
TEST_VTK_OUTPUT
)
add_compile_definitions
(
TEST_VORONOI
)
# For C++ projects including ALL the following macros must also be defined at
# the moment, if the respective features are used. Otherwise, they are not
# visible in the header files.
add_compile_definitions
(
ALL_VTK_OUTPUT
)
add_compile_definitions
(
ALL_VORONOI_ACTIVE
)
find_package
(
ALL 0.9.1
)
add_executable
(
ALL_Staggered ALL_Staggered.cpp
)
target_link_libraries
(
ALL_Staggered PRIVATE ALL::ALL
)
target_link_libraries
(
ALL_Staggered PUBLIC ALL::ALL
)
# This is in this case not .necessary., since it is already inherited from ALL,
# however, for readability and clear intent, we should still link against MPI
# ourselves, since our code also uses MPI directly.
target_link_libraries
(
ALL_Staggered PUBLIC
${
MPI_CXX_LINK_FLAGS
}
${
MPI_CXX_LIBRARIES
}
)
target_include_directories
(
ALL_Staggered PRIVATE
${
MPI_CXX_INCLUDE_PATH
}
)
add_executable
(
ALL_Staggered_f ALL_Staggered_f.F90
)
target_link_libraries
(
ALL_Staggered_f LINK_PRIVATE ALL::ALL
)
target_link_libraries
(
ALL_Staggered_f LINK_PRIVATE ALL::ALL_fortran
)
set_property
(
TARGET ALL_Staggered_f PROPERTY LINKER_LANGUAGE Fortran
)
#todo(s.schulz): link against MPI
target_link_libraries
(
ALL_Staggered_f PUBLIC ALL::ALL_fortran
)
target_link_libraries
(
ALL_Staggered_f PUBLIC
${
MPI_Fortran_LINK_FLAGS
}
${
MPI_Fortran_LIBRARIES
}
)
target_include_directories
(
ALL_Staggered_f PRIVATE
${
MPI_Fortran_INCLUDE_PATH
}
)
add_executable
(
ALL_test ALL_test.cpp
)
target_link_libraries
(
ALL_test PUBLIC ALL::ALL
)
target_link_libraries
(
ALL_test PUBLIC
${
MPI_CXX_LINK_FLAGS
}
${
MPI_CXX_LIBRARIES
}
)
target_include_directories
(
ALL_test PRIVATE
${
MPI_CXX_INCLUDE_PATH
}
)
# should also explicitly link against VTK
This diff is collapsed.
Click to expand it.
example/CMakeProject/build_all.sh
+
28
−
4
View file @
6b1805ac
...
...
@@ -9,9 +9,16 @@ set -x
# $ALL_INSTALL_DIR must be an absolute path!
ALL_ROOT_DIR
=
../..
ALL_BUILD_DIR
=
all_build
ALL_INSTALL_DIR
=
`
pwd
`
/all_bin
ALL_INSTALL_DIR
=
`
pwd
`
/all_bin
#where ALL installs itself to
ALL_PACKAGE
=
`
pwd
`
/all_package
#where our project expects the installed ALL
VTK_DIR
=
`
pwd
`
/../../../vtk_bin
BUILD_DIR
=
build
# We only move ALL after installation from $ALL_INSTALL_DIR to $ALL_PACKAGE to
# test for errors in relocatability of the library. A typical user does not
# need to do that and can just set $ALL_PACKAGE to the directory ALL installs
# itself to.
export
CC
=
gcc
export
CXX
=
g++
...
...
@@ -21,21 +28,38 @@ build_all () {
cmake
-S
"
$ALL_ROOT_DIR
"
-B
"
$ALL_BUILD_DIR
"
\
-DCMAKE_INSTALL_PREFIX
=
"
$ALL_INSTALL_DIR
"
\
-DCM_ALL_FORTRAN
=
ON
\
-DCMAKE_BUILD_TYPE
=
Release
-DCM_ALL_VTK_OUTPUT
=
ON
\
-DCM_ALL_VORONOI
=
ON
\
-DCMAKE_BUILD_TYPE
=
Release
\
-DVTK_DIR
=
"
$VTK_DIR
"
/lib/cmake/vtk-7.1
cmake
--build
"
$ALL_BUILD_DIR
"
rm
-rf
"ALL_INSTALL_DIR"
cmake
--install
"
$ALL_BUILD_DIR
"
if
[[
$ALL_INSTALL_DIR
!=
$ALL_PACKAGE
]]
then
mv
"
$ALL_INSTALL_DIR
"
"
$ALL_PACKAGE
"
fi
}
build_self
()
{
rm
-rf
"
$BUILD_DIR
"
mkdir
"
$BUILD_DIR
"
cmake
-S
.
-B
"
$BUILD_DIR
"
\
-DALL_DIR
=
"
$ALL_INSTALL_DIR
"
/lib/cmake/ALL
-DALL_DIR
=
"
$ALL_PACKAGE
"
/lib/cmake/ALL
\
-DVTK_DIR
=
"
$VTK_DIR
"
/lib/cmake/vtk-7.1
VERBOSE
=
1 cmake
--build
"
$BUILD_DIR
"
}
cmake
--build
"
$BUILD_DIR
"
prepare_example
()
{
cat
$1
|
sed
\
-e
's/ALL_VTK_OUTPUT/TEST_VTK_OUTPUT/'
\
-e
's/ALL_VORONOI_ACTIVE/TEST_VORONOI/'
\
>
$2
}
prepare_example ../ALL_test.cpp ALL_test.cpp
build_all
build_self
This diff is collapsed.
Click to expand it.
src/CMakeLists.txt
+
9
−
12
View file @
6b1805ac
...
...
@@ -12,9 +12,6 @@ set(ALL_HEADER_FILES
${
ALL_INCLUDE_DIR
}
/ALL_Tensor.hpp
${
ALL_INCLUDE_DIR
}
/ALL_Voronoi.hpp
)
# todo(s.schulz): Should these be installed explicitly?
# install(FILES ${ALL_HEADER_FILES} DESTINATION include)
add_library
(
ALL ALL.cpp ALL_fortran.cpp
${
ALL_HEADER_FILES
}
)
if
(
CM_ALL_VTK_OUTPUT
)
...
...
@@ -25,14 +22,18 @@ if(CM_ALL_VORONOI)
target_link_libraries
(
ALL PUBLIC voro
)
endif
(
CM_ALL_VORONOI
)
target_link_libraries
(
ALL INTERFACE stdc++
)
target_include_directories
(
ALL PUBLIC
${
MPI_CXX_INCLUDE_PATH
}
)
target_link_libraries
(
ALL PUBLIC
${
MPI_CXX_LINK_FLAGS
}
${
MPI_CXX_LIBRARIES
}
)
target_include_directories
(
ALL
PUBLIC
"$<BUILD_INTERFACE:
${
ALL_INCLUDE_DIR
}
>"
"$<INSTALL_INTERFACE:include>"
)
target_link_libraries
(
ALL PUBLIC
${
MPI_CXX_LINK_FLAGS
}
${
MPI_CXX_LIBRARIES
}
)
# For inclusion in Fortran code, explicit linking against the C++ standard
# library is necessary.
target_link_libraries
(
ALL INTERFACE stdc++
)
install
(
TARGETS ALL
EXPORT ALLTargets
...
...
@@ -49,17 +50,13 @@ if (CM_ALL_FORTRAN)
add_library
(
ALL_fortran ALL_module.F90
)
set_property
(
TARGET ALL_fortran PROPERTY LINKER_LANGUAGE Fortran
)
if
(
CM_ALL_VTK_OUTPUT
)
target_include_directories
(
ALL_fortran PUBLIC
${
VTK_INCLUDE_DIRS
}
)
target_link_libraries
(
ALL_fortran PUBLIC
${
VTK_LIBRARIES
}
)
endif
(
CM_ALL_VTK_OUTPUT
)
target_include_directories
(
ALL_fortran PUBLIC
${
MPI_Fortran_INCLUDE_PATH
}
)
target_include_directories
(
ALL_fortran
INTERFACE
"$<BUILD_INTERFACE:
${
CMAKE_Fortran_MODULE_DIRECTORY
}
>"
"$<INSTALL_INTERFACE:include/modules>"
)
target_link_libraries
(
ALL_fortran PUBLIC
${
MPI_Fortran_LINK_FLAGS
}
${
MPI_Fortran_LIBRARIES
}
ALL
)
target_link_libraries
(
ALL_fortran PUBLIC
${
MPI_Fortran_LINK_FLAGS
}
${
MPI_Fortran_LIBRARIES
}
)
target_link_libraries
(
ALL_fortran PUBLIC ALL
)
install
(
TARGETS ALL_fortran
EXPORT ALLTargets
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment