Re: [CMake] Does Makefile generated by CMake support make -jN?

2016-07-17 Thread Chaos Zhang
Hi, Raymond, J Decker, Andrew, Chuck,

Thanks a lot for your generous help, i have found it was dependencies
missing of my project, for i have not found my project was built in
parallel.

BTW, i have used env var "MAKEFLAGS=-j" to make in parallel, is there any
way i can set "make -j" option in CMake file? For i use Qt Creator as IDE,
and the CMake compile system is provided for other R teams, so i want to
make the CMake compile system as simply and automatically as i can. Could
you please give me some advice?

Thanks again,
Chao

Chaos Zhang wrote
> Hi, Chuck,
> 
> Thanks for your generous help. 
> 
> Actually there is no make -j option in the already exist make flow of my
> project as i  know so far. Because i have read the makefiles in detail,
> and when i make my project, the sub projects in my project executed in
> order.
> 
> The problem i found is it cost much more time when use CMake generated
> Makefile to compile a single source file with gcc. I choose a passage of
> gcc options for each flow:
> 
> In alredy exist Makfile:
> 
> g++ “some gcc options like -W...”
> -c -g -DMACRO1 -DMACRO2 ... -isystemdir1 -isystemdir2 ...
> header_include_dir1header_include_dir2 ... -MMD -MP -MF -o src.o src.cpp
> 
> In CMake generated Makfile:
> 
> g++ “some gcc options like -W...” 
> -g header_include_dir1header_include_dir2 ... -DMACRO1 -DMACRO2 ...
> -isystemdir1 -isystemdir2 -o src.o -c src.cpp
> 
> other files when compile are also like above, but will cost much more
> time(2-3times), could you please give me some advices? If you need more
> details, please email me.
> 
> Sincere thanks,
> Chao
> Chuck Atkins wrote
>>>
>>> Thanks for your analysis for me Andrew. I can't use "-j" options, i
>>> think
>>> the
>> 
>> reason is the project i dealed with is not parallel. Thus when i use
>> "make
>>> -jN", it couldn't work correctly every time. Obviously it caused by the
>>> Makefile generated by CMake, so i wonder if there are some CMake options
>>> to
>>> use CPU effectively.
>> 
>> 
>> This usually means missing dependencies the CMakeLists.txt files. 
>> Because
>> of this you get unpredictable results when compiling in parallel.  Check
>> your dependencies on targets, link lines, and source files and make sure
>> they are all correct and not missing anything.
>> 
>> 
>> 
>>> Because i found when i use already exist Makefile, just
>>> use "make", it used about 480% CPU.
>> 
>> 
>> The Makefile is probably explicitly adding a fixed number of -j options.
>> CMake will not do this and instead rely on the user to call make with
>> their
>> desired appropriate level of parallelism.
>> 
>> 
>> 
>>> And when i use CMake generated Makefile, it just uesd about 96% CPU. The
>>> "hardware acceleration" i said means how to
>>> CPU more effectively in CMake.
>>>
>> 
>> -jN is as good as it gets for make.  That being said, you can always try
>> a
>> different generator, like Ninja, which tends to have quite a bit better
>> build times in parallel.
>> 
>> First things first though, you need to get your dependency problem
>> squared
>> away.  That's the underlying cause of why your parallel builds with -j
>> are
>> unpredictable.
>> 
>> -- 
>> 
>> 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





--
View this message in context: 
http://cmake.3232098.n2.nabble.com/Does-Makefile-generated-by-CMake-support-make-jN-tp7593949p7593973.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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] Does Makefile generated by CMake support make -jN?

2016-07-14 Thread Chaos Zhang
Hi, Chuck,

Thanks for your generous help. 

Actually there is no make -j option in the already exist make flow of my
project as i  know so far. Because i have read the makefiles in detail, and
when i make my project, the sub projects in my project executed in order.

The problem i found is it cost much more time when use CMake generated
Makefile to compile a single source file with gcc. I choose a passage of gcc
options for each flow:

In alredy exist Makfile:

g++ “some gcc options like -W...”
-c -g -DMACRO1 -DMACRO2 ... -isystemdir1 -isystemdir2 ...
header_include_dir1header_include_dir2 ... -MMD -MP -MF -o src.o src.cpp

In CMake generated Makfile:

g++ “some gcc options like -W...” 
-g header_include_dir1header_include_dir2 ... -DMACRO1 -DMACRO2 ...
-isystemdir1 -isystemdir2 -o src.o -c src.cpp

other files when compile are also like above, but will cost much more
time(2-3times), could you please give me some advices? If you need more
details, please email me.

Sincere thanks,
Chao


Chuck Atkins wrote
>>
>> Thanks for your analysis for me Andrew. I can't use "-j" options, i think
>> the
> 
> reason is the project i dealed with is not parallel. Thus when i use "make
>> -jN", it couldn't work correctly every time. Obviously it caused by the
>> Makefile generated by CMake, so i wonder if there are some CMake options
>> to
>> use CPU effectively.
> 
> 
> This usually means missing dependencies the CMakeLists.txt files.  Because
> of this you get unpredictable results when compiling in parallel.  Check
> your dependencies on targets, link lines, and source files and make sure
> they are all correct and not missing anything.
> 
> 
> 
>> Because i found when i use already exist Makefile, just
>> use "make", it used about 480% CPU.
> 
> 
> The Makefile is probably explicitly adding a fixed number of -j options.
> CMake will not do this and instead rely on the user to call make with
> their
> desired appropriate level of parallelism.
> 
> 
> 
>> And when i use CMake generated Makefile, it just uesd about 96% CPU. The
>> "hardware acceleration" i said means how to
>> CPU more effectively in CMake.
>>
> 
> -jN is as good as it gets for make.  That being said, you can always try a
> different generator, like Ninja, which tends to have quite a bit better
> build times in parallel.
> 
> First things first though, you need to get your dependency problem squared
> away.  That's the underlying cause of why your parallel builds with -j are
> unpredictable.
> 
> -- 
> 
> 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





--
View this message in context: 
http://cmake.3232098.n2.nabble.com/Does-Makefile-generated-by-CMake-support-make-jN-tp7593949p7593966.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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] Does Makefile generated by CMake support make -jN?

2016-07-13 Thread Chaos Zhang
Thanks for your analysis for me Andrew. I can't use "-j" options, i think the
reason is the project i dealed with is not parallel. Thus when i use "make
-jN", it couldn't work correctly every time. Obviously it caused by the
Makefile generated by CMake, so i wonder if there are some CMake options to
use CPU effectively. Because i found when i use already exist Makefile, just
use "make", it used about 480% CPU. And when i use CMake generated Makefile,
it just uesd about 96% CPU. The "hardware acceleration" i said means how to
CPU more effectively in CMake.

Thanks again,
Chao

Andrew Melo wrote
> On Tue, Jul 12, 2016 at 10:48 PM, Chaos Zhang 

> zcsd2012@

>  wrote:
>> Thanks for your reply Raymond, by 'If you got 96% both times, then I
>> would
>> say there's a problem.', did you mean if make performed like this, it
>> means
>> this project can't use make -jN?
> 
> If "make -j1" and "make -j8" ran in the same amount of time, there
> would be a problem. Since "make -j1" uses 96% CPU and "make -j8" uses
> 690% CPU, it implies that the "-j" options make compilation time
> scale, which is what you want.
> 
>> BTW, does CMake support some options to
>> turn on hardware acceleration?
> 
> What do you mean by "hardware acceleration"?
> 
> 
> 
>>
>> Raymond Wan-2 wrote
>>> Hi Chao,
>>>
>>>
>>> On Wed, Jul 13, 2016 at 10:54 AM, Chaos Zhang 
>>
>>> zcsd2012@
>>
>>>  wrote:
>>>> I was trying to compile my project using CMake, after CMake generated
>>>> Makefile.
>>>> I used `/usr/bin/time -v make` to make the Makefile,  got the result:
>>>> 'Percent of CPU this job got: 96%'.
>>>> Then i used `/usr/bin/time -v make -j8` to make the Makefile, the
>>>> result
>>>> of
>>>> CPU used is  'Percent of CPU this job got: 648%'.
>>>> So i wonder if Makefile generated by CMake support make -jN, BTW my CPU
>>>> is
>>>> I7-4790, and after i use 'cat /proc/cpuinfo', there are 8 processors.
>>>
>>>
>>> I'm not sure what you are asking...
>>>
>>> You ran make with -j 8 and you got a percentage greater than 96% ...
>>> this implies that the Makefile does support -jN, doesn't it?  If you
>>> got 96% both times, then I would say there's a problem.
>>>
>>> Is what you're wondering why it is 648% and not 800%?  I think that
>>> depends on the dependencies in your Makefile.  It's possible that some
>>> of them depend on each other in such a way that 8 parallel threads is
>>> not possible.
>>>
>>> Also, I can't remember the value returned by /usr/bin/time -v, but I
>>> guess 648% is the average and not maximum.  So, perhaps there are
>>> parts within the Makefile that only one thread could be used and then
>>> it gets averaged out?
>>>
>>> Ray
>>> --
>>>
>>> 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
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://cmake.3232098.n2.nabble.com/Does-Makefile-generated-by-CMake-support-make-jN-tp7593949p7593951.html
>> Sent from the CMake mailing list archive at Nabble.com.
>> --
>>
>> 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.kitwar

Re: [CMake] Does Makefile generated by CMake support make -jN?

2016-07-13 Thread Chaos Zhang
Thanks for your  references Decker, the condition is it cost close to three
times time after i use CMake than already exist makefile  to build project.
And i found the CPU  didn't use effectively than exist make flow, so i
wonder if CMake provide some options to use CPU more effectively.
Thanks,
Chao

J Decker wrote
> On Tue, Jul 12, 2016 at 7:54 PM, Chaos Zhang 

> zcsd2012@

>  wrote:
> 
>> Hi, all,
>>
>> I was trying to compile my project using CMake, after CMake generated
>> Makefile.
>> I used `/usr/bin/time -v make` to make the Makefile,  got the result:
>> 'Percent of CPU this job got: 96%'.
>> Then i used `/usr/bin/time -v make -j8` to make the Makefile, the result
>> of
>> CPU used is  'Percent of CPU this job got: 648%'.
>> So i wonder if Makefile generated by CMake support make -jN, BTW my CPU
>> is
>> I7-4790, and after i use 'cat /proc/cpuinfo', there are 8 processors.
>>
>>
> All the sources, headers, etc come from the IO system, from the disk,
> probably you're running into the bottleneck of how long it takes to move
> the memory for the compiler to do work on?  did you profile IO ?
> 
> 
>> Thanks a lot,
>> Chao
>>
>>
>>
>> --
>> View this message in context:
>> http://cmake.3232098.n2.nabble.com/Does-Makefile-generated-by-CMake-support-make-jN-tp7593949.html
>> Sent from the CMake mailing list archive at Nabble.com.
>> --
>>
>> 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
>>
> 
> -- 
> 
> 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





--
View this message in context: 
http://cmake.3232098.n2.nabble.com/Does-Makefile-generated-by-CMake-support-make-jN-tp7593949p7593954.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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] Does Makefile generated by CMake support make -jN?

2016-07-12 Thread Chaos Zhang
Thanks for your reply Raymond, by 'If you got 96% both times, then I would
say there's a problem.', did you mean if make performed like this, it means
this project can't use make -jN? BTW, does CMake support some options to
turn on hardware acceleration?

Raymond Wan-2 wrote
> Hi Chao,
> 
> 
> On Wed, Jul 13, 2016 at 10:54 AM, Chaos Zhang 

> zcsd2012@

>  wrote:
>> I was trying to compile my project using CMake, after CMake generated
>> Makefile.
>> I used `/usr/bin/time -v make` to make the Makefile,  got the result:
>> 'Percent of CPU this job got: 96%'.
>> Then i used `/usr/bin/time -v make -j8` to make the Makefile, the result
>> of
>> CPU used is  'Percent of CPU this job got: 648%'.
>> So i wonder if Makefile generated by CMake support make -jN, BTW my CPU
>> is
>> I7-4790, and after i use 'cat /proc/cpuinfo', there are 8 processors.
> 
> 
> I'm not sure what you are asking...
> 
> You ran make with -j 8 and you got a percentage greater than 96% ...
> this implies that the Makefile does support -jN, doesn't it?  If you
> got 96% both times, then I would say there's a problem.
> 
> Is what you're wondering why it is 648% and not 800%?  I think that
> depends on the dependencies in your Makefile.  It's possible that some
> of them depend on each other in such a way that 8 parallel threads is
> not possible.
> 
> Also, I can't remember the value returned by /usr/bin/time -v, but I
> guess 648% is the average and not maximum.  So, perhaps there are
> parts within the Makefile that only one thread could be used and then
> it gets averaged out?
> 
> Ray
> -- 
> 
> 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





--
View this message in context: 
http://cmake.3232098.n2.nabble.com/Does-Makefile-generated-by-CMake-support-make-jN-tp7593949p7593951.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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


[CMake] Does Makefile generated by CMake support make -jN?

2016-07-12 Thread Chaos Zhang
Hi, all,

I was trying to compile my project using CMake, after CMake generated
Makefile.
I used `/usr/bin/time -v make` to make the Makefile,  got the result:
'Percent of CPU this job got: 96%'.
Then i used `/usr/bin/time -v make -j8` to make the Makefile, the result of
CPU used is  'Percent of CPU this job got: 648%'. 
So i wonder if Makefile generated by CMake support make -jN, BTW my CPU is
I7-4790, and after i use 'cat /proc/cpuinfo', there are 8 processors.

Thanks a lot,
Chao



--
View this message in context: 
http://cmake.3232098.n2.nabble.com/Does-Makefile-generated-by-CMake-support-make-jN-tp7593949.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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


[CMake] How to assign specific c, c++, fortran compiler and does CMake support Intel C/C++/Fortran Compiler?

2016-07-01 Thread Chaos Zhang
Hi, all,

First, thanks for review my email. There are two questions i faced now:

1. I faced problem to assign specific compiler in CMake, and i searched for
a while then i found [ CC="Foo\gcc.exe" CXX="Foo\g++.exe" cmake . ] seem
work. Now i use CMake in QtCreator, is there other way i can assign specific
compiler?

2. The compiler i want to assign is Intel C/C++/Fortran Compiler, does CMake
support it? I have found in CMake\share\cmake-3.2\Modules\Compiler there are
[ Intel-C.cmake ] and [ Intel-CXX.cmake  ], could you please tell me the
function of them?

Best regards,
chao



--
View this message in context: 
http://cmake.3232098.n2.nabble.com/How-to-assign-specific-c-c-fortran-compiler-and-does-CMake-support-Intel-C-C-Fortran-Compiler-tp7593880.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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


[CMake] Why a foo.dll.a generated when i build shared lib foo.dll or foo.exe file?

2016-06-19 Thread Chaos Zhang
Hi,all,

I am working on transferring an existed make project into cmake, and the
platform is MinGW(32 bit) on windows. The make flow to build foo.dll or
foo.exe would not generate  foo.dll.a, but when i use CMake, this generated.
I was wondering if this foo.dll.a is necessary, and if it is not necessary,
what can i do to avoid generating this file.

Thanks a lot,
Chao



--
View this message in context: 
http://cmake.3232098.n2.nabble.com/Why-a-foo-dll-a-generated-when-i-build-shared-lib-foo-dll-or-foo-exe-file-tp7593769.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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


[CMake] How to set gcc option "-Wl,-rpath-link," in CMake?make

2016-06-06 Thread Chaos Zhang
Hi, all,

i am trying to converting an existed make project into CMake project, and
there are some gcc link options i should convert. Not long ago, Mr. Atkins
told me 'RPATHs are automatically added by CMake to executables so they can
use libraries from the build tree.'. Now i don't know weather
"-Wl,-rpath-link," automatically added by CMake after search for some time.
Could you please give me some advice?

Best Regards,
Chao



--
View this message in context: 
http://cmake.3232098.n2.nabble.com/How-to-set-gcc-option-Wl-rpath-link-in-CMake-make-tp7593638.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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] How to hundle gcc link options(like whole-archive, --allow-multiple-definition) in CMake?

2016-05-31 Thread Chaos Zhang
Thanks for your generous Mr. Atkins, what you answer me worked well and
solved my question. I would keep 'always use target names in a
CMakeLists.txt instead of the actual output file' in my mind. :-)

Chao

Chuck Atkins wrote
> Hi Chao,
> 
> You want to let CMake to as much of the work for you as possible.  You're
> still trying to explicitly pass the path to the library file to
> target_link_libraries.  If you look at the line:
> 
> target_link_library(exe1 "-Wl, --whole-archive ../sub_dir1/liblib1.a
> --no-whole-archive")
> 
> there's no CMake target name so CMake can't know about the dependency.
> However, if you use the target name instead:
> 
> top_dir/CMakeLists.txt:
> cmake_minimum_required(VERSION 3.0)
> project(foo)
> add_subdirectory(sub_dir2)
> add_subdirectory(sub_dir1)
> 
> top_dir/sub_dir1/CMakeLists.txt
> add_library(L1 1.c)
> 
> top_dit/sub_dir2/CMakeLists.txt
> add_executable(exe1 main.c)
> target_link_libraries(exe1 "-Wl,--whole-archive" *L1*
> "-Wl,--no-whole-archive")
> 
> Notice how in the target_link_libraries line for exe1, the link options
> are
> separate instead of 1 big string combining them all and the actual CMake
> target name, L1, is used instead of the output file libL1.a.  You can see
> the resulting output is what you want:
> 
> $ make VERBOSE=1
> ...
> [100%] Linking C executable exe1
> ...
> /usr/bin/cc CMakeFiles/exe1.dir/main.c.o  -o exe1 -rdynamic
> *-Wl,--whole-archive
> ../sub_dir1/libL1.a -Wl,--no-whole-archive*
> 
> Generally speaking, always use target names in a CMakeLists.txt instead of
> the actual output file.  There are a few situations where you may need the
> actual file name but they are uncommon and even then you would do it
> through target properties and generator expressions rather than hard code
> the library file name.
> 
> - Chuck
> 
> On Mon, May 30, 2016 at 8:35 AM, Chaos Zhang 

> zcsd2012@

>  wrote:
> 
>> Hi, all,
>>
>> Thanks for taking your time to review my email. I have a demo project and
>> it's structure like as below:
>>
>> top_dir
>> CMakeLists.txt
>> sub_dir1
>> CMakeLists.txt
>> sub_dir2
>> CMakeLists.txt
>>
>> top_dir/sub_dir1/CMakeLists.txt used to build `lib1` by using
>> `add_library(lib1 ...)`,
>> top_dir/sub_dir2/CMakeLists.txt used to build `exe1` with linking lib1 by
>> `target_link_library(exe1 lib1)`.
>> And the content of top_dir/CMakeLists.txt is as below:
>>
>> add_subdirectory(sub_dir2)
>> add_subdirectory(sub_dir1)
>>
>> Normally, when build target exe1, cmake will check dependency so `lib1`
>> will
>> be built before building exe1. The problem is I am transfering an existed
>> makefile project into CMake, and there are many gcc link options, like
>> "whole-archive ... no-whole-archive, allow-mutiple-definition", if use
>> like
>> `target_link_library(exe1 "-Wl, --whole-archive ../sub_dir1/liblib1.a
>> --no-whole-archive")`(The form like this, and this may not work, it just
>> a
>> e.g.), cmake seem don't built `lib1` any more. Is there any way i can use
>> target_link_library like `target_link_library(exe1 "-Wl, --whole-archive
>> ../sub_dir1/liblib1.a")` and cmake link dependency checking still work,
>> or
>> other way i can transfer these gcc link options into cmake?
>>
>> Thanks a lot,
>> Chao
>>
>>
>>
>> --
>> View this message in context:
>> http://cmake.3232098.n2.nabble.com/How-to-hundle-gcc-link-options-like-whole-archive-allow-multiple-definition-in-CMake-tp7593563.html
>> Sent from the CMake mailing list archive at Nabble.com.
>> --
>>
>> 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
>>
> 
> -- 
> 
> 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 va

[CMake] How to hundle gcc link options(like whole-archive, --allow-multiple-definition) in CMake?

2016-05-30 Thread Chaos Zhang
Hi, all,

Thanks for taking your time to review my email. I have a demo project and
it's structure like as below:

top_dir
CMakeLists.txt
sub_dir1
CMakeLists.txt
sub_dir2
CMakeLists.txt

top_dir/sub_dir1/CMakeLists.txt used to build `lib1` by using
`add_library(lib1 ...)`, 
top_dir/sub_dir2/CMakeLists.txt used to build `exe1` with linking lib1 by
`target_link_library(exe1 lib1)`. 
And the content of top_dir/CMakeLists.txt is as below:

add_subdirectory(sub_dir2)
add_subdirectory(sub_dir1)

Normally, when build target exe1, cmake will check dependency so `lib1` will
be built before building exe1. The problem is I am transfering an existed
makefile project into CMake, and there are many gcc link options, like
"whole-archive ... no-whole-archive, allow-mutiple-definition", if use like
`target_link_library(exe1 "-Wl, --whole-archive ../sub_dir1/liblib1.a
--no-whole-archive")`(The form like this, and this may not work, it just a
e.g.), cmake seem don't built `lib1` any more. Is there any way i can use
target_link_library like `target_link_library(exe1 "-Wl, --whole-archive
../sub_dir1/liblib1.a")` and cmake link dependency checking still work, or
other way i can transfer these gcc link options into cmake?

Thanks a lot,
Chao



--
View this message in context: 
http://cmake.3232098.n2.nabble.com/How-to-hundle-gcc-link-options-like-whole-archive-allow-multiple-definition-in-CMake-tp7593563.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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] How to use 'CMAKE_EXE_LINKER_FLAGS' correctly

2016-05-24 Thread Chaos Zhang
This CMake  feature is interesting, the first step i plan is to make the
project work first, then i will try to optimize it, and i think this feature
would be used next step. Thanks. :-)

Chuck Atkins wrote
> If you know the full path to the library then I'd suggest using it as
> /path/to/foo/libfoo.a (or .so if it's shared) instead of -L/path/to/foo
> -lfoo.  CMake will adjust the flags to -L and -l if needed but the
> preference is always to use the full library path.
> 
> - Chuck
> 
> On Mon, May 23, 2016 at 2:23 AM, Chaos Zhang 

> zcsd2012@

>  wrote:
> 
>> Thanks a lot! `set(FOO_LIBRARY "-Wl,--whole-archive ${FOO_LIBRARY}
>> -Wl,--no-whole-archive")` worked when the content of ${FOO_LIBRARY} look
>> like `-Ldir -llib`, if just use lib name as the content of
>> ${FOO_LIBRARY},
>> error while occur.
>>
>> Chuck Atkins wrote
>> >> -rpath
>> >
>> >
>> >  RPATHs are automatically added by CMake to executables so they can use
>> > libraries from the build tree.
>> >
>> >
>> >
>> >> -whole-archive
>> >>
>> >
>> > whole-archive is definitely trickier since you shouldn't be applying it
>> to
>> > the entire executable but instead wrapping individual libraries with
>> it.
>> > Conveniently, you can pass link options directly with
>> > target_link_libraries.  So you could have:
>> >
>> > # Just an example, find_library calls should really be isolated to
>> > separate
>> > find modules
>> > find_library(FOO_LIBRARY foo)
>> > set(FOO_LIBRARY "-Wl,--whole-archive ${FOO_LIBRARY}
>> > -Wl,--no-whole-archive")
>> >
>> > add_executable(hello main.c)
>> > target_link_libraries(hello ${FOO_LIBRARY})
>> >
>> >
>> >>> set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L . -lhello")
>> >>
>> >
>> > CMAKE_EXE_LINKER_FLAGS should work for other more general cases that
>> > aren't
>> > tied to specific libraries.  The problem with your example is likely
>> not
>> > using an absolute path for -L since the compilation is actually taking
>> > place in a nested work directory somewhere.
>> >
>> > --
>> >
>> > 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
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://cmake.3232098.n2.nabble.com/How-to-use-CMAKE-EXE-LINKER-FLAGS-correctly-tp7593495p7593518.html
>> Sent from the CMake mailing list archive at Nabble.com.
>> --
>>
>> 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
>>
> 
> -- 
> 
> 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.kit

Re: [CMake] How to use 'CMAKE_EXE_LINKER_FLAGS' correctly

2016-05-23 Thread Chaos Zhang
Thanks a lot! `set(FOO_LIBRARY "-Wl,--whole-archive ${FOO_LIBRARY}
-Wl,--no-whole-archive")` worked when the content of ${FOO_LIBRARY} look
like `-Ldir -llib`, if just use lib name as the content of ${FOO_LIBRARY},
error while occur.

Chuck Atkins wrote
>> -rpath
> 
> 
>  RPATHs are automatically added by CMake to executables so they can use
> libraries from the build tree.
> 
> 
> 
>> -whole-archive
>>
> 
> whole-archive is definitely trickier since you shouldn't be applying it to
> the entire executable but instead wrapping individual libraries with it.
> Conveniently, you can pass link options directly with
> target_link_libraries.  So you could have:
> 
> # Just an example, find_library calls should really be isolated to
> separate
> find modules
> find_library(FOO_LIBRARY foo)
> set(FOO_LIBRARY "-Wl,--whole-archive ${FOO_LIBRARY}
> -Wl,--no-whole-archive")
> 
> add_executable(hello main.c)
> target_link_libraries(hello ${FOO_LIBRARY})
> 
> 
>>> set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L . -lhello")
>>
> 
> CMAKE_EXE_LINKER_FLAGS should work for other more general cases that
> aren't
> tied to specific libraries.  The problem with your example is likely not
> using an absolute path for -L since the compilation is actually taking
> place in a nested work directory somewhere.
> 
> -- 
> 
> 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





--
View this message in context: 
http://cmake.3232098.n2.nabble.com/How-to-use-CMAKE-EXE-LINKER-FLAGS-correctly-tp7593495p7593518.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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] How to use 'CMAKE_EXE_LINKER_FLAGS' correctly

2016-05-20 Thread Chaos Zhang
Nice to see you again, Mr. Atkins. I was trying to add a very long gcc link
option to a ELF file, there are some options, like -whole-archive,
-rpath,and i don't known how to set in CMake, so i decided to use original
gcc option, is there better way to solve this?

Chuck Atkins wrote
> Is there a reason to not use target_link_libraries here? For the purposes
> of your example there's no reason to be using CMAKE_EXE_LINKER_FLAGS. 
> What
> are you actually trying to accomplish? Because there is almost certainly a
> better way to achieve your desired result than via CMAKE_EXE_LINKER_FLAGS.
> 
> - Chuck
> 
> On Fri, May 20, 2016 at 4:28 AM, Chaos Zhang 

> zcsd2012@

>  wrote:
> 
>> Hi, all,
>>
>> I try to use some gcc link option and libs(except libs link by
>> target_link_libraries(...)), i researched and try to use
>> 'CMAKE_EXE_LINKER_FLAGS' in a simple project, as below:
>> in dir, there are 5 files:
>>
>> -hello.h
>> -hello.c
>> -main.c
>> -hello.o
>> -libhello.a
>>
>> hello.o was compiled by hello.c(gcc -c hello.c) and libhello.a contained
>> hello.o. And other 3 files content:
>> 1.In hello.h:
>>
>> void hello();
>>
>> 2.In hello.c:
>>
>> #include
> 
>> void hello()
>> {
>> printf("hello\n");
>> }
>>
>> 3.In main.c:
>>
>> #include "hello.h"
>> void main()
>> {
>>hello();
>> }
>>
>> When i used gcc -o main main.c libhello.a, the exe file: main generated,
>> and
>> it work well.
>> Then i write a CMakeLists.txt, the content as below:
>>
>> set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L . -lhello")
>> add_executable(main main.c)
>>
>> When i cmake this project, an error occurred: main.c:undefined
>> reference to 'hello'.
>>
>> Since i wil add a complicated link option and would not conflict with 
>> libs
>> link by target_link_libraries(...), i should figure out how to use
>> 'CMAKE_EXE_LINKER_FLAGS' or other ways, could you please give me some
>> advices? :-)
>>
>> Thanks,
>> Chao
>>
>>
>>
>> --
>> View this message in context:
>> http://cmake.3232098.n2.nabble.com/How-to-use-CMAKE-EXE-LINKER-FLAGS-correctly-tp7593495.html
>> Sent from the CMake mailing list archive at Nabble.com.
>> --
>>
>> 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
>>
> 
> -- 
> 
> 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





--
View this message in context: 
http://cmake.3232098.n2.nabble.com/How-to-use-CMAKE-EXE-LINKER-FLAGS-correctly-tp7593495p7593503.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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

[CMake] How to use 'CMAKE_EXE_LINKER_FLAGS' correctly

2016-05-20 Thread Chaos Zhang
Hi, all,

I try to use some gcc link option and libs(except libs link by
target_link_libraries(...)), i researched and try to use
'CMAKE_EXE_LINKER_FLAGS' in a simple project, as below:
in dir, there are 5 files:

-hello.h
-hello.c
-main.c
-hello.o
-libhello.a

hello.o was compiled by hello.c(gcc -c hello.c) and libhello.a contained
hello.o. And other 3 files content:
1.In hello.h:

void hello();

2.In hello.c:

#include
void hello()
{
printf("hello\n");
}

3.In main.c:

#include "hello.h"
void main()
{
   hello();
}

When i used gcc -o main main.c libhello.a, the exe file: main generated, and
it work well.
Then i write a CMakeLists.txt, the content as below:

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L . -lhello")
add_executable(main main.c)

When i cmake this project, an error occurred: main.c:undefined
reference to 'hello'.

Since i wil add a complicated link option and would not conflict with  libs
link by target_link_libraries(...), i should figure out how to use
'CMAKE_EXE_LINKER_FLAGS' or other ways, could you please give me some
advices? :-)

Thanks,
Chao



--
View this message in context: 
http://cmake.3232098.n2.nabble.com/How-to-use-CMAKE-EXE-LINKER-FLAGS-correctly-tp7593495.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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


[CMake] Linking CXX executable xxx :undefined reference to `stlp_std::cout'

2016-05-16 Thread Chaos Zhang
Hi all,

I was trying to convert an existed c++ project to CMake. The existed worked
well with makefile, and i have converted similar one successfully.  but when
i try to convert this one, some confusing errors occurred, as below:
18:22:10: Running steps for project encryption...
18:22:10: Starting: "/export/opt/cmake-3.2.2/bin/cmake" --build . --target
all
Linking CXX executable dist/Debug_64/GNU-Linux-x86/encryption
CMakeFiles/encryption.dir/encryption.cc.o: In function `main':
/export1/chao/nanos/nano_clean/nano_clean/src/encryption/encryption.cc:33:
undefined reference to `stlp_std::cout'
...
/export1/chao/nanos/nano_clean/nano_clean/lib/STLport/stlport/stl/_string.c:604:
undefined reference to `stlp_std::__stl_throw_out_of_range(char const*)'
...
(more detail at bottom of this mail)

At first i think it can't find iostream, so i include iostream at
/export1/chao/nanos/nano_clean/nano_clean/lib/STLport/stlport/ by using
'INCLUDE_DIRECTORIES', but i did not work. Could you please give me some
advices?

Best regards,
Chao

detail error messages:

18:22:10: Running steps for project encryption...
18:22:10: Starting: "/export/opt/cmake-3.2.2/bin/cmake" --build . --target
all
Linking CXX executable dist/Debug_64/GNU-Linux-x86/encryption
CMakeFiles/encryption.dir/encryption.cc.o: In function `main':
/export1/chao/nanos/nano_clean/nano_clean/src/encryption/encryption.cc:33:
undefined reference to `stlp_std::cout'
/export1/chao/nanos/nano_clean/nano_clean/src/encryption/encryption.cc:39:
undefined reference to `stlp_std::cout'
/export1/chao/nanos/nano_clean/nano_clean/src/encryption/encryption.cc:46:
undefined reference to `stlp_std::cout'
/export1/chao/nanos/nano_clean/nano_clean/src/encryption/encryption.cc:48:
undefined reference to `stlp_std::cout'
/export1/chao/nanos/nano_clean/nano_clean/src/encryption/encryption.cc:54:
undefined reference to `stlp_std::cout'
CMakeFiles/encryption.dir/encryption.cc.o:/export1/chao/nanos/nano_clean/nano_clean/src/encryption/encryption.cc:56:
more undefined references to `stlp_std::cout' follow
CMakeFiles/encryption.dir/encryption.cc.o: In function
`stlp_std::ios_base::_M_check_exception_mask()':
/export1/chao/nanos/nano_clean/nano_clean/lib/STLport/stlport/stl/_ios_base.h:191:
undefined reference to `stlp_std::ios_base::_M_throw_failure()'
CMakeFiles/encryption.dir/encryption.cc.o: In function
`stlp_std::priv::_String_base
>::_M_throw_out_of_range() const':
/export1/chao/nanos/nano_clean/nano_clean/lib/STLport/stlport/stl/_string.c:604:
undefined reference to `stlp_std::__stl_throw_out_of_range(char const*)'
CMakeFiles/encryption.dir/encryption.cc.o: In function
`stlp_std::priv::_String_base
>::_M_throw_length_error() const':
/export1/chao/nanos/nano_clean/nano_clean/lib/STLport/stlport/stl/_string.c:600:
undefined reference to `stlp_std::__stl_throw_length_error(char const*)'
CMakeFiles/encryption.dir/encryption.cc.o: In function `char*
boost::detail::lcast_put_unsigned, unsigned
int, char>(unsigned int, char*)':
/export1/chao/nanos/nano_clean/nano_clean/lib/boost/1.49.0/boost/lexical_cast.hpp:561:
undefined reference to `stlp_std::locale::locale()'
/export1/chao/nanos/nano_clean/nano_clean/lib/boost/1.49.0/boost/lexical_cast.hpp:562:
undefined reference to `stlp_std::locale::classic()'
/export1/chao/nanos/nano_clean/nano_clean/lib/boost/1.49.0/boost/lexical_cast.hpp:562:
undefined reference to `stlp_std::locale::operator!=(stlp_std::locale
const&) const'
/export1/chao/nanos/nano_clean/nano_clean/lib/boost/1.49.0/boost/lexical_cast.hpp:617:
undefined reference to `stlp_std::locale::~locale()'
/export1/chao/nanos/nano_clean/nano_clean/lib/boost/1.49.0/boost/lexical_cast.hpp:617:
undefined reference to `stlp_std::locale::~locale()'
CMakeFiles/encryption.dir/encryption.cc.o: In function
`stlp_std::allocator::_M_allocate(unsigned long, unsigned long&)':
/export1/chao/nanos/nano_clean/nano_clean/lib/STLport/stlport/stl/_alloc.h:348:
undefined reference to `stlp_std::__malloc_alloc::allocate(unsigned long)'
CMakeFiles/encryption.dir/encryption.cc.o: In function
`stlp_std::numpunct*
stlp_std::priv::_UseFacet >(stlp_std::locale
const&, stlp_std::numpunct const*)':
/export1/chao/nanos/nano_clean/nano_clean/lib/STLport/stlport/stl/_locale.h:349:
undefined reference to `stlp_std::locale::_M_use_facet(stlp_std::locale::id
const&) const'
CMakeFiles/encryption.dir/encryption.cc.o: In function
`stlp_std::locale::id&
stlp_std::priv::_GetFacetId
>(stlp_std::numpunct const*)':
/export1/chao/nanos/nano_clean/nano_clean/lib/STLport/stlport/stl/_locale.h:325:
undefined reference to `stlp_std::numpunct::id'
collect2: error: ld returned 1 exit status
gmake[2]: *** [dist/Debug_64/GNU-Linux-x86/encryption] Error 1
gmake[1]: *** [CMakeFiles/encryption.dir/all] Error 2
gmake: *** [all] Error 2
18:22:10: The process "/export/opt/cmake-3.2.2/bin/cmake" exited with 

Re: [CMake] How to link shared lib on windows (visual studio 2014).

2016-04-26 Thread Chaos Zhang
Thanks again Mr. Atkins.

Chuck Atkins wrote
> May others have mentioned the various different ways to address generating
> import libraries.  One thing that will help with the "can't find .dll"
> issue is to change the default location that various components end up.
> With Windows shared libraries, you have both a runtime component (.dll)
> and
> a link time component (.lib).  Setting the following at the top of your
> CMakeLists.txt:
> 
> if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
>   set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
> endif()
> if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
>   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
> endif()
> if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
>   set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
> endif()
> 
> This is a common pattern to place near the beginning of a top-level
> CMakeLists.txt after the project(...) copmmand.  What this does is make
> sure that all runtime components end up in the bin directory, including
> both .exe's and .dll's, and that all link-time components, including .so's
> and .a's in Linux and .lib's on Windows, end up in the the lib directory.
> This way when you run your executable on Windows, their necessary runtime
> components live next to them.  It also consolidates all your build
> products
> into one place instead of leaving them scattered across the various
> sub-directories of the build folder.
> 
> - Chuck
> 
> On Tue, Apr 26, 2016 at 9:22 AM, Chaos Zhang 

> zcsd2012@

>  wrote:
> 
>> Hi, all,
>>
>> Thanks for your sincerely help, and i understand it clearly now. ( ^_^ )
>>
>> Best regards,
>> Chao
>>
>>
>> J. Caleb Wherry wrote
>> > (Shameless plug ahead)
>> >
>> > If you want to see a working example of what I said above, you can
>> check
>> > out my ExampleCMakeProject:
>> >
>> > https://github.com/calebwherry/example-cmake-project
>> >
>> > It is currently being built and tested on TravisCI (Linux + Mac [GGC5
>> and
>> > Clang3.7]) and Appveyor (Windows [VS2015]) and provides a simple
>> example
>> > of
>> > how to write/structure CMake for cross-platform C/C++ projects. You can
>> > ignore the python wrapper if you want, it just makes working with the
>> > CMake
>> > exe and system builds easier (calculates core counts, creates
>> directories
>> > for build, nicer CLI options, etc) since I find the options to CMake to
>> be
>> > very... verbose.
>> >
>> > The POST_BUILD example is here:
>> >
>> >
>> https://github.com/calebwherry/example-cmake-project/blob/master/src/app/test-app/CMakeLists.txt
>> >
>> > If you really are looking to get a one-off project working, Decker's
>> > recommendation about PATH modification is easiest. It's just not
>> something
>> > I think is viable in the long run and doesn't work as an actual
>> solution
>> > to
>> > the problem if you are trying to solve it for many projects.
>> >
>> > -Caleb
>> >
>> > On Mon, Apr 25, 2016 at 9:01 PM, Chaos Zhang 
>>
>> > zcsd2012@
>>
>> >  wrote:
>> >
>> >> Hi,
>> >>
>> >> I faced this problem when i try built a shared lib  and linked it on
>> >> windows. The structure of my project as below:
>> >> -test_dir/
>> >>  -sub_hello/
>> >>CMakeLists.txt
>> >>hello.c
>> >>  -top/
>> >>main.c
>> >>CMakeLists.txt
>> >>  CMakeLists.txt
>> >>
>> >> The content of each file:
>> >> ①test_dir/CMakeLists.txt:
>> >> PROJECT(TESTLIB)
>> >> add_subdirectory(sub_hello sub_hello)
>> >> add_subdirectory(top top)
>> >>
>> >> ②test_dir/sub_hello/CMakeLists.txt:
>> >> message("message from sub_hello")
>> >> add_library(hello_lib  SHARED hello.c)
>> >>
>> >> ③test_dir/top/CMakeLists.txt:
>> >> include_directories(../sub_hello)
>> >> add_executable(main main.c)
>> >> target_link_libraries(main hello_lib)
>> >>
>> >> ④test_dir/sub_hello/hello.c:
>> >> #include
>> > 
> 
>> >> void HelloFunc()
>> >> {
>> >> printf("###hello###\n");
>> >> }
>> >>
>> >> ⑤test_dir/top/

Re: [CMake] How to link shared lib on windows (visual studio 2014).

2016-04-26 Thread Chaos Zhang
Hi, all,

Thanks for your sincerely help, and i understand it clearly now. ( ^_^ )

Best regards,
Chao


J. Caleb Wherry wrote
> (Shameless plug ahead)
> 
> If you want to see a working example of what I said above, you can check
> out my ExampleCMakeProject:
> 
> https://github.com/calebwherry/example-cmake-project
> 
> It is currently being built and tested on TravisCI (Linux + Mac [GGC5 and
> Clang3.7]) and Appveyor (Windows [VS2015]) and provides a simple example
> of
> how to write/structure CMake for cross-platform C/C++ projects. You can
> ignore the python wrapper if you want, it just makes working with the
> CMake
> exe and system builds easier (calculates core counts, creates directories
> for build, nicer CLI options, etc) since I find the options to CMake to be
> very... verbose.
> 
> The POST_BUILD example is here:
> 
> https://github.com/calebwherry/example-cmake-project/blob/master/src/app/test-app/CMakeLists.txt
> 
> If you really are looking to get a one-off project working, Decker's
> recommendation about PATH modification is easiest. It's just not something
> I think is viable in the long run and doesn't work as an actual solution
> to
> the problem if you are trying to solve it for many projects.
> 
> -Caleb
> 
> On Mon, Apr 25, 2016 at 9:01 PM, Chaos Zhang 

> zcsd2012@

>  wrote:
> 
>> Hi,
>>
>> I faced this problem when i try built a shared lib  and linked it on
>> windows. The structure of my project as below:
>> -test_dir/
>>  -sub_hello/
>>CMakeLists.txt
>>hello.c
>>  -top/
>>main.c
>>CMakeLists.txt
>>  CMakeLists.txt
>>
>> The content of each file:
>> ①test_dir/CMakeLists.txt:
>> PROJECT(TESTLIB)
>> add_subdirectory(sub_hello sub_hello)
>> add_subdirectory(top top)
>>
>> ②test_dir/sub_hello/CMakeLists.txt:
>> message("message from sub_hello")
>> add_library(hello_lib  SHARED hello.c)
>>
>> ③test_dir/top/CMakeLists.txt:
>> include_directories(../sub_hello)
>> add_executable(main main.c)
>> target_link_libraries(main hello_lib)
>>
>> ④test_dir/sub_hello/hello.c:
>> #include 
> 
>> void HelloFunc()
>> {
>> printf("###hello###\n");
>> }
>>
>> ⑤test_dir/top/main.c:
>> int main()
>> {
>> HelloFunc();
>> return 0;
>> }
>>
>> After i cmake this project, generated .sln and .proj files, then i built
>> it
>> and i get an error in vs:
>>
>> Error   LNK1104 can't open file "..\sub_hello\Debug\hello_lib.lib"
>>
>> In folder ..\sub_hello\Debug\ , there was not a hello_lib.lib existed.
>> Then i look thorough and found a solution:
>>
>> Add "set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS YES)" in file
>> test_dir/sub_hello/hello.c
>>
>> Then i built this solution again, this time it success, and hello_lib.lib
>> and main.exe was generated. But when i try to run main.exe, an error
>> occured: "lose hello_lib.dll". And i moved hello_lib.dll into the folder
>> of
>> main.exe, and it worked well.
>>
>> There are two questions i could not figure out:
>> ①Is this "..\sub_hello\Debug\hello_lib.lib" associates with
>> "..\sub_hello\Debug\hello_lib.dll"? For windows can not use .dll
>> directly,
>> and use a .lib to record the .dll's  entrance and location.
>> ②How to solve the problem of main.exe can not find .dll file.
>>
>> Best regards,
>> Chao Zhang
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://cmake.3232098.n2.nabble.com/How-to-link-shared-lib-on-windows-visual-studio-2014-tp7593346.html
>> Sent from the CMake mailing list archive at Nabble.com.
>> --
>>
>> 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
> 
> 
> 
> 
> -- 
> J. Caleb Wherry
> *Scient

Re: [CMake] Need a example to use dll in vs

2016-04-25 Thread Chaos Zhang


Jakob van Bethlehem wrote
> Hej,
> 
> You really should provide more detailed information about your project
> structure, and what is going wrong. There are some subtle differences
> between Linux/Windows, but not at the level you're referring to. Certainly
> the IMPORTED property has nothing to do with a platform distinction.
> IMPORTED libraries work exactly the same on Windows/Linux.
> 
> There is a very big difference between Linux/Windows though in the sense
> that on Windows you need to explicitly export symbols you want to be
> available on the interface of the dll. My first guess from your very
> limited info is that something is wrong in that area (and if that's the
> case, you can easily resolve this using the GenerateExportHeader module).
> 
> But back to my original comment: provide more details on what you are
> trying to do, and what is failing.
> 
> Sincerely,
> Jakob van Bethlehem
> 
> On Mon, Apr 25, 2016 at 5:13 AM, Chaos Zhang 

> zcsd2012@

>  wrote:
> 
>> Hi all,
>>
>> I faced a problem when i migrate a project from Linux to windows for the
>> visual stdio seem can not use dll directly. I look through a number of
>> material  and known i seem should use IMPORTED in add_library(...), but i
>> can not find a practical example about how to use it. Could you please
>> give
>> me one or some? BTW the dll lib seem could be used in Mingw makefile on
>> windows.
>>
>> Thanks,
>> Chao Zhang
>>
>>
>>
>> --
>> View this message in context:
>> http://cmake.3232098.n2.nabble.com/Need-a-example-to-use-dll-in-vs-tp7593331.html
>> Sent from the CMake mailing list archive at Nabble.com.
>> --
>>
>> 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
>>
> 
> -- 
> 
> Powered by www.kitware.com
> Thanks for your advice, i have add a new topic named "How to link shared
> lib on windows (visual studio 2014)", sincerely look forward to your
> reply. ^_^ 
> 
> Chao
> 
> 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





--
View this message in context: 
http://cmake.3232098.n2.nabble.com/Need-a-example-to-use-dll-in-vs-tp7593331p7593347.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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


[CMake] How to link shared lib on windows (visual studio 2014).

2016-04-25 Thread Chaos Zhang
Hi,

I faced this problem when i try built a shared lib  and linked it on
windows. The structure of my project as below:
-test_dir/
 -sub_hello/
   CMakeLists.txt
   hello.c
 -top/
   main.c
   CMakeLists.txt
 CMakeLists.txt

The content of each file:
①test_dir/CMakeLists.txt:
PROJECT(TESTLIB)
add_subdirectory(sub_hello sub_hello)
add_subdirectory(top top) 

②test_dir/sub_hello/CMakeLists.txt:
message("message from sub_hello")
add_library(hello_lib  SHARED hello.c)

③test_dir/top/CMakeLists.txt:
include_directories(../sub_hello)
add_executable(main main.c)
target_link_libraries(main hello_lib)

④test_dir/sub_hello/hello.c:
#include 
void HelloFunc()
{
printf("###hello###\n");
}

⑤test_dir/top/main.c:
int main()
{
HelloFunc();
return 0;
}

After i cmake this project, generated .sln and .proj files, then i built it
and i get an error in vs: 

Error   LNK1104 can't open file "..\sub_hello\Debug\hello_lib.lib"

In folder ..\sub_hello\Debug\ , there was not a hello_lib.lib existed.
Then i look thorough and found a solution: 

Add "set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS YES)" in file
test_dir/sub_hello/hello.c  

Then i built this solution again, this time it success, and hello_lib.lib
and main.exe was generated. But when i try to run main.exe, an error 
occured: "lose hello_lib.dll". And i moved hello_lib.dll into the folder of
main.exe, and it worked well.

There are two questions i could not figure out:
①Is this "..\sub_hello\Debug\hello_lib.lib" associates with
"..\sub_hello\Debug\hello_lib.dll"? For windows can not use .dll directly,
and use a .lib to record the .dll's  entrance and location.
②How to solve the problem of main.exe can not find .dll file.

Best regards,
Chao Zhang





--
View this message in context: 
http://cmake.3232098.n2.nabble.com/How-to-link-shared-lib-on-windows-visual-studio-2014-tp7593346.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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

[CMake] Exe file can't find .dll file on windows

2016-04-25 Thread Chaos Zhang
Hi, all, 

At first i was struggled to solve the problem of link shared lib on windows
by CMake, and i found solution by using set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
YES). But when i executed the exe file, an error occurred: "The program
can't start because hello_lib.dll is missing from your computer. Try
reinstalling to fix this problem." And after i copy hello_lib.dll to the
folder of exe file, it worked.

Thanks,
Chao Zhang



--
View this message in context: 
http://cmake.3232098.n2.nabble.com/Exe-file-can-t-find-dll-file-on-windows-tp7593334.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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] Need a example to use dll in vs

2016-04-24 Thread Chaos Zhang
Thanks for your reply Mr Scott, but my project worked well on Linux and i am
sure the path is right. This question has been asked long before, as below:
On Sat, Jul 24, 2010 at 11:00 PM, John Drescher 
wrote:
>>> I know that target_link_libraries can be used to link a .lib ,
>>>
>>> but how to link a .dll into the project?
>>>
>>>
>> You do not link against a .dll in windows ever.
>>
> When you create a .dll there is also a small import lib associated
> with the dll. You link with that and when the application starts it
> searches the path for each dll it needs.
>
> John

And the error was not dll lib was not found but .lib(static lib) was not
found. As i knew so far, i think this error is related to windows platform.


Scott Aron Bloom-2 wrote
> When I am building DLLs I tend to use an "install step" as part of my
> cmake process.  Then I make sure the builds' install area is in the path
> of the application.
> 
> The issue may be your EXE cant find the DLL in its path.
> 
> Scott
> 
> -Original Message-
> From: CMake [mailto:

> cmake-bounces@

> ] On Behalf Of Chaos Zhang
> Sent: Sunday, April 24, 2016 8:14 PM
> To: 

> cmake@

> Subject: [CMake] Need a example to use dll in vs
> 
> Hi all,
> 
> I faced a problem when i migrate a project from Linux to windows for the
> visual stdio seem can not use dll directly. I look through a number of
> material  and known i seem should use IMPORTED in add_library(...), but i
> can not find a practical example about how to use it. Could you please
> give me one or some? BTW the dll lib seem could be used in Mingw makefile
> on windows.
> 
> Thanks,
> Chao Zhang
> 
> 
> 
> --
> View this message in context:
> http://cmake.3232098.n2.nabble.com/Need-a-example-to-use-dll-in-vs-tp7593331.html
> Sent from the CMake mailing list archive at Nabble.com.
> -- 
> 
> 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
> -- 
> 
> 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





--
View this message in context: 
http://cmake.3232098.n2.nabble.com/Need-a-example-to-use-dll-in-vs-tp7593331p759.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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


[CMake] Need a example to use dll in vs

2016-04-24 Thread Chaos Zhang
Hi all,

I faced a problem when i migrate a project from Linux to windows for the
visual stdio seem can not use dll directly. I look through a number of
material  and known i seem should use IMPORTED in add_library(...), but i
can not find a practical example about how to use it. Could you please give
me one or some? BTW the dll lib seem could be used in Mingw makefile on
windows.

Thanks,
Chao Zhang



--
View this message in context: 
http://cmake.3232098.n2.nabble.com/Need-a-example-to-use-dll-in-vs-tp7593331.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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


[CMake] How to transfer CMake variable and include other makefile in one makefile which generated by CMake

2016-04-23 Thread Chaos Zhang
Hi all,
I faced this problem when i converting an existing Makefile to CMake. I have
try my best to search this problem in google and stack overflow but finally
failed for my poor English.In the existing makefile, the content like as
below:

var=test_var
include(test.mk)

What i want to do is convert this makefile into CMakeLists.txt, and after
cmake this CMakeLists.txt, i can get a makefile like this. What should i do?

Thanks,
Chao Zhang



--
View this message in context: 
http://cmake.3232098.n2.nabble.com/How-to-transfer-CMake-variable-and-include-other-makefile-in-one-makefile-which-generated-by-CMake-tp7593327.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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] CMake:question of the time when the command will happen in add_custom_command(...)

2016-04-22 Thread Chaos Zhang
Sorry for i just know reply by email and thinks for your help again. :-)


Petr Kmoch wrote
> No, it is indeed compiled and linked just fine. What I meant is:
> 
> Without any custom commands, the build process conceptually looks like
> this:
> 
> buildMain() {
>   compile_object_files();
>   link_main_binary();
> 
>   message("Built target main");
> }
> 
> With a post-build custom command:
> 
> buildMain() {
>   compile_object_files();
>   link_main_binary();
>   post_build_command();
> 
>   message("Built target main");
> }
> 
> The custom command becomes a part of the entire process of "Building
> target," that's why the "Built target" message appears after the command
> runs.
> 
> BTW, please keep the mailing list in copy when replying.
> 
> Petr
> 
> On 22 April 2016 at 10:02, Chaos Zhang 

> zcsd2012@

>  wrote:
> 
>> So what you mean is the target have not been complied and linked after i
>> introduce
>> custom commands into this target right? Do i understand right?
>>
>> Thanks a lot for your generous help. :-)
>>
>> 2016-04-22 16:38 GMT+08:00 Petr Kmoch 

> petr.kmoch@

> :
>>
>>> Hi,
>>>
>>> the reason is that the post-build command is actually a part of building
>>> "main the target." Once you introduce custom commands into a target,
>>> building it includes them all, and not just compiling the object files
>>> and
>>> linking the binary. You will notice that the "Linking C exectuable main"
>>> line came before the post-build message, so it did happen in the correct
>>> order.
>>>
>>> Petr
>>>
>>> On 22 April 2016 at 06:25, Chaos Zhang 

> zcsd2012@

>  wrote:
>>>
>>>> Hi all,
>>>>
>>>> I have some trouble when i use PRE_BUILD | PRE_LINK | POST_BUILD in
>>>> command
>>>> "add_custom_command(...)". When i use POST_BUILD, i found the command
>>>> will
>>>> execute before target had been built, like this:
>>>>
>>>> 1 [root@VM_33_35_centos build]# make
>>>> 2 Scanning dependencies of target main
>>>> 3 [100%] Building C object CMakeFiles/main.dir/main.c.o
>>>> 4 Linking C executable main
>>>> 5 This is pre build
>>>> 6 This is post build
>>>> 7 [100%] Built target main
>>>>
>>>> In my CMakeLists.txt, the content is:
>>>>  1 cmake_minimum_required(VERSION 2.8)
>>>>  2 add_executable(main main.c)
>>>>  3 add_custom_command(TARGET main
>>>>  4 PRE_BUILD
>>>>  5 COMMAND echo "This is pre build "
>>>>  6 )
>>>>  7 add_custom_command(TARGET main
>>>>  8 POST_BUILD
>>>>  9 COMMAND echo "This is post build"
>>>>  10 )
>>>>
>>>> Why the command echo "This is post build" in 8 line(CMakeLists.txt) did
>>>> not
>>>> execute after [100%] Built target main in 7 line(Linux command)?
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://cmake.3232098.n2.nabble.com/CMake-question-of-the-time-when-the-command-will-happen-in-add-custom-command-tp7593314.html
>>>> Sent from the CMake mailing list archive at Nabble.com.
>>>> --
>>>>
>>>> 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
>>>>
>>>
>>>
>>
> 
> -- 
> 
> Powered by www.kitware.com
> 
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
&

[CMake] CMake:question of the time when the command will happen in add_custom_command(...)

2016-04-21 Thread Chaos Zhang
Hi all,

I have some trouble when i use PRE_BUILD | PRE_LINK | POST_BUILD in command
"add_custom_command(...)". When i use POST_BUILD, i found the command will
execute before target had been built, like this:

1 [root@VM_33_35_centos build]# make
2 Scanning dependencies of target main
3 [100%] Building C object CMakeFiles/main.dir/main.c.o
4 Linking C executable main
5 This is pre build 
6 This is post build
7 [100%] Built target main

In my CMakeLists.txt, the content is:
 1 cmake_minimum_required(VERSION 2.8)
 2 add_executable(main main.c)
 3 add_custom_command(TARGET main
 4 PRE_BUILD
 5 COMMAND echo "This is pre build "
 6 )
 7 add_custom_command(TARGET main
 8 POST_BUILD
 9 COMMAND echo "This is post build"
 10 )

Why the command echo "This is post build" in 8 line(CMakeLists.txt) did not
execute after [100%] Built target main in 7 line(Linux command)?




--
View this message in context: 
http://cmake.3232098.n2.nabble.com/CMake-question-of-the-time-when-the-command-will-happen-in-add-custom-command-tp7593314.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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


[CMake] CMake: how to use 'for cyclic sentence' in command add_custom_command(...)

2016-04-19 Thread Chaos Zhang
Hi,

I was using 'for cyclic sentence' in command add_custom_command(...), the
content of the CMakeLists.txt as below:
add_custom_command(TARGET temp_target
POST_BUILD
COMMAND for x in a b c\; 
do echo $x \;
done\;)

The result of execution was not like as below:
a
b
c
But like this:



Just print 3 blank lines. So how to use it correctly?

Thanks for your help,
Chao Zhang



--
View this message in context: 
http://cmake.3232098.n2.nabble.com/CMake-how-to-use-for-cyclic-sentence-in-command-add-custom-command-tp7593286.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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] CMake: how to use 'if condition' in command add_custom_command(...)

2016-04-19 Thread Chaos Zhang
I have read the description of PRE_BUILD before in CMake doc, but when i
use it, i found something confuesed.
(1) In CMakeLists.txt, the content as below:

​(2)After i make the makefile generated by this CMakeLists.txt, i get
result as below:
"3_pre_build" is behind "1_pre_link", if POST_BUILD gets treated as
PRE_LINK, why "3_pre_build" was printed before "1_pre_link"?

Thanks for you reply,
Chaos Zhang
​

2016-04-19 15:50 GMT+08:00 Craig Scott-3 [via CMake] <
ml-node+s3232098n7593281...@n2.nabble.com>:

> In case it matters, in Clark's suggested code, note that PRE_BUILD is only
> fully honoured with Visual Studio generators. For everything else, it gets
> treated as PRE_LINK, which occurs later (i.e. after compiling all the
> sources rather than before). So it depends on what your "if" test is trying
> to do whether or not this matters in your case.
>
> On Tue, Apr 19, 2016 at 5:24 PM, Clark Wang <[hidden email]
> <http:///user/SendEmail.jtp?type=node=7593281=0>> wrote:
>
> On Tue, Apr 19, 2016 at 1:15 PM, Chaos Zhang <[hidden email]
>> <http:///user/SendEmail.jtp?type=node=7593281=1>> wrote:
>>
>>> Hi,
>>>
>>> Is there a way to use Linux command 'if' like this :
>>> <http://cmake.3232098.n2.nabble.com/file/n7593278/2016-04-19_113005.png>
>>> For i need to execute 'if condition' in make phase rather than cmake
>>> phase.
>>>
>>
>> Try like this:
>>
>> % cat CMakeLists.txt
>> add_custom_target(foo ALL)
>> add_custom_command(TARGET foo
>> PRE_BUILD
>> COMMAND if [ -f bar ]\; then echo yes\; else echo no\; fi)
>> % cmake .
>> % make
>> no
>> Built target foo
>> % touch bar
>> % make
>> yes
>> Built target foo
>> %
>>
>>
>>> Thanks a lot
>>> Chaos Zhang
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://cmake.3232098.n2.nabble.com/CMake-how-to-use-if-condition-in-command-add-custom-command-tp7593278.html
>>> Sent from the CMake mailing list archive at Nabble.com.
>>> --
>>>
>>> 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
>>>
>>
>>
>> --
>>
>> 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
>>
>
>
>
> --
> Craig Scott
> Melbourne, Australia
> http://crascit.com
>
> --
>
> 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
>
> --
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://cmake.3232098.n2.nabble.com/CMake-how-to-use-if-condition-in

[CMake] CMake: how to use 'if condition' in command add_custom_command(...)

2016-04-18 Thread Chaos Zhang
Hi, 

Is there a way to use Linux command 'if' like this : 
<http://cmake.3232098.n2.nabble.com/file/n7593278/2016-04-19_113005.png> 
For i need to execute 'if condition' in make phase rather than cmake phase. 

Thanks a lot 
Chaos Zhang 



--
View this message in context: 
http://cmake.3232098.n2.nabble.com/CMake-how-to-use-if-condition-in-command-add-custom-command-tp7593278.html
Sent from the CMake mailing list archive at Nabble.com.
-- 

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