Skip to content

Commit

Permalink
cxx11: deprecate and use cxx-standard
Browse files Browse the repository at this point in the history
  • Loading branch information
nim65s committed Sep 16, 2023
1 parent 5f61443 commit 5331803
Showing 1 changed file with 6 additions and 34 deletions.
40 changes: 6 additions & 34 deletions cxx11.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,16 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.

include(CheckCXXCompilerFlag)

# .rst: .. ifmode:: user
#
# .. command:: CHECK_CXX11_SUPPORT
#
# Set ouput variable CXX11_SUPPORTED to TRUE if C++11 is supported by the
# current compiler. Set to FALSE otherwise.
#
function(CHECK_CXX11_SUPPORT CXX11_SUPPORTED)
check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)

if(COMPILER_SUPPORTS_CXX0X OR COMPILER_SUPPORTS_CXX11)
set(${CXX11_SUPPORTED}
TRUE
PARENT_SCOPE)
else()
set(${CXX11_SUPPORTED}
FALSE
PARENT_SCOPE)
endif()
endfunction(CHECK_CXX11_SUPPORT)

# .rst: .. ifmode:: user
#
# .. command:: PROJECT_USE_CXX11
#
# This macro set up the project to compile the whole project with C++11
# standards.
# DEPRECATED. This macro set up the project to compile the whole project with
# C++11 standards.
#
macro(PROJECT_USE_CXX11)
check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX0X OR COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_STANDARD 11)
set(CXX_STANDARD_REQUIRED ON)
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
endif()
message(
DEPRECATION
"This macro is deprecated. Use CHECK_MINIMAL_CXX_STANDARD instead.")
check_minimal_cxx_standard(11 REQUIRED)
endmacro(PROJECT_USE_CXX11)

0 comments on commit 5331803

Please sign in to comment.