首页 > CMake > CMake-导入链接库(linux+window)
2013七月20

CMake-导入链接库(linux+window)

一种是自己bin路径的:

if(WIN32)
    TARGET_LINK_LIBRARIES(FixedClient debug PPCore_d.lib)
	TARGET_LINK_LIBRARIES(FixedClient optimized PPCore.lib)
else()
	if (USE_PPCOREDLL_)
		 TARGET_LINK_LIBRARIES(FixedClient debug libPPCore_d.so)
		 TARGET_LINK_LIBRARIES(FixedClient optimized libPPCore.so)
	else()
		 TARGET_LINK_LIBRARIES(FixedClient debug libPPCore_d.a)
		 TARGET_LINK_LIBRARIES(FixedClient optimized libPPCore.a)
	endif()
endif()

另一种是系统的,如linux下的mysql,要先查找

if (WIN32)
SET_TARGET_PROPERTIES(PPServer PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
else ()

if (USE_PPCOREDLL_)
	 FIND_LIBRARY(MYSQL_lIB mysqlclient PATHS /usr/lib/mysql)
	 TARGET_LINK_LIBRARIES(PPServer ${MYSQL_lIB})
	 TARGET_LINK_LIBRARIES(PPServer debug libPPCore_d.so)
	 TARGET_LINK_LIBRARIES(PPServer optimized libPPCore.so)
else()
	 FIND_LIBRARY(MYSQL_lIB mysqlclient PATHS /usr/lib/mysql)
	 TARGET_LINK_LIBRARIES(PPServer ${MYSQL_lIB})
	 TARGET_LINK_LIBRARIES(PPServer debug libPPCore_d.a)
	 TARGET_LINK_LIBRARIES(PPServer optimized libPPCore.a)
endif()
endif()#WIN32

文章作者:hgy413
本文地址:https://hgy413.com/2183.html
版权所有 © 转载时必须以链接形式注明作者和原始出处!

本文的评论功能被关闭了.