Skip to content

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

@Sebanisu

Description

@Sebanisu

$<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 ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions