Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve TribitsExampleProject and TribitsExampleApp readme #445

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tribits/examples/TribitsExampleApp/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# TribitsExampleApp

The example project `TribitsExampleApp` is a raw CMake project that pulls in
libraries from packages from `TribitsExampleProject`. To build against all of
the installed packages from an upstream `TribitsExampleProject`, configure,
build, and run the tests with:
libraries from packages from `TribitsExampleProject`. If subpackage C of
`TribitsExampleProject` was build, then Fortran compiler is required to build
`TribitsExampleApp`. To build against all of the installed packages from an
upstream `TribitsExampleProject`, configure, build, and run the tests with:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, if the WithSubpackageC subpackage or or the MixedLang packages are built, then a Fortran compiler is required.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change pushed


```
cmake \
Expand Down
16 changes: 14 additions & 2 deletions tribits/examples/TribitsExampleProject/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The project `TribitsExampleProject` defines a TriBITS CMake project designed to
provide a simple example to demonstrate how to use the TriBITS system to
create a CMake build, test, and deployment system using a package-based
architecture.
architecture. To build `TribitsExampleProject` Fortran compiler is needed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To build all of the packages from TribitsExampleProject, a Fortran compiler is needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change pushed


To build and test the project, one must first create a build directory and
configure by pointing to the TriBITS source dir `<tribits-dir>`
Expand All @@ -19,16 +19,28 @@ with:
-DTribitsExProj_TRIBITS_DIR=<tribits-dir> \
-DTribitsExProj_ENABLE_TESTS=ON \
-DTribitsExProj_ENABLE_ALL_PACKAGES=ON
-DTribitsExProj_ENABLE_SECONDARY_TESTED_CODE=ON \
-DCMAKE_CXX_COMPILER=g++ \
<path-to-TribitsExampleProject>
```

and then build and test with:
then build and test with:

```
make -j4 && ctest -j4
```

and then install:

```
make DESTDIR=<path-to-install-dir> install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you confirm this works? I know this works if the CMake project is using GNUInstallDirs.cmake and specifying install() commands correctly but I am not sure if TriBITS is doing that yet. See #411.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine for my, that's what I did on my machine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! But I thinks that only works if you specify relative paths for the various install dirs fir includes, libs, etc. But that is the default so that is why this is working I guess.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that is really what DESTDIR does then you don't want to use it. No one wants things installed under <install-prefix>/user/local.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is wrong with using -D CMAKE_INSTALL_PREFIX=<install-prefix>? That does what people want (i.e. installs headers under <install-prefix>/include, libraries under <install-prefix>/libs, etc.) and has worked for years. The other option is to use the newer cmake --install <build-dir> --prefix <install-prefix> command supported with CMake 3.15+. Have you tried that? That has the advantage that it works with any build tool (i.e. Makefiles or Ninja).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ross, there is nothing wrong with it. It was just a proposal. It could stay as it was.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DESTDIR is mentioned here as well. I will change it as you wanted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DESTDIR is obviously an old Makefiles standard and CMake supports it to be a drop-in replacement for other old Makefile-based build systems. But that does not mean that you have to use it or encourage that people use it. It seems the purpose is to allow people to test the installation of things that should go under /usr/local without actually doing it. That is never that case with most of the software we are installing.

Let's never mention or use DESTDIR in TriBITS documentation or processes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcinwrobel1986, more careful reading of:

make it clear that DESTDIR is just used for "staging installs" and not for the actual final install location itself. I got confirmation from Kitware that this is how this is used. It seems the CMake documentation for DESTDIR and "Professional CMake: 10th edition" don't really mention how DESTDIR is supposed to be used (that it is not for the final install destination). That variable name DESTDIR is a terrible name because it does not explain the intent of the variable. Based on its intent, it should be called something like STAGING_PREFIX (see section "The Most Important Naming Consideration" in Chapter 11 "The Power of Variable Names" in the book "Code Complete: 2nd Edition").

```

`TribitsExampleProject` will be installed to
`<path-to-install-dir>/usr/local/` and this path should be then used
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that true? It will install to <path-to-install-dir>/usr/local/? Does DESTDIR not just override the configure-time option CMAKE_INSTALL_PREFIX?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Ross,
please find logs below:

 marcin@pop-os ~/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/build 
 ls -la ../install  
total 8
drwxrwxr-x 2 marcin marcin 4096 lut  4 10:47 .
drwxrwxr-x 7 marcin marcin 4096 lut  4 10:47 ..

 marcin@pop-os ~/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/build 
 make DESTDIR=/home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install install
Consolidate compiler generated dependencies of target simplecxx
[  5%] Built target simplecxx
Consolidate compiler generated dependencies of target simplecxx-helloworld
[ 10%] Built target simplecxx-helloworld
Consolidate compiler generated dependencies of target SimpleCxx_HelloWorldTests
[ 16%] Built target SimpleCxx_HelloWorldTests
Consolidate compiler generated dependencies of target mixedlang
[ 29%] Built target mixedlang
Consolidate compiler generated dependencies of target MixedLang_RayTracerTests
[ 35%] Built target MixedLang_RayTracerTests
Consolidate compiler generated dependencies of target pws_a
[ 40%] Built target pws_a
Consolidate compiler generated dependencies of target WithSubpackagesA_a_test
[ 45%] Built target WithSubpackagesA_a_test
Consolidate compiler generated dependencies of target pws_b
[ 51%] Built target pws_b
Consolidate compiler generated dependencies of target WithSubpackagesB_b_test
[ 56%] Built target WithSubpackagesB_b_test
Consolidate compiler generated dependencies of target b_test_utils
[ 62%] Built target b_test_utils
Consolidate compiler generated dependencies of target b_mixed_lang
[ 67%] Built target b_mixed_lang
Consolidate compiler generated dependencies of target WithSubpackagesB_test_of_b_mixed_lang
[ 72%] Built target WithSubpackagesB_test_of_b_mixed_lang
Consolidate compiler generated dependencies of target c_util
[ 78%] Built target c_util
Consolidate compiler generated dependencies of target pws_c
[ 83%] Built target pws_c
Consolidate compiler generated dependencies of target WithSubpackagesC_c_test
[ 89%] Built target WithSubpackagesC_c_test
Consolidate compiler generated dependencies of target c_b_mixed_lang
[ 94%] Built target c_b_mixed_lang
Consolidate compiler generated dependencies of target WithSubpackagesC_test_of_c_b_mixed_lang
[100%] Built target WithSubpackagesC_test_of_c_b_mixed_lang
Install the project...
-- Install configuration: "RELEASE"
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/external_packages/HeaderOnlyTpl/HeaderOnlyTplConfig.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/external_packages/HeaderOnlyTpl/HeaderOnlyTplConfigVersion.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/include/TribitsExProj_version.h
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/libsimplecxx.a
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/include/SimpleCxx_config.h
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/include/SimpleCxx_HelloWorld.hpp
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/bin/simplecxx-helloworld
-- Set runtime path of "/home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/bin/simplecxx-helloworld" to "/usr/local/lib"
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/SimpleCxx/SimpleCxxConfig.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/SimpleCxx/SimpleCxxTargets.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/SimpleCxx/SimpleCxxTargets-release.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/libmixedlang.a
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/include/MixedLang_config.h
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/include/MixedLang.hpp
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/include/Ray_Tracer.hh
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/include/Ray.hh
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/MixedLang/MixedLangConfig.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/MixedLang/MixedLangTargets.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/MixedLang/MixedLangTargets-release.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/libpws_a.a
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/include/A.hpp
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/WithSubpackagesA/WithSubpackagesAConfig.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/WithSubpackagesA/WithSubpackagesATargets.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/WithSubpackagesA/WithSubpackagesATargets-release.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/libpws_b.a
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/include/B.hpp
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/include/WithSubpackagesB_config.h
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/share/WithSubpackagesB/stuff
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/share/WithSubpackagesB/stuff/regular_file.txt
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/share/WithSubpackagesB/stuff/exec_script.sh
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/WithSubpackagesB/WithSubpackagesBConfig.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/WithSubpackagesB/WithSubpackagesBTargets.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/WithSubpackagesB/WithSubpackagesBTargets-release.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/libpws_c.a
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/include/wsp_c/C.hpp
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/WithSubpackagesC/WithSubpackagesCConfig.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/WithSubpackagesC/WithSubpackagesCTargets.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/WithSubpackagesC/WithSubpackagesCTargets-release.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/WithSubpackages/WithSubpackagesConfig.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/WithSubpackages/WithSubpackagesTargets.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/lib/cmake/TribitsExProj/TribitsExProjConfigVersion.cmake
-- Installing: /home/marcin/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/install/usr/local/include/TribitsExProjConfig.cmake

 marcin@pop-os ~/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/build 
 ls -la ../install                                                                                                           
total 12
drwxrwxr-x 3 marcin marcin 4096 lut  4 10:50 .
drwxrwxr-x 7 marcin marcin 4096 lut  4 10:47 ..
drwxrwxr-x 3 marcin marcin 4096 lut  4 10:50 usr

 marcin@pop-os ~/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/build 
 ls -la ../install/usr
total 12
drwxrwxr-x 3 marcin marcin 4096 lut  4 10:50 .
drwxrwxr-x 3 marcin marcin 4096 lut  4 10:50 ..
drwxrwxr-x 6 marcin marcin 4096 lut  4 10:50 local

 marcin@pop-os ~/Dokumenty/NGA/projects/tribits_test/TriBITS/tribits/examples/TribitsExampleProject/build 
 ls -la ../install/usr/local 
total 24
drwxrwxr-x 6 marcin marcin 4096 lut  4 10:50 .
drwxrwxr-x 3 marcin marcin 4096 lut  4 10:50 ..
drwxrwxr-x 2 marcin marcin 4096 lut  4 10:50 bin
drwxrwxr-x 3 marcin marcin 4096 lut  4 10:50 include
drwxrwxr-x 4 marcin marcin 4096 lut  4 10:50 lib
drwxrwxr-x 3 marcin marcin 4096 lut  4 10:50 share

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay then, you definitely don't want to encourage that. No one wants things installed under <install-prefix>/usr/local. Let's remove that and go back to:

cmake -D CMAKE_INSTALL_PREFIX=<install-prefix> ...

to point `-DCMAKE_PREFIX_PATH=<path-to-install-dir>/usr/local/` when
building e.g. `TribitsExampleApp`

The layout of a TriBITS project is described in:

* https://tribits.org/doc/TribitsUsersGuide.html#tribits-project-structure
Expand Down