Tang Hai 14 лет назад
Родитель
Сommit
017ecf7c61

+ 6 - 1
Src/CMakeLists.txt

@@ -20,7 +20,12 @@ LINK_DIRECTORIES(${PROTOBUF_LIBRARIES})
 
 FIND_PACKAGE(PythonLibs REQUIRED)
 INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
-LINK_DIRECTORIES(${PYTHON_LIBRARIES})
+
+FIND_PACKAGE(Boost REQUIRED python thread system)
+SET(Boost_USE_STATIC_LIBS    ON)
+SET(Boost_USE_MULTITHREADED  ON)
+SET(Boost_USE_STATIC_RUNTIME OFF)
+INCLUDE_DIRECTORIES(${BOOST_INCLUDE_DIRS})
 
 ADD_SUBDIRECTORY(Egametang)
 ADD_SUBDIRECTORY(ThirdParty)

+ 3 - 3
Src/Egametang/CMakeLists.txt

@@ -1,3 +1,3 @@
-add_subdirectory(Python)
-add_subdirectory(Thread)
-add_subdirectory(Rpc)
+ADD_SUBDIRECTORY(Python)
+ADD_SUBDIRECTORY(Thread)
+ADD_SUBDIRECTORY(Rpc)

+ 2 - 2
Src/Egametang/Python/CMakeLists.txt

@@ -15,12 +15,12 @@ SET(Excutes
 FOREACH(Excute ${Excutes})
 	TARGET_LINK_LIBRARIES(${Excute}
 		PythonEntry
-		boost_python
-		${PYTHON_LIBRARIES}
 		Glog
 		Gflags
 		Gtest
 		Gmock
+		${Boost_LIBRARIES}
+		${PYTHON_LIBRARY}
 	)
 	ADD_TEST(${Excute} ${Excute})
 ENDFOREACH()

+ 12 - 12
Src/Egametang/Rpc/CMakeLists.txt

@@ -1,29 +1,29 @@
-protobuf_generate_cpp(proto_srcs proto_hdrs RpcProtobufData.proto)
+PROTOBUF_GENERATE_CPP(proto_srcs proto_hdrs RpcProtobufData.proto)
 
-set(RpcSrc 
+SET(RpcSrc 
 	RPCCommunicator.cc
 	${proto_srcs}
 	)
 
-add_library(Rpc ${RpcSrc})
+ADD_LIBRARY(Rpc ${RpcSrc})
 
-add_executable(RpcCommunicatorTest RPCCommunicatorTest.cc)
+ADD_EXECUTABLE(RpcCommunicatorTest RPCCommunicatorTest.cc)
 
-set(Excutes 
+SET(Excutes 
 	RpcCommunicatorTest
 )
 
-foreach(Excute ${Excutes})
-	target_link_libraries(${Excute}
+FOREACH(Excute ${Excutes})
+	TARGET_LINK_LIBRARIES(${Excute}
 		Rpc
 		Thread
-		${protobuf_library}
-		boost_thread
-		boost_system
 		Glog
 		Gflags
 		Gtest
 		Gmock
+		${Boost_LIBRARIES}
+		${PYTHON_LIBRARY}
+		${PROTOBUF_LIBRARY}
 	)
-	add_test(${Excute} ${Excute})
-endforeach()
+	ADD_TEST(${Excute} ${Excute})
+ENDFOREACH()

+ 11 - 10
Src/Egametang/Thread/CMakeLists.txt

@@ -1,25 +1,26 @@
-set(ThreadSrc 
+SET(ThreadSrc 
 	ThreadPool.cc
 	CountBarrier.cc)
 
-add_library(Thread ${ThreadSrc})
+ADD_LIBRARY(Thread ${ThreadSrc})
 
-add_executable(ThreadPoolTest ThreadPoolTest.cc)
-add_executable(CountBarrierTest CountBarrierTest.cc)
+ADD_EXECUTABLE(ThreadPoolTest ThreadPoolTest.cc)
+ADD_EXECUTABLE(CountBarrierTest CountBarrierTest.cc)
 
-set(Excutes 
+SET(Excutes 
 	ThreadPoolTest 
 	CountBarrierTest
 )
 
-foreach(Excute ${Excutes})
-	target_link_libraries(${Excute}
+FOREACH(Excute ${Excutes})
+	TARGET_LINK_LIBRARIES(${Excute}
 		Thread
-		boost_thread
 		Glog
 		Gflags
 		Gtest
 		Gmock
+		${Boost_LIBRARIES}
+		${PYTHON_LIBRARY}
 	)
-	add_test(${Excute} ${Excute})
-endforeach()
+	ADD_TEST(${Excute} ${Excute})
+ENDFOREACH()

+ 4 - 4
Src/ThirdParty/CMakeLists.txt

@@ -2,7 +2,7 @@
 # gtest-1.6.0
 # gmock-1.6.0
 
-add_subdirectory(glog)
-add_subdirectory(gmock)
-add_subdirectory(gtest)
-add_subdirectory(gflags)
+ADD_SUBDIRECTORY(glog)
+ADD_SUBDIRECTORY(gmock)
+ADD_SUBDIRECTORY(gtest)
+ADD_SUBDIRECTORY(gflags)