Hi,
I have used Cmake to build a VS2005C++ project under windows. And for the
project i need to link to some external library. I can manually do it under
VS2005, but i wish i could do it using cmake statement.
The project name is TEST, i put the external library in a folder named
${TEST_SOURCE_DIR}/epanet/ which contains the epanet2.h epanet2.lib and
epanet2.dll files. I use the Include_directories and link_directories to point
to the /epanet/ folder. And i use TARGET_LINK_LIBRARIES to link the
library. However, i still have to put the full path like
${TEST_SOURCE_DIR}/epanet2/epanet2.lib to link to the library including file
extension. And I do not know how to link to the epanet2.dll file. I have to
manually copy the dll file in order to make the code to work otherwise it will
complain cannot find the .dll file. How can i do that in cmake so that both
the .lib file and .dll file will be linked without manual actions? Thanks.
Regards,
zhigao
Below is the cmake file
=============================
PROJECT(TEST)
cmake_minimum_required(VERSION 2.6)
SET(TEST_SRCS
${TEST_SOURCE_DIR}/DLLTest.cpp)
ADD_EXECUTABLE(TEST
${TEST_SRCS})
INCLUDE_DIRECTORIES(${TEST_SOURCE_DIR}/epanet)
LINK_DIRECTORIES(${TEST_SOURCE_DIR}/epanet)
SET(_LINK_EPANET_LIB ${TEST_SOURCE_DIR}/epanet/epanet2.lib)
TARGET_LINK_LIBRARIES(TEST ${_LINK_EPANET_LIB})
CONFIDENTIALITY: This email is intended solely for the person(s) named. The
contents may be confidential and/or privileged. If you are not the intended
recipient, please delete it, notify us, and do not copy or use it, nor disclose
its contents. Thank you.
Towards A Sustainable Earth: Print Only When Necessary
_______________________________________________
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