cmake,MinGWビルド時のcygtool.dll が inno_setup から使えるよう修正
- cygtool.dllでエクスポートしている関数(symbol)のデコレーション
- MinGWのlink時、-Wl,--add-stdcall-alias オプションを追加
- cygtool.h (r9836で追加)にファイルヘッダを追加
- プロトタイプに declspec(dllexport) を追加
- cygwin/cygtool/CMakeLists.txt
- cygwin/CMakeLists.txt
- cygwin/cygtool_build/CMakeLists.txt
@@ -31,9 +31,9 @@ | ||
31 | 31 | # other build system... |
32 | 32 | if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0") |
33 | 33 | add_subdirectory(cygtool_build) |
34 | - if(TARGET cygtool_build) | |
34 | + if(TARGET cygtool) | |
35 | 35 | set_target_properties( |
36 | - cygtool_build | |
36 | + cygtool | |
37 | 37 | PROPERTIES FOLDER cygwin) |
38 | 38 | endif() |
39 | 39 | endif() |
@@ -7,28 +7,24 @@ | ||
7 | 7 | add_library( |
8 | 8 | ${PACKAGE_NAME} SHARED |
9 | 9 | cygtool.c |
10 | - cygtool.def | |
10 | + cygtool.h | |
11 | 11 | ) |
12 | - | |
13 | 12 | if(MSVC) |
14 | - target_compile_options( | |
13 | + target_sources( | |
15 | 14 | ${PACKAGE_NAME} |
16 | 15 | PRIVATE |
17 | - -MT | |
16 | + cygtool.def | |
18 | 17 | ) |
19 | 18 | endif() |
20 | 19 | |
21 | 20 | if(MINGW) |
22 | 21 | # 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 | + ) | |
32 | 28 | endif() |
33 | 29 | |
34 | 30 | if(SUPPORT_OLD_WINDOWS) |
@@ -48,6 +44,14 @@ | ||
48 | 44 | endif() |
49 | 45 | endif(SUPPORT_OLD_WINDOWS) |
50 | 46 | |
47 | +if(MINGW) | |
48 | + set_target_properties( | |
49 | + ${PACKAGE_NAME} | |
50 | + PROPERTIES PREFIX "" | |
51 | + SUFFIX ".dll" | |
52 | + ) | |
53 | +endif() | |
54 | + | |
51 | 55 | target_link_libraries( |
52 | 56 | ${PACKAGE_NAME} |
53 | 57 | PRIVATE |
@@ -62,14 +66,9 @@ | ||
62 | 66 | |
63 | 67 | install( |
64 | 68 | TARGETS ${PACKAGE_NAME} |
65 | - DESTINATION . | |
69 | + RUNTIME DESTINATION . | |
66 | 70 | ) |
67 | 71 | |
68 | -install( | |
69 | - TARGETS ${PACKAGE_NAME} | |
70 | - DESTINATION . | |
71 | - ) | |
72 | - | |
73 | 72 | ###### cygtool_tester |
74 | 73 | |
75 | 74 | add_executable( |
@@ -77,12 +76,6 @@ | ||
77 | 76 | cygtool_tester.c |
78 | 77 | ) |
79 | 78 | |
80 | -target_compile_options( | |
81 | - cygtool_tester | |
82 | - PRIVATE | |
83 | - -I ${CMAKE_CURRENT_LIST_DIR}/../../teraterm/common | |
84 | - ) | |
85 | - | |
86 | 79 | target_link_libraries( |
87 | 80 | cygtool_tester |
88 | 81 | PRIVATE |
@@ -30,6 +30,7 @@ | ||
30 | 30 | #include <stdio.h> |
31 | 31 | #include <wchar.h> |
32 | 32 | |
33 | +#define CYGTOOL_DLL | |
33 | 34 | #include "cygtool.h" |
34 | 35 | |
35 | 36 | int __stdcall FindCygwinPath(const wchar_t *CygwinDirectory, wchar_t *Dir, size_t Dirlen) |
@@ -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 | + */ | |
1 | 28 | |
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); |
@@ -1,12 +1,13 @@ | ||
1 | -# VS 32bit 以外のビルドシステムから cygtool をビルドする | |
1 | +# 32bit Windows 用 cygtool をビルドする | |
2 | 2 | |
3 | 3 | cmake_minimum_required(VERSION 3.13) # for Generator-Expression |
4 | 4 | |
5 | -if(NOT ("${CMAKE_GENERATOR}" MATCHES "Visual Studio")) | |
6 | - # 現在VS以外はうまくっていない | |
5 | +if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux") | |
6 | + # linux上ではcygwin関連はビルドしない | |
7 | 7 | return() |
8 | 8 | endif() |
9 | 9 | |
10 | +set(CYGTOOL_DIR "${CMAKE_CURRENT_LIST_DIR}/../cygtool") | |
10 | 11 | if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") |
11 | 12 | set(BINARY_DIR "${CMAKE_BINARY_DIR}/$<CONFIG>") |
12 | 13 | else() |
@@ -14,14 +15,15 @@ | ||
14 | 15 | endif() |
15 | 16 | |
16 | 17 | 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 | |
20 | 21 | ) |
21 | 22 | |
22 | 23 | add_custom_target( |
23 | - cygtool_build ALL | |
24 | + cygtool ALL | |
24 | 25 | DEPENDS ${BINARY_DIR}/cygtool.dll |
26 | + DEPENDS ${SRC} | |
25 | 27 | SOURCES ${SRC} |
26 | 28 | ) |
27 | 29 |
@@ -30,7 +32,11 @@ | ||
30 | 32 | add_custom_command( |
31 | 33 | OUTPUT ${BINARY_DIR}/cygtool.dll |
32 | 34 | 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 | |
34 | 40 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cygtool_build |
35 | 41 | ) |
36 | 42 |