Joachim Ziegler schrieb:
> if(CMAKE_HOST_WIN32)
>   INCLUDE_DIRECTORIES(D:/nspr-4.6/include)
>   LINK_DIRECTORIES(D:/nspr-4.6/lib)
>   ADD_EXECUTABLE(testPR PRifdefd.cpp ${BASEFILES})
>   TARGET_LINK_LIBRARIES(testPR nspr4 Ws2_32)
> ...
> 
> To run the executable, I have to copy the lib files libnspr4.dll and
> libnspr4.lib into the build directory (where the executable testPR is
> built). (Can I avoid this somehow?)

I am pretty sure you do not have to copy them, at least no the .dll
file. Read the FIND_LIBRARY command help but LINK_DIRECTORIES as about
should work as well.

> But now, what if I want to compile statically against NSPR (and maybe
> Winsock2), so that I can give away my executable to a customer?

ws2_32 is a system library, there's no sense in wanting to link that
statically.
If you put the libnspr4.dll (you do not need to ship the .lib file) into
the same directory as the executable, it will get used.

Additionally, if the .lib file is a static library, then you link
statically. If it is not, then you do not link statically. It is as easy
as this.

HS

_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to