[CMake] help with learning add_library
Gerhard Gappmeier
gerhard.gappmeier at ascolab.com
Sat Nov 6 12:27:06 EDT 2010
Hi
this three lines should do the job:
CMakeLists.txt:
project(learnCMAKE)
add_definitions(-DXXX -DYYY -DSAMPLE=5)
add_library(learnCMAKE file1.c file2.c)
To build static libraries:
mkdir bldStatic
cd bldStatic
cmake -DBUILD_SHARED_LIBS=off -DCMAKE_BUILD_TYPE=Release ..
make
cd ,,
To build shared libraries:
mkdir bldDynamic
cd bldDynamic
cmake -DBUILD_SHARED_LIBS=on -DCMAKE_BUILD_TYPE=Release ..
make
cd ..
On Saturday 06 November 2010 17:26:11 luxInteg wrote:
> Greetings,
>
> I am learning cmake.
>
> I have a question on using add_library. in my project(learnCMAKE). The
> latter has:-
>
> ---a) 2 source files file1.c file2.c
> ---b) the envar {CFLAGS} set
> ---c) need to generate libLearnCMAKE.so and libLearnCMAKE.a
> ---d) need to add preprocessor agruments -DXXX to CFLAGS in the
> compilation of the source files before liberies are archived like so:-
>
> gcc ${CFLAGS} -DDINT /path/to/file1.c
> gcc ${CFLAGS} -DDINT /path/to/file2.c
>
> gcc ${CFLAGS} -DDLONG /path/to/file1.c
> gcc ${CFLAGS} -DDLONG /path/to/file2.c
>
> How can this be achived in a marco or whatever with add_library ?
> Help would be appreciated
>
> sincerely
> lux-integ
> _______________________________________________
> 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
--
mit freundlichen Grüßen / best regards
*Gerhard Gappmeier*
ascolab GmbH - automation systems communication laboratory
Tel.: +49 9131 691 123
Fax: +49 9131 691 128
Web: http://www.ascolab.com
GPG Key Id: 5AAC50C4
GPG Fingerprint: 967A 15F1 2788 164D CCA3 6C46 07CD 6F82 5AAC 50C4
--
*ascolab GmbH*
Geschäftsführer: Gerhard Gappmeier, Matthias Damm, Uwe Steinkrauß
Sitz der Gesellschaft: Am Weichselgarten 7 . 91058 Erlangen . Germany
Registernummer: HRB 9360
Registergericht: Amtsgericht Fürth
More information about the CMake
mailing list