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

Add CGAL/version_checker.h #7528

Merged
merged 4 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Installation/include/CGAL/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
#include <boost/version.hpp>

#include <CGAL/version.h>
#include <CGAL/version_checker.h>

//----------------------------------------------------------------------//
// platform specific workaround flags (CGAL_CFG_...)
Expand Down
53 changes: 53 additions & 0 deletions Installation/include/CGAL/version_checker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) 2023 GeometryFactory.
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : -

#ifndef CGAL_VERSION_CHECKER_H
#define CGAL_VERSION_CHECKER_H

#include <CGAL/version_macros.h>

// All files including this header are meant to work with a given version of CGAL
// When using forked headers, set the following macro to the version of CGAL
// you want to use.

//// Set the 3 following macros to the version of CGAL you want to use
//#define CGAL_AUTHORIZED_VERSION_MAJOR 6
//#define CGAL_AUTHORIZED_VERSION_MINOR 0
//#define CGAL_AUTHORIZED_VERSION_PATCH 0

// Set the following macros to 1 to get a warning/an error
// when using a bad version of CGAL
#define CGAL_VERSION_CHECKER_ERROR 0
#define CGAL_VERSION_CHECKER_WARNING 0

#define CGAL_AUTHORIZED_VERSION_STR CGAL_STR(CGAL_AUTHORIZED_VERSION_MAJOR) "." \
CGAL_STR(CGAL_AUTHORIZED_VERSION_MINOR) "." \
CGAL_STR(CGAL_AUTHORIZED_VERSION_PATCH)


// Check that the version of CGAL used is the one expected
#if CGAL_AUTHORIZED_VERSION_MAJOR != CGAL_VERSION_MAJOR \
lrineau marked this conversation as resolved.
Show resolved Hide resolved
|| CGAL_AUTHORIZED_VERSION_MINOR != CGAL_VERSION_MINOR \
|| CGAL_AUTHORIZED_VERSION_PATCH != CGAL_VERSION_PATCH

#if CGAL_VERSION_CHECKER_WARNING || CGAL_VERSION_CHECKER_ERROR
#pragma message("These headers are meant to be used with CGAL " CGAL_AUTHORIZED_VERSION_STR " only."\
" You are using CGAL version: " CGAL_STR(CGAL_VERSION) ".")

#ifdef CGAL_VERSION_CHECKER_ERROR
#error "Wrong version of CGAL"
#endif

#endif

#endif

#endif // CGAL_VERSION_CHECKER_H