Re: [CMake] Troubles with macros and STREQUAL

2019-05-31 Thread Kyle Edwards via CMake
On Fri, 2019-05-31 at 20:43 +0200, Steven Truppe wrote:
> macro(bsAddLibrary lib)
>  # get all WITH_LIB varables
>      message(STATUS "${lib}")
> 
>  get_cmake_property(_variables VARIABLES)
>  foreach(_var ${_variables})
> 
> -->> (${lib} is "WITH_LIB_GLAD" but allways return false =(       
> if(_var STREQUAL ${lib})

Should be:

if(_var STREQUAL lib)

due to how if() expands variable references.

https://cmake.org/cmake/help/v3.14/command/if.html#variable-expansion

Kyle
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


[CMake] Troubles with macros and STREQUAL

2019-05-31 Thread Steven Truppe

cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
include(CMakePrintHelpers)



set(BSEDIT_INC_PATH "/usr/local/include")
set(BSEDIT_LIB_PATH "/usr/incude/lib")

set(WITH_LIB_GLAD "Support the GLAD library" 1)
set(LIB_GLAD_INC_PATH "/usr/include/glad")
set(LIB_GLAD_LIB_PATH "/usr/lib/glad")

set(WITH_LIB_GLFW "Support for the GLFW library" 1)


list(APPEND BSEDIT_INC_PATH ${LIB_GLAD_INC_PATH})


macro(bsAddLibrary lib)
    # get all WITH_LIB varables
        message(STATUS "${lib}")

    get_cmake_property(_variables VARIABLES)
    foreach(_var ${_variables})

-->> (${lib} is "WITH_LIB_GLAD" but allways return false =(       
if(_var STREQUAL ${lib})
            message(STATUS "Found library: ${_var}")
            if(DEFINED ${${CMAKE_MATCH_0}_INC_PATH})
                message(STATUS "FOUND GLAD_INC_PATH")
            endif()
        endif()
    endforeach()
endmacro()


bsAddLibrary(WITH_LIB_GLAD)

message(STATUS "BSEDIT_INC_PATH = ${BSEDIT_INC_PATH}")
message(STATUS "BSEDIT_LIB_PATH = ${BSEDIT_LIB_PATH}")

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake