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

Possibly could remove $<BUILD_INTERFACE: from cmakelists.txt #50

Open
Sebanisu opened this issue May 27, 2021 · 0 comments
Open

Possibly could remove $<BUILD_INTERFACE: from cmakelists.txt #50

Sebanisu opened this issue May 27, 2021 · 0 comments

Comments

@Sebanisu
Copy link

$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Main/StackWalker>

$<BUILD_INTERFACE: prevent including StackWalker.h when using FetchContent to download and link to the library from inside CMake.

If this were removed I could use target_link_libraries(... PRIVATE StackWalker) and then the compiler would know where to look for the StackWalker.h.

My fetch content code with my workaround.

I also had to force the MSVC_RUNTIME_LIBRARY because linker errors in my current setup. Basically all the third party libraries and the main library need to use the same runtime library.

I'm hoping once I have everything dynamically downloading and building I can remove hacks like MSVC_RUNTIME_LIBRARY .

include(FetchContent)
#options for FetchContent are at https://cmake.org/cmake/help/latest/module/ExternalProject.html
FetchContent_Declare(
        stackwalker_fetch
        GIT_REPOSITORY https://github.com/JochenKalmbach/StackWalker.git
        GIT_TAG origin/master
        GIT_REMOTE_UPDATE_STRATEGY CHECKOUT
)
#FetchContent_MakeAvailable(StackWalker)
FetchContent_GetProperties(stackwalker_fetch)
if (NOT stackwalker_fetch_POPULATED)
    FetchContent_Populate(stackwalker_fetch)
    #add_subdirectory(${stackwalker_fetch_SOURCE_DIR} ${stackwalker_fetch_BINARY_DIR} EXCLUDE_FROM_ALL)
    #their cmakelists.txt isn't friendly to including via fetch content.-
    add_library(stackwalker_paths STATIC
            ${stackwalker_fetch_SOURCE_DIR}/Main/StackWalker/StackWalker.cpp
            )
    target_include_directories(stackwalker_paths
            PUBLIC ${stackwalker_fetch_SOURCE_DIR}/Main/StackWalker
            )
    set_target_properties(stackwalker_paths PROPERTIES
            MSVC_RUNTIME_LIBRARY "MultiThreadedDebug" # cl : Command line warning D9025 : overriding '/MD' with '/MTd'
            )
endif ()
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