Re: [CMake] cmp0065

2016-07-06 Thread David Cole via CMake
Seems like you ought to be able to avoid this warning just by setting
ENABLE_EXPORTS to 0 or 1 ... If you're going to require 3.0, then use 3.0.
If you're going to use 3.5, then add the property to squelch the warning
and get the behavior you want.


D


On Wednesday, July 6, 2016, J Decker  wrote:

>
> M:/tmp/cmake_cmp0065/CMakeLists.txt(1):  cmake_minimum_required(VERSION
> 3.0 )
> M:/tmp/cmake_cmp0065/CMakeLists.txt(2):  project(cmake-test )
> M:/tmp/cmake_cmp0065/CMakeLists.txt(3):  add_executable(myExe main.c )
> M:/tmp/cmake_cmp0065/CMakeLists.txt(4):  target_compile_definitions(myExe
> PRIVATE MY_DEFINITION )
> M:/tmp/cmake_cmp0065/CMakeLists.txt(5):  target_compile_definitions(myExe
> PRIVATE VERSION_STRING="0.8.15" )
> M:/tmp/cmake_cmp0065/CMakeLists.txt(6):  set(project myExe )
>
> -- Configuring done
> CMake Warning (dev) in CMakeLists.txt:
>   Policy CMP0065 is not set: Do not add flags to export symbols from
>   executables without the ENABLE_EXPORTS target property.  Run "cmake
>   --help-policy CMP0065" for policy details.  Use the cmake_policy command
> to
>   set the policy and suppress this warning.
>
>   For compatibility with older versions of CMake, additional flags may be
>   added to export symbols on all executables regardless of thier
>   ENABLE_EXPORTS property.
> This warning is for project developers.  Use -Wno-dev to suppress it.
>
> -- Generating done
> -- Build files have been written to: M:/tmp/cmake_cmp0065/build
>
> ---
> you have cmake_minimum_required(VERSION 3.5 ) in your example... setting
> 3.0 instead and adding --trace shows the warning...
>
> -
> then command you said to use is doing exactly the same thing I'm doing to
> the same target property... of course it should generate the same
> result and it does.
>
>
>
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] cmp0065

2016-07-06 Thread J Decker
M:/tmp/cmake_cmp0065/CMakeLists.txt(1):  cmake_minimum_required(VERSION 3.0
)
M:/tmp/cmake_cmp0065/CMakeLists.txt(2):  project(cmake-test )
M:/tmp/cmake_cmp0065/CMakeLists.txt(3):  add_executable(myExe main.c )
M:/tmp/cmake_cmp0065/CMakeLists.txt(4):  target_compile_definitions(myExe
PRIVATE MY_DEFINITION )
M:/tmp/cmake_cmp0065/CMakeLists.txt(5):  target_compile_definitions(myExe
PRIVATE VERSION_STRING="0.8.15" )
M:/tmp/cmake_cmp0065/CMakeLists.txt(6):  set(project myExe )

-- Configuring done
CMake Warning (dev) in CMakeLists.txt:
  Policy CMP0065 is not set: Do not add flags to export symbols from
  executables without the ENABLE_EXPORTS target property.  Run "cmake
  --help-policy CMP0065" for policy details.  Use the cmake_policy command
to
  set the policy and suppress this warning.

  For compatibility with older versions of CMake, additional flags may be
  added to export symbols on all executables regardless of thier
  ENABLE_EXPORTS property.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: M:/tmp/cmake_cmp0065/build

---
you have cmake_minimum_required(VERSION 3.5 ) in your example... setting
3.0 instead and adding --trace shows the warning...

-
then command you said to use is doing exactly the same thing I'm doing to
the same target property... of course it should generate the same
result and it does.
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] cmp0065

2016-07-06 Thread Johannes Zarl
Hi,

On Wednesday 06 July 2016 08:43:44 you wrote:
> > #if defined(WIN32)
> > #endif
> 
> not WIN32 that way... as in add_executable( something WIN32 ... )  (or not
> WIN32)

I'm not sure I can follow. I thought you want to have compile time definitions 
like "-DSOMETHING" for GCC or "/DSOMETHING" for MSVC.
If that's what you want, then use the already defined macros for your target 
platform/OS. For Windows, the correct macro is "_WIN32" (sorry I forgot the 
underscore before).

A comprehensive list of these macros can be found here:
https://sourceforge.net/p/predef/wiki/OperatingSystems/

If that's not what you want, it would help if you could elaborate a little, or 
maybe even provide a minimum working example.

 
> > target_compile_definitions( yourTarget PRIVATE COMPILE_SHELL)
> > https://cmake.org/cmake/help/v3.4/command/target_compile_definitions.html
> > 
> > Is that what you are searching for?
> 
> it says "tems will populate theCOMPILE_DEFINITIONS
>  t:COMPILE_DEFINITIONS> property
> of"
> sounds like that will trigger the same CMP0065 warnings.

Did you verify that? I cannot fathom how using target_compile_definitions 
could trigger a CMP0065 warning. But maybe I'm just reading the docs 
completely wrong...
Btw. the documentation states that CMP0065 does not warn by default, but 
silently reverts to the old behavior if it's not set.


Cheers,
  Johannes


P.S.: Checking this using a minimum example does not trigger any warning for 
me on cmake 3.5.2:

--CMakeLists.txt:
cmake_minimum_required(VERSION 3.5)
project(cmake-test)
add_executable(myExe main.cpp)
target_compile_definitions(myExe PRIVATE MY_DEFINITION)
target_compile_definitions(myExe PRIVATE VERSION_STRING="0.8.15")

--main.cpp:
#include 
#ifdef _WIN32
#warning "Target platform is windows 32 or 64 bit!"
#endif
int main(int argc, char** argv)
{
#ifdef MY_DEFINITION
   std::cout << argv[0] << "compiled with MY_DEFINITION!" << std::endl;
#endif
   std::cout << argv[0] << VERSION_STRING << std::endl;
   return 0;
}

For quoted definitions, I usually use configure_file to create a platform 
header.
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake


Re: [CMake] cmp0065

2016-07-06 Thread Johannes Zarl-Zierl
Hi,

On Tuesday 05 July 2016 23:46:16 J Decker wrote:
> https://cmake.org/cmake/help/v3.4/policy/CMP0065.html
> while I like the idea it suggests, I don't use the flags for -rdynamic so
> this is meaningless to me

I'm not sure I understood you correctly, but if the policy is meaningless to 
you, it shouldn't affect you...

> https://cmake.org/cmake/help/v3.4/prop_tgt/ENABLE_EXPORTS.html#prop_tgt:ENAB
> LE_EXPORTS
>   SET_PROPERTY(TARGET ${project} APPEND PROPERTY COMPILE_DEFINITIONS
> TARGET_LABEL=${TARGET_LABEL};TARETNAME=\"${TARGETNAME}\" )
> 
> or
> 
> SET_PROPERTY( TARGET ${project} APPEND PROPERTY COMPILE_DEFINITIONS
> "CONSOLE_SHELL" )
> 
> to indicate it's non-WIN32

First of all, there are the usual standard definitions provided by the 
compiler, so you can just use 

#if defined(WIN32)
#endif

to check whether the compilation happens for windows or another platform.

If you have the need for additional definitions, it seems to me that the usual 
command:

target_compile_definitions( yourTarget PRIVATE COMPILE_SHELL)
https://cmake.org/cmake/help/v3.4/command/target_compile_definitions.html

Is that what you are searching for?

> I noted at the bottom of that the the default behavior will eventually be
> phased out... but then can we have some other flag to phase it back in?

You can always set policies to “OLD” to revert to the old behavior (until it 
is finally phased out). In the case of cmp0065 the documentation explains what 
you can do to have the same behavior with the policiy enabled:
Just set the ENABLE_EXPORTS property on the targets that need to export their 
symbols.

HTH,
  Johannes
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake