Skip to content

Adjustments to CMake Building#1925

Merged
danmar merged 1 commit intocppcheck-opensource:masterfrom
scottfurry:CMakeChanges
Jun 26, 2019
Merged

Adjustments to CMake Building#1925
danmar merged 1 commit intocppcheck-opensource:masterfrom
scottfurry:CMakeChanges

Conversation

@scottfurry
Copy link
Copy Markdown
Contributor

From CMake Docs( https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html ),
BUILD_SHARED_LIBS may not be defined. This can result in printinfo.cmake outputing
variable without a value. A conditional is applied to ensure that some output is
provided to the user should variable not be defined.

Removed explicit C++ standard flag. Any setting user would add on the command
line would be replaced due to ordering. -std=c++0x would be last value added
to CMAKE_CXX_FLAGS and ultimately the one used by the compiler.

From CMake Docs( https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html ),
BUILD_SHARED_LIBS may not be defined. This can result in printinfo.cmake outputing
variable without a value. A conditional is applied to ensure that some output is
provided to the user should variable not be defined.

Removed explicit C++ standard flag. Any setting user would add on the command
line would be replaced due to ordering. `-std=c++0x` would be last value added
to CMAKE_CXX_FLAGS and ultimately the one used by the compiler.
@danmar
Copy link
Copy Markdown
Collaborator

danmar commented Jun 26, 2019

Removed explicit C++ standard flag.

ok.. how can it be provided by user if needed? I assume that is needed if an old gcc is used.

@danmar danmar merged commit fc61596 into cppcheck-opensource:master Jun 26, 2019
@scottfurry
Copy link
Copy Markdown
Contributor Author

scottfurry commented Jun 26, 2019

Two ways:

  1. on the command line passing cmake ... -DCMAKE_CXX_STANDARD=11 ... if CMake version is > 3.1.

or 2) export CXXFLAGS="-std=c++11 before calling cmake

There is the set_target_properties() function available for older CMake (<3.1) but it would have to be set in multiple files as multiple targets are defined. Minimal CMake for project is starting to get old. I had to dig to find docs covering minimum required version.

@scottfurry scottfurry deleted the CMakeChanges branch June 26, 2019 12:44
@danmar
Copy link
Copy Markdown
Collaborator

danmar commented Jun 27, 2019

ok thanks. I added some cmake instructions to the readme with the commit fef7bc5. Feel free to review that.

@scottfurry
Copy link
Copy Markdown
Contributor Author

Project CMake specify minimum required version as 2.8.11. Hopefully people are at least updated to 3.x series and can use the flag identified. Again, alternative is to export CXXFLAGS='-std=c++11' if all else fails. Someone who has built software before should be aware of using export flag as a last resort.

Project Qt .pro files all have -std=c++11 explicitly set.

I think changes should cover most usage.
My mistake forgetting about updating documentation. Changes made look good.

jubnzv pushed a commit to jubnzv/cppcheck that referenced this pull request Nov 13, 2019
From CMake Docs( https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html ),
BUILD_SHARED_LIBS may not be defined. This can result in printinfo.cmake outputing
variable without a value. A conditional is applied to ensure that some output is
provided to the user should variable not be defined.

Removed explicit C++ standard flag. Any setting user would add on the command
line would be replaced due to ordering. `-std=c++0x` would be last value added
to CMAKE_CXX_FLAGS and ultimately the one used by the compiler.
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