[Ttssh2-commit] [7171] single configuration に対応

scmno****@osdn***** scmno****@osdn*****
2018年 8月 1日 (水) 00:28:11 JST


Revision: 7171
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7171
Author:   zmatsuo
Date:     2018-08-01 00:28:11 +0900 (Wed, 01 Aug 2018)
Log Message:
-----------
single configuration に対応
 cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release などができるようになった
うまくbuildできないことがあったので修正
次の2ファイルはデバッグオプションなどがなくなっていたので修正
 teraterm/teraterm/CMakeLists.txt
 teraterm/ttpmacro/CMakeLists.txt

Modified Paths:
--------------
    branches/cmake/CMakeLists.txt
    branches/cmake/libs/SFMT.cmake
    branches/cmake/libs/buildall.cmake
    branches/cmake/libs/buildall_cmake.bat
    branches/cmake/libs/lib_SFMT.cmake
    branches/cmake/libs/lib_oniguruma.cmake
    branches/cmake/libs/lib_openssl.cmake
    branches/cmake/libs/lib_zlib.cmake
    branches/cmake/libs/oniguruma.cmake
    branches/cmake/libs/openssl.cmake
    branches/cmake/libs/zlib.cmake
    branches/cmake/teraterm/teraterm/CMakeLists.txt
    branches/cmake/teraterm/ttpmacro/CMakeLists.txt

Added Paths:
-----------
    branches/cmake/libs/script_support.cmake

-------------- next part --------------
Modified: branches/cmake/CMakeLists.txt
===================================================================
--- branches/cmake/CMakeLists.txt	2018-07-29 14:17:09 UTC (rev 7170)
+++ branches/cmake/CMakeLists.txt	2018-07-31 15:28:11 UTC (rev 7171)
@@ -12,7 +12,7 @@
 string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
 string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
 string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
-if(CMAKE_GENERATOR MATCHES "Visual Studio 15 2017")
+if(${CMAKE_GENERATOR} MATCHES "Visual Studio 15 2017")
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
 endif()
@@ -22,6 +22,6 @@
 add_subdirectory(TTProxy)
 add_subdirectory(ttssh2)
 add_subdirectory(TTXKanjiMenu)
-if(ENABLE_TTXSAMPLES)
+if(${ENABLE_TTXSAMPLES})
   add_subdirectory(TTXSamples)
 endif()

Modified: branches/cmake/libs/SFMT.cmake
===================================================================
--- branches/cmake/libs/SFMT.cmake	2018-07-29 14:17:09 UTC (rev 7170)
+++ branches/cmake/libs/SFMT.cmake	2018-07-31 15:28:11 UTC (rev 7171)
@@ -1,7 +1,53 @@
-# cmake -DGENERATOR="Visual Studio 15 2017" -P SFMT.cmake
+# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -P SFMT.cmake
+# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -DCMAKE_CONFIGURATION_TYPE=Release -P SFMT.cmake
 
-string(REPLACE " " "_" GENERATOR_ ${GENERATOR})
+####
+if(("${CMAKE_BUILD_TYPE}" STREQUAL "") AND ("${CMAKE_CONFIGURATION_TYPE}" STREQUAL ""))
+  if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
+	# multi-configuration
+	execute_process(
+	  COMMAND ${CMAKE_COMMAND}
+	  -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
+	  -DCMAKE_CONFIGURATION_TYPE=Release
+	  -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake
+	  -P SFMT.cmake
+	  )
+	execute_process(
+	  COMMAND ${CMAKE_COMMAND}
+	  -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
+	  -DCMAKE_CONFIGURATION_TYPE=Debug
+	  -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake
+	  -P SFMT.cmake
+	  )
+	return()
+  elseif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")
+	# mingw
+	# single-configuration
+	if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "")
+	  set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/../mingw.toolchain.cmake")
+	endif()
+	if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+	  set(CMAKE_BUILD_TYPE Release)
+	endif()
+  elseif("${CMAKE_GENERATOR}" MATCHES "NMake Makefiles")
+	# VS nmake
+	# single-configuration
+	if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "")
+	  set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/VSToolchain.cmake")
+	endif()
+	if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+	  set(CMAKE_BUILD_TYPE Release)
+	endif()
+  else()
+	# single-configuration
+	if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+	  set(CMAKE_BUILD_TYPE Release)
+	endif()
+  endif()
+endif()
 
+include(script_support.cmake)
+
 set(SRC_DIR_BASE "SFMT-src-1.5.1")
 set(SRC_ARC "SFMT-1.5.1.zip")
 set(SRC_URL "http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/SFMT-src-1.5.1.zip")
@@ -10,9 +56,11 @@
 set(DOWN_DIR "${CMAKE_SOURCE_DIR}/donwload/SFMT")
 set(EXTRACT_DIR "${CMAKE_SOURCE_DIR}/build/SFMT/src")
 set(SRC_DIR "${CMAKE_SOURCE_DIR}/build/SFMT/src/${SRC_DIR_BASE}")
-set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build/SFMT/build_${GENERATOR_}")
-set(INSTALL_DIR "${CMAKE_SOURCE_DIR}/SFMT_${GENERATOR_}")
+set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build/SFMT/build_${TOOLSET}")
+set(INSTALL_DIR "${CMAKE_SOURCE_DIR}/SFMT_${TOOLSET}")
 
+########################################
+
 if(NOT EXISTS ${SRC_DIR}/README.txt)
 
   file(DOWNLOAD
@@ -33,80 +81,82 @@
 
 ########################################
 
-file(WRITE "${SRC_DIR}/CMakeLists.txt"
-  "cmake_minimum_required(VERSION 2.4.4)\n"
-  "project(SFMT C)\n"
-  "\n"
-  "if(MSVC)\n"
-  "  set(CMAKE_DEBUG_POSTFIX \"d\")\n"
-  "endif()\n"
-  "\n"
-  "add_library(\n"
-  "  sfmt STATIC\n"
-  "  SFMT.c\n"
-  "  )\n"
-  "\n"
-  "install(\n"
-  "  TARGETS sfmt\n"
-  "  ARCHIVE DESTINATION \${CMAKE_INSTALL_PREFIX}/lib\n"
-  "  )\n"
-  "install(\n"
-  "  FILES SFMT.h SFMT-params.h SFMT-params19937.h\n"
-  "  DESTINATION \${CMAKE_INSTALL_PREFIX}/include\n"
-  "  )\n"
-  )
+if(NOT EXISTS ${SRC_DIR}/CMakeLists.txt)
+  file(WRITE "${SRC_DIR}/CMakeLists.txt"
+	"cmake_minimum_required(VERSION 2.4.4)\n"
+	"project(SFMT C)\n"
+	"\n"
+	"if(MSVC)\n"
+	"  set(CMAKE_DEBUG_POSTFIX \"d\")\n"
+	"endif()\n"
+	"\n"
+	"add_library(\n"
+	"  sfmt STATIC\n"
+	"  SFMT.c\n"
+	"  )\n"
+	"\n"
+	"install(\n"
+	"  TARGETS sfmt\n"
+	"  ARCHIVE DESTINATION \${CMAKE_INSTALL_PREFIX}/lib\n"
+	"  )\n"
+	"install(\n"
+	"  FILES SFMT.h SFMT-params.h SFMT-params19937.h\n"
+	"  DESTINATION \${CMAKE_INSTALL_PREFIX}/include\n"
+	"  )\n"
+	)
+endif()
 
 ########################################
 
 file(MAKE_DIRECTORY "${BUILD_DIR}")
 
-execute_process(
-  COMMAND ${CMAKE_COMMAND} ${SRC_DIR} -G ${GENERATOR}
-  -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake
-  -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
-  WORKING_DIRECTORY ${BUILD_DIR}
-  RESULT_VARIABLE rv
-  )
-if(NOT rv STREQUAL "0")
-  message(FATAL_ERROR "cmake generate fail ${rv}")
-endif()
+if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
 
-########################################
+  ######################################## multi configuration
 
-execute_process(
-  COMMAND ${CMAKE_COMMAND} --build . --config release
-  WORKING_DIRECTORY ${BUILD_DIR}
-  RESULT_VARIABLE rv
-  )
-if(NOT rv STREQUAL "0")
-  message(FATAL_ERROR "cmake build fail ${rv}")
-endif()
+  execute_process(
+	COMMAND ${CMAKE_COMMAND} ${SRC_DIR} -G ${CMAKE_GENERATOR}
+	-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
+	-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
+	${TOOLCHAINFILE}
+	WORKING_DIRECTORY ${BUILD_DIR}
+	RESULT_VARIABLE rv
+	)
+  if(NOT rv STREQUAL "0")
+	message(FATAL_ERROR "cmake generate fail ${rv}")
+  endif()
 
-execute_process(
-  COMMAND ${CMAKE_COMMAND} --build . --config release --target install
-  WORKING_DIRECTORY ${BUILD_DIR}
-  RESULT_VARIABLE rv
-  )
-if(NOT rv STREQUAL "0")
-  message(FATAL_ERROR "cmake install fail ${rv}")
-endif()
+  execute_process(
+	COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_CONFIGURATION_TYPE} --target install
+	WORKING_DIRECTORY ${BUILD_DIR}
+	RESULT_VARIABLE rv
+	)
+  if(NOT rv STREQUAL "0")
+	message(FATAL_ERROR "cmake install fail ${rv}")
+  endif()
 
-########################################
+else()
+  ######################################## single configuration
+  
+  execute_process(
+	COMMAND ${CMAKE_COMMAND} ${SRC_DIR} -G ${CMAKE_GENERATOR}
+	-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+	-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
+	-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
+	WORKING_DIRECTORY ${BUILD_DIR}
+	RESULT_VARIABLE rv
+	)
+  if(NOT rv STREQUAL "0")
+	message(FATAL_ERROR "cmake build fail ${rv}")
+  endif()
+  
+  execute_process(
+	COMMAND ${CMAKE_COMMAND} --build . --target install
+	WORKING_DIRECTORY ${BUILD_DIR}
+	RESULT_VARIABLE rv
+	)
+  if(NOT rv STREQUAL "0")
+	message(FATAL_ERROR "cmake install fail ${rv}")
+  endif()
 
-execute_process(
-  COMMAND ${CMAKE_COMMAND} --build . --config debug
-  WORKING_DIRECTORY ${BUILD_DIR}
-  RESULT_VARIABLE rv
-  )
-if(NOT rv STREQUAL "0")
-  message(FATAL_ERROR "cmake build fail ${rv}")
 endif()
-
-execute_process(
-  COMMAND ${CMAKE_COMMAND} --build . --config debug --target install
-  WORKING_DIRECTORY ${BUILD_DIR}
-  RESULT_VARIABLE rv
-  )
-if(NOT rv STREQUAL "0")
-  message(FATAL_ERROR "cmake install fail ${rv}")
-endif()

Modified: branches/cmake/libs/buildall.cmake
===================================================================
--- branches/cmake/libs/buildall.cmake	2018-07-29 14:17:09 UTC (rev 7170)
+++ branches/cmake/libs/buildall.cmake	2018-07-31 15:28:11 UTC (rev 7171)
@@ -1,8 +1,8 @@
-# cmake -DGENERATOR="Vsual Studio 15 2017" -P buildall.cmake 
+# cmake -DCMAKE_GENERATOR="Vsual Studio 15 2017" -P buildall.cmake 
 
-if("${GENERATOR}" STREQUAL "")
-  #set(GENERATOR "Visual Studio 15 2017")
-  message(FATAL_ERROR "set GENERATOR!")
+if("${CMAKE_GENERATOR}" STREQUAL "")
+  #set(CMAKE_GENERATOR "Visual Studio 15 2017")
+  message(FATAL_ERROR "set CMAKE_GENERATOR!")
 endif()
 
 # utf-8
@@ -12,17 +12,17 @@
 
 # build
 execute_process(
-  COMMAND ${CMAKE_COMMAND} -DGENERATOR=${GENERATOR} -P oniguruma.cmake
+  COMMAND ${CMAKE_COMMAND} -DCMAKE_GENERATOR=${CMAKE_GENERATOR} -P oniguruma.cmake
   )
 execute_process(
-  COMMAND ${CMAKE_COMMAND} -DGENERATOR=${GENERATOR} -P zlib.cmake
+  COMMAND ${CMAKE_COMMAND} -DCMAKE_GENERATOR=${CMAKE_GENERATOR} -P zlib.cmake
   )
 execute_process(
   COMMAND ${CMAKE_COMMAND} -P putty.cmake
   )
 execute_process(
-  COMMAND ${CMAKE_COMMAND} -DGENERATOR=${GENERATOR} -P openssl.cmake
+  COMMAND ${CMAKE_COMMAND} -DCMAKE_GENERATOR=${CMAKE_GENERATOR} -P SFMT.cmake
   )
 execute_process(
-  COMMAND ${CMAKE_COMMAND} -DGENERATOR=${GENERATOR} -P SFMT.cmake
+  COMMAND ${CMAKE_COMMAND} -DCMAKE_GENERATOR=${CMAKE_GENERATOR} -P openssl.cmake
   )

Modified: branches/cmake/libs/buildall_cmake.bat
===================================================================
--- branches/cmake/libs/buildall_cmake.bat	2018-07-29 14:17:09 UTC (rev 7170)
+++ branches/cmake/libs/buildall_cmake.bat	2018-07-31 15:28:11 UTC (rev 7171)
@@ -1,6 +1,7 @@
 @echo off
 setlocal
 
+set opt=
 :retry
 echo 1. Visual Studio 15 2017
 echo 2. Visual Studio 14 2015
@@ -9,6 +10,8 @@
 echo 5. Visual Studio 10 2010
 echo 6. Visual Studio 9 2008
 echo 7. Visual Studio 8 2005
+echo 9. Visual Studio NMake
+echo z. Cygwin MinGW Release + Unix Makefiles
 set /p no="select no "
 
 echo %no%
@@ -19,12 +22,16 @@
 if "%no%" == "5" set GENERATOR="Visual Studio 10 2010" & goto build_all
 if "%no%" == "6" set GENERATOR="Visual Studio 9 2008" & goto build_all
 if "%no%" == "7" set GENERATOR="Visual Studio 8 2005" & goto build_all
+if "%no%" == "9" set GENERATOR="NMake Makefiles" & set OPT=-DCMAKE_BUILD_TYPE=Release & goto build_all
+if "%no%" == "z" set GENERATOR="Unix Makefiles" & goto build_all
 echo ? retry
 goto retry
 
 :build_all
-echo cmake -DGENERATOR=%GENERATOR% -P buildall.cmake
+set C=cmake -DCMAKE_GENERATOR=%GENERATOR% %OPT% -P buildall.cmake
+echo %C%
+title %C%
 pause
-cmake -DGENERATOR=%GENERATOR% -P buildall.cmake
+%C%
 endlocal
 pause

Modified: branches/cmake/libs/lib_SFMT.cmake
===================================================================
--- branches/cmake/libs/lib_SFMT.cmake	2018-07-29 14:17:09 UTC (rev 7170)
+++ branches/cmake/libs/lib_SFMT.cmake	2018-07-31 15:28:11 UTC (rev 7171)
@@ -1,10 +1,10 @@
 
-string(REPLACE " " "_" GENERATOR_ ${CMAKE_GENERATOR})
+include(${CMAKE_CURRENT_LIST_DIR}/script_support.cmake)
 
 set(SFMT_INCLUDE_DIRS
-  "${CMAKE_CURRENT_LIST_DIR}/SFMT_${GENERATOR_}/include"
+  "${CMAKE_CURRENT_LIST_DIR}/SFMT_${TOOLSET}/include"
   )
 
 set(SFMT_LIBRARY_DIRS
-  "${CMAKE_CURRENT_LIST_DIR}/SFMT_${GENERATOR_}/lib"
+  "${CMAKE_CURRENT_LIST_DIR}/SFMT_${TOOLSET}/lib"
   )

Modified: branches/cmake/libs/lib_oniguruma.cmake
===================================================================
--- branches/cmake/libs/lib_oniguruma.cmake	2018-07-29 14:17:09 UTC (rev 7170)
+++ branches/cmake/libs/lib_oniguruma.cmake	2018-07-31 15:28:11 UTC (rev 7171)
@@ -1,11 +1,5 @@
 
-string(REPLACE " " "_" GENERATOR_ ${CMAKE_GENERATOR})
+include(${CMAKE_CURRENT_LIST_DIR}/script_support.cmake)
 
-list(
-  APPEND
-  CMAKE_PREFIX_PATH
-  "${CMAKE_CURRENT_LIST_DIR}/oniguruma_${GENERATOR_}/"
-  )
-find_package(PkgConfig REQUIRED)
-pkg_check_modules(ONIGURUMA REQUIRED oniguruma)
-
+set(ONIGURUMA_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/oniguruma_${TOOLSET}/include)
+set(ONIGURUMA_LIBRARY_DIRS ${CMAKE_CURRENT_LIST_DIR}/oniguruma_${TOOLSET}/lib)

Modified: branches/cmake/libs/lib_openssl.cmake
===================================================================
--- branches/cmake/libs/lib_openssl.cmake	2018-07-29 14:17:09 UTC (rev 7170)
+++ branches/cmake/libs/lib_openssl.cmake	2018-07-31 15:28:11 UTC (rev 7171)
@@ -1,14 +1,14 @@
 
-string(REPLACE " " "_" GENERATOR_ ${CMAKE_GENERATOR})
+include(${CMAKE_CURRENT_LIST_DIR}/script_support.cmake)
 
 set(OPENSSL_INCLUDE_DIRS
-  "$<$<CONFIG:Debug>:${CMAKE_CURRENT_LIST_DIR}/openssl_${GENERATOR_}_debug/include>"
-  "$<$<CONFIG:Release>:${CMAKE_CURRENT_LIST_DIR}/openssl_${GENERATOR_}/include>"
+  "$<$<CONFIG:Debug>:${CMAKE_CURRENT_LIST_DIR}/openssl_${TOOLSET}_debug/include>"
+  "$<$<CONFIG:Release>:${CMAKE_CURRENT_LIST_DIR}/openssl_${TOOLSET}/include>"
   )
 
 set(OPENSSL_LIB
-  debug ${CMAKE_CURRENT_LIST_DIR}/openssl_${GENERATOR_}_debug/lib/libeay32.lib
-  debug ${CMAKE_CURRENT_LIST_DIR}/openssl_${GENERATOR_}_debug/lib/ssleay32.lib
-  optimized ${CMAKE_CURRENT_LIST_DIR}/openssl_${GENERATOR_}/lib/libeay32.lib
-  optimized ${CMAKE_CURRENT_LIST_DIR}/openssl_${GENERATOR_}/lib/ssleay32.lib
+  debug ${CMAKE_CURRENT_LIST_DIR}/openssl_${TOOLSET}_debug/lib/libeay32.lib
+#  debug ${CMAKE_CURRENT_LIST_DIR}/openssl_${TOOLSET}_debug/lib/ssleay32.lib
+  optimized ${CMAKE_CURRENT_LIST_DIR}/openssl_${TOOLSET}/lib/libeay32.lib
+#  optimized ${CMAKE_CURRENT_LIST_DIR}/openssl_${TOOLSET}/lib/ssleay32.lib
   )

Modified: branches/cmake/libs/lib_zlib.cmake
===================================================================
--- branches/cmake/libs/lib_zlib.cmake	2018-07-29 14:17:09 UTC (rev 7170)
+++ branches/cmake/libs/lib_zlib.cmake	2018-07-31 15:28:11 UTC (rev 7171)
@@ -1,11 +1,5 @@
 
-string(REPLACE " " "_" GENERATOR_ ${CMAKE_GENERATOR})
+include(${CMAKE_CURRENT_LIST_DIR}/script_support.cmake)
 
-list(
-  APPEND
-  CMAKE_PREFIX_PATH
-  "${CMAKE_CURRENT_LIST_DIR}/zlib_${GENERATOR_}"
-  )
-find_package(PkgConfig REQUIRED)
-pkg_check_modules(ZLIB REQUIRED zlib)
-
+set(ZLIB_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/zlib_${TOOLSET}/include)
+set(ZLIB_LIBRARY_DIRS ${CMAKE_CURRENT_LIST_DIR}/zlib_${TOOLSET}/lib)

Modified: branches/cmake/libs/oniguruma.cmake
===================================================================
--- branches/cmake/libs/oniguruma.cmake	2018-07-29 14:17:09 UTC (rev 7170)
+++ branches/cmake/libs/oniguruma.cmake	2018-07-31 15:28:11 UTC (rev 7171)
@@ -1,7 +1,53 @@
-# cmake -DGENERATOR="Visual Studio 15 2017" -P oniguruma.cmake
+# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -P oniguruma.cmake
+# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -DCMAKE_CONFIGURATION_TYPE=Release -P oniguruma.cmake
 
-string(REPLACE " " "_" GENERATOR_ ${GENERATOR})
+####
+if(("${CMAKE_BUILD_TYPE}" STREQUAL "") AND ("${CMAKE_CONFIGURATION_TYPE}" STREQUAL ""))
+  if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
+	# multi-configuration
+	execute_process(
+	  COMMAND ${CMAKE_COMMAND}
+	  -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
+	  -DCMAKE_CONFIGURATION_TYPE=Release
+	  -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake
+	  -P oniguruma.cmake
+	  )
+	execute_process(
+	  COMMAND ${CMAKE_COMMAND}
+	  -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
+	  -DCMAKE_CONFIGURATION_TYPE=Debug
+	  -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake
+	  -P oniguruma.cmake
+	  )
+	return()
+  elseif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")
+	# mingw
+	# single-configuration
+	if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "")
+	  set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/../mingw.toolchain.cmake")
+	endif()
+	if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+	  set(CMAKE_BUILD_TYPE Release)
+	endif()
+  elseif("${CMAKE_GENERATOR}" MATCHES "NMake Makefiles")
+	# VS nmake
+	# single-configuration
+	if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "")
+	  set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/VSToolchain.cmake")
+	endif()
+	if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+	  set(CMAKE_BUILD_TYPE Release)
+	endif()
+  else()
+	# single-configuration
+	if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+	  set(CMAKE_BUILD_TYPE Release)
+	endif()
+  endif()
+endif()
 
+include(script_support.cmake)
+
 set(SRC_DIR_BASE "onig-6.8.2")
 set(SRC_ARC "onig-6.8.2.tar.gz")
 set(SRC_URL "https://github.com/kkos/oniguruma/releases/download/v6.8.2/onig-6.8.2.tar.gz")
@@ -10,9 +56,11 @@
 set(DOWN_DIR "${CMAKE_SOURCE_DIR}/donwload/oniguruma")
 set(EXTRACT_DIR "${CMAKE_SOURCE_DIR}/build/oniguruma/src")
 set(SRC_DIR "${CMAKE_SOURCE_DIR}/build/oniguruma/src/${SRC_DIR_BASE}")
-set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build/oniguruma/build_${GENERATOR_}")
-set(INSTALL_DIR "${CMAKE_SOURCE_DIR}/oniguruma_${GENERATOR_}")
+set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build/oniguruma/build_${TOOLSET}")
+set(INSTALL_DIR "${CMAKE_SOURCE_DIR}/oniguruma_${TOOLSET}")
 
+########################################
+
 if(NOT EXISTS ${SRC_DIR}/README.md)
 
   file(DOWNLOAD
@@ -22,10 +70,9 @@
     SHOW_PROGRESS
     )
 
+  file(MAKE_DIRECTORY ${EXTRACT_DIR})
+
   execute_process(
-    COMMAND ${CMAKE_COMMAND} -E make_directory ${EXTRACT_DIR}
-    )
-  execute_process(
     COMMAND ${CMAKE_COMMAND} -E tar "xvf" ${DOWN_DIR}/${SRC_ARC}
     WORKING_DIRECTORY ${EXTRACT_DIR}
     )
@@ -36,55 +83,56 @@
 
 file(MAKE_DIRECTORY "${BUILD_DIR}")
 
-execute_process(
-  COMMAND ${CMAKE_COMMAND} ${SRC_DIR} -G ${GENERATOR}
-  -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake
-  -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
-  -DCMAKE_DEBUG_POSTFIX=d
-  -DBUILD_SHARED_LIBS=OFF
-  WORKING_DIRECTORY ${BUILD_DIR}
-  RESULT_VARIABLE rv
-  )
-if(NOT rv STREQUAL "0")
-  message(FATAL_ERROR "cmake generate fail ${rv}")
-endif()
+if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
 
-########################################
+  ######################################## multi configuration
 
-execute_process(
-  COMMAND ${CMAKE_COMMAND} --build . --config release
-  WORKING_DIRECTORY ${BUILD_DIR}
-  RESULT_VARIABLE rv
-  )
-if(NOT rv STREQUAL "0")
-  message(FATAL_ERROR "cmake build fail ${rv}")
-endif()
+  execute_process(
+	COMMAND ${CMAKE_COMMAND} ${SRC_DIR} -G ${CMAKE_GENERATOR}
+	-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
+	-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
+	${TOOLCHAINFILE}
+	-DCMAKE_DEBUG_POSTFIX=d
+	-DBUILD_SHARED_LIBS=OFF
+	WORKING_DIRECTORY ${BUILD_DIR}
+	RESULT_VARIABLE rv
+	)
+  if(NOT rv STREQUAL "0")
+	message(FATAL_ERROR "cmake generate fail ${rv}")
+  endif()
 
-execute_process(
-  COMMAND ${CMAKE_COMMAND} --build . --config release --target install
-  WORKING_DIRECTORY ${BUILD_DIR}
-  RESULT_VARIABLE rv
-  )
-if(NOT rv STREQUAL "0")
-  message(FATAL_ERROR "cmake install fail ${rv}")
-endif()
+  execute_process(
+	COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_CONFIGURATION_TYPE} --target install
+	WORKING_DIRECTORY ${BUILD_DIR}
+	RESULT_VARIABLE rv
+	)
+  if(NOT rv STREQUAL "0")
+	message(FATAL_ERROR "cmake install fail ${rv}")
+  endif()
 
-########################################
+else()
+  ######################################## single configuration
+  
+  execute_process(
+	COMMAND ${CMAKE_COMMAND} ${SRC_DIR} -G ${CMAKE_GENERATOR}
+	-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+	-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
+	-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
+	-DBUILD_SHARED_LIBS=OFF
+	WORKING_DIRECTORY ${BUILD_DIR}
+	RESULT_VARIABLE rv
+	)
+  if(NOT rv STREQUAL "0")
+	message(FATAL_ERROR "cmake build fail ${rv}")
+  endif()
+  
+  execute_process(
+	COMMAND ${CMAKE_COMMAND} --build . --target install
+	WORKING_DIRECTORY ${BUILD_DIR}
+	RESULT_VARIABLE rv
+	)
+  if(NOT rv STREQUAL "0")
+	message(FATAL_ERROR "cmake install fail ${rv}")
+  endif()
 
-execute_process(
-  COMMAND ${CMAKE_COMMAND} --build . --config debug
-  WORKING_DIRECTORY ${BUILD_DIR}
-  RESULT_VARIABLE rv
-  )
-if(NOT rv STREQUAL "0")
-  message(FATAL_ERROR "cmake build fail ${rv}")
 endif()
-
-execute_process(
-  COMMAND ${CMAKE_COMMAND} --build . --config debug --target install
-  WORKING_DIRECTORY ${BUILD_DIR}
-  RESULT_VARIABLE rv
-  )
-if(NOT rv STREQUAL "0")
-  message(FATAL_ERROR "cmake install fail ${rv}")
-endif()

Modified: branches/cmake/libs/openssl.cmake
===================================================================
--- branches/cmake/libs/openssl.cmake	2018-07-29 14:17:09 UTC (rev 7170)
+++ branches/cmake/libs/openssl.cmake	2018-07-31 15:28:11 UTC (rev 7171)
@@ -1,7 +1,53 @@
-# cmake -DGENERATOR="Visual Studio 15 2017" -P openssl.cmake
+# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -P openssl.cmake
+# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -DCMAKE_BUILD_TYPE=Release -P openssl.cmake
 
-string(REPLACE " " "_" GENERATOR_ ${GENERATOR})
+####
+if(("${CMAKE_BUILD_TYPE}" STREQUAL "") AND ("${CMAKE_CONFIGURATION_TYPE}" STREQUAL ""))
+  if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
+	# multi-configuration
+	execute_process(
+	  COMMAND ${CMAKE_COMMAND}
+	  -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
+	  -DCMAKE_CONFIGURATION_TYPE=Release
+	  -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake
+	  -P openssl.cmake
+	  )
+	execute_process(
+	  COMMAND ${CMAKE_COMMAND}
+	  -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
+	  -DCMAKE_CONFIGURATION_TYPE=Debug
+	  -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake
+	  -P openssl.cmake
+	  )
+	return()
+  elseif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")
+	# mingw
+	# single-configuration
+	if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "")
+	  set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/../mingw.toolchain.cmake")
+	endif()
+	if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+	  set(CMAKE_BUILD_TYPE Release)
+	endif()
+  elseif("${CMAKE_GENERATOR}" MATCHES "NMake Makefiles")
+	# VS nmake
+	# single-configuration
+	if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "")
+	  set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/VSToolchain.cmake")
+	endif()
+	if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+	  set(CMAKE_BUILD_TYPE Release)
+	endif()
+  else()
+	# single-configuration
+	if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+	  set(CMAKE_BUILD_TYPE Release)
+	endif()
+  endif()
+endif()
 
+include(script_support.cmake)
+
 set(SRC_DIR_BASE "openssl-1.0.2o")
 set(SRC_ARC "openssl-1.0.2o.tar.xz")
 set(SRC_URL "https://www.openssl.org/source/openssl-1.0.2o.tar.gz")
@@ -9,10 +55,16 @@
 
 set(DOWN_DIR "${CMAKE_SOURCE_DIR}/donwload/openssl")
 
-set(EXTRACT_DIR "${CMAKE_SOURCE_DIR}/build/openssl/src_${GENERATOR_}")
+set(EXTRACT_DIR "${CMAKE_SOURCE_DIR}/build/openssl/src_${TOOLSET}")
 set(SRC_DIR "${EXTRACT_DIR}/${SRC_DIR_BASE}")
-set(INSTALL_DIR "${CMAKE_SOURCE_DIR}/openssl_${GENERATOR_}")
+set(INSTALL_DIR "${CMAKE_SOURCE_DIR}/openssl_${TOOLSET}")
 
+if((${CMAKE_GENERATOR} MATCHES "Visual Studio") AND ("${CMAKE_CONFIGURATION_TYPE}" STREQUAL "Debug"))
+  set(EXTRACT_DIR "${EXTRACT_DIR}_debug")
+  set(SRC_DIR "${EXTRACT_DIR}/${SRC_DIR_BASE}")
+  set(INSTALL_DIR "${INSTALL_DIR}_debug")
+endif()
+
 ########################################
 
 file(DOWNLOAD
@@ -32,19 +84,6 @@
 if(PERL-NOTFOUND)
   message(FATAL_ERROR "perl not found")
 endif()
-if(GENERATOR MATCHES "Visual Studio 15 2017")
-  find_program(
-	VCVARS32 vcvars32.bat
-	HINTS "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build"
-	HINTS "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Auxiliary/Build"
-	HINTS "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Auxiliary/Build"
-	)
-else()
-  set(VCVARS32-NOTFOUND 1)
-endif()  
-if(VCVARS32-NOTFOUND)
-  message(FATAL_ERROR "vcvars32.bat not found")
-endif()
 
 ########################################
 
@@ -63,66 +102,126 @@
 
 ########################################
 
-file(TO_NATIVE_PATH ${INSTALL_DIR} INSTALL_DIR_N)
-file(WRITE "${SRC_DIR}/build_cmake.bat"
-  "call \"${VCVARS32}\"\n"
-  "cd %~dp0\n"
-  "${PERL} Configure no-asm VC-WIN32 --prefix=${INSTALL_DIR_N}\n"
-  "call ms\\do_ms.bat\n"
-  "nmake -f ms\\nt.mak install\n"
-  )
+if((${CMAKE_GENERATOR} MATCHES "Visual Studio") OR
+	(${CMAKE_GENERATOR} MATCHES "NMake Makefiles"))
+  ######################################## VS
+  if(${CMAKE_GENERATOR} MATCHES "NMake Makefiles")
+  elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 15 2017")
+	find_program(
+	  VCVARS32 vcvars32.bat
+	  HINTS "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build"
+	  HINTS "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Auxiliary/Build"
+	  HINTS "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Auxiliary/Build"
+	  )
+  elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 14 2015")
+	find_program(
+	  VCVARS32 vcvars32.bat
+	  HINTS "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin"
+	  )
+  elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 12 2013")
+	find_program(
+	  VCVARS32 vcvars32.bat
+	  HINTS "C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin"
+	  )
+  elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 11 2012")
+	find_program(
+	  VCVARS32 vcvars32.bat
+	  HINTS "C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin"
+	  )
+  elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 10 2010")
+	find_program(
+	  VCVARS32 vcvars32.bat
+	  HINTS "C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin"
+	  )
+  elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 9 2008")
+	find_program(
+	  VCVARS32 vcvars32.bat
+	  HINTS "C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin"
+	  )
+  elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 8 2005")
+	find_program(
+	  VCVARS32 vcvars32.bat
+	  HINTS "C:/Program Files (x86)/Microsoft Visual Studio 8.0/VC/bin"
+	  )
+  else()
+	message(FATAL_ERROR "CMAKE_GENERATOR ${CMAKE_GENERATOR} not supported")
+  endif()  
+  if(VCVARS32-NOTFOUND)
+	message(FATAL_ERROR "vcvars32.bat not found")
+  endif()
 
-set(BUILD_CMAKE_BAT "${SRC_DIR}/build_cmake.bat")
-file(TO_NATIVE_PATH ${BUILD_CMAKE_BAT} BUILD_CMAKE_BAT_N)
-execute_process(
-  COMMAND cmd /c ${BUILD_CMAKE_BAT_N}
-  WORKING_DIRECTORY ${SRC_DIR}
-  RESULT_VARIABLE rv
-  )
-if(NOT rv STREQUAL "0")
-  message(FATAL_ERROR "cmake build fail ${rv}")
-endif()
+  if(("${CMAKE_BUILD_TYPE}" STREQUAL "Release") OR ("${CMAKE_CONFIGURATION_TYPE}" STREQUAL "Release"))
+	set(CONFIG_TARGET "VC-WIN32")
+  else()
+	set(CONFIG_TARGET "debug-VC-WIN32")
+  endif()
 
-########################################
+  file(WRITE "${SRC_DIR}/build_cmake.bat"
+	"cd %~dp0\n"
+	)
+  if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
+	file(TO_NATIVE_PATH ${VCVARS32} VCVARS32_N)
+	file(APPEND "${SRC_DIR}/build_cmake.bat"
+	  "call \"${VCVARS32_N}\"\n"
+	  )
+  endif()
+  file(TO_NATIVE_PATH ${PERL} PERL_N)
+  file(TO_NATIVE_PATH ${INSTALL_DIR} INSTALL_DIR_N)
+  file(APPEND "${SRC_DIR}/build_cmake.bat"
+	"del crypto\\buildinf.h\n"
+	"${PERL_N} Configure no-asm ${CONFIG_TARGET} --prefix=${INSTALL_DIR_N}\n"
+	"rem call ms\\do_ms.bat\n"
+	"${PERL_N} util/mkfiles.pl > MINFO\n"
+	"${PERL_N} util/mk1mf.pl no-asm VC-WIN32 > ms\\nt.mak\n"
+	"nmake -f ms\\nt.mak install\n"
+	)
 
-set(EXTRACT_DIR "${EXTRACT_DIR}_debug")
-set(SRC_DIR "${EXTRACT_DIR}/${SRC_DIR_BASE}")
-set(INSTALL_DIR "${INSTALL_DIR}_debug")
-
-########################################
-
-if(NOT EXISTS ${SRC_DIR}/README)
-
+  set(BUILD_CMAKE_BAT "${SRC_DIR}/build_cmake.bat")
+  file(TO_NATIVE_PATH ${BUILD_CMAKE_BAT} BUILD_CMAKE_BAT_N)
   execute_process(
-    COMMAND ${CMAKE_COMMAND} -E make_directory ${EXTRACT_DIR}
-    )
-
+	COMMAND cmd /c ${BUILD_CMAKE_BAT_N}
+	WORKING_DIRECTORY ${SRC_DIR}
+	RESULT_VARIABLE rv
+	)
+  if(NOT rv STREQUAL "0")
+	message(FATAL_ERROR "cmake build fail ${rv}")
+  endif()
+else()
+  ######################################## MinGW
+  find_program(
+	MAKE make.exe
+	HINTS c:/cygwin/usr/bin
+	HINTS c:/cygwin64/usr/bin
+	)
+  include(${CMAKE_SOURCE_DIR}/../mingw.toolchain.cmake)
+  set(ENV{PREFIX} i686-w64-mingw32)
+  set(ENV{CC} ${CMAKE_C_COMPILER})
+  set(ENV{CXX} ${CMAKE_CXX_COMPILER})
+  set(ENV{AR} "i686-w64-mingw32-ar")
+  set(ENV{RANLIB} "i686-w64-mingw32-ranlib")
   execute_process(
-    COMMAND ${CMAKE_COMMAND} -E tar "xvf" ${DOWN_DIR}/${SRC_ARC}
-    WORKING_DIRECTORY ${EXTRACT_DIR}
-    )
-
+	COMMAND ${PERL} ./Configure mingw --prefix=${INSTALL_DIR}
+	WORKING_DIRECTORY ${SRC_DIR}
+	RESULT_VARIABLE rv
+	)
+  if(NOT rv STREQUAL "0")
+	message(FATAL_ERROR "cmake configure fail ${rv}")
+  endif()
+  execute_process(
+	COMMAND ${MAKE}
+	WORKING_DIRECTORY ${SRC_DIR}
+	RESULT_VARIABLE rv
+	)
+  if(NOT rv STREQUAL "0")
+	message(FATAL_ERROR "cmake build fail ${rv}")
+  endif()
+  execute_process(
+	COMMAND ${MAKE} install
+	WORKING_DIRECTORY ${SRC_DIR}
+	RESULT_VARIABLE rv
+	)
+  if(NOT rv STREQUAL "0")
+	message(FATAL_ERROR "cmake install fail ${rv}")
+  endif()
 endif()
 
-########################################
-
-file(TO_NATIVE_PATH ${INSTALL_DIR} INSTALL_DIR_N)
-file(WRITE "${SRC_DIR}/build_cmake.bat"
-  "call \"${VCVARS32}\"\n"
-  "cd %~dp0\n"
-  "${PERL} Configure no-asm debug-VC-WIN32 --prefix=${INSTALL_DIR_N}\n"
-  "call ms\\do_ms.bat\n"
-  "nmake -f ms\\nt.mak install\n"
-  )
-
-set(BUILD_CMAKE_BAT "${SRC_DIR}/build_cmake.bat")
-file(TO_NATIVE_PATH ${BUILD_CMAKE_BAT} BUILD_CMAKE_BAT_N)
-execute_process(
-  COMMAND cmd /c ${BUILD_CMAKE_BAT_N}
-  WORKING_DIRECTORY ${SRC_DIR}
-  RESULT_VARIABLE rv
-  )
-if(NOT rv STREQUAL "0")
-  message(FATAL_ERROR "cmake build fail ${rv}")
-endif()
-

Added: branches/cmake/libs/script_support.cmake
===================================================================
--- branches/cmake/libs/script_support.cmake	                        (rev 0)
+++ branches/cmake/libs/script_support.cmake	2018-07-31 15:28:11 UTC (rev 7171)
@@ -0,0 +1,29 @@
+# TOOLSET	ツールセット名
+if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
+  if(${CMAKE_GENERATOR} MATCHES "Visual Studio 15 2017")
+	set(MSVC_TOOLSET_VERSION 141)
+  elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 14 2015")
+	set(MSVC_TOOLSET_VERSION 140)
+  elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 12 2013")
+	set(MSVC_TOOLSET_VERSION 120)
+  elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 11 2012")
+	set(MSVC_TOOLSET_VERSION 110)
+  elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 10 2010")
+	set(MSVC_TOOLSET_VERSION 100)
+  elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 9 2008")
+	set(MSVC_TOOLSET_VERSION 90)
+  else()
+	set(MSVC_TOOLSET_VERSION "Unknown")
+	message(FATAL_ERROR "unknown Visual Studio ${CMAKE_GENERATOR}")
+  endif()
+  set(TOOLSET "VS_${MSVC_TOOLSET_VERSION}")
+elseif((${CMAKE_GENERATOR} MATCHES "Unix Makefiles") OR
+	(${CMAKE_GENERATOR} MATCHES "MSYS Makefiles") OR
+	(${CMAKE_GENERATOR} MATCHES "MinGW Makefiles") OR
+	(${CMAKE_GENERATOR} MATCHES "Ninja"))
+  set(TOOLSET "mingw")
+elseif(${CMAKE_GENERATOR} MATCHES "NMake Makefiles")
+  set(TOOLSET "VS_NMake")
+else()
+	message(FATAL_ERROR "unknown GENERATOR ${CMAKE_GENERATOR}")
+endif()

Modified: branches/cmake/libs/zlib.cmake
===================================================================
--- branches/cmake/libs/zlib.cmake	2018-07-29 14:17:09 UTC (rev 7170)
+++ branches/cmake/libs/zlib.cmake	2018-07-31 15:28:11 UTC (rev 7171)
@@ -1,7 +1,53 @@
-# cmake -DGENERATOR="Visual Studio 15 2017" -P zlib.cmake
+# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -P zlib.cmake
+# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -DCMAKE_CONFIGURATION_TYPE=Release -P zlib.cmake
 
-string(REPLACE " " "_" GENERATOR_ ${GENERATOR})
+####
+if(("${CMAKE_BUILD_TYPE}" STREQUAL "") AND ("${CMAKE_CONFIGURATION_TYPE}" STREQUAL ""))
+  if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
+	# multi-configuration
+	execute_process(
+	  COMMAND ${CMAKE_COMMAND}
+	  -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
+	  -DCMAKE_CONFIGURATION_TYPE=Release
+	  -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake
+	  -P zlib.cmake
+	  )
+	execute_process(
+	  COMMAND ${CMAKE_COMMAND}
+	  -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
+	  -DCMAKE_CONFIGURATION_TYPE=Debug
+	  -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake
+	  -P zlib.cmake
+	  )
+	return()
+  elseif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")
+	# mingw
+	# single-configuration
+	if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "")
+	  set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/../mingw.toolchain.cmake")
+	endif()
+	if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+	  set(CMAKE_BUILD_TYPE Release)
+	endif()
+  elseif("${CMAKE_GENERATOR}" MATCHES "NMake Makefiles")
+	# VS nmake
+	# single-configuration
+	if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "")
+	  set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/VSToolchain.cmake")
+	endif()
+	if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+	  set(CMAKE_BUILD_TYPE Release)
+	endif()
+  else()
+	# single-configuration
+	if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+	  set(CMAKE_BUILD_TYPE Release)
+	endif()
+  endif()
+endif()
 
+include(script_support.cmake)
+
 set(SRC_DIR_BASE "zlib-1.2.11")
 set(SRC_ARC "zlib-1.2.11.tar.xz")
 set(SRC_URL "https://zlib.net/zlib-1.2.11.tar.xz")
@@ -10,9 +56,11 @@
 set(DOWN_DIR "${CMAKE_SOURCE_DIR}/donwload/zlib")
 set(EXTRACT_DIR "${CMAKE_SOURCE_DIR}/build/zlib/src")
 set(SRC_DIR "${CMAKE_SOURCE_DIR}/build/zlib/src/${SRC_DIR_BASE}")
-set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build/zlib/build_${GENERATOR_}")
-set(INSTALL_DIR "${CMAKE_SOURCE_DIR}/zlib_${GENERATOR_}")
+set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build/zlib/build_${TOOLSET}")
+set(INSTALL_DIR "${CMAKE_SOURCE_DIR}/zlib_${TOOLSET}")
 
+########################################
+
 if(NOT EXISTS ${SRC_DIR}/README)
 
   file(DOWNLOAD
@@ -22,9 +70,7 @@
     SHOW_PROGRESS
     )
 
-  execute_process(
-    COMMAND ${CMAKE_COMMAND} -E make_directory ${EXTRACT_DIR}
-    )
+  file(MAKE_DIRECTORY ${EXTRACT_DIR})
 
   execute_process(
     COMMAND ${CMAKE_COMMAND} -E tar "xvf" ${DOWN_DIR}/${SRC_ARC}
@@ -37,53 +83,53 @@
 
 file(MAKE_DIRECTORY "${BUILD_DIR}")
 
-execute_process(
-  COMMAND ${CMAKE_COMMAND} ${SRC_DIR} -G ${GENERATOR}
-  -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake
-  -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
-  WORKING_DIRECTORY ${BUILD_DIR}
-  RESULT_VARIABLE rv
-  )
-if(NOT rv STREQUAL "0")
-  message(FATAL_ERROR "cmake generate fail ${rv}")
-endif()
+if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
 
-########################################
+  ######################################## multi configuration
 
-execute_process(
-  COMMAND ${CMAKE_COMMAND} --build . --config release
-  WORKING_DIRECTORY ${BUILD_DIR}
-  RESULT_VARIABLE rv
-  )
-if(NOT rv STREQUAL "0")
-  message(FATAL_ERROR "cmake build fail ${rv}")
-endif()
+  execute_process(
+	COMMAND ${CMAKE_COMMAND} ${SRC_DIR} -G ${CMAKE_GENERATOR}
+	-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
+	-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
+	${TOOLCHAINFILE}
+	WORKING_DIRECTORY ${BUILD_DIR}
+	RESULT_VARIABLE rv
+	)
+  if(NOT rv STREQUAL "0")
+	message(FATAL_ERROR "cmake generate fail ${rv}")
+  endif()
 
-execute_process(
-  COMMAND ${CMAKE_COMMAND} --build . --config release --target install
-  WORKING_DIRECTORY ${BUILD_DIR}
-  RESULT_VARIABLE rv
-  )
-if(NOT rv STREQUAL "0")
-  message(FATAL_ERROR "cmake install fail ${rv}")
-endif()
+  execute_process(
+	COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_CONFIGURATION_TYPE} --target install
+	WORKING_DIRECTORY ${BUILD_DIR}
+	RESULT_VARIABLE rv
+	)
+  if(NOT rv STREQUAL "0")
+	message(FATAL_ERROR "cmake install fail ${rv}")
+  endif()
 
-########################################
+else()
+  ######################################## single configuration
+  
+  execute_process(
+	COMMAND ${CMAKE_COMMAND} ${SRC_DIR} -G ${CMAKE_GENERATOR}
+	-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+	-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
+	-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
+	WORKING_DIRECTORY ${BUILD_DIR}
+	RESULT_VARIABLE rv
+	)
+  if(NOT rv STREQUAL "0")
+	message(FATAL_ERROR "cmake build fail ${rv}")
+  endif()
+  
+  execute_process(
+	COMMAND ${CMAKE_COMMAND} --build . --target install
+	WORKING_DIRECTORY ${BUILD_DIR}
+	RESULT_VARIABLE rv
+	)
+  if(NOT rv STREQUAL "0")
+	message(FATAL_ERROR "cmake install fail ${rv}")
+  endif()
 
-execute_process(
-  COMMAND ${CMAKE_COMMAND} --build . --config debug
-  WORKING_DIRECTORY ${BUILD_DIR}
-  RESULT_VARIABLE rv
-  )
-if(NOT rv STREQUAL "0")
-  message(FATAL_ERROR "cmake build fail ${rv}")
 endif()
-
-execute_process(
-  COMMAND ${CMAKE_COMMAND} --build . --config debug --target install
-  WORKING_DIRECTORY ${BUILD_DIR}
-  RESULT_VARIABLE rv
-  )
-if(NOT rv STREQUAL "0")
-  message(FATAL_ERROR "cmake install fail ${rv}")
-endif()

Modified: branches/cmake/teraterm/teraterm/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/teraterm/CMakeLists.txt	2018-07-29 14:17:09 UTC (rev 7170)
+++ branches/cmake/teraterm/teraterm/CMakeLists.txt	2018-07-31 15:28:11 UTC (rev 7171)
@@ -107,9 +107,9 @@
 
 set(CMAKE_MFC_FLAG 1)
 
-set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/NODEFAULTLIB:nafxcw.lib /NODEFAULTLIB:LIBCMT.lib")
-set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:nafxcwd.lib /NODEFAULTLIB:LIBCMTD.lib")
-set(CMAKE_EXE_LINKER_FLAGS "/DELAYLOAD:imagehlp.dll /DELAYLOAD:user32.dll /DELAYLOAD:shell32.dll")
+set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:nafxcw.lib /NODEFAULTLIB:LIBCMT.lib")
+set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:nafxcwd.lib /NODEFAULTLIB:LIBCMTD.lib")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:imagehlp.dll /DELAYLOAD:user32.dll /DELAYLOAD:shell32.dll")
 
 add_executable(
   teraterm WIN32
@@ -132,6 +132,7 @@
   ws2_32.lib
   imm32.lib
   imagehlp.lib
+  delayimp.lib
   )
 
 add_dependencies(

Modified: branches/cmake/teraterm/ttpmacro/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttpmacro/CMakeLists.txt	2018-07-29 14:17:09 UTC (rev 7170)
+++ branches/cmake/teraterm/ttpmacro/CMakeLists.txt	2018-07-31 15:28:11 UTC (rev 7171)
@@ -75,9 +75,9 @@
 
 set(CMAKE_MFC_FLAG 1)
 
-set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/NODEFAULTLIB:nafxcw.lib /NODEFAULTLIB:LIBCMT.lib")
-set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:nafxcwd.lib /NODEFAULTLIB:LIBCMTD.lib")
-set(CMAKE_EXE_LINKER_FLAGS "/DELAYLOAD:iphlpapi.dll /DELAYLOAD:user32.dll")
+set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:nafxcw.lib /NODEFAULTLIB:LIBCMT.lib")
+set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:nafxcwd.lib /NODEFAULTLIB:LIBCMTD.lib")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:iphlpapi.dll /DELAYLOAD:user32.dll")
 
 add_executable(
   ttpmacro WIN32
@@ -96,6 +96,7 @@
   optimized sfmt.lib
   debug sfmtd.lib
   iphlpapi.lib
+  delayimp.lib
   )
 
 add_dependencies(



Ttssh2-commit メーリングリストの案内