Re: [CMake] using cmake to link header files: file could be found, is included, but build error when using nmake.

2016-03-31 Thread Petr Kmoch
Hi Karel,

I've noticed a few points where you could start looking for a solution:

* You're mentioning that CMake warns about some linking stuff, but the
compiler error is one about including a header file. Libraries and headers
are fundamentally different objects: header files are used by the compiler,
libraries are used by the linker.

* Regarding the linking thing:

AVRO_LIBRARY- The Avro C++ libraries

Yet you seem to be setting this to a directory:

set(AVRO_LIBRARY
D:/kuleuven/thesis/kaa/kaaBuild/avro_1.8.0/lang/c++/build.win)

when you're supposed to set it to a library (.lib file).

* As for the header issue, you're setting:

set(AVRO_INCLUDE_DIR
D:/kuleuven/thesis/kaa/kaaBuild/avro_1.8.0/lang/c++/avro)

but then using:

include_directories (
 ${AVRO_INCLUDE_DIRS}
 )

Note the difference in the trailing 'S'.

* Additionally, variables like AVRO_INCLUDE_DIR and AVRO_LIBRARY look like
something the find package should be setting *for* you. It doesn't seem
like a package shipped with CMake, so consult its docs to check you're
using it as intended.

Petr

On Wed, Mar 30, 2016 at 5:15 PM, Karel Geiregat 
wrote:

> Dear users at Cmake
>
>
> It could be that I don't have understood the linking process when building
> the project by cmake. The project has three dependencies: (1) Boost, (2)
> (Apache) Avro and (3) Botan.
> After issuing the following command to be able to use the nmake command
> from Visual Studio:
>
> D:\...\build>cmake -G "NMake Makefiles" -DKAA_INSTALL_PATH="D:\kaa\kaaSDK"
>> -DKAA_DEBUG_ENABLED=1 ..
>>
>
> It ran without problems, except minor warnings like
>
> WARNING: Target "kaacpp" requests linking to directory
>> "D:/kaa/kaaBuild/avro_1.8.0/lang/c++/build.win".  Targets may link only to
>> libraries.  CMake is dropping the item.
>>
> => note: full log is at the bottom of this mail (appendix 1).
>
> but when i call nmake after, it immediately throws up error:
>
> D:\...\build>nmake
>>
>> Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
>> Copyright (C) Microsoft Corporation.  All rights reserved.
>>
>> Scanning dependencies of target kaacpp_o
>> [  1%] Building CXX object
>> CMakeFiles/kaacpp_o.dir/impl/event/registration/EndpointRegistrationManager.cpp.obj
>> EndpointRegistrationManager.cpp
>> D:\kaa\kaa-cpp-ep-sdk-aXrMkhHEE2BrPBehV_Vbxym2MfU\kaa/gen/EndpointGen.hpp(26):
>> fatal error C1083: Cannot open include file: 'avro/Specific.hh': No such
>> file or directory
>> NMAKE : fatal error U1077: 'C:\PROGRA~2\VISUAL~1.0\VC\bin\cl.exe' :
>> return code '0x2'
>> Stop.
>> NMAKE : fatal error U1077: '"C:\Program Files (x86)\Visual Studio
>> 14.0\VC\BIN\nmake.exe"' : return code '0x2'
>> Stop.
>>
>
> I have checked the file, and there is the following includes
>
> #include 
>> #include "boost/any.hpp"
>> #include "avro/Specific.hh" < error line
>> #include "avro/Encoder.hh"
>> #include "avro/Decoder.hh"
>>
>
> My idea is that the linking of the avro library is not set up correctly
> since the error got thrown after including a Boost file.
> Here is a fragment of my cmakelists.txt file where Avro got added and how
> the packages got found/added
>
> #  AVRO_ROOT_DIR   - Set this variable to the root installation
>> of  Avro C++ if the module has problems finding the proper installation
>> path.
>> #  AVRO_LIBRARY- The Avro C++ libraries
>> #  AVRO_INCLUDE_DIR- The location of Avro C++ headers
>> set(AVRO_ROOT_DIR D:/kuleuven/thesis/kaa/kaaBuild/avro_1.8.0/lang/c++)
>> set(AVRO_LIBRARY
>> D:/kuleuven/thesis/kaa/kaaBuild/avro_1.8.0/lang/c++/build.win)
>> set(AVRO_INCLUDE_DIR
>> D:/kuleuven/thesis/kaa/kaaBuild/avro_1.8.0/lang/c++/avro)
>>
>
>>
> some contents omitte
>>
>
>>
> #
>> # Find third-party dependencies
>> #
>> find_package (Boost 1.54 REQUIRED COMPONENTS log system thread)
>> find_package (Avro REQUIRED)
>> find_package (Botan REQUIRED)
>>
> => note: full cmakelist.txt file is added as appendix2
>
>
> After that, i have issued the following messaging
>
> message("--- AVRO: Found? " ${AVRO_FOUND}) <- displays "--- AVRO:
>> Found? TRUE"
>> message(${AVRO_LIBRARIES}) <- displays "
>> D:/kaa/kaaBuild/avro_1.8.0/lang/c++/build.win"
>
>
>
> So, the library can be found. However, it surprises me that the specific
> file, Specific.hh could not be found while it is in the include directory,
> AVRO_INCLUDE_DIR (according to the findavrocpp.cmake
> 
> it's used for headers).
> I have issued the following PowerShell command to show that the file is in
> the given directory
>
> PS D:\kaa\kaaBuild\avro_1.8.0\lang\c++\avro> Get-childitem Specific.hh
>>
>> Directory: D:\kaa\kaaBuild\avro_1.8.0\lang\c++\avro
>>
>> ModeLastWriteTime Length Name
>> - -- 
>> -a 2/9/2012   7:11 PM   7428 

[CMake] using cmake to link header files: file could be found, is included, but build error when using nmake.

2016-03-30 Thread Karel Geiregat
Dear users at Cmake


It could be that I don't have understood the linking process when building
the project by cmake. The project has three dependencies: (1) Boost, (2)
(Apache) Avro and (3) Botan.
After issuing the following command to be able to use the nmake command
from Visual Studio:

D:\...\build>cmake -G "NMake Makefiles" -DKAA_INSTALL_PATH="D:\kaa\kaaSDK"
> -DKAA_DEBUG_ENABLED=1 ..
>

It ran without problems, except minor warnings like

WARNING: Target "kaacpp" requests linking to directory
> "D:/kaa/kaaBuild/avro_1.8.0/lang/c++/build.win".  Targets may link only to
> libraries.  CMake is dropping the item.
>
=> note: full log is at the bottom of this mail (appendix 1).

but when i call nmake after, it immediately throws up error:

D:\...\build>nmake
>
> Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
> Copyright (C) Microsoft Corporation.  All rights reserved.
>
> Scanning dependencies of target kaacpp_o
> [  1%] Building CXX object
> CMakeFiles/kaacpp_o.dir/impl/event/registration/EndpointRegistrationManager.cpp.obj
> EndpointRegistrationManager.cpp
> D:\kaa\kaa-cpp-ep-sdk-aXrMkhHEE2BrPBehV_Vbxym2MfU\kaa/gen/EndpointGen.hpp(26):
> fatal error C1083: Cannot open include file: 'avro/Specific.hh': No such
> file or directory
> NMAKE : fatal error U1077: 'C:\PROGRA~2\VISUAL~1.0\VC\bin\cl.exe' : return
> code '0x2'
> Stop.
> NMAKE : fatal error U1077: '"C:\Program Files (x86)\Visual Studio
> 14.0\VC\BIN\nmake.exe"' : return code '0x2'
> Stop.
>

I have checked the file, and there is the following includes

#include 
> #include "boost/any.hpp"
> #include "avro/Specific.hh" < error line
> #include "avro/Encoder.hh"
> #include "avro/Decoder.hh"
>

My idea is that the linking of the avro library is not set up correctly
since the error got thrown after including a Boost file.
Here is a fragment of my cmakelists.txt file where Avro got added and how
the packages got found/added

#  AVRO_ROOT_DIR   - Set this variable to the root installation of
> Avro C++ if the module has problems finding the proper installation path.
> #  AVRO_LIBRARY- The Avro C++ libraries
> #  AVRO_INCLUDE_DIR- The location of Avro C++ headers
> set(AVRO_ROOT_DIR D:/kuleuven/thesis/kaa/kaaBuild/avro_1.8.0/lang/c++)
> set(AVRO_LIBRARY
> D:/kuleuven/thesis/kaa/kaaBuild/avro_1.8.0/lang/c++/build.win)
> set(AVRO_INCLUDE_DIR
> D:/kuleuven/thesis/kaa/kaaBuild/avro_1.8.0/lang/c++/avro)
>

>
some contents omitte
>

>
#
> # Find third-party dependencies
> #
> find_package (Boost 1.54 REQUIRED COMPONENTS log system thread)
> find_package (Avro REQUIRED)
> find_package (Botan REQUIRED)
>
=> note: full cmakelist.txt file is added as appendix2


After that, i have issued the following messaging

message("--- AVRO: Found? " ${AVRO_FOUND}) <- displays "--- AVRO:
> Found? TRUE"
> message(${AVRO_LIBRARIES}) <- displays "
> D:/kaa/kaaBuild/avro_1.8.0/lang/c++/build.win"



So, the library can be found. However, it surprises me that the specific
file, Specific.hh could not be found while it is in the include directory,
AVRO_INCLUDE_DIR (according to the findavrocpp.cmake

it's used for headers).
I have issued the following PowerShell command to show that the file is in
the given directory

PS D:\kaa\kaaBuild\avro_1.8.0\lang\c++\avro> Get-childitem Specific.hh
>
> Directory: D:\kaa\kaaBuild\avro_1.8.0\lang\c++\avro
>
> ModeLastWriteTime Length Name
> - -- 
> -a 2/9/2012   7:11 PM   7428 Specific.hh
>


So it could be that it is not linking correctly. Is the cmakelist.txt
incorrect or is cmake unable to link the right header file without throwing
an error ?
Is there a solution for this ? I don't have a clue where to find the cause
of the linking problems so i can solve it.

If you need more information, please check the appendix 1 & 2 here below.
If these isn't sufficient enough, please inform me which information i can
provide.

Sincerely
- kg



*APPENDIX 1: output of cmake command*

D:\kaa\kaa-cpp-ep-sdk-aXrMkhHEE2BrPBehV_Vbxym2MfU\build>cmake -G "NMake
> Makefiles" -DKAA_INSTALL_PATH="D:\kaa\kaaSDK" -DKAA_DEBUG_ENABLED=1 ..
> ==
> CMake Warning (dev) at CMakeLists.txt:73 (if):
>   Policy CMP0054 is not set: Only interpret if() arguments as variables or
>   keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
>   details.  Use the cmake_policy command to set the policy and suppress
> this
>   warning.
>
>   Quoted variables like "MSVC" will no longer be dereferenced when the
> policy
>   is set to NEW.  Since the policy is not set the OLD behavior will be
> used.
> This warning is for project developers.  Use -Wno-dev to suppress it.
>
> ==
> KAA_MAX_LOG_LEVEL=6
> EVENTS ENABLED
> NOTIFICATIONS ENABLED
> CONFIGURATION ENABLED
> LOGGING