Re: [CMake] Determining debug & release configurations

2012-12-18 Thread Robert Dailey
Is there no solution to this based on my assumptions?

On Mon, Dec 10, 2012 at 11:07 AM, Robert Dailey
 wrote:
> Thanks for the tips...
>
> I think this might be a little overkill, because the solution I was
> looking at involved the DEBUG_CONFIGURATIONS variable. For
> multi-configuration generators, you can see if any items in
> CMAKE_CONFIGURATION_TYPES match what's inside of DEBUG_CONFIGURATIONS.
> Any match is a DEBUG configuration, anything that doesn't match is
> RELEASE.
>
> I don't know for sure if this works for single-configuration
> generators, where I'd check CMAKE_BUILD_TYPE against
> DEBUG_CONFIGURATIONS. But I was hoping someone would comment on how to
> do this for single-configuration generators.
>
> Thanks in advance...
>
> On Fri, Dec 7, 2012 at 3:38 AM, Andreas Mohr  wrote:
>> Hi,
>>
>> On Fri, Dec 07, 2012 at 04:01:27AM -0500, cmake-requ...@cmake.org wrote:
>>> Date: Thu, 6 Dec 2012 11:54:42 -0600
>>> From: Robert Dailey 
>>
>>> Does anyone have any code that can detect if a given configuration (by
>>> name) is a debug or release configuration? This should work in both
>>> single-configuration and multi-configuration generators.
>>>
>>> For example, in Visual Studio:
>>>
>>> Release -> Release
>>> MinSizeRel -> Release
>>> RelWithDebInfo -> Release
>>> Debug -> Debug
>>>
>>> Also any custom-added configurations should also work.
>>>
>>> For single configuration generators, it should also work. Example:
>>>
>>> CMAKE_BUILD_TYPE -> MinSizeRel -> should evaluate to "Release".
>>> CMAKE_BUILD_TYPE -> Debug -> should evaluate to "Debug".
>>
>> That's quite exactly what I'm doing right now (*dynamic*, *build-time*
>> calculation of required, *random-content* flag strings).
>>
>> My solution (workaround?) is to provide functions to return a Win32 batch 
>> scriptlet
>> to automatically map those config names to their equivalents,
>> then continue filling batch file with what I actually want to do,
>> making use of the %var% helpers which were nicely defined by the prepended 
>> scriptlet code.
>>
>> And of course that unfortunately means having to generate batch files to be 
>> executed
>> rather than possibly adding custom targets with direkt cmake -E copy 
>> handling.
>>
>>
>> But of course with a complex mapping of *dynamic* Debug/Release switching at 
>> *build-time*
>> you most likely do need to have a build-executable foundation to get this 
>> figured out properly.
>> Unless you write completely differing *static-content* scripts,
>> located in completely differing build tree prefixes of Debug/Release 
>> configurations.
>> That's possibly a better solution since with dynamic switching
>> within an existing tree of payload files
>> you may end up getting unwanted build configuration conflicts.
>>
>> Actual possible implementation: add a scripts_[BUILD_CONFIGURATION] dir
>> somewhere in binary dir, for all configurations that you of course know of 
>> at configure time
>> (CMAKE_CONFIGURATION_TYPES).
>> Then configure-time generate
>> only-so-slightly differing scripts there, and invoke them using some
>>
>> ${CMAKE_SOME_BINARY_SUB_DIR}/scripts_${CMAKE_CFG_INTDIR}/my_script.bat
>>
>> expression.
>>
>>
>>
>> Helper functions suitable for *dynamic* (i.e., non-configure-time-generated)
>> evaluation of build-configuration-related values:
>>
>>
>> function(sbuild_configure_batch_var_name_debug_release_string_lower_get _out)
>>   set(${_out} "cfg_build_string_debug_release" PARENT_SCOPE)
>> endfunction(sbuild_configure_batch_var_name_debug_release_string_lower_get 
>> _out)
>> function(sbuild_configure_batch_var_name_debug_yes_no_get _out)
>>   set(${_out} "cfg_build_debug_yes_no" PARENT_SCOPE)
>> endfunction(sbuild_configure_batch_var_name_debug_yes_no_get _out)
>>
>> function(sbuild_configure_batch_scriptlet_debug_flag_get 
>> _out_debug_flag_content)
>>   # Provide DOS batch syntax to support dynamic Debug/Release switching in 
>> multi-configuration generators (Visual Studio) [see 
>> CMAKE_CONFIGURATION_TYPES]
>>
>>   # Within local handling, *always* query the authoritative helper for batch 
>> variable names,
>>   # to prevent any variable renaming issues from appearing.
>>   sbuild_configure_batch_var_name_debug_yes_no_get(var_name_debug_yes_no)
>>   
>> sbuild_configure_batch_var_name_debug_release_string_lower_get(var_name_debrel_string_lower)
>>   set(sbuild_configure_batch_debug_flag_content "
>> set build_config=%1
>> echo \"%0: build config: %build_config%\"
>>
>> if \"%build_config%\" == \"Release\" goto cfg_release
>> if \"%build_config%\" == \"Debug\" goto cfg_debug
>> if \"%build_config%\" == \"RelWithDebInfo\" goto cfg_release
>> if \"%build_config%\" == \"MinSizeRel\" goto cfg_release
>>
>> echo \"Unknown build configuration (%build_config%), please add support!\"
>>
>> rem fall-through to default Release setting (default should always be 
>> non-debug! don't leak debug symbols...)
>>
>> rem Provide several very different variables, to satisfy any and all 
>> potent

Re: [CMake] Using gnu flux with cmake

2012-12-18 Thread Martin Koller
On Monday 17 December 2012 19:45:53 Derek Cole wrote:
> 
> I am trying to figure out what I am doing wrong when trying to use just flex 
> in a Cmake file to build a shared lib.
> 
> i basically have the following
> 
> find_package(FLEX)
> FLEX_TARGET(Test ../src/test.l ../src/test.c)
> set(SRC_FILES mysource.c ${FLEX_Test_OUTPUTS})
> add_libary(testlib ${SRC_FILES})
> target_link_libraries(testlib crypto c ${FLEX_LIBRARIES})
> 
> this is giving me a problem saying it cant find ../src/test.c

I assume there is a problem with WHERE the generated file is located.
In the docs they say:
FLEX_TARGET(MyScanner lexer.l  ${CMAKE_CURRENT_BINARY_DIR}/lexer.cpp)

so try to use ${CMAKE_CURRENT_BINARY_DIR}/src/test.c

> any ideas how I can make sure Lex ran first? secondly,how can i pass my -L 
> and -d options to lex (like I am doing in my normal, pre-cmake version of 
> this makefile)

The docs says:
FLEX_TARGET(Name FlexInput FlexOutput [COMPILE_FLAGS ])

I assume you can do:

FLEX_TARGET(Test ../src/test.l  ${CMAKE_CURRENT_BINARY_DIR}/src/test.c 
COMPILE_FLAGS "-L xxx -D xxx")

-- 
Best regards/Schöne Grüße

Martin

A: Because it breaks the logical sequence of discussion
Q: Why is top posting bad?

()  ascii ribbon campaign - against html e-mail 
/\  www.asciiribbon.org   - against proprietary attachments

This mail was not scanned before sending.
It was sent from a secure Linux desktop.
--

Powered by www.kitware.com

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

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

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


Re: [CMake] Execute a custom command without any dependency

2012-12-18 Thread Martin Koller
On Monday 17 December 2012 20:04:48 Sergey Prokhorenko wrote:
> Hello.
> 
> I want to run a custom command that parses a whole source tree, so I
> can't list dependencies to add_custom_command/target. Is there another
> way? Just always run a program, that's all.

add_custom_target doc says:
"The target has no output file and is ALWAYS CONSIDERED OUT OF DATE"

so it should work to use

add_custom_target(do_always ALL COMMAND theCommand)

-- 
Best regards/Schöne Grüße

Martin

A: Because it breaks the logical sequence of discussion
Q: Why is top posting bad?

()  ascii ribbon campaign - against html e-mail 
/\  www.asciiribbon.org   - against proprietary attachments

This mail was not scanned before sending.
It was sent from a secure Linux desktop.
--

Powered by www.kitware.com

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

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

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


Re: [CMake] FindPostgreSQL.cmake won't work on ubuntu

2012-12-18 Thread Ilia Choly

On 12-12-17 03:11 PM, Matthew Woehlke wrote:

On 2012-12-17 14:55, Ilia Choly wrote:

I'm trying to get the `FindPostgreSQL` module to find
`/usr/include/postgresql/libpq-fe.h`.

This is the error I get:

 CMake Error at
/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97
(MESSAGE):
   Could NOT find PostgreSQL (missing: PostgreSQL_TYPE_INCLUDE_DIR)
(found
   version "9.2.2")


Is pg_config in your PATH? (Do you have the necessary -dev package(s) 
installed?)


From a cursory look at the find module, it looks like having pg_config 
in your path should be all that is needed.




The pg_config binary is in my path but looking at he module it doesn't 
look like it's being used.


After a bit more debugging I figured out that it's getting stuck here 
trying to find pg_type.h
This file is located in /usr/include/postgresql/catalog/pg_types.h but 
the module is expecting to find it in 
/usr/postgresql/server/catalog/pg_types.h


find_path(PostgreSQL_TYPE_INCLUDE_DIR
  NAMES catalog/pg_type.h
  PATHS
   # Look in other places.
   ${PostgreSQL_ROOT_DIRECTORIES}
  PATH_SUFFIXES
pgsql/server
postgresql/server
include/server
  # Help the user find it if we cannot.
  DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
)

It works if I add postgresql to the PATH_SUFFIXES

- icholy

--

Powered by www.kitware.com

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

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

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


Re: [CMake] How to use CMAKE_POLICY?

2012-12-18 Thread David Cole
On Mon, Dec 17, 2012 at 11:57 AM, Alexander Neundorf <
a.neundorf-w...@gmx.net> wrote:

> On Monday 17 December 2012, David Cole wrote:
> > I thought we wanted them to switch to the new behavior... Isn't that the
> > goal of emitting warnings from policy implementations...?
>
> ...but not as long as the project still wants to keep the old minimum
> required
> cmake version (or am I mixing things up) ?
>
> Alex
>


No, you're not mixing things up. You're correct.

If somebody wants to use minimum required 2.6.2 *and* they don't like
warnings emitted by newer versions of CMake about new policies, then they
have to change their code, or use the -D CMAKE_POLICY_DEFAULT_CMP
technique.

Now if they're going to change their code anyway, why not make a change
that is compatible with the new policy introduced rather than adding a
bunch of code to keep things in the OLD state. With many policies it is
possible to write CMake code that honors the NEW state of the policy, but
still works with older CMakes.

I would ask for specific advice regarding the particulars of the policy
violation to see if there is such a way to re-write the code to work with
older AND newer CMakes before I would ever consider setting a policy to OLD
in my own CMakeLists files.


HTH,
David
--

Powered by www.kitware.com

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

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

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

Re: [CMake] How to use CMAKE_POLICY?

2012-12-18 Thread David Cole
The question in this thread is about what previous versions of CMake do
with cmake_policy(SET ... OLD) commands where they do not know about the
policy

By default, policies introduced after the minimum required are UNSET, not
set to OLD.


>From http://cmake.org/cmake/help/v2.8.10/cmake.html#command:cmake_policy:

All policies introduced after the specified version will be unset (unless
variable CMAKE_POLICY_DEFAULT_CMP sets a default). This effectively
requests behavior preferred as of a given CMake version and tells newer
CMake versions to warn about their new policies. The policy version
specified must be at least 2.4 or the command will report an error. In
order to get compatibility features supporting versions earlier than 2.4
see documentation of policy CMP0001.

  cmake_policy(SET CMP NEW)
  cmake_policy(SET CMP OLD)

Tell CMake to use the OLD or NEW behavior for a given policy. Projects
depending on the old behavior of a given policy may silence a policy
warning by setting the policy state to OLD. Alternatively one may fix the
project to work with the new behavior and set the policy state to NEW.




On Tue, Dec 18, 2012 at 7:20 AM, Johannes Zarl  wrote:

> Sorry if I add to the confusion, but shouldn't set cmake_minimum_required
> automatically set all policies newer than the specified version to old?
>
>   Johannes
>
> On Monday, 17. December 2012, 17:57:18, Alexander Neundorf wrote:
> > On Monday 17 December 2012, David Cole wrote:
> > > I thought we wanted them to switch to the new behavior... Isn't that
> the
> > > goal of emitting warnings from policy implementations...?
> >
> > ...but not as long as the project still wants to keep the old minimum
> > required cmake version (or am I mixing things up) ?
> >
> > Alex
> > --
> >
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the CMake FAQ at:
> > http://www.cmake.org/Wiki/CMake_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.cmake.org/mailman/listinfo/cmake
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
--

Powered by www.kitware.com

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

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

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

Re: [CMake] How to use CMAKE_POLICY?

2012-12-18 Thread Johannes Zarl
Sorry if I add to the confusion, but shouldn't set cmake_minimum_required 
automatically set all policies newer than the specified version to old?

  Johannes

On Monday, 17. December 2012, 17:57:18, Alexander Neundorf wrote:
> On Monday 17 December 2012, David Cole wrote:
> > I thought we wanted them to switch to the new behavior... Isn't that the
> > goal of emitting warnings from policy implementations...?
> 
> ...but not as long as the project still wants to keep the old minimum
> required cmake version (or am I mixing things up) ?
> 
> Alex
> --
> 
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

--

Powered by www.kitware.com

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

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

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