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

Fix BUILD_TESTING=off #72

Merged
merged 3 commits into from
Nov 12, 2024

Conversation

wusatosi
Copy link
Member

@wusatosi wusatosi commented Nov 10, 2024

exemplar currently cannot install when BUILD_TEST=off (see: #70).

This is due to CMAKE_INSTALL_INCLUDEDIR/ CMAKE_INSTALL_LIBDIR not defined when we are not fetching configuration for Google Test.

This PR fixes that by adding include(GNUInstallDirs).

This PR also adds configuration test (plain cmake build, no unit testing) for the BUILD_TEST cmake parameter to CI.

Closes: #70

@wusatosi wusatosi changed the title Add disable build test to CI. Fix BUILD_TEST=off Nov 12, 2024
CMakeLists.txt Outdated Show resolved Hide resolved
@neatudarius
Copy link
Contributor

neatudarius commented Nov 12, 2024

Tested with preset gcc-release and gcc-debug:

dariusn@pc:~/git/Beman/exemplar$ rm -rf .build /opt/beman.exemplar/ && cmake --workflow --preset gcc-debug 
Executing workflow step 1 of 3: configure preset "gcc-debug"

Preset CMake variables:

  CMAKE_BUILD_TYPE="Debug"
  CMAKE_CXX_COMPILER="g++"
  CMAKE_CXX_FLAGS="-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=leak -fsanitize=undefined"
  CMAKE_CXX_STANDARD="17"

-- Configuring done (0.2s)
-- Generating done (0.0s)
-- Build files have been written to: /home/dariusn/git/Beman/exemplar/build/gcc-debug

Executing workflow step 2 of 3: build preset "gcc-debug"

ninja: no work to do.

Executing workflow step 3 of 3: test preset "gcc-debug"

Test project /home/dariusn/git/Beman/exemplar/build/gcc-debug
    Start 1: IdentityTest.call_identity_with_int
1/4 Test #1: IdentityTest.call_identity_with_int ...........   Passed    0.01 sec
    Start 2: IdentityTest.call_identity_with_custom_type
2/4 Test #2: IdentityTest.call_identity_with_custom_type ...   Passed    0.01 sec
    Start 3: IdentityTest.compare_std_vs_beman
3/4 Test #3: IdentityTest.compare_std_vs_beman .............   Passed    0.01 sec
    Start 4: IdentityTest.check_is_transparent
4/4 Test #4: IdentityTest.check_is_transparent .............   Passed    0.01 sec

100% tests passed, 0 tests failed out of 4

Total Test time (real) =   0.04 sec
dariusn@pc:~/git/Beman/exemplar$ cmake --install build/gcc-debug --prefix /opt/beman.exemplar
-- Install configuration: "Debug"
-- Installing: /opt/beman.exemplar/debug/lib/libbeman.exemplar.a
-- Installing: /opt/beman.exemplar/include/beman/exemplar/identity.hpp
dariusn@pc:~/git/Beman/exemplar$ tree /opt/beman.exemplar/
/opt/beman.exemplar/
├── debug
│   └── lib
│       └── libbeman.exemplar.a
└── include
    └── beman
        └── exemplar
            └── identity.hpp

6 directories, 2 files
dariusn@pc:~/git/Beman/exemplar$ rm -rf .build /opt/beman.exemplar/ && cmake --workflow --preset gcc-release 
Executing workflow step 1 of 3: configure preset "gcc-release"

Preset CMake variables:

  CMAKE_BUILD_TYPE="RelWithDebInfo"
  CMAKE_CXX_COMPILER="g++"
  CMAKE_CXX_FLAGS="-O3"
  CMAKE_CXX_STANDARD="17"

-- The CXX compiler identification is GNU 13.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The C compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Python3: /usr/bin/python3.12 (found version "3.12.3") found components: Interpreter
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done (2.7s)
-- Generating done (0.0s)
-- Build files have been written to: /home/dariusn/git/Beman/exemplar/build/gcc-release

Executing workflow step 2 of 3: build preset "gcc-release"

[10/10] Linking CXX executable tests/beman/exemplar/beman.exemplar.tests.identity

Executing workflow step 3 of 3: test preset "gcc-release"

Test project /home/dariusn/git/Beman/exemplar/build/gcc-release
    Start 1: IdentityTest.call_identity_with_int
1/4 Test #1: IdentityTest.call_identity_with_int ...........   Passed    0.00 sec
    Start 2: IdentityTest.call_identity_with_custom_type
2/4 Test #2: IdentityTest.call_identity_with_custom_type ...   Passed    0.00 sec
    Start 3: IdentityTest.compare_std_vs_beman
3/4 Test #3: IdentityTest.compare_std_vs_beman .............   Passed    0.00 sec
    Start 4: IdentityTest.check_is_transparent
4/4 Test #4: IdentityTest.check_is_transparent .............   Passed    0.00 sec

100% tests passed, 0 tests failed out of 4

Total Test time (real) =   0.00 sec
dariusn@pc:~/git/Beman/exemplar$ cmake --install build/gcc-release --prefix /opt/beman.exemplar
-- Install configuration: "RelWithDebInfo"
-- Installing: /opt/beman.exemplar/lib/libbeman.exemplar.a
-- Installing: /opt/beman.exemplar/include/beman/exemplar/identity.hpp
dariusn@pc:~/git/Beman/exemplar$ tree /opt/beman.exemplar/
/opt/beman.exemplar/
├── include
│   └── beman
│       └── exemplar
│           └── identity.hpp
└── lib
    └── libbeman.exemplar.a

5 directories, 2 files

That's OK!

===================

Tested with BUILD_TESTING=OFF on main with this script:

set -x

rm -rf .build /opt/beman.exemplar/ 
cmake -B .build -S . &> /dev/null
cmake --build .build --config Asan --target all -- -k 0 &> /dev/null
ctest --build-config Asan --output-on-failure --test-dir .build
cmake --install .build --prefix /opt/beman.exemplar
tree /opt/beman.exemplar

rm -rf .build /opt/beman.exemplar/ 
cmake -B .build -S . -DBUILD_TESTING=OFF &> /dev/null
cmake --build .build --config Asan --target all -- -k 0 &> /dev/null
ctest --build-config Asan --output-on-failure --test-dir .build
cmake --install .build --prefix /opt/beman.exemplar
tree /opt/beman.exemplar

Indeed, it's broken. Your fix is valid.

Do you want to create an issue to also run one with BUILD_TESTING=OFF on CI? It can be a default compiler ("system") and it can only validate that we install the library when tests are deactivated. For all other CI cases, we should run tests, install library, and the check we have expected files in the tree. LE It seems you already started in configuration-test.

Copy link
Contributor

@neatudarius neatudarius left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Can I merge your PR?

@wusatosi
Copy link
Member Author

Go for it!

@neatudarius neatudarius changed the title Fix BUILD_TEST=off Fix BUILD_TESTING=off Nov 12, 2024
CMakeLists.txt Outdated Show resolved Hide resolved
@wusatosi
Copy link
Member Author

I already included a CI check for configuration with BUILD_TEST=off + cmake install, if that's what you're asking.

@wusatosi wusatosi merged commit 06e121f into beman-project:main Nov 12, 2024
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disabling BUILD_TESTING causes project to fail to install
2 participants