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

Typo in cmake/test.cmake #3902

Closed
m-hilgendorf opened this issue Dec 28, 2022 · 7 comments · Fixed by #3951
Closed

Typo in cmake/test.cmake #3902

m-hilgendorf opened this issue Dec 28, 2022 · 7 comments · Fixed by #3951
Assignees
Labels
good first issue kind: bug solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@m-hilgendorf
Copy link

Description

At line 260 in cmake/test.cmake there is this code

        include(CheckTypeSize)
        check_type_size("size_t" sizeof_size_t LANGUAGE CXX)
        if(sizeof_size_t AND ${sizeof_size_t} EQUAL 4)
            message(STATUS "Auto-enabling 32bit unit test.")
            set(${build_32bit_var} ON)
        else()
            set(${build_32bit_var} OFF)
        endif()

The conditional check

        if(sizeof_size_t AND ${sizeof_size_t} EQUAL 4)

The first condition if(sizeof_size_t is always TRUE, since it is comparing against the string value "sizeof_size_t". To check if the string is empty (meaning check_type_size could not return a value for size_t) it should be

        if(${sizeof_size_t} AND ${sizeof_size_t} EQUAL 4)

If for some reason the size of size_t is unknown (for example, using exotic toolchains where stddef.h might not be visible during the initial cmake evaluation) this will cause the invocation of cmake to fail.

Reproduction steps

Replace the call to check_type_size with

set(sizeof_size_t "")

Expected vs. actual results

Running cmake . should not fail.

Minimal code example

No response

Error messages

if given arguments:

    "sizeof_size_t" "AND" "EQUAL" "4"

  Unknown arguments specified


### Compiler and operating system

gcc 11.2.0, Linux

### Library version

3.11.2

### Validation

- [X] The bug also occurs if the latest version from the [`develop`](https://github.com/nlohmann/json/tree/develop) branch is used.
- [ ] I can successfully [compile and run the unit tests](https://github.com/nlohmann/json#execute-unit-tests).
@nlohmann
Copy link
Owner

Good catch!

@akbhuker
Copy link

akbhuker commented Feb 3, 2023

Hi @nlohmann can you please assign me

@nlohmann
Copy link
Owner

nlohmann commented Feb 3, 2023

Go ahead!

@akbhuker
Copy link

akbhuker commented Feb 5, 2023

Hi @nlohmann I'm new to CMake can you suggest to me how to setup development environment on my local machine and how to run the project

@nlohmann
Copy link
Owner

nlohmann commented Feb 7, 2023

No, I cannot assist you there. Please let me know if I should un-assign you.

@theevilone45
Copy link
Contributor

Hey @nlohmann, can I do it?

@nlohmann
Copy link
Owner

Go ahead!

@nlohmann nlohmann assigned theevilone45 and unassigned akbhuker Feb 22, 2023
@nlohmann nlohmann linked a pull request Mar 5, 2023 that will close this issue
@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Mar 5, 2023
@nlohmann nlohmann added this to the Release 3.11.3 milestone Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue kind: bug solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants