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

Bugfix: cmake_multi generator used with Xcode CMake generator #7341

Merged
merged 4 commits into from Jul 27, 2020

Conversation

SSE4
Copy link
Contributor

@SSE4 SSE4 commented Jul 11, 2020

improved version of #7099

Changelog: Bugfix: cmake_multi generator used with Xcode CMake generator.
Docs: omit

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

Note: By default this PR will skip the slower tests and will use a limited set of python versions. Check here how to increase the testing level by writing some tags in the current PR body text.

Signed-off-by: SSE4 <tomskside@gmail.com>
@SSE4 SSE4 force-pushed the apple_framework_multi branch from d379ece to 690dbb2 Compare Jul 11, 2020
@SSE4 SSE4 changed the title This fixes a problem where Mac frameworks cannot be found… #7099 Bugfix: cmake_multi generator used with Xcode CMake generator Jul 11, 2020
@jgsogo jgsogo requested a review from danimtb Jul 15, 2020
@jgsogo jgsogo added this to the 1.28 milestone Jul 15, 2020
@danimtb
Copy link
Member

@danimtb danimtb commented Jul 16, 2020

The conan_find_apple_frameworks macro is used in other generators. Should we provide the new BUILD_TYPE argument in those as well or it will be an empty string if the argument is omitted?

@SSE4
Copy link
Contributor Author

@SSE4 SSE4 commented Jul 16, 2020

@danimtb I've tested all generators.
there are seems to be two different implementations:

macro(conan_find_apple_frameworks FRAMEWORKS_FOUND FRAMEWORKS FRAMEWORKS_DIRS)
(cmake_find_package, cmake_find_package_multi)
macro(conan_find_apple_frameworks FRAMEWORKS_FOUND FRAMEWORKS SUFFIX)
(cmake, cmake_multi)

@danimtb
Copy link
Member

@danimtb danimtb commented Jul 16, 2020

thank you, I forgot about the different implementations.

Copy link
Member

@danimtb danimtb left a comment

I would like to have the implementation as suggested here #7341 (comment) but it would require major changes in the generators using this macro

@jgsogo
Copy link
Member

@jgsogo jgsogo commented Jul 17, 2020

I think I didn't explain myself well enough. In this PR we have:

    apple_frameworks_macro = textwrap.dedent("""
        macro(conan_find_apple_frameworks FRAMEWORKS_FOUND FRAMEWORKS SUFFIX BUILD_TYPE)
            if(APPLE)
                if(CMAKE_BUILD_TYPE)
                    if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
                        set(CONAN_FRAMEWORKS${SUFFIX} ${CONAN_FRAMEWORKS${SUFFIX}_DEBUG} ${CONAN_FRAMEWORKS${SUFFIX}})
                        set(CONAN_FRAMEWORK_DIRS${SUFFIX} ${CONAN_FRAMEWORK_DIRS${SUFFIX}_DEBUG} ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
                    elseif(${CMAKE_BUILD_TYPE} MATCHES "Release")
                        set(CONAN_FRAMEWORKS${SUFFIX} ${CONAN_FRAMEWORKS${SUFFIX}_RELEASE} ${CONAN_FRAMEWORKS${SUFFIX}})
                        set(CONAN_FRAMEWORK_DIRS${SUFFIX} ${CONAN_FRAMEWORK_DIRS${SUFFIX}_RELEASE} ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
                    elseif(${CMAKE_BUILD_TYPE} MATCHES "RelWithDebInfo")
                        set(CONAN_FRAMEWORKS${SUFFIX} ${CONAN_FRAMEWORKS${SUFFIX}_RELWITHDEBINFO} ${CONAN_FRAMEWORKS${SUFFIX}})
                        set(CONAN_FRAMEWORK_DIRS${SUFFIX} ${CONAN_FRAMEWORK_DIRS${SUFFIX}_RELWITHDEBINFO} ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
                    elseif(${CMAKE_BUILD_TYPE} MATCHES "MinSizeRel")
                        set(CONAN_FRAMEWORKS${SUFFIX} ${CONAN_FRAMEWORKS${SUFFIX}_MINSIZEREL} ${CONAN_FRAMEWORKS${SUFFIX}})
                        set(CONAN_FRAMEWORK_DIRS${SUFFIX} ${CONAN_FRAMEWORK_DIRS${SUFFIX}_MINSIZEREL} ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
                    endif()
                elseif(NOT BUILD_TYPE STREQUAL "")
                    if(${BUILD_TYPE} MATCHES "_DEBUG")
                        set(CONAN_FRAMEWORKS${SUFFIX} ${CONAN_FRAMEWORKS${SUFFIX}_DEBUG} ${CONAN_FRAMEWORKS${SUFFIX}})
                        set(CONAN_FRAMEWORK_DIRS${SUFFIX} ${CONAN_FRAMEWORK_DIRS${SUFFIX}_DEBUG} ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
                    elseif(${BUILD_TYPE} MATCHES "_RELEASE")
                        set(CONAN_FRAMEWORKS${SUFFIX} ${CONAN_FRAMEWORKS${SUFFIX}_RELEASE} ${CONAN_FRAMEWORKS${SUFFIX}})
                        set(CONAN_FRAMEWORK_DIRS${SUFFIX} ${CONAN_FRAMEWORK_DIRS${SUFFIX}_RELEASE} ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
                    elseif(${BUILD_TYPE} MATCHES "_RELWITHDEBINFO")
                        set(CONAN_FRAMEWORKS${SUFFIX} ${CONAN_FRAMEWORKS${SUFFIX}_RELWITHDEBINFO} ${CONAN_FRAMEWORKS${SUFFIX}})
                        set(CONAN_FRAMEWORK_DIRS${SUFFIX} ${CONAN_FRAMEWORK_DIRS${SUFFIX}_RELWITHDEBINFO} ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
                    elseif(${BUILD_TYPE} MATCHES "_MINSIZEREL")
                        set(CONAN_FRAMEWORKS${SUFFIX} ${CONAN_FRAMEWORKS${SUFFIX}_MINSIZEREL} ${CONAN_FRAMEWORKS${SUFFIX}})
                        set(CONAN_FRAMEWORK_DIRS${SUFFIX} ${CONAN_FRAMEWORK_DIRS${SUFFIX}_MINSIZEREL} ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
                    endif()
                endif()
                foreach(_FRAMEWORK ${FRAMEWORKS})
                    # https://cmake.org/pipermail/cmake-developers/2017-August/030199.html
                    find_library(CONAN_FRAMEWORK_${_FRAMEWORK}_FOUND NAME ${_FRAMEWORK} PATHS ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
                    if(CONAN_FRAMEWORK_${_FRAMEWORK}_FOUND)
                        list(APPEND ${FRAMEWORKS_FOUND} ${CONAN_FRAMEWORK_${_FRAMEWORK}_FOUND})
                    else()
                        message(FATAL_ERROR "Framework library ${_FRAMEWORK} not found in paths: ${CONAN_FRAMEWORK_DIRS${SUFFIX}}")
                    endif()
                endforeach()
            endif()
        endmacro()

I'm proposing something like:

    apple_frameworks_macro = textwrap.dedent("""
        macro(conan_find_apple_frameworks FRAMEWORKS_FOUND FRAMEWORKS SUFFIX BUILD_TYPE)
            if(APPLE)

                if(CMAKE_BUILD_TYPE)
                    set(_BTYPE CMAKE_BUILD_TYPE)
                elseif(NOT BUILD_TYPE STREQUAL "")
                    set(_BTYPE BUILD_TYPE)
                endif()

                if(_BTYPE)
                    if(${_BTYPE} MATCHES "Debug|_DEBUG")
                        set(CONAN_FRAMEWORKS${SUFFIX} ${CONAN_FRAMEWORKS${SUFFIX}_DEBUG} ${CONAN_FRAMEWORKS${SUFFIX}})
                        set(CONAN_FRAMEWORK_DIRS${SUFFIX} ${CONAN_FRAMEWORK_DIRS${SUFFIX}_DEBUG} ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
                    elseif(${_BTYPE} MATCHES "Release|_RELEASE")
                        set(CONAN_FRAMEWORKS${SUFFIX} ${CONAN_FRAMEWORKS${SUFFIX}_RELEASE} ${CONAN_FRAMEWORKS${SUFFIX}})
                        set(CONAN_FRAMEWORK_DIRS${SUFFIX} ${CONAN_FRAMEWORK_DIRS${SUFFIX}_RELEASE} ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
                    elseif(${_BTYPE} MATCHES "RelWithDebInfo|_RELWITHDEBINFO")
                        set(CONAN_FRAMEWORKS${SUFFIX} ${CONAN_FRAMEWORKS${SUFFIX}_RELWITHDEBINFO} ${CONAN_FRAMEWORKS${SUFFIX}})
                        set(CONAN_FRAMEWORK_DIRS${SUFFIX} ${CONAN_FRAMEWORK_DIRS${SUFFIX}_RELWITHDEBINFO} ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
                    elseif(${_BTYPE} MATCHES "MinSizeRel|_MINSIZEREL")
                        set(CONAN_FRAMEWORKS${SUFFIX} ${CONAN_FRAMEWORKS${SUFFIX}_MINSIZEREL} ${CONAN_FRAMEWORKS${SUFFIX}})
                        set(CONAN_FRAMEWORK_DIRS${SUFFIX} ${CONAN_FRAMEWORK_DIRS${SUFFIX}_MINSIZEREL} ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
                    endif()
                endif()
                foreach(_FRAMEWORK ${FRAMEWORKS})
                    # https://cmake.org/pipermail/cmake-developers/2017-August/030199.html
                    find_library(CONAN_FRAMEWORK_${_FRAMEWORK}_FOUND NAME ${_FRAMEWORK} PATHS ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
                    if(CONAN_FRAMEWORK_${_FRAMEWORK}_FOUND)
                        list(APPEND ${FRAMEWORKS_FOUND} ${CONAN_FRAMEWORK_${_FRAMEWORK}_FOUND})
                    else()
                        message(FATAL_ERROR "Framework library ${_FRAMEWORK} not found in paths: ${CONAN_FRAMEWORK_DIRS${SUFFIX}}")
                    endif()
                endforeach()
            endif()
        endmacro()

Maybe I'm not able to see something and those blocks are not identical...

@SSE4
Copy link
Contributor Author

@SSE4 SSE4 commented Jul 17, 2020

@jgsogo seems like it doesn't pass tests with code you have proposed, it doesn't find frameworks any longer. probably, I'll revert it.

@jgsogo
Copy link
Member

@jgsogo jgsogo commented Jul 17, 2020

@jgsogo seems like it doesn't pass tests with code you have proposed, it doesn't find frameworks any longer. probably, I'll revert it.

It works locally...

@SSE4
Copy link
Contributor Author

@SSE4 SSE4 commented Jul 17, 2020

@jgsogo seems like it doesn't pass tests with code you have proposed, it doesn't find frameworks any longer. probably, I'll revert it.

It works locally...

maybe I have missed something or did a stupid typo, feel free to push into my branch with your local changes

@jgsogo
Copy link
Member

@jgsogo jgsogo commented Jul 17, 2020

@jgsogo seems like it doesn't pass tests with code you have proposed, it doesn't find frameworks any longer. probably, I'll revert it.

It works locally...

maybe I have missed something or did a stupid typo, feel free to push into my branch with your local changes

It was a typo in my suggestion. We need to use the values:

                if(CMAKE_BUILD_TYPE)
                    set(_BTYPE ${CMAKE_BUILD_TYPE})
                elseif(NOT BUILD_TYPE STREQUAL "")
                    set(_BTYPE ${BUILD_TYPE})
                endif()

jgsogo
jgsogo approved these changes Jul 17, 2020
Copy link
Member

@jgsogo jgsogo left a comment

We really need to refactor all this stuff... I'll keep working on it. 💪

set(CONAN_FRAMEWORKS${SUFFIX} ${CONAN_FRAMEWORKS${SUFFIX}_DEBUG} ${CONAN_FRAMEWORKS${SUFFIX}})
set(CONAN_FRAMEWORK_DIRS${SUFFIX} ${CONAN_FRAMEWORK_DIRS${SUFFIX}_DEBUG} ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
elseif(${CMAKE_BUILD_TYPE} MATCHES "Release")
elseif(${_BTYPE} MATCHES "Release|_RELEASE")
Copy link
Member

@memsharded memsharded Jul 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this needs to be refactored, improved at some point, but I understand that now it is better to move forward.

@memsharded memsharded merged commit 7329ee9 into conan-io:develop Jul 27, 2020
2 checks passed
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

Successfully merging this pull request may close these issues.

None yet

4 participants