[Ttssh2-commit] [7258] libs/ ビルドできるよう調整

scmno****@osdn***** scmno****@osdn*****
2018年 11月 4日 (日) 00:33:55 JST


Revision: 7258
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7258
Author:   zmatsuo
Date:     2018-11-04 00:33:55 +0900 (Sun, 04 Nov 2018)
Log Message:
-----------
libs/ ビルドできるよう調整

Modified Paths:
--------------
    branches/cmake/00memo.md
    branches/cmake/CMakeLists.txt
    branches/cmake/TTProxy/StdAfx.cpp
    branches/cmake/TTXKanjiMenu/CMakeLists.txt
    branches/cmake/TTXSamples/TTXCommandLineOpt/CMakeLists.txt
    branches/cmake/libs/SFMT.cmake
    branches/cmake/libs/buildall_cmake.bat
    branches/cmake/libs/oniguruma.cmake
    branches/cmake/libs/openssl.cmake
    branches/cmake/libs/zlib.cmake
    branches/cmake/mingw.toolchain.cmake
    branches/cmake/teraterm/common/tmfc.cpp
    branches/cmake/teraterm/common/tmfc_frame.cpp
    branches/cmake/teraterm/teraterm/ttermpro.rc
    branches/cmake/ttpmenu/CMakeLists.txt

Added Paths:
-----------
    branches/cmake/libs/build_library_with_cmake.md

-------------- next part --------------
Modified: branches/cmake/00memo.md
===================================================================
--- branches/cmake/00memo.md	2018-11-03 15:33:38 UTC (rev 7257)
+++ branches/cmake/00memo.md	2018-11-03 15:33:55 UTC (rev 7258)
@@ -3,3 +3,9 @@
 cmake -DCMAKE_FIND_ROOT_PATH=/usr/i686-w64-mingw32 -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++ -DCMAKE_RC_COMPILER=i686-w64-mingw32-windres .. -G "Unix Makefiles"
 
 cmake -DCMAKE_FIND_ROOT_PATH=/usr/i686-w64-mingw32 -DCMAKE_C_COMPILER=i686-w64-mingw32-clang -DCMAKE_CXX_COMPILER=i686-w64-mingw32-clang++ -DCMAKE_RC_COMPILER=i686-w64-mingw32-windres .. -G "Unix Makefiles"
+
+# mingw on linux
+
+CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ cmake -DCMAKE_RC_COMPILER i686-mingw32-windres .. -G "Unix Makefiles"
+
+cmake -DCMAKE_TOOLCHAIN_FILE=../gcc-cross-compiler-i686.cmake .. -G "Unix Makefiles"

Modified: branches/cmake/CMakeLists.txt
===================================================================
--- branches/cmake/CMakeLists.txt	2018-11-03 15:33:38 UTC (rev 7257)
+++ branches/cmake/CMakeLists.txt	2018-11-03 15:33:55 UTC (rev 7258)
@@ -3,11 +3,13 @@
 
 project(teraterm_all)
 
+option(ENABLE_TTXSAMPLES "TTXSamples" ON)
+
 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
 
-option(ENABLE_TTXSAMPLES "TTXSamples" ON)
-
 set(CMAKE_CONFIGURATION_TYPES "Debug;Release")
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
 
 if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
   string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})

Modified: branches/cmake/TTProxy/StdAfx.cpp
===================================================================
--- branches/cmake/TTProxy/StdAfx.cpp	2018-11-03 15:33:38 UTC (rev 7257)
+++ branches/cmake/TTProxy/StdAfx.cpp	2018-11-03 15:33:55 UTC (rev 7258)
@@ -2,7 +2,7 @@
 //              ttx.pch \x90\xB6\x90\xAC\x82\xB3\x82\xEA\x82\xE9\x83v\x83\x8A\x83R\x83\x93\x83p\x83C\x83\x8B\x8Dσw\x83b\x83_\x81[
 //              stdafx.obj \x90\xB6\x90\xAC\x82\xB3\x82\xEA\x82\xE9\x83v\x83\x8A\x83R\x83\x93\x83p\x83C\x83\x8B\x8Dσ^\x83C\x83v\x8F\xEE\x95\xF1
 
-#include "stdafx.h"
+#include "StdAfx.h"
 
 // TODO: STDAFX.H \x82Ɋ܂܂\xEA\x82Ă\xA2\x82āA\x82\xB1\x82̃t\x83@\x83C\x83\x8B\x82ɋL\x8Fq\x82\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xA2
 // \x83w\x83b\x83_\x81[\x83t\x83@\x83C\x83\x8B\x82\xF0\x92lj\xC1\x82\xB5\x82Ă\xAD\x82\xBE\x82\xB3\x82\xA2\x81B

Modified: branches/cmake/TTXKanjiMenu/CMakeLists.txt
===================================================================
--- branches/cmake/TTXKanjiMenu/CMakeLists.txt	2018-11-03 15:33:38 UTC (rev 7257)
+++ branches/cmake/TTXKanjiMenu/CMakeLists.txt	2018-11-03 15:33:55 UTC (rev 7258)
@@ -1,7 +1,5 @@
 project(ttxkanjimenu)
 
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/")
-
 set(SRC
   resource.h
   ttxkanjimenu.c

Modified: branches/cmake/TTXSamples/TTXCommandLineOpt/CMakeLists.txt
===================================================================
--- branches/cmake/TTXSamples/TTXCommandLineOpt/CMakeLists.txt	2018-11-03 15:33:38 UTC (rev 7257)
+++ branches/cmake/TTXSamples/TTXCommandLineOpt/CMakeLists.txt	2018-11-03 15:33:55 UTC (rev 7258)
@@ -28,6 +28,7 @@
   TTXCommandLineOpt
   PROPERTIES
   PREFIX ""
+  SUFFIX ".dll"
   )
 
 target_link_libraries(

Modified: branches/cmake/libs/SFMT.cmake
===================================================================
--- branches/cmake/libs/SFMT.cmake	2018-11-03 15:33:38 UTC (rev 7257)
+++ branches/cmake/libs/SFMT.cmake	2018-11-03 15:33:55 UTC (rev 7258)
@@ -20,6 +20,11 @@
 	  -P SFMT.cmake
 	  )
 	return()
+  elseif("$ENV{MSYSTEM}" MATCHES "MINGW32")
+	# mingw on msys2
+	if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+	  set(CMAKE_BUILD_TYPE Release)
+	endif()
   elseif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")
 	# mingw
 	# single-configuration

Added: branches/cmake/libs/build_library_with_cmake.md
===================================================================
--- branches/cmake/libs/build_library_with_cmake.md	                        (rev 0)
+++ branches/cmake/libs/build_library_with_cmake.md	2018-11-03 15:33:55 UTC (rev 7258)
@@ -0,0 +1,43 @@
+
+# libフォルダ
+
+- teratermが利用する外部のライブラリをビルドするためのフォルダ
+- コンパイラ向けに各々ビルドする
+- 1度ビルドしてライブラリを生成しておく
+
+# ビルド手順
+
+## Visual Studioの場合
+
+- buildall_cmake.bat を実行
+- cmakeを選択
+- コンパイルする Visual Studioを選ぶ
+
+## MinGW 共通
+
+- Cygwin,MSYS2,linux(wsl)上のMinGWでビルドできる
+- 各環境で動作するcmake,make,(MinGW)gcc,perlが必要
+- 各々の環境のcmakeを使って
+  `cmake -DCMAKE_GENERATOR="Unix Makefiles" -P buildall.cmake` を実行
+
+# 各フォルダについて
+
+## 生成されるライブラリフォルダ
+
+- 次のフォルダにライブラリの`*.h`,`*.lib`が生成される
+	- oniguruma_{compiler}
+	- openssl_{compiler}
+	- putty
+	- SFMT_{compiler}
+	- zlib_{compiler}
+
+## download アーカイブダウンロードフォルダ
+
+- ダウンロードしたアーカイブファイルが置かれます
+- 自動でダウンロードされます
+- ダウンロードされていると再利用する
+
+## build ビルドフォルダ
+
+- build/oniguruma_{compiler}/ などの下でビルドされます
+- ビルド後は参照する必要がなければ削除できます。

Modified: branches/cmake/libs/buildall_cmake.bat
===================================================================
--- branches/cmake/libs/buildall_cmake.bat	2018-11-03 15:33:38 UTC (rev 7257)
+++ branches/cmake/libs/buildall_cmake.bat	2018-11-03 15:33:55 UTC (rev 7258)
@@ -42,7 +42,7 @@
 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
+if "%no%" == "z" set GENERATOR="Unix Makefiles" & set OPT=-DCMAKE_TOOLCHAIN_FILE=../mingw.toolchain.cmake & goto build_all
 echo ? retry
 goto retry_vs
 

Modified: branches/cmake/libs/oniguruma.cmake
===================================================================
--- branches/cmake/libs/oniguruma.cmake	2018-11-03 15:33:38 UTC (rev 7257)
+++ branches/cmake/libs/oniguruma.cmake	2018-11-03 15:33:55 UTC (rev 7258)
@@ -20,6 +20,11 @@
 	  -P oniguruma.cmake
 	  )
 	return()
+  elseif("$ENV{MSYSTEM}" MATCHES "MINGW32")
+	# mingw on msys2
+	if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+	  set(CMAKE_BUILD_TYPE Release)
+	endif()
   elseif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")
 	# mingw
 	# single-configuration

Modified: branches/cmake/libs/openssl.cmake
===================================================================
--- branches/cmake/libs/openssl.cmake	2018-11-03 15:33:38 UTC (rev 7257)
+++ branches/cmake/libs/openssl.cmake	2018-11-03 15:33:55 UTC (rev 7258)
@@ -20,6 +20,12 @@
 	  -P openssl.cmake
 	  )
 	return()
+  elseif("$ENV{MSYSTEM}" MATCHES "MINGW32")
+	# mingw on msys2
+	# single-configuration
+	if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+	  set(CMAKE_BUILD_TYPE Release)
+	endif()
   elseif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")
 	# mingw
 	# single-configuration
@@ -78,13 +84,21 @@
 
 ########################################
 
-find_program(
-  PERL perl.exe
-  HINTS c:/Perl64/bin
-  HINTS c:/Perl/bin
-  HINTS c:/cygwin/usr/bin
-  HINTS c:/cygwin64/usr/bin
-  )
+if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux")
+  find_program(
+	PERL perl
+	)
+else()
+  # CYGWIN 
+  find_program(
+	PERL perl.exe
+	HINTS c:/Perl64/bin
+	HINTS c:/Perl/bin
+	HINTS c:/cygwin/usr/bin
+	HINTS c:/cygwin64/usr/bin
+	)
+endif()
+
 if(${PERL} STREQUAL "PERL-NOTFOUND")
   message(FATAL_ERROR "perl not found")
 endif()
@@ -220,19 +234,32 @@
   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")
+  if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux")
+	find_program(
+	  MAKE make
+	  )
+  else()
+	find_program(
+	  MAKE make.exe
+	  HINTS c:/cygwin/usr/bin
+	  HINTS c:/cygwin64/usr/bin
+	  )
+  endif()
+  set(ENV{PATH} "/usr/bin;/bin")
+  if("$ENV{MSYSTEM}" MATCHES "MINGW32")
+	set(CMAKE_C_COMPILER "cc")
+	set(PATH "/mingw32/bin:/usr/local/bin:/usr/bin:/bin")
+	message("compiler ${CMAKE_C_COMPILER} ${CMAKE_CXX_COMPILER}")
+  else()
+	include(${CMAKE_SOURCE_DIR}/../mingw.toolchain.cmake)
+	set(ENV{PREFIX} i686-w64-mingw32)
+	set(ENV{CC} ${CMAKE_C_COMPILER})
+	set(ENV{AR} "i686-w64-mingw32-ar")
+	set(ENV{RANLIB} "i686-w64-mingw32-ranlib")
+	set(PATH "/usr/bin:/bin")
+  endif()
   execute_process(
-	COMMAND ${PERL} ./Configure mingw --prefix=${INSTALL_DIR}
+	COMMAND ${CMAKE_COMMAND} -E env "PATH=/usr/bin:/bin" ${PERL} ./Configure mingw --prefix=${INSTALL_DIR}
 	WORKING_DIRECTORY ${SRC_DIR}
 	RESULT_VARIABLE rv
 	)
@@ -240,7 +267,7 @@
 	message(FATAL_ERROR "cmake configure fail ${rv}")
   endif()
   execute_process(
-	COMMAND ${MAKE}
+	COMMAND ${CMAKE_COMMAND} -E env "PATH=${PATH}" ${MAKE} CC=${CMAKE_C_COMPILER}
 	WORKING_DIRECTORY ${SRC_DIR}
 	RESULT_VARIABLE rv
 	)
@@ -248,7 +275,7 @@
 	message(FATAL_ERROR "cmake build fail ${rv}")
   endif()
   execute_process(
-	COMMAND ${MAKE} install
+	COMMAND ${CMAKE_COMMAND} -E env "PATH=${PATH}" ${MAKE} install
 	WORKING_DIRECTORY ${SRC_DIR}
 	RESULT_VARIABLE rv
 	)

Modified: branches/cmake/libs/zlib.cmake
===================================================================
--- branches/cmake/libs/zlib.cmake	2018-11-03 15:33:38 UTC (rev 7257)
+++ branches/cmake/libs/zlib.cmake	2018-11-03 15:33:55 UTC (rev 7258)
@@ -20,6 +20,11 @@
 	  -P zlib.cmake
 	  )
 	return()
+  elseif("$ENV{MSYSTEM}" MATCHES "MINGW32")
+	# mingw on msys2
+	if("${CMAKE_BUILD_TYPE}" STREQUAL "")
+	  set(CMAKE_BUILD_TYPE Release)
+	endif()
   elseif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")
 	# mingw
 	# single-configuration

Modified: branches/cmake/mingw.toolchain.cmake
===================================================================
--- branches/cmake/mingw.toolchain.cmake	2018-11-03 15:33:38 UTC (rev 7257)
+++ branches/cmake/mingw.toolchain.cmake	2018-11-03 15:33:55 UTC (rev 7258)
@@ -1,31 +1,35 @@
-# how to build:
-# mkdir build; cd build
-# cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../mingw.toolchain.cmake
-# cmake --build .
-
-set(CMAKE_SYSTEM_NAME Windows)
-
-if(0)
-  set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
-  if(1)
-	set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
-	set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
-  endif()
-  if(0)
-	set(CMAKE_C_COMPILER x86_64-w64-mingw32-clang)
-	set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-clang++)
-  endif()
-  set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
-else()
-  set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
-  set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
-  set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
-  set(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
-endif()
-
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -static -static-libgcc -static-libstdc++ -ffunction-sections -fdata-sections" CACHE STRING "")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -static -static-libgcc -static-libstdc++ -ffunction-sections -fdata-sections" CACHE STRING "")
-set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -s -Wl,--gc-sections" CACHE STRING "")
-set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++ -s -Wl,--gc-sections" CACHE STRING "")
-
-set(CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE} CACHE PATH "toolchain file")
+# how to build:
+# mkdir build; cd build
+# cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../mingw.toolchain.cmake
+# cmake --build .
+
+# target
+set(CMAKE_SYSTEM_NAME Windows)
+
+# option
+option(USE_CLANG "use clang compiler" OFF)
+
+# mingw on msys
+#set(CMAKE_SYSROOT /mingw32/i686-w64-mingw32)
+#set(CMAKE_FIND_ROOT_PATH /mingw32/i686-w64-mingw32)
+
+# mingw
+set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
+#set(CMAKE_SYSROOT /usr/i686-w64-mingw32)
+
+if(USE_CLANG)
+  set(CMAKE_C_COMPILER i686-w64-mingw32-clang)
+  set(CMAKE_CXX_COMPILER i686-w64-mingw32-clang++)
+else()
+  set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
+  set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
+endif()
+set(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
+
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
+
+set(CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE} CACHE PATH "toolchain file")
+

Modified: branches/cmake/teraterm/common/tmfc.cpp
===================================================================
--- branches/cmake/teraterm/common/tmfc.cpp	2018-11-03 15:33:38 UTC (rev 7257)
+++ branches/cmake/teraterm/common/tmfc.cpp	2018-11-03 15:33:55 UTC (rev 7258)
@@ -40,7 +40,8 @@
 // テンプレートの書き換えを行う
 #define REWRITE_TEMPLATE
 
-#if defined(_MSC_VER) && (_MSC_VER <= 1500)
+#if (defined(_MSC_VER) && (_MSC_VER <= 1500)) || \
+	(__cplusplus <= 199711L)
 #define nullptr NULL	// C++11,nullptr / > VS2010
 #endif
 

Modified: branches/cmake/teraterm/common/tmfc_frame.cpp
===================================================================
--- branches/cmake/teraterm/common/tmfc_frame.cpp	2018-11-03 15:33:38 UTC (rev 7257)
+++ branches/cmake/teraterm/common/tmfc_frame.cpp	2018-11-03 15:33:55 UTC (rev 7258)
@@ -32,7 +32,8 @@
 #include "tmfc.h"
 #include "ttlib.h"
 
-#if defined(_MSC_VER) && (_MSC_VER <= 1500)
+#if (defined(_MSC_VER) && (_MSC_VER <= 1500)) || \
+	(__cplusplus <= 199711L)
 #define nullptr NULL	// C++11,nullptr / > VS2010
 #endif
 

Modified: branches/cmake/teraterm/teraterm/ttermpro.rc
===================================================================
--- branches/cmake/teraterm/teraterm/ttermpro.rc	2018-11-03 15:33:38 UTC (rev 7257)
+++ branches/cmake/teraterm/teraterm/ttermpro.rc	2018-11-03 15:33:55 UTC (rev 7258)
@@ -1,7 +1,7 @@
 // Microsoft Visual C++ generated resource script.
 //
 #include <windows.h>
-#include "..\common\tt_res.h"
+#include "../common/tt_res.h"
 #define IDC_STATIC 0
 #define APSTUDIO_READONLY_SYMBOLS
 /////////////////////////////////////////////////////////////////////////////
@@ -488,14 +488,14 @@
 
 // Icon with lowest ID value placed first to ensure application icon
 // remains consistent on all systems.
-IDI_TTERM               ICON                    "..\\common\\teraterm.ico"
-IDI_VT                  ICON                    "..\\common\\vt.ico"
-IDI_TEK                 ICON                    "..\\common\\tek.ico"
-IDI_TTERM_CLASSIC       ICON                    "..\\common\\teraterm_classic.ico"
-IDI_VT_CLASSIC          ICON                    "..\\common\\vt_classic.ico"
-IDI_TTERM_3D            ICON                    "..\\common\\teraterm_3d.ico"
-IDI_VT_3D               ICON                    "..\\common\\vt_3d.ico"
-IDI_CYGTERM             ICON                    "..\\..\\cygterm\\cygterm.ico"
+IDI_TTERM               ICON                    "../common/teraterm.ico"
+IDI_VT                  ICON                    "../common/vt.ico"
+IDI_TEK                 ICON                    "../common/tek.ico"
+IDI_TTERM_CLASSIC       ICON                    "../common/teraterm_classic.ico"
+IDI_VT_CLASSIC          ICON                    "../common/vt_classic.ico"
+IDI_TTERM_3D            ICON                    "../common/teraterm_3d.ico"
+IDI_VT_3D               ICON                    "../common/vt_3d.ico"
+IDI_CYGTERM             ICON                    "../../cygterm/cygterm.ico"
 
 /////////////////////////////////////////////////////////////////////////////
 //

Modified: branches/cmake/ttpmenu/CMakeLists.txt
===================================================================
--- branches/cmake/ttpmenu/CMakeLists.txt	2018-11-03 15:33:38 UTC (rev 7257)
+++ branches/cmake/ttpmenu/CMakeLists.txt	2018-11-03 15:33:55 UTC (rev 7258)
@@ -31,8 +31,11 @@
 
 target_link_libraries(
   ttpmenu
-  version.lib
-  comctl32.lib
+  version
+  comctl32
+  user32
+  gdi32
+  comdlg32
   )
 
 


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