当前位置:Gxlcms > 数据库问题 > rhel7 编写CMakeList.txt编译运行MySQL官方例子代码

rhel7 编写CMakeList.txt编译运行MySQL官方例子代码

时间:2021-07-01 10:21:17 帮助过:20人阅读

(tools) #MESSAGE(SEND_ERROR "Send Error." "${CMAKE_CURRENT_SOURCE_DIR}") #MESSAGE(STATUS "Status." "${PROJECT_SOURCE_DIR}") #MESSAGE(FATAL_ERROR "Fatal Error." "${PROJECT_BINARY_DIR}") #ADD_SUBDIRECTORY(SRC_SUBDIR_LIST) #SET(SRC_LIST ${SRC_LIST} main.cpp) AUX_SOURCE_DIRECTORY(. SRC_LIST) SET(EXECUTABLE ${SRC_LIST}) SET(TARGET_NAME mysqltransfer) #---include SET(INCLUDE_LIST ${INCLUDE_LIST} ${CMAKE_CURRENT_LIST_DIR}/../include/) INCLUDE_DIRECTORIES(${INCLUDE_LIST}) #SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/../lib/) #ADD_LIBRARY(${LINK_NAME} SHARED ${LINKABLE}) SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../bin/) ADD_EXECUTABLE(${TARGET_NAME} ${EXECUTABLE}) #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMYSQLCLIENT_STATIC_LINKING=1") #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Bdynamic") #---dynamically steps--- #---step 1:copy lib*.so.7.1.1.9 /usr/local/libX #---step 2:ln -s lib*.so.7.1.1.9 lib*.so.7 #---step 3:ln -s lib*.so.7 lib*.so #---dynamic1-mysqlcppconn--- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lmysqlcppconn") LINK_DIRECTORIES(${CMAKE_CURRENT_LIST_DIR}/../lib/) #---dynamic2-mysqlcppconn--- #TARGET_LINK_LIBRARIES(${TARGET_NAME} mysqlcppconn) #---dynamic3-mysqlcppconn--- #FIND_LIBRARY(MySQL_CppConn NAMES mysqlcppconn PATHS ${PROJECT_SOURCE_DIR}/../lib/) #IF(MySQL_CppConn) # SET(LIBS_LIST ${LIBS_LIST} mysqlcppconn) # TARGET_LINK_LIBRARIES(${TARGET_NAME} ${LIBS_LIST}) #ELSE(MySQL_CppConn) # MESSAGE(SEND_ERROR "\tmysqlcppconn not found!\n") #ENDIF(MySQL_CppConn) #---static-mysqlcppconn--- #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ldl") #ADD_LIBRARY(mysqlcppconn STATIC IMPORTED) #SET_PROPERTY(TARGET mysqlcppconn PROPERTY IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../lib/libmysqlcppconn-static.a) #TARGET_LINK_LIBRARIES(${TARGET_NAME} mysqlcppconn pthread) #SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES -DBOOST_ROOT boost) SET(BOOST_ROOT "/usr/local/boost") #SET(BOOST_INCLUDEDIR "/usr/local/boost/include") #SET(BOOST_LIBRARYDIR "/usr/local/boost/libs") FIND_PACKAGE(Boost) IF(Boost_FOUND) #TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME} INTERFACE ${Boost_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) #LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) TARGET_LINK_LIBRARIES(${TARGET_NAME} ${Boost_LIBRARIES}) ELSE(Boost_FOUND) MESSAGE(SEND_ERROR "\tboost not found!\n") ENDIF(Boost_FOUND) #MESSAGE(STATUS "Test Messages:\n\t" ${PROJECT_SOURCE_DIR}/../lib/)

 

rhel7 编写CMakeList.txt编译运行MySQL官方例子代码

标签:not   sub   current   include   连接   minimum   文档   nbsp   rar   

人气教程排行