shell + cmake + increasebuild 自动编译脚本

#!/bin/sh
#edit cmake

makefilelist=CMakeLists.txt
PROJECT_NAME=embedding
PYD_NAME=extending

rm -f $makefilelist
#工程设置
echo -e	'PROJECT(' $PROJECT_NAME ')' '\n' >> $makefilelist
	 
#不用修改设置
echo -e 'SET(VC9_DIR $ENV{VC9_DIR})' '\n'\
		'SET(PYTHON_DIR $ENV{PYTHON_DIR})' '\n'\
		'SET(BOOST_DIR $ENV{BOOST_DIR})' '\n'\
		'SET(CMAKE_C_COMPILER  "${VC9_DIR}/bin/cl.exe")' '\n'\
		'SET(CMAKE_CXX_COMPILER  "${VC9_DIR}/bin/cl.exe")' '\n'\
		'SET(LIBRARY_OUTPUT_PATH  "${PROJECT_BINARY_DIR}")' '\n'\
		'include_directories ("${PYTHON_DIR}/include" "${BOOST_DIR}/include" )' '\n'\
		'link_directories ("${PYTHON_DIR}/libs" "${PYTHON_DIR}/Lib" "${BOOST_DIR}/lib")' '\n' >> $makefilelist
	 
#库和exe设置
echo -e 'add_library('$PYD_NAME 'SHARED extending.cpp)' '\n'\
		'add_executable('$PROJECT_NAME 'embedding.cpp)' '\n' >> $makefilelist
	 
#执行脚本
rm -fr build
mkdir build
cd build

echo 'start cmake'
cmake -G  "Visual Studio 9 2008" ..

echo 'start build'
echo -e	BuildConsole.exe $PROJECT_NAME /build /cfg=\"Debug\|Win32\" '\n'\
		rm -f ../$PYD_NAME.pyd '\n'\
		cp Debug/$PYD_NAME.dll ../$PYD_NAME.pyd '\n'\
		rm -f ../$PROJECT_NAME.exe '\n'\
		cp Debug/$PROJECT_NAME.exe ../$PROJECT_NAME.exe '\n'\
		pause '\n'\
		exit > build.bat

start build.bat
cd ..

#删除脚本
#rm -f $makefilelist

你可能感兴趣的:(shell + cmake + increasebuild 自动编译脚本)