cpm-cmake / CPM.cmake

📦 CMake's missing package manager. A small CMake script for setup-free, cross-platform, reproducible dependency management.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add example for using the `libuv` repository

midhunadarvin opened this issue · comments

Repository : https://github.com/libuv/libuv

I tried with the following configuration :

CPMAddPackage(
        NAME libuv
        GITHUB_REPOSITORY libuv/libuv
        VERSION 1.48.0
)

and linked it with my target, but it seems the files inside the include folder of libuv are not accessible. Is there any other change that I need to make ?

Works for me.

Here`s how my files look:

CPMAddPackage(
	NAME libuv
	GITHUB_REPOSITORY libuv/libuv
	VERSION 1.48.0
)

add_executable( libuv_test )
target_sources( libuv_test PRIVATE
	src/main.cpp
)

target_link_libraries( libuv_test PRIVATE uv_a )

Took this from the libuv docs: https://docs.libuv.org/en/v1.x/guide/basics.html

#include <stdio.h>
#include <stdlib.h>
#include <uv.h>
#include <uv/version.h>

int main()
{
	printf( "Version: %d.%d.%d\n", UV_VERSION_MAJOR, UV_VERSION_MINOR, UV_VERSION_PATCH );

	uv_loop_t *loop = reinterpret_cast<uv_loop_t *>( malloc( sizeof( uv_loop_t ) ) );
	uv_loop_init( loop );

	printf( "Now quitting.\n" );
	uv_run( loop, UV_RUN_DEFAULT );

	uv_loop_close( loop );
	free( loop );

	return 0;
}

Thanks, I managed to make it work with the following configuration also. Closing this issue.

CPMAddPackage(
        NAME libuv
        GITHUB_REPOSITORY libuv/libuv
        VERSION 1.48.0
)
target_link_libraries(
        ${PROJECT_NAME}
        uv
)

target_include_directories(${PROJECT_NAME} PUBLIC ${libuv_SOURCE_DIR}/include)