Skip to content

Commit

Permalink
Merge pull request #955 from m-tmatma/feature/find-tool-cmake
Browse files Browse the repository at this point in the history
cmake のパスを find-tools.bat で検索して cmake のパスが通っていなくてもビルドできるようにする
  • Loading branch information
m-tmatma authored Aug 4, 2019
2 parents 1b6f445 + 74d7707 commit dd7f176
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
8 changes: 7 additions & 1 deletion tests/build-project.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ set platform=%1
set configuration=%2
set ERROR_RESULT=0

if not defined CMD_CMAKE call "%~dp0..\tools\find-tools.bat"
if not defined CMD_CMAKE (
echo cmake.exe was not found.
exit /b 1
)

pushd %~dp0
if not exist googletest (
git submodule init
git submodule update
)

set BUILDDIR=build\%platform%
cmake --build %BUILDDIR% --config %configuration% || set ERROR_RESULT=1
"%CMD_CMAKE%" --build %BUILDDIR% --config %configuration% || set ERROR_RESULT=1

popd

Expand Down
8 changes: 7 additions & 1 deletion tests/create-project.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ set platform=%1
set configuration=%2
set ERROR_RESULT=0

if not defined CMD_CMAKE call "%~dp0..\tools\find-tools.bat"
if not defined CMD_CMAKE (
echo cmake.exe was not found.
exit /b 1
)

@rem produces header files necessary in creating the project.
if "%platform%" == "MinGW" (
set BUILD_EDITOR_BAT=build-gnu.bat
Expand Down Expand Up @@ -32,7 +38,7 @@ if exist "%BUILDDIR%" (
mkdir "%BUILDDIR%"

call :setenv_%platform% %platform% %configuration%
cmake %CMAKE_GEN_OPT% -H. -B"%BUILDDIR%" || set ERROR_RESULT=1
"%CMD_CMAKE%" %CMAKE_GEN_OPT% -H. -B"%BUILDDIR%" || set ERROR_RESULT=1

popd

Expand Down
13 changes: 13 additions & 0 deletions tools/find-tools.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if not defined CMD_CPPCHECK call :cppcheck 2> nul
if not defined CMD_DOXYGEN call :doxygen 2> nul
if not defined CMD_VSWHERE call :vswhere 2> nul
if not defined CMD_MSBUILD call :msbuild 2> nul
if not defined CMD_CMAKE call :cmake 2> nul
echo ^|- CMD_GIT=%CMD_GIT%
echo ^|- CMD_7Z=%CMD_7Z%
echo ^|- CMD_HHC=%CMD_HHC%
Expand All @@ -37,6 +38,7 @@ echo ^|- CMD_CPPCHECK=%CMD_CPPCHECK%
echo ^|- CMD_DOXYGEN=%CMD_DOXYGEN%
echo ^|- CMD_VSWHERE=%CMD_VSWHERE%
echo ^|- CMD_MSBUILD=%CMD_MSBUILD%
echo ^|- CMD_CMAKE=%CMD_CMAKE%
endlocal ^
&& set "CMD_GIT=%CMD_GIT%" ^
&& set "CMD_7Z=%CMD_7Z%" ^
Expand All @@ -46,6 +48,7 @@ endlocal ^
&& set "CMD_DOXYGEN=%CMD_DOXYGEN%" ^
&& set "CMD_VSWHERE=%CMD_VSWHERE%" ^
&& set "CMD_MSBUILD=%CMD_MSBUILD%" ^
&& set "CMD_CMAKE=%CMD_CMAKE%" ^
&& echo end

set FIND_TOOLS_CALLED=1
Expand Down Expand Up @@ -151,3 +154,13 @@ for /f "usebackq delims=" %%a in (`where msbuild.exe`) do (
exit /b
)
exit /b


:cmake
set APPDIR=CMake\bin
set PATH2=%PATH%;%ProgramFiles%\%APPDIR%\;%ProgramFiles(x86)%\%APPDIR%\;%ProgramW6432%\%APPDIR%\;
for /f "usebackq delims=" %%a in (`where $PATH2:cmake`) do (
set "CMD_CMAKE=%%a"
exit /b
)
exit /b

0 comments on commit dd7f176

Please sign in to comment.