[CMake] DLL import/export flag differentiation
Nicholas Yue
yue.nicholas at gmail.com
Sat Nov 24 19:53:17 EST 2007
Hi,
I am attempting to migrate the ANN build to CMake for my own ease of cross
platform maintenance.
The cmake configuration works fine on OSX but have problem Windows because
of the additional linkage requirement.
I understand that there is no per target DEFINITIONS setup so I'd like to
hear advice from experience cmake user how I should configure my build.
The library needs the -DDLL_EXPORT while the application must not have
that set so that it imports the exported symbols.
At the moment, my build fails at the ann_test target because it inherits
the -DDLL_EXPORT flag from the top.
Regards
8<------8<------8<------8<------8<------8<------8<------8<------8<------8<------
PROJECT (ANN)
INCLUDE_DIRECTORIES ( ../include )
IF (WIN32)
ADD_DEFINITIONS ( -DDLL_EXPORTS -DANN_PERF -DANN_NO_RANDOM
-D_CRT_SECURE_NO_DEPRECATE )
SET ( LIBRARY_TYPE SHARED )
ELSE (WIN32)
SET ( LIBRARY_TYPE STATIC )
ENDIF (WIN32)
ADD_LIBRARY ( ANN ${LIBRARY_TYPE}
../src/ANN.cpp
../src/bd_fix_rad_search.cpp
../src/bd_pr_search.cpp
../src/bd_search.cpp
../src/bd_tree.cpp
../src/brute.cpp
../src/kd_dump.cpp
../src/kd_fix_rad_search.cpp
../src/kd_pr_search.cpp
../src/kd_search.cpp
../src/kd_split.cpp
../src/kd_tree.cpp
../src/kd_util.cpp
../src/perf.cpp
)
ADD_EXECUTABLE ( ann_test
../test/ann_test.cpp
../test/rand.cpp
)
ADD_EXECUTABLE ( ann_sample
../sample/ann_sample.cpp
)
ADD_EXECUTABLE ( ann2fig
../ann2fig/ann2fig.cpp
)
TARGET_LINK_LIBRARIES ( ann_test ANN )
TARGET_LINK_LIBRARIES ( ann_sample ANN )
TARGET_LINK_LIBRARIES ( ann2fig ANN )
INSTALL ( TARGETS ann_test ann_sample ann2fig ANN
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20071125/705d99dd/attachment.htm
More information about the CMake
mailing list