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

Guidance on using an external library in a min project #208

Open
isabelgk opened this issue Feb 20, 2023 · 1 comment
Open

Guidance on using an external library in a min project #208

isabelgk opened this issue Feb 20, 2023 · 1 comment

Comments

@isabelgk
Copy link
Contributor

isabelgk commented Feb 20, 2023

I would certainly appreciate some better (or simpler) guidance on how to use CMake to link an external library (on an arbitrary path) with a min project.

I don't understand CMake, and trying to link my project to an arbitrary .lib file already compiled from a solution is doing my head in. I have managed the include file, but getting the subsequent project to link has proved impossible.

Originally posted by @scblakely in #204 (comment)

@isabelgk
Copy link
Contributor Author

For now, how I'd do it something like this in your external's CMakeLists.txt. I haven't tested this exact set up, but I've done it similarly to this in the past.

cmake_minimum_required(VERSION 3.0)

set(C74_MIN_API_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../min-api)
include(${C74_MIN_API_DIR}/script/min-pretarget.cmake)

include_directories( 
	"${C74_INCLUDES}"
)

set( SOURCE_FILES
	${PROJECT_NAME}.cpp
)

add_library( 
	${PROJECT_NAME} 
	MODULE
	${SOURCE_FILES}
)

#   ====== see this section
#  /
# v
if (MSVC)
    # include any headers needed by your library that's kept at <repository root>/libs/include,
    # and you can change for your situation
    include_directories("${CMAKE_SOURCE_DIR}/libs/include")

    # this links to a library that's kept at <repository root>/libs/foo.lib, and you can change for your situation
    target_link_libraries(${PROJECT_NAME} PUBLIC "${CMAKE_SOURCE_DIR}/libs/foo.lib")
endif()


include(${C74_MIN_API_DIR}/script/min-posttarget.cmake)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant