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

Use cmake cache variables to customize build settings #465

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hotwatermorning
Copy link

Hi.

I want to use IXWebSocket library with C++17 project but it seems that IXWebSocket can be built only for C++11.

Thus I modified CMakeLists.txt to use cache variables to enable customizing build settings outside of the file.
(And fixed CXX_STANDARD_REQUIRED usage. It should be CMAKE_CXX_STANDARD_REQUIRED because CXX_STANDARD_REQUIRED is a property.
https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD_REQUIRED.html
)

Thanks.

@hotwatermorning hotwatermorning changed the title Use cmake cache variables to customize Use cmake cache variables to customize build settings May 8, 2023
Use cache variables in CMakeLists.txt to customize build settings.
@hotwatermorning hotwatermorning force-pushed the use-cmake-cache-variables branch from 0d4f63d to e400619 Compare September 3, 2023 18:03
@rh101
Copy link
Contributor

rh101 commented Dec 8, 2024

How about this instead?

set(_IXWEBSOCKET_MIN_CXX_STD 11)
if (NOT DEFINED CMAKE_CXX_STANDARD)
    set(CMAKE_CXX_STANDARD ${_IXWEBSOCKET_MIN_CXX_STD})
endif()
if (CMAKE_CXX_STANDARD LESS ${_IXWEBSOCKET_MIN_CXX_STD})
    message(FATAL_ERROR "IXWebsocket requires c++ std >= ${_IXWEBSOCKET_MIN_CXX_STD}")
endif()

if(NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

if(NOT DEFINED CMAKE_CXX_EXTENSIONS)
    set(CMAKE_CXX_EXTENSIONS OFF)
endif()

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.

2 participants