• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision9877 (tree)
Time2022-04-21 22:40:43
Authorzmatsuo

Log Message

cmake,MinGWビルド時のcygtool.dll が inno_setup から使えるよう修正

- cygtool.dllでエクスポートしている関数(symbol)のデコレーション

- VS, stdcall + def file
- symbol
- inno setup の例で示されている方法
- MinGW, stdcall
- symbol@n
- inno setup では使えない
- MinGW,stdcall + -add-stdcall-alias
- symbol + symbol@n

- MinGWのlink時、-Wl,--add-stdcall-alias オプションを追加
- cygtool.h (r9836で追加)にファイルヘッダを追加

- declspec(dllexport),declspec(import)を追加
- cygtool_tester から使用

- プロトタイプに declspec(dllexport) を追加

- def ファイルを使用せずに export するため

- cygwin/cygtool/CMakeLists.txt

- install() を2つ記述していたので1つを削除
- dll以外に .lib(.a) もインストールしていたので削除

- cygwin/CMakeLists.txt

- 32bitビルドの時はcygtoolをそのままaddするようにした

- cygwin/cygtool_build/CMakeLists.txt

- 64bit MinGW時もビルドできるよう修正
- ターゲット名を cygtool に変更
- inno_setup が cygtool に依存している
- 32bitでも64bitでも同じターゲット名のほうが都合が良いため

Change Summary

Incremental Difference

--- trunk/cygwin/CMakeLists.txt (revision 9876)
+++ trunk/cygwin/CMakeLists.txt (revision 9877)
@@ -31,9 +31,9 @@
3131 # other build system...
3232 if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0")
3333 add_subdirectory(cygtool_build)
34- if(TARGET cygtool_build)
34+ if(TARGET cygtool)
3535 set_target_properties(
36- cygtool_build
36+ cygtool
3737 PROPERTIES FOLDER cygwin)
3838 endif()
3939 endif()
--- trunk/cygwin/cygtool/CMakeLists.txt (revision 9876)
+++ trunk/cygwin/cygtool/CMakeLists.txt (revision 9877)
@@ -7,28 +7,24 @@
77 add_library(
88 ${PACKAGE_NAME} SHARED
99 cygtool.c
10- cygtool.def
10+ cygtool.h
1111 )
12-
1312 if(MSVC)
14- target_compile_options(
13+ target_sources(
1514 ${PACKAGE_NAME}
1615 PRIVATE
17- -MT
16+ cygtool.def
1817 )
1918 endif()
2019
2120 if(MINGW)
2221 # libgcc_s_dw2-1.dll に依存しないため
23- if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13.0")
24- target_link_options(
25- ${PACKAGE_NAME}
26- PRIVATE
27- -static-libgcc
28- )
29- else()
30- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc")
31- endif()
22+ target_link_options(
23+ ${PACKAGE_NAME}
24+ PRIVATE
25+ -static-libgcc
26+ -Wl,--add-stdcall-alias
27+ )
3228 endif()
3329
3430 if(SUPPORT_OLD_WINDOWS)
@@ -48,6 +44,14 @@
4844 endif()
4945 endif(SUPPORT_OLD_WINDOWS)
5046
47+if(MINGW)
48+ set_target_properties(
49+ ${PACKAGE_NAME}
50+ PROPERTIES PREFIX ""
51+ SUFFIX ".dll"
52+ )
53+endif()
54+
5155 target_link_libraries(
5256 ${PACKAGE_NAME}
5357 PRIVATE
@@ -62,14 +66,9 @@
6266
6367 install(
6468 TARGETS ${PACKAGE_NAME}
65- DESTINATION .
69+ RUNTIME DESTINATION .
6670 )
6771
68-install(
69- TARGETS ${PACKAGE_NAME}
70- DESTINATION .
71- )
72-
7372 ###### cygtool_tester
7473
7574 add_executable(
@@ -77,12 +76,6 @@
7776 cygtool_tester.c
7877 )
7978
80-target_compile_options(
81- cygtool_tester
82- PRIVATE
83- -I ${CMAKE_CURRENT_LIST_DIR}/../../teraterm/common
84- )
85-
8679 target_link_libraries(
8780 cygtool_tester
8881 PRIVATE
--- trunk/cygwin/cygtool/cygtool.c (revision 9876)
+++ trunk/cygwin/cygtool/cygtool.c (revision 9877)
@@ -30,6 +30,7 @@
3030 #include <stdio.h>
3131 #include <wchar.h>
3232
33+#define CYGTOOL_DLL
3334 #include "cygtool.h"
3435
3536 int __stdcall FindCygwinPath(const wchar_t *CygwinDirectory, wchar_t *Dir, size_t Dirlen)
--- trunk/cygwin/cygtool/cygtool.h (revision 9876)
+++ trunk/cygwin/cygtool/cygtool.h (revision 9877)
@@ -1,4 +1,39 @@
1+/*
2+ * Copyright (C) 2022- TeraTerm Project
3+ * All rights reserved.
4+ *
5+ * Redistribution and use in source and binary forms, with or without
6+ * modification, are permitted provided that the following conditions
7+ * are met:
8+ *
9+ * 1. Redistributions of source code must retain the above copyright
10+ * notice, this list of conditions and the following disclaimer.
11+ * 2. Redistributions in binary form must reproduce the above copyright
12+ * notice, this list of conditions and the following disclaimer in the
13+ * documentation and/or other materials provided with the distribution.
14+ * 3. The name of the author may not be used to endorse or promote products
15+ * derived from this software without specific prior written permission.
16+ *
17+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
18+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+ */
128
2-int __stdcall FindCygwinPath(const wchar_t *CygwinDirectory, wchar_t *Dir, size_t Dirlen);
3-int __stdcall PortableExecutableMachine(const wchar_t *file);
4-int __stdcall CygwinVersion(const wchar_t *dll, int *major, int *minor);
29+#pragma once
30+
31+#ifdef CYGTOOL_DLL
32+#define CYGTOOL_API __declspec(dllexport)
33+#else
34+#define CYGTOOL_API __declspec(dllimport)
35+#endif
36+
37+CYGTOOL_API int __stdcall FindCygwinPath(const wchar_t *CygwinDirectory, wchar_t *Dir, size_t Dirlen);
38+CYGTOOL_API int __stdcall PortableExecutableMachine(const wchar_t *file);
39+CYGTOOL_API int __stdcall CygwinVersion(const wchar_t *dll, int *major, int *minor);
--- trunk/cygwin/cygtool_build/CMakeLists.txt (revision 9876)
+++ trunk/cygwin/cygtool_build/CMakeLists.txt (revision 9877)
@@ -1,12 +1,13 @@
1-# VS 32bit 以外のビルドシステムから cygtool をビルドする
1+# 32bit Windows 用 cygtool をビルドする
22
33 cmake_minimum_required(VERSION 3.13) # for Generator-Expression
44
5-if(NOT ("${CMAKE_GENERATOR}" MATCHES "Visual Studio"))
6- # 現在VS以外はうまくっていない
5+if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux")
6+ # linux上ではcygwin関連はビルドしない
77 return()
88 endif()
99
10+set(CYGTOOL_DIR "${CMAKE_CURRENT_LIST_DIR}/../cygtool")
1011 if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
1112 set(BINARY_DIR "${CMAKE_BINARY_DIR}/$<CONFIG>")
1213 else()
@@ -14,14 +15,15 @@
1415 endif()
1516
1617 set(SRC
17- ${CMAKE_CURRENT_LIST_DIR}/../cygtool/cygtool.c
18- ${CMAKE_CURRENT_LIST_DIR}/../cygtool/cygtool.h
19- ${CMAKE_CURRENT_LIST_DIR}/../cygtool/cygtool.def
18+ ${CYGTOOL_DIR}/cygtool.c
19+ ${CYGTOOL_DIR}/cygtool.h
20+ ${CYGTOOL_DIR}/cygtool.def
2021 )
2122
2223 add_custom_target(
23- cygtool_build ALL
24+ cygtool ALL
2425 DEPENDS ${BINARY_DIR}/cygtool.dll
26+ DEPENDS ${SRC}
2527 SOURCES ${SRC}
2628 )
2729
@@ -30,7 +32,11 @@
3032 add_custom_command(
3133 OUTPUT ${BINARY_DIR}/cygtool.dll
3234 DEPENDS ${SRC}
33- COMMAND ${CMAKE_COMMAND} -DCMAKE_GENERATOR=${CMAKE_GENERATOR} -DCMAKE_INSTALL_PREFIX=${BINARY_DIR} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -P ${CMAKE_CURRENT_LIST_DIR}/../cygtool/build_cygtool.cmake
35+ COMMAND ${CMAKE_COMMAND}
36+ -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
37+ -DCMAKE_INSTALL_PREFIX=${BINARY_DIR}
38+ -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
39+ -P ${CYGTOOL_DIR}/build_cygtool.cmake
3440 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cygtool_build
3541 )
3642
Show on old repository browser