stellar

UCI Chess engine written in C++20
git clone git://git.dimitrijedobrota.com/stellar.git
Log | Files | Refs | README | LICENSE |

commit90991d29e87f77efec7d9cafb2df36ba4c5d4dfd
parent281e3825c71af5c9f88d0d7ce1972d379f992820
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateMon, 28 Aug 2023 10:52:57 +0200

Inject project version information with CMake

Diffstat:
Msrc/CMakeLists.txt|++++
Msrc/engine/CMakeLists.txt|+
Msrc/engine/engine.cpp|+++++-----
Asrc/stellar_version.cpp.in|+++++++
Asrc/stellar_version.hpp|++++++++

5 files changed, 25 insertions(+), 5 deletions(-)


diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt

@@ -7,3 +7,7 @@ foreach(file in ${files})

endif()
endforeach()
configure_file(stellar_version.cpp.in stellar_version.cpp @ONLY)
add_library(Stellar_version STATIC ${CMAKE_CURRENT_BINARY_DIR}/stellar_version.cpp)
target_include_directories(Stellar_version PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

diff --git a/src/engine/CMakeLists.txt b/src/engine/CMakeLists.txt

@@ -4,6 +4,7 @@ add_executable(engine

)
target_link_libraries(engine
PRIVATE Stellar_version
PRIVATE board
PRIVATE moves
PRIVATE piece

diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp

@@ -1,8 +1,8 @@

#include <algorithm>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include "attack.hpp"
#include "board.hpp"

@@ -10,6 +10,7 @@

#include "movelist.hpp"
#include "piece.hpp"
#include "score.hpp"
#include "stellar_version.hpp"
#include "transposition.hpp"
#include "utils.hpp"

@@ -352,9 +353,9 @@ void search_position(int depth) {

}
void print_info(void) {
printf("id name Stellar\n");
printf("id author Dimitrije Dobrota\n");
printf("uciok\n");
std::cout << "id name Stellar " << getStellarVersion() << "\n";
std::cout << "id author Dimitrije Dobrota\n";
std::cout << "uciok\n";
}
typedef struct Instruction Instruction;

@@ -414,7 +415,6 @@ Move parse_move(char *move_string) {

Square source = square_from_coordinates(move_string);
Square target = square_from_coordinates(move_string + 2);
const MoveList list(board);
for (int i = 0; i < list.size(); i++) {
const Move move = list[i];

diff --git a/src/stellar_version.cpp.in b/src/stellar_version.cpp.in

@@ -0,0 +1,7 @@

#include "stellar_version.hpp"
std::string getStellarVersion() { return "@Stellar_VERSION@"; }
unsigned int getStellarVersionMajor() { return @Stellar_VERSION_MAJOR@ +0; }
unsigned int getStellarVersionMinor() { return @Stellar_VERSION_MINOR@ +0; }
unsigned int getStellarVersionPatch() { return @Stellar_VERSION_PATCH@ +0; }
unsigned int getStellarVersionTweak() { return @Stellar_VERSION_TWEAK@ +0; }

diff --git a/src/stellar_version.hpp b/src/stellar_version.hpp

@@ -0,0 +1,8 @@

#include <string>
std::string getStellarVersion();
unsigned int getStellarVersionMajor();
unsigned int getStellarVersionMinor();
unsigned int getStellarVersionPatch();
unsigned int getStellarVersionTweak();