Skip to content

Commit

Permalink
Install
Browse files Browse the repository at this point in the history
  • Loading branch information
flagarde committed May 13, 2024
1 parent 65dc844 commit 4b028d8
Show file tree
Hide file tree
Showing 25 changed files with 289 additions and 224 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ endif()

if(KHAOS_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
endif()
2 changes: 1 addition & 1 deletion CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set noparent
filter=-whitespace/braces
filter=-whitespace/braces,-readability/multiline_comment,-whitespace/comments,-build/header_guard
linelength=250
root=include/
5 changes: 5 additions & 0 deletions cmake/KhaosConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@

include(${CMAKE_CURRENT_LIST_DIR}/KhaosTargets.cmake)

check_required_components(Khaos)
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
add_executable(KhaosVersion.example KhaosVersion.cpp)
target_link_libraries(KhaosVersion.example PRIVATE Khaos::Khaos)
target_link_libraries(KhaosVersion.example PRIVATE Khaos::Khaos)
14 changes: 10 additions & 4 deletions examples/KhaosVersion.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
/*
* Khaos
* C/C++ library for writing cross-platform codes.
*
* SPDX-FileCopyrightText: 2024-2024 flagarde
*
* SPDX-License-Identifier: MIT
*/

#include <Khaos/KhaosVersion.h>
#include <iostream>

int main()
{
std::cout<<"Khaos version : "<<GET_VERSION_MAJOR(Khaos)<<"."<<GET_VERSION_MINOR(Khaos)<<"."<<GET_VERSION_PATCH(Khaos)<<"."<<GET_VERSION_TWEAK(Khaos)<<std::endl;
}
int main() { std::cout << "Khaos version : " << GET_VERSION_MAJOR(Khaos) << "." << GET_VERSION_MINOR(Khaos) << "." << GET_VERSION_PATCH(Khaos) << "." << GET_VERSION_TWEAK(Khaos) << std::endl; }
52 changes: 0 additions & 52 deletions include/Khaos/C.h

This file was deleted.

46 changes: 0 additions & 46 deletions include/Khaos/CXX.h

This file was deleted.

26 changes: 0 additions & 26 deletions include/Khaos/CXXStandards.h

This file was deleted.

52 changes: 0 additions & 52 deletions include/Khaos/CompareVersionMacros.h

This file was deleted.

52 changes: 52 additions & 0 deletions include/Khaos/CompareVersions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Khaos
* C/C++ library for writing cross-platform codes.
*
* SPDX-FileCopyrightText: 2020-2024 flagarde
*
* SPDX-License-Identifier: MIT
*/

#ifndef KHAOS_COMPARE_VERSIONS_H_
#define KHAOS_COMPARE_VERSIONS_H_

#include "Khaos/Version.h"

/** \file CompareVersion.h
* \brief Define macros to compare versions.
* \note Use these macros only if you need preprocessor version checking.
* \note For example :
* \code{.cpp}
* #if CHECK_VERSIONS(version1,==,version2)
* ...
* #else
* ...
* #endif
* \endcode
*/

/** \hideinitializer
* \brief Check the \b version with \b major, \b minor, \b patch, \b tweak using the operator \b op
* \param[in] version version to compare.
* \param[in] op operator =, !=, >=, <= >, < .
* \param[in] major major part.
* \param[in] minor minor part.
* \param[in] patch patch part.
* \param[in] tweak tweak part.
*
* \note Value can be directly used in both preprocessor and compiler expressions for comparison to other similarly defined values.
*/
#define CHECK_VERSION(version, op, major, minor, patch, tweak) ((KHAOS_DEFINE_##version##_VERSION_PRIVATE())op(SET_VERSION(major, minor, patch, tweak)))

/** \hideinitializer
* \brief Check the \b versiona with \b versionb using the operator \b op
* \param[in] versiona version to compare.
* \param[in] op operator =, !=, >=, <= >, < .
* \param[in] versionb version to compare.
*
* \note Value can be directly used in both preprocessor and compiler expressions for comparison to other similarly defined values.
*/

#define CHECK_VERSIONS(a, op, b) ((KHAOS_DEFINE_##a##_VERSION_PRIVATE())op(KHAOS_DEFINE_##b##_VERSION_PRIVATE()))

#endif /* KHAOS_COMPARE_VERSIONS_H_ */
8 changes: 4 additions & 4 deletions include/Khaos/Language.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
#define KHAOS_LANGUAGE_Fortran_PRIVATE() 1L
#elif defined(__cplusplus)
#define KHAOS_LANGUAGE_CXX_PRIVATE() 1L
#include "Khaos/CXX.h"
#include "Khaos/details/languages/CXX.h"
#else
#define KHAOS_LANGUAGE_C_PRIVATE() 1L
#include "Khaos/C.h"
#include "Khaos/details/languages/C.h"
#endif

#if !defined(KHAOS_LANGUAGE_Cuda_PRIVATE)
Expand Down Expand Up @@ -151,11 +151,11 @@
*/
#define LANGUAGE_IS_LOWER(standard) (KHAOS_C_STANDARD_PRIVATE() < KHAOS_STANDARD_##standard##_PRIVATE()) /* //NOSONAR */
#elif LANGUAGE_IS(CXX)
#define LANGUAGE_IS_GREATER(standard) (KHAOS_CXX_STANDARD_PRIVATE() > KHAOS_STANDARD_##standard##_PRIVATE()) /* //NOSONAR */
#define LANGUAGE_IS_GREATER(standard) (KHAOS_CXX_STANDARD_PRIVATE() > KHAOS_STANDARD_##standard##_PRIVATE()) /* //NOSONAR */
#define LANGUAGE_IS_GREATER_EQUAL(standard) (KHAOS_CXX_STANDARD_PRIVATE() >= KHAOS_STANDARD_##standard##_PRIVATE()) /* //NOSONAR */
#define LANGUAGE_IS_EQUAL(standard) (KHAOS_CXX_STANDARD_PRIVATE() == KHAOS_STANDARD_##standard##_PRIVATE()) /* //NOSONAR */
#define LANGUAGE_IS_LOWER_EQUAL(standard) (KHAOS_CXX_STANDARD_PRIVATE() <= KHAOS_STANDARD_##standard##_PRIVATE()) /* //NOSONAR */
#define LANGUAGE_IS_LOWER(standard) (KHAOS_CXX_STANDARD_PRIVATE() < KHAOS_STANDARD_##standard##_PRIVATE()) /* //NOSONAR */
#define LANGUAGE_IS_LOWER(standard) (KHAOS_CXX_STANDARD_PRIVATE() < KHAOS_STANDARD_##standard##_PRIVATE()) /* //NOSONAR */
#else
#define LANGUAGE_IS_GREATER(standard) (0L)
#define LANGUAGE_IS_GREATER_EQUAL(standard) (0L)
Expand Down
33 changes: 33 additions & 0 deletions include/Khaos/Preprocessor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Khaos
* C/C++ library for writing cross-platform codes.
*
* SPDX-FileCopyrightText: 2020-2024 flagarde
*
* SPDX-License-Identifier: MIT
*/

#ifndef KHAOS_PREPROCESSOR_H_
#define KHAOS_PREPROCESSOR_H_

/*! \file Preprocessor.h
* \brief Detect some preprocessor behaviors.
*/

/*!
* \hideinitializer
* Check if the preprocessor is in traditional mode.
*/
#if(defined(_MSVC_TRADITIONAL) && (_MSVC_TRADITIONAL == 1)) || (!defined(_MSVC_TRADITIONAL) && defined(_MSC_VER))
#define KHAOS_PREPROCESSOR_Traditional_PRIVATE() (1L)
#else
#define KHAOS_PREPROCESSOR_Traditional_PRIVATE() (0L)
#endif

/*!
* \hideinitializer
* Return the processor checked value.
*/
#define PREPROCESSOR_IS(check) KHAOS_PREPROCESSOR_##check##_PRIVATE()

#endif /* KHAOS_PROCESSOR_H_ */
18 changes: 9 additions & 9 deletions include/Khaos/VersionMacros.h → include/Khaos/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
* SPDX-License-Identifier: MIT
*/

#ifndef KHAOS_VERSIONMACROS_H_
#define KHAOS_VERSIONMACROS_H_
#ifndef KHAOS_VERSION_H_
#define KHAOS_VERSION_H_

/** \file VersionMacros.h
/** \file Version.h
* \brief Define macros to set, get versions.
* \note Use these macros only if you need preprocessor version checking.
* \note For example :
Expand Down Expand Up @@ -41,38 +41,38 @@
* #define KHAOS_DEFINE_name_VERSION_PRIVATE() SET_VERSION(2,3,4,5)
* \endcode
*/
#define SET_VERSION(major, minor, patch, tweak) ((((major)*1ULL % (1<<16)) << 48) + (((minor)*1ULL % (1<<16)) << 32) + (((patch)*1ULL % (1<<16)) << 16) + ((tweak)*1ULL % (1<<16))) /* //NOSONAR */
#define SET_VERSION(major, minor, patch, tweak) ((((major)*1ULL % (1 << 16)) << 48) + (((minor)*1ULL % (1 << 16)) << 32) + (((patch)*1ULL % (1 << 16)) << 16) + ((tweak)*1ULL % (1 << 16))) /* //NOSONAR */

/** \hideinitializer
* \brief Get the major version numbers.
* \param[in] name The name for which to return the corresponding major version number.
*
* \note Value can be directly used in both preprocessor and compiler expressions for comparison to other similarly defined values.
*/
#define GET_VERSION_MAJOR(name) ((((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1ULL) >> 48) % (1<<16)) /* //NOSONAR */
#define GET_VERSION_MAJOR(name) ((((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1ULL) >> 48) % (1 << 16)) /* //NOSONAR */

/** \hideinitializer
* \brief Get the minor version numbers.
* \param[in] name The name for which to return the corresponding minor version number.
*
* \note Value can be directly used in both preprocessor and compiler expressions for comparison to other similarly defined values.
*/
#define GET_VERSION_MINOR(name) ((((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1ULL) >> 32) % (1<<16)) /* //NOSONAR */
#define GET_VERSION_MINOR(name) ((((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1ULL) >> 32) % (1 << 16)) /* //NOSONAR */

/** \hideinitializer
* \brief Get the patch version numbers.
* \param[in]name The name for which to return the corresponding patch version number.
*
* \note Value can be directly used in both preprocessor and compiler expressions for comparison to other similarly defined values.
*/
#define GET_VERSION_PATCH(name) ((((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1ULL) >> 16) % (1<<16)) /* //NOSONAR */
#define GET_VERSION_PATCH(name) ((((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1ULL) >> 16) % (1 << 16)) /* //NOSONAR */

/** \hideinitializer
* \brief Get the tweak version numbers.
* \param[in] name The name for which to return the corresponding tweak version number.
*
* \note Value can be directly used in both preprocessor and compiler expressions for comparison to other similarly defined values.
*/
#define GET_VERSION_TWEAK(name) (((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1ULL) % (1<<16)) /* //NOSONAR */
#define GET_VERSION_TWEAK(name) (((KHAOS_DEFINE_##name##_VERSION_PRIVATE()) * 1ULL) % (1 << 16)) /* //NOSONAR */

#endif /* KHAOS_VERSIONMACROS_H_ */
#endif /* KHAOS_VERSION_H_ */
Loading

0 comments on commit 4b028d8

Please sign in to comment.