diff --git a/sakura_core/Makefile b/sakura_core/Makefile index d60cacf28f..374268373d 100644 --- a/sakura_core/Makefile +++ b/sakura_core/Makefile @@ -20,7 +20,7 @@ endif CC= $(PREFIX)gcc CXX= $(PREFIX)g++ RC= $(RCPREFIX)windres -RM= cmd /c $(CURDIR)/../sakura/mingw32-del.bat +RM= "$(CURDIR)/../sakura/mingw32-del.bat" DEFINES= \ -DWIN32 \ @@ -439,7 +439,7 @@ Funccode_enum.h: $(HEADERMAKE) Funccode_x.hsrc $(HEADERMAKE) -in=../sakura_core/Funccode_x.hsrc -out=../sakura_core/Funccode_enum.h -mode=enum -enum=EFunctionCode githash: - cmd /c $(CURDIR)/../sakura/githash.bat ..\\sakura_core + "$(CURDIR)/../sakura/githash.bat" ../sakura_core stdafx: Funccode_enum.h StdAfx.h $(CXX) $(CXXFLAGS) -c StdAfx.h diff --git a/tests/build-and-test.bat b/tests/build-and-test.bat index 734d26acd7..565b26f2c3 100644 --- a/tests/build-and-test.bat +++ b/tests/build-and-test.bat @@ -2,13 +2,8 @@ set platform=%1 set configuration=%2 set ERROR_RESULT=0 -if "%platform%" == "MinGW" ( - @echo test for MinGW will be skipped. ^(platform: %platform%, configuration: %configuration%^) - exit /b 0 -) - @echo ---- start create-project.bat ---- -call %~dp0create-project.bat %platform% %configuration% +call "%~dp0create-project.bat" %platform% %configuration% if errorlevel 1 ( @echo ERROR in create-project.bat %errorlevel% exit /b 1 @@ -16,7 +11,7 @@ if errorlevel 1 ( @echo ---- end create-project.bat ---- @echo ---- start build-project.bat ---- -call %~dp0build-project.bat %platform% %configuration% +call "%~dp0build-project.bat" %platform% %configuration% if errorlevel 1 ( @echo ERROR in build-project.bat %errorlevel% exit /b 1 @@ -24,7 +19,7 @@ if errorlevel 1 ( @echo ---- end build-project.bat ---- @echo ---- start run-tests.bat ---- -call %~dp0run-tests.bat %platform% %configuration% +call "%~dp0run-tests.bat" %platform% %configuration% if errorlevel 1 ( @echo ERROR in run-tests.bat %errorlevel% exit /b 1 diff --git a/tests/create-project.bat b/tests/create-project.bat index 779997c896..b6a45930d7 100644 --- a/tests/create-project.bat +++ b/tests/create-project.bat @@ -2,11 +2,16 @@ set platform=%1 set configuration=%2 set ERROR_RESULT=0 +@rem produces header files necessary in creating the project. +if "%platform%" == "MinGW" ( + set BUILD_EDITOR_BAT=build-gnu.bat +) else ( + set BUILD_EDITOR_BAT=build-sln.bat +) pushd "%~dp0.." -rem produces header files necessary in creating the project. -@echo ---- start build-sln.bat ---- -call build-sln.bat %platform% %configuration% || set ERROR_RESULT=1 -@echo ---- end build-sln.bat ---- +@echo ---- start %BUILD_EDITOR_BAT% ---- +call "%BUILD_EDITOR_BAT%" %platform% %configuration% || set ERROR_RESULT=1 +@echo ---- end %BUILD_EDITOR_BAT% ---- popd if "%ERROR_RESULT%" == "1" ( @echo ERROR @@ -24,8 +29,10 @@ set BUILDDIR=build\%platform% if exist "%BUILDDIR%" ( rmdir /s /q "%BUILDDIR%" ) -mkdir %BUILDDIR% -cmake -DCMAKE_GENERATOR_PLATFORM=%platform% -B%BUILDDIR% -H. || set ERROR_RESULT=1 +mkdir "%BUILDDIR%" + +call :setenv_%platform% %platform% %configuration% +cmake %CMAKE_GEN_OPT% -H. -B"%BUILDDIR%" || set ERROR_RESULT=1 popd @@ -33,3 +40,19 @@ if "%ERROR_RESULT%" == "1" ( @echo ERROR exit /b 1 ) + +exit /b + +@rem ---------------------------------------------- +@rem sub-routines +@rem ---------------------------------------------- + +:setenv_Win32 +:setenv_x64 + set CMAKE_GEN_OPT=-G "Visual Studio 15 2017" -A "%~1" +exit /b + +:setenv_MinGW + set CMAKE_GEN_OPT=-G "MinGW Makefiles" -D CMAKE_BUILD_TYPE="%~2" + set PATH=C:\msys64\mingw64\bin;%PATH:C:\Program Files\Git\usr\bin;=% +exit /b diff --git a/tests/unittests/CMakeLists.txt b/tests/unittests/CMakeLists.txt index ee5dacf3f7..61ad2acbc6 100644 --- a/tests/unittests/CMakeLists.txt +++ b/tests/unittests/CMakeLists.txt @@ -30,13 +30,24 @@ if (BUILD_SHARED_LIBS) endif (BUILD_SHARED_LIBS) # link libraries -target_link_libraries(${project_name} gtest) -target_link_libraries(${project_name} gtest_main) +target_link_libraries(${project_name} PRIVATE gtest) +target_link_libraries(${project_name} PRIVATE gtest_main) # Hacks to reuse compiled editor objects. -target_compile_definitions(${project_name} PUBLIC WIN32 _WIN32_WINNT=_WIN32_WINNT_WIN7) -target_compile_options (${project_name} PUBLIC $<$:/GL> /MT$<$:d> /GF /FD /EHsc /Zi /TP /source-charset:utf-8 /execution-charset:shift_jis) -target_link_libraries (${project_name} $<$:-LTCG> comctl32.lib Imm32.lib mpr.lib imagehlp.lib Shlwapi.lib "${CMAKE_CURRENT_LIST_DIR}/../../sakura/${CMAKE_GENERATOR_PLATFORM}/$/*.obj") -set_target_properties (${project_name} PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_GENERATOR_PLATFORM}/$" -) +target_compile_definitions(${project_name} PRIVATE WIN32 _WIN32_WINNT=_WIN32_WINNT_WIN7) +if (MSVC) + target_compile_options (${project_name} PRIVATE $<$:/GL> /MT$<$:d> /GF /FD /EHsc /Zi /TP /source-charset:utf-8 /execution-charset:shift_jis) + target_link_libraries (${project_name} PRIVATE $<$:-LTCG> "${CMAKE_CURRENT_LIST_DIR}/../../sakura/${CMAKE_GENERATOR_PLATFORM}/$/*.obj") + set_target_properties (${project_name} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_GENERATOR_PLATFORM}/$" + ) +elseif (MINGW) + target_compile_options (${project_name} PRIVATE -finput-charset=utf-8 -fexec-charset=cp932) + file (GLOB_RECURSE ALL_O + "${CMAKE_CURRENT_LIST_DIR}/../../sakura_core/*.cpp" + "${CMAKE_CURRENT_LIST_DIR}/../../sakura_core/*.rc" + ) + list (TRANSFORM ALL_O REPLACE "\\.(cpp|rc)$" ".o") + target_link_libraries (${project_name} PRIVATE ${ALL_O}) +endif () +target_link_libraries (${project_name} PRIVATE winspool ole32 oleaut32 uuid comctl32 imm32 mpr imagehlp shlwapi winmm)