Re: [CMake] Fwd: building libs and specifying addition folders

2012-01-20 Thread Michael Hertling
On 01/19/2012 08:15 AM, Dev Guy wrote:
> On Thu, Jan 19, 2012 at 1:01 AM, John Drescher  wrote:
>> -- Forwarded message --
>> From: John Drescher 
>> Date: Thu, Jan 19, 2012 at 1:00 AM
>> Subject: Re: [CMake] building libs and specifying addition folders
>> To: Dev Guy 
>>
>>
>> On Wed, Jan 18, 2012 at 10:57 PM, Dev Guy  wrote:
>>> Hi,
>>>
>>> I am relatively new to CMake and I've read the tutorial. However I
>>> have a few questions.
>>>
>>> 1. How can I declare a CMakeLists file to create a project to build a
>>> DLL or static lib ? I assume if I build a DLL on windows, it will
>>> build as a shared lib on Linux
>>
>> put SHARED in the add_library statement
>>
>> For more info than that type the following from a command prompt or shell:
>>
>> cmake --help-command add_library
>>
>>>
>>> 2. If my main source folder has 2 sub-folders, one that only includes
>>> header files call is Include and another folder that contains source
>>> files call it Utils. How do I add declare them to my CMakeLists files
>>> so that both the header and addition source files are found and and
>>> compiled in the main source folder to build the final binary.
>>>
>>
>> add_subdirectory
>>
>> Again for help:
>> cmake --help-command add_subdirectory
>>
>>
>> John
>>
>>
>> --
>> John M. Drescher
>> --
> 
> John thanks,
> 
> I was able to get a DLL built, now I have a program that want to link
> against the lib and use the DLL.
> 
> What I've done is create a Lib folder under the source folder wanting
> to use the lib, I copied over the lib find and header file. I added
> the following to CMakeLists.txt
> 
> add_subdirectory(Lib)
> 
> 
> target_link_libraries (SimpleTester UnitTest)
> 
> However I am seeing 2 errors:
> 
> Error 1, when I run CMake I see:
> 
> CMake Warning (dev) at CMakeLists.txt:6 (add_subdirectory):
>   The source directory
> 
> C:/dev/Project/UnitTestSample/Lib
> 
>   does not contain a CMakeLists.txt file.
> 
>   CMake does not support this case but it used to work accidentally and is
>   being allowed for compatibility.
> 
>   Policy CMP0014 is not set: Input directories must have CMakeLists.txt.  Run
>   "cmake --help-policy CMP0014" for policy details.  Use the cmake_policy
>   command to set the policy and suppress this warning.
> This warning is for project developers.  Use -Wno-dev to suppress it.
> 
> -- Configuring done
> -- Generating done
> -- Build files have been written to: C:/dev/Project/UnitTestSample/build
> 
> ==
> 
> Error 2
> 
> When I build I get a link error, which I fix by copying over the lib
> file into the build folder. How can I tell the linker from CMake where
> to find the lib?
> 
> LINK : fatal error LNK1104: cannot open file 'UnitTest.lib'
> LINK Pass 1 failed. with 2
> NMAKE : fatal error U1077: '"C:\Program Files\CMake
> 2.8\bin\cmake.exe"' : return code '0x'
> Stop.
> NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio
> 10.0\VC\BIN\nmake.exe"' : retu
> rn code '0x2'
> Stop.
> NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio
> 10.0\VC\BIN\nmake.exe"' : retu
> rn code '0x2'
> Stop.

Could you provide a small but self-sufficient exemplary project which
demonstrates what you're doing and allows for further investigation?

Regards,

Michael
--

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] Fwd: building libs and specifying addition folders

2012-01-18 Thread Dev Guy
On Thu, Jan 19, 2012 at 1:01 AM, John Drescher  wrote:
> -- Forwarded message --
> From: John Drescher 
> Date: Thu, Jan 19, 2012 at 1:00 AM
> Subject: Re: [CMake] building libs and specifying addition folders
> To: Dev Guy 
>
>
> On Wed, Jan 18, 2012 at 10:57 PM, Dev Guy  wrote:
>> Hi,
>>
>> I am relatively new to CMake and I've read the tutorial. However I
>> have a few questions.
>>
>> 1. How can I declare a CMakeLists file to create a project to build a
>> DLL or static lib ? I assume if I build a DLL on windows, it will
>> build as a shared lib on Linux
>
> put SHARED in the add_library statement
>
> For more info than that type the following from a command prompt or shell:
>
> cmake --help-command add_library
>
>>
>> 2. If my main source folder has 2 sub-folders, one that only includes
>> header files call is Include and another folder that contains source
>> files call it Utils. How do I add declare them to my CMakeLists files
>> so that both the header and addition source files are found and and
>> compiled in the main source folder to build the final binary.
>>
>
> add_subdirectory
>
> Again for help:
> cmake --help-command add_subdirectory
>
>
> John
>
>
> --
> John M. Drescher
> --

John thanks,

I was able to get a DLL built, now I have a program that want to link
against the lib and use the DLL.

What I've done is create a Lib folder under the source folder wanting
to use the lib, I copied over the lib find and header file. I added
the following to CMakeLists.txt

add_subdirectory(Lib)


target_link_libraries (SimpleTester UnitTest)

However I am seeing 2 errors:

Error 1, when I run CMake I see:

CMake Warning (dev) at CMakeLists.txt:6 (add_subdirectory):
  The source directory

C:/dev/Project/UnitTestSample/Lib

  does not contain a CMakeLists.txt file.

  CMake does not support this case but it used to work accidentally and is
  being allowed for compatibility.

  Policy CMP0014 is not set: Input directories must have CMakeLists.txt.  Run
  "cmake --help-policy CMP0014" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done
-- Build files have been written to: C:/dev/Project/UnitTestSample/build

==

Error 2

When I build I get a link error, which I fix by copying over the lib
file into the build folder. How can I tell the linker from CMake where
to find the lib?

LINK : fatal error LNK1104: cannot open file 'UnitTest.lib'
LINK Pass 1 failed. with 2
NMAKE : fatal error U1077: '"C:\Program Files\CMake
2.8\bin\cmake.exe"' : return code '0x'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio
10.0\VC\BIN\nmake.exe"' : retu
rn code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio
10.0\VC\BIN\nmake.exe"' : retu
rn code '0x2'
Stop.
--

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


[CMake] Fwd: building libs and specifying addition folders

2012-01-18 Thread John Drescher
-- Forwarded message --
From: John Drescher 
Date: Thu, Jan 19, 2012 at 1:00 AM
Subject: Re: [CMake] building libs and specifying addition folders
To: Dev Guy 


On Wed, Jan 18, 2012 at 10:57 PM, Dev Guy  wrote:
> Hi,
>
> I am relatively new to CMake and I've read the tutorial. However I
> have a few questions.
>
> 1. How can I declare a CMakeLists file to create a project to build a
> DLL or static lib ? I assume if I build a DLL on windows, it will
> build as a shared lib on Linux

put SHARED in the add_library statement

For more info than that type the following from a command prompt or shell:

cmake --help-command add_library

>
> 2. If my main source folder has 2 sub-folders, one that only includes
> header files call is Include and another folder that contains source
> files call it Utils. How do I add declare them to my CMakeLists files
> so that both the header and addition source files are found and and
> compiled in the main source folder to build the final binary.
>

add_subdirectory

Again for help:
cmake --help-command add_subdirectory


John


-- 
John M. Drescher
--

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