How to use this with cmake ?
Opened this issue · 4 comments
ElCapor commented
How can i integrate this library in my cmake project since DStruct use xmake ?
Sunrisepeak commented
How can i integrate this library in my cmake project since DStruct use xmake ?
1.like headonly lib,add dstruct's root-dir to include search-dir in cmake
-
include dstruct.hpp in your program
-
use it
Sunrisepeak commented
xmake only as build example's tool in dstruct
Sunrisepeak commented
@ElCapor I wrote a demo to auto-config for cmake project, you can try it. as follows:
CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
project(dstruct_cmake_example)
include(FetchContent)
FetchContent_Declare(
dstruct
GIT_REPOSITORY https://github.com/sunrisepeak/DStruct.git
GIT_TAG main
)
FetchContent_MakeAvailable(dstruct)
FetchContent_GetProperties(dstruct)
set(DSTRUCT_INCLUDE_DIRS ${dstruct_SOURCE_DIR})
add_executable(dstruct_cmake_example main.cpp)
target_include_directories(dstruct_cmake_example PRIVATE ${DSTRUCT_INCLUDE_DIRS})
main.cpp
#include <iostream>
#include <dstruct.hpp>
int main() {
dstruct::Array<int, 10> arr(2);
decltype(arr)::ValueType val = 6;
arr[0] = arr[-1] = val;
for (int i = 0; i < arr.size(); i++) {
std::cout << arr[-(i + 1)] << " : " << arr[i] << std::endl;
}
return 0;
}
ElCapor commented
Thank you very much i'm giving it a try tomorrow, very kind from you to help me !