Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ if (COMMAND cmake_policy)
cmake_policy(SET CMP0005 NEW)
endif ()

if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif ()

if (POLICY CMP0064)
cmake_policy(SET CMP0064 NEW)
endif ()
# First, declare project (important for prerequisite checks).
project(rocketmq-client-python)

Expand All @@ -56,7 +63,7 @@ if (NOT CMAKE_BUILD_TYPE)
endif ()

set(CXX_FLAGS
#-std=c++0x
-std=c++11
-g
-Wall
-Wno-deprecated
Expand Down Expand Up @@ -151,7 +158,7 @@ option(Boost_USE_STATIC_LIBS "only find boost static libs" OFF) # find boost lib
if (WIN32)
find_package(Boost REQUIRED COMPONENTS python)
elseif (APPLE)
find_package(Boost REQUIRED COMPONENTS python27)
find_package(Boost REQUIRED COMPONENTS python)
else ()
find_package(Boost REQUIRED COMPONENTS python)
endif (WIN32)
Expand Down Expand Up @@ -196,4 +203,14 @@ set(STDC_HEADERS 1)
set(TIME_WITH_SYS_TIME 1)
set(HAVE_SOCKLEN_T 1)

option(TEST "Build test cases" OFF)

if (TEST)
enable_testing()
option(gtest_build_tests OFF)
add_subdirectory(third_party/googletest/googletest)
include_directories(SYSTEM ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
add_subdirectory(unitests)
endif ()

add_subdirectory(project)
53 changes: 53 additions & 0 deletions install_boostpython.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
VERSION=1.58.0
BOOST=boost_1_58_0

if [ ! -d ${HOME}/${BOOST} ]; then
if [ -e ${HOME}/${BOOST}.tar.gz ]; then
echo "Find Packge ${HOME}/${BOOST}.tar.gz......."
else
wget -O ${HOME}/${BOOST}.tar.gz http://sourceforge.net/projects/boost/files/boost/${VERSION}/${BOOST}.tar.gz
fi
if [ $? -ne 0 ];then
exit 1
fi
tar -xzf ${HOME}/${BOOST}.tar.gz -C ${HOME}
if [ $? -ne 0 ];then
exit 1
fi
else
echo "Find Boost Source:${HOME}/${BOOST}, Build and install....."
fi

cd ${HOME}/${BOOST}

./bootstrap.sh --prefix=/usr/local --with-libraries=python
if [ $? -ne 0 ];then
exit 1
fi
echo "Install boost static library...."
sudo ./bjam cflags="-fPIC" cxxflags="-fPIC -Wno-unused-local-typedefs -Wno-strict-aliasing" link=static \
--with-python \
-a install
if [ $? -ne 0 ];then
exit 1
fi
echo "Install boost dynamic library....."
sudo ./bjam cflags="-fPIC" cxxflags="-fPIC -Wno-unused-local-typedefs -Wno-strict-aliasing" link=shared \
--with-python
-a install
4 changes: 4 additions & 0 deletions third_party/googletest/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Google Test

-----------------------
Download [Here](!https://github.com/abseil/googletest)
14 changes: 14 additions & 0 deletions unitests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
add_executable(runUnitTests
PythonWrapperTest.cpp
)

target_link_libraries(runUnitTests
dl
gtest)

if (UNIX AND NOT APPLE)
target_link_libraries(runUnitTests rt)
endif ()

set_target_properties(runUnitTests PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
26 changes: 26 additions & 0 deletions unitests/PythonWrapperTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "gtest/gtest.h"

int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);
int ret = RUN_ALL_TESTS();
}

TEST(Message, testCreateMessage) {
ASSERT_TRUE(1 == 1);
}