Re: [CMake] General question about variable scope.

2019-06-14 Thread Chuck Atkins
So, a couple things:

string(TOUPPER ${lib} lib_upper)
>   set(WITH_LIB_${lib_upper}_EXAMPLES "")
>
> This needs to be outside the foreach loop.  It's getting reset to empty on
every iteration rather than accumulating results

list(APPEND ${WITH_LIB_${lib_upper}_EXAMPLES} ${CMAKE_MATCH_1})
>
> Don't de-reference the first argument, just use the variable name itself,
i.e.:
list(APPEND WITH_LIB_${lib_upper}_EXAMPLES ${CMAKE_MATCH_1})

This is also well suited to a function, which are generally preferred over
macros as it will avoid polluting the current variable scope with temporary
variables:

function(bsBuildLibExamples lib)
  string(TOUPPER ${lib} lib_upper)
  set(all_lib_examples)
  get_cmake_property(all_vars VARIABLES)
  foreach(var IN LISTS all_vars)
if(var MATCHES "^WITH_LIB_${lib_upper}_EXAMPLE_([A-Za-z]+)$")
  list(APPEND all_lib_examples ${CMAKE_MATCH_1})
endif()
  endforeach()
  set(WITH_LIB_${lib_upper}_EXAMPLES "${all_lib_examples}" PARENT_SCOPE)
endmacro()

- Chuck
-- 

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] General question about variable scope.

2019-06-04 Thread Steven Truppe

Hi everyone,


i've the following code:

macro(bsBuildLibExamples lib)
# get all examples
get_cmake_property(_vars VARIABLES)
foreach(_var ${_vars})
string(TOUPPER ${lib} lib_upper)
set(WITH_LIB_${lib_upper}_EXAMPLES "")
if(_var MATCHES "^WITH_LIB_${lib_upper}_EXAMPLE_([A-Za-z]+)$")
message(STATUS "Example found: ${CMAKE_MATCH_1}")
list(APPEND ${WITH_LIB_${lib_upper}_EXAMPLES} ${CMAKE_MATCH_1})
 endif()
endforeach()

message(STATUS "Glad examples: ${WITH_LIB_GLAD_EXAMPLES}")
message(STATUS "GLFW examples: ${WITH_LIB_GLFW_EXAMPLES}")

endmacro()


The problem is that ${WITH_LIB_${lib_upper}_EXAMPLES} is not available
anymore after the foreach, i was not able to find something in the docs
about this, i hope someone here can help me out.


best regrads!



-- 

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


Re: [CMake] General question about regex

2019-06-04 Thread Steven Truppe

Thanks alot. My other problem i have no how can i loop over the result,
there are just variables and ${CMAKE_CATCH_COUNT) what command can i use
the iterate over the result ??


best regrads!

On 04.06.19 19:22, Kyle Edwards wrote:

On Tue, 2019-06-04 at 19:19 +0200, Steven Truppe wrote:

I found the solution:
     get_cmake_property(_vars VARIABLES)
     foreach(_var ${_vars})
         string(TOUPPER ${lib} lib_upper)
         if(_var MATCHES "^WITH_LIB_${lib_upper}_EXAMPLE_([A-Za-
z]+)$")
        message(STATUS "Number of examples found:
${CMAKE_MATCH_COUNT}")
        message(STATUS "Number 1 found: ${CMAKE_MATCH_0}")
         endif()
     endforeach()
Now i've two problem - the CMAKE_MATCH_0 contains the hole string and
not only the part the is in the (), i need only the part from the ()
- is there another command i can use for this ?

CMAKE_MATCH_1

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


Re: [CMake] General question about regex

2019-06-04 Thread Kyle Edwards via CMake
On Tue, 2019-06-04 at 19:19 +0200, Steven Truppe wrote:
> I found the solution:
>     get_cmake_property(_vars VARIABLES)
>     foreach(_var ${_vars})
>         string(TOUPPER ${lib} lib_upper)
>         if(_var MATCHES "^WITH_LIB_${lib_upper}_EXAMPLE_([A-Za-
> z]+)$")
>           message(STATUS "Number of examples found:
> ${CMAKE_MATCH_COUNT}")
>       message(STATUS "Number 1 found: ${CMAKE_MATCH_0}")
>         endif()
>     endforeach()
> Now i've two problem - the CMAKE_MATCH_0 contains the hole string and
> not only the part the is in the (), i need only the part from the ()
> - is there another command i can use for this ?

CMAKE_MATCH_1

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


Re: [CMake] General question about regex

2019-06-04 Thread Steven Truppe

I found the solution:

    get_cmake_property(_vars VARIABLES)
    foreach(_var ${_vars})
        string(TOUPPER ${lib} lib_upper)
        if(_var MATCHES "^WITH_LIB_${lib_upper}_EXAMPLE_([A-Za-z]+)$")
        message(STATUS "Number of examples found: ${CMAKE_MATCH_COUNT}")
        message(STATUS "Number 1 found: ${CMAKE_MATCH_0}")
        endif()

    endforeach()

Now i've two problem - the CMAKE_MATCH_0 contains the hole string and
not only the part the is in the (), i need only the part from the () -
is there another command i can use for this ?


On 04.06.19 18:47, Kornel Benko wrote:

Am Dienstag, 4. Juni 2019, 18:10:19 CEST schrieb Steven Truppe:

Hello again,


i've the following variable defined:

set(WITH_LIB_GLAD_EXAMPLE_BASIC 1)

And the if the line


foreach(_var VARIABLES)

  if(_var MATCHES "WITH_LIB_GLAD_EXAMPLE_([A-Za-z]+)")

  message(STATUS "Found a match")

endforeach()


I never get the message "Found match", what am i doing wrong here ??



What about the attached?

Kornel

-- 

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


Re: [CMake] General question about regex

2019-06-04 Thread Kornel Benko
Am Dienstag, 4. Juni 2019, 18:10:19 CEST schrieb Steven Truppe:
> Hello again,
> 
> 
> i've the following variable defined:
> 
> set(WITH_LIB_GLAD_EXAMPLE_BASIC 1)
> 
> And the if the line
> 
> 
> foreach(_var VARIABLES)
> 
>  if(_var MATCHES "WITH_LIB_GLAD_EXAMPLE_([A-Za-z]+)")
> 
>  message(STATUS "Found a match")
> 
> endforeach()
> 
> 
> I never get the message "Found match", what am i doing wrong here ??
> 
> 

What about the attached?

Kornel
set(WITH_LIB_GLAD_EXAMPLE_BASIC 1)

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

 message(STATUS "_var = ${_var}")
 if(_var MATCHES "WITH_LIB_GLAD_EXAMPLE_([A-Za-z]+)")

 message(STATUS "Found a match")
endif()

endforeach()



signature.asc
Description: This is a digitally signed message part.
-- 

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] General question about regex

2019-06-04 Thread Steven Truppe

Hello again,


i've the following variable defined:

set(WITH_LIB_GLAD_EXAMPLE_BASIC 1)

And the if the line


foreach(_var VARIABLES)

    if(_var MATCHES "WITH_LIB_GLAD_EXAMPLE_([A-Za-z]+)")

        message(STATUS "Found a match")

endforeach()


I never get the message "Found match", what am i doing wrong here ??

--

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] General question

2019-06-04 Thread Steven Truppe

    Hi everyone,


i have the following code:

set(ALL_LIBS "glad;glfw")

# WITH_LIB_GLAD
option(WITH_LIB_GLAD 1)
option(WITH_LIB_GLAD_EXAMPLE_BASIC "Build the basic Glad example (default:0)" 1)
option(WITH_LIB_GLAD_EXAMPLE_SECOND "Build the second Glad example (default:0)" 
1)

# WITH_LIB_GLFW
option(WITH_LIB_GLFW 1)
option(WITH_LIB_GLFW_EXAMPLE_CBASIC "Build the basic GLFW C example 
(default:1)" 1)
option(WITH_LIB_GLFW_EXAMPLE_CPPBASIC "Build the basic GLFW C example 
(default:1)" 1)



## bsBuildLib ##

macro(bsBuildLibs libs)
    foreach(lib ${libs})
        message(STATUS "Searching incude path for lib: <${lib}>")
        bsIncludeLibs(${lib})
        bsBuildLibExamples(${lib})
    endforeach()
endmacro()

###
## bsIncludeLibs ##
###
macro(bsIncludeLibs lib)
    message(STATUS "INCLUDE library ${lib}")
    include("lib_${lib}")
endmacro()


## bsBuildLibExamples ##

macro(bsBuildLibExamples lib)
    # get all examples
    foreach(_var in VARIABLES)
        string(TOUPPER ${lib} lib_upper)
        if(_var MATCHES "WITH_LIB_${lib_upper}_EXAMPLE_([A-Za-z]+)")
            message(STATUS "Found example: ${CMAKE_MATCH_0}")
        endif()
    endforeach()
endmacro()

The final result should be that i get the name of the examples, like for
glad BASIC and SECOND and for glfw CBASIC and CPPBASIC.


best regards!




-- 

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


Re: [CMake] General question:

2019-06-04 Thread Kyle Edwards via CMake
On Tue, 2019-06-04 at 17:11 +0200, Steven Truppe wrote:
> I want the output not to be 'in' but 'glade' ...
> 
> 
> On 04.06.19 17:10, Steven Truppe wrote:
> > 
> > Hi everyone again,
> > 
> > 
> > i've the following code:
> > 
> > https://paste.debian.net/1086040/
> > 
> > and i just try to traverse a list and include files whose part of
> > the
> > name are the list entries.
> > 
> > 
> > best regards!
> > 

Please see the foreach() documentation:

https://cmake.org/cmake/help/v3.14/command/foreach.html

I think you want:

foreach(lib IN LISTS libs)

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


Re: [CMake] General question:

2019-06-04 Thread Steven Truppe

I want the output not to be 'in' but 'glade' ...


On 04.06.19 17:10, Steven Truppe wrote:

Hi everyone again,


i've the following code:

https://paste.debian.net/1086040/

and i just try to traverse a list and include files whose part of the
name are the list entries.


best regards!


--

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] General question:

2019-06-04 Thread Steven Truppe

Hi everyone again,


i've the following code:

https://paste.debian.net/1086040/

and i just try to traverse a list and include files whose part of the
name are the list entries.


best regards!

--

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] general question on documenting modules using the new FooConfig.cmake files

2008-12-04 Thread Alexander Neundorf
Hi,

I've got a general question.
Regular cmake FindFoo.cmake modules are documented by putting the docs at the 
top of the file.
This documentation should list the variables, macros etc. provided by that 
module.

Now if I switch to using FooConfig.cmake files and just very simple 
FindFoo.cmake files (basically only for getting some nicer messages etc.), 
how do I do this then ?
I still could put the documentation in the FindFoo.cmake file, but this 
documentation would be for stuff which is in the FooConfig.cmake file, which 
is loaded later.
While this is no technical problem, there is the real problem that the 
contents of the FooConfig.cmake file can change, i.e. a new variable can be 
added. But this doesn't necessarily mean that also the FindFoo.cmake changes. 
But if it doesn't, then the documentation is out of date.

So, what would you prefer where to put the documentation ?
In the FooConfig.cmake file, which is relatively hidden ?
Or in the FindFoo.cmake file, which can get out of sync to the contents of the 
FooConfig.cmake file ?

Alex
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake