[CMake] Creating static executables

Bill Hoffman bill.hoffman at kitware.com
Tue Jun 12 10:23:58 EDT 2007


Ajay Divekar wrote:
> Bill,
> Before I give out the actual command here is the CmakeList.txt file that I am 
> using to generate the makefile. This is FreeBSD 5.5
>
> LINK_DIRECTORIES ($ENV{PP_ROOTDIR}/lib .)
> ADD_EXECUTABLE (IANd IANd.c IANServer.c IANProcess.cc )
> SET_TARGET_PROPERTIES (IANd PROPERTIES LINK_FLAGS "-L/usr/local/lib/ 
> -L/usr/lib")
> SET (CMAKE_EXE_LINK_DYNAMIC_C_FLAGS "-Wl,-Bstatic")
> TARGET_LINK_LIBRARIES (IANd PSutils PSconfig GSF ShMem CLog PDTPClient ImgIO 
> ImgUtil ImgVal ImgBase ${IPP_LIB1} ${IPP_LIB2} ${IPP_LIB3} ${IPP_LIB4} 
> ${IPP_LIB5} PSDebug PDTPClient libtiff.a libjpeg.a libz.a)
>
> Here is the actual command that is being executed
>
> cd /usr/home/ajayd/CMakeProject/src/IAN && /usr/local/bin/g++34     -O3 
> -DNDEBUG  -fPIC -L/usr/local/lib/ -L/usr/lib "CMakeFiles/IANd.dir/IANd.o"  
> "CMakeFiles/IANd.dir/IANServer.o"  "CMakeFiles/IANd.dir/IANProcess.o"   -o 
> IANd  -L/usr/home/ajayd/CMakeProject/lib -L. 
>   
You need to set CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS as well as C flag, if 
you notice
it is using g++34 for the compiler to link with.  This is because of the 
.cc file you have in the executable.

-Bill






More information about the CMake mailing list