Skip to content

Commit fb1290b

Browse files
committed
Merge branch 'master' into release
2 parents 6f715a5 + 9271ef4 commit fb1290b

File tree

588 files changed

+80326
-142338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

588 files changed

+80326
-142338
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
[Rr]eleases/
2020
x64/
2121
x86/
22+
!/DeepSkyStackerKernel/simde/x86
2223
bld/
2324
[Bb]in/
2425
[Oo]bj/
@@ -32,6 +33,13 @@ bld/
3233
# Visual Studio 2017 auto generated files
3334
GeneratedFiles/
3435

36+
# CMake build directory
37+
build/
38+
out/build/
39+
40+
# vcpkg installed directories
41+
vcpkg_installed/
42+
3543
# MSTest test Results
3644
[Tt]est[Rr]esult*/
3745
[Bb]uild[Ll]og.*

CMake/Default.cmake

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
################################################################################
2+
# Command for variable_watch. This command issues error message, if a variable
3+
# is changed. If variable PROPERTY_READER_GUARD_DISABLED is TRUE nothing happens
4+
# variable_watch(<variable> property_reader_guard)
5+
################################################################################
6+
function(property_reader_guard VARIABLE ACCESS VALUE CURRENT_LIST_FILE STACK)
7+
if("${PROPERTY_READER_GUARD_DISABLED}")
8+
return()
9+
endif()
10+
11+
if("${ACCESS}" STREQUAL "MODIFIED_ACCESS")
12+
message(FATAL_ERROR
13+
" Variable ${VARIABLE} is not supposed to be changed.\n"
14+
" It is used only for reading target property ${VARIABLE}.\n"
15+
" Use\n"
16+
" set_target_properties(\"<target>\" PROPERTIES \"${VARIABLE}\" \"<value>\")\n"
17+
" or\n"
18+
" set_target_properties(\"<target>\" PROPERTIES \"${VARIABLE}_<CONFIG>\" \"<value>\")\n"
19+
" instead.\n")
20+
endif()
21+
endfunction()
22+
23+
################################################################################
24+
# Create variable <name> with generator expression that expands to value of
25+
# target property <name>_<CONFIG>. If property is empty or not set then property
26+
# <name> is used instead. Variable <name> has watcher property_reader_guard that
27+
# doesn't allow to edit it.
28+
# create_property_reader(<name>)
29+
# Input:
30+
# name - Name of watched property and output variable
31+
################################################################################
32+
function(create_property_reader NAME)
33+
set(PROPERTY_READER_GUARD_DISABLED TRUE)
34+
set(CONFIG_VALUE "$<TARGET_GENEX_EVAL:${PROPS_TARGET},$<TARGET_PROPERTY:${PROPS_TARGET},${NAME}_$<UPPER_CASE:$<CONFIG>>>>")
35+
set(IS_CONFIG_VALUE_EMPTY "$<STREQUAL:${CONFIG_VALUE},>")
36+
set(GENERAL_VALUE "$<TARGET_GENEX_EVAL:${PROPS_TARGET},$<TARGET_PROPERTY:${PROPS_TARGET},${NAME}>>")
37+
set("${NAME}" "$<IF:${IS_CONFIG_VALUE_EMPTY},${GENERAL_VALUE},${CONFIG_VALUE}>" PARENT_SCOPE)
38+
variable_watch("${NAME}" property_reader_guard)
39+
endfunction()
40+
41+
################################################################################
42+
# Set property $<name>_${PROPS_CONFIG_U} of ${PROPS_TARGET} to <value>
43+
# set_config_specific_property(<name> <value>)
44+
# Input:
45+
# name - Prefix of property name
46+
# value - New value
47+
################################################################################
48+
function(set_config_specific_property NAME VALUE)
49+
set_target_properties("${PROPS_TARGET}" PROPERTIES "${NAME}_${PROPS_CONFIG_U}" "${VALUE}")
50+
endfunction()
51+
52+
################################################################################
53+
54+
create_property_reader("TARGET_NAME")
55+
create_property_reader("OUTPUT_DIRECTORY")
56+
57+
set_config_specific_property("TARGET_NAME" "${PROPS_TARGET}")
58+
set_config_specific_property("OUTPUT_NAME" "${TARGET_NAME}")
59+
set_config_specific_property("ARCHIVE_OUTPUT_NAME" "${TARGET_NAME}")
60+
set_config_specific_property("LIBRARY_OUTPUT_NAME" "${TARGET_NAME}")
61+
set_config_specific_property("RUNTIME_OUTPUT_NAME" "${TARGET_NAME}")
62+
63+
set_config_specific_property("ARCHIVE_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}")
64+
set_config_specific_property("LIBRARY_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}")
65+
set_config_specific_property("RUNTIME_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}")

CMake/DefaultCXX.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
include("${CMAKE_CURRENT_LIST_DIR}/Default.cmake")
2+
3+
set_config_specific_property("OUTPUT_DIRECTORY" "${CMAKE_SOURCE_DIR}$<$<NOT:$<STREQUAL:${CMAKE_VS_PLATFORM_NAME},Win32>>:/${CMAKE_VS_PLATFORM_NAME}>/${PROPS_CONFIG}")
4+
5+
if(MSVC)
6+
create_property_reader("DEFAULT_CXX_EXCEPTION_HANDLING")
7+
create_property_reader("DEFAULT_CXX_DEBUG_INFORMATION_FORMAT")
8+
9+
set_target_properties("${PROPS_TARGET}" PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
10+
set_config_specific_property("DEFAULT_CXX_EXCEPTION_HANDLING" "/EHsc")
11+
set_config_specific_property("DEFAULT_CXX_DEBUG_INFORMATION_FORMAT" "/Zi")
12+
endif()

CMake/DefaultFortran.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
include("${CMAKE_CURRENT_LIST_DIR}/Default.cmake")
2+
3+
set_config_specific_property("OUTPUT_DIRECTORY" "${CMAKE_CURRENT_SOURCE_DIR}$<$<NOT:$<STREQUAL:${CMAKE_VS_PLATFORM_NAME},Win32>>:/${CMAKE_VS_PLATFORM_NAME}>/${PROPS_CONFIG}")
4+
5+
get_target_property(${PROPS_TARGET}_BINARY_DIR ${PROPS_TARGET} BINARY_DIR)
6+
set(DEFAULT_FORTRAN_MODULES_DIR "${${PROPS_TARGET}_BINARY_DIR}/${PROPS_TARGET}.Modules.dir")
7+
set_target_properties(${PROPS_TARGET} PROPERTIES Fortran_MODULE_DIRECTORY ${DEFAULT_FORTRAN_MODULES_DIR})
8+
9+
if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
10+
# Hack for visual studio generator (https://gitlab.kitware.com/cmake/cmake/issues/19552)
11+
add_custom_command(TARGET ${PROPS_TARGET} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_PROPERTY:${PROPS_TARGET},Fortran_MODULE_DIRECTORY>/${CMAKE_CFG_INTDIR})
12+
endif()

CMake/Utils.cmake

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
# utils file for projects came from visual studio solution with cmake-converter.
2+
3+
################################################################################
4+
# Wrap each token of the command with condition
5+
################################################################################
6+
cmake_policy(PUSH)
7+
cmake_policy(SET CMP0054 NEW)
8+
macro(prepare_commands)
9+
unset(TOKEN_ROLE)
10+
unset(COMMANDS)
11+
foreach(TOKEN ${ARG_COMMANDS})
12+
if("${TOKEN}" STREQUAL "COMMAND")
13+
set(TOKEN_ROLE "KEYWORD")
14+
elseif("${TOKEN_ROLE}" STREQUAL "KEYWORD")
15+
set(TOKEN_ROLE "CONDITION")
16+
elseif("${TOKEN_ROLE}" STREQUAL "CONDITION")
17+
set(TOKEN_ROLE "COMMAND")
18+
elseif("${TOKEN_ROLE}" STREQUAL "COMMAND")
19+
set(TOKEN_ROLE "ARG")
20+
endif()
21+
22+
if("${TOKEN_ROLE}" STREQUAL "KEYWORD")
23+
list(APPEND COMMANDS "${TOKEN}")
24+
elseif("${TOKEN_ROLE}" STREQUAL "CONDITION")
25+
set(CONDITION ${TOKEN})
26+
elseif("${TOKEN_ROLE}" STREQUAL "COMMAND")
27+
list(APPEND COMMANDS "$<$<NOT:${CONDITION}>:${DUMMY}>$<${CONDITION}:${TOKEN}>")
28+
elseif("${TOKEN_ROLE}" STREQUAL "ARG")
29+
list(APPEND COMMANDS "$<${CONDITION}:${TOKEN}>")
30+
endif()
31+
endforeach()
32+
endmacro()
33+
cmake_policy(POP)
34+
35+
################################################################################
36+
# Transform all the tokens to absolute paths
37+
################################################################################
38+
macro(prepare_output)
39+
unset(OUTPUT)
40+
foreach(TOKEN ${ARG_OUTPUT})
41+
if(IS_ABSOLUTE ${TOKEN})
42+
list(APPEND OUTPUT "${TOKEN}")
43+
else()
44+
list(APPEND OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${TOKEN}")
45+
endif()
46+
endforeach()
47+
endmacro()
48+
49+
################################################################################
50+
# Parse add_custom_command_if args.
51+
#
52+
# Input:
53+
# PRE_BUILD - Pre build event option
54+
# PRE_LINK - Pre link event option
55+
# POST_BUILD - Post build event option
56+
# TARGET - Target
57+
# OUTPUT - List of output files
58+
# DEPENDS - List of files on which the command depends
59+
# COMMANDS - List of commands(COMMAND condition1 commannd1 args1 COMMAND
60+
# condition2 commannd2 args2 ...)
61+
# Output:
62+
# OUTPUT - Output files
63+
# DEPENDS - Files on which the command depends
64+
# COMMENT - Comment
65+
# PRE_BUILD - TRUE/FALSE
66+
# PRE_LINK - TRUE/FALSE
67+
# POST_BUILD - TRUE/FALSE
68+
# TARGET - Target name
69+
# COMMANDS - Prepared commands(every token is wrapped in CONDITION)
70+
# NAME - Unique name for custom target
71+
# STEP - PRE_BUILD/PRE_LINK/POST_BUILD
72+
################################################################################
73+
function(add_custom_command_if_parse_arguments)
74+
cmake_parse_arguments("ARG" "PRE_BUILD;PRE_LINK;POST_BUILD" "TARGET;COMMENT" "DEPENDS;OUTPUT;COMMANDS" ${ARGN})
75+
76+
if(WIN32)
77+
set(DUMMY "cd.")
78+
elseif(UNIX)
79+
set(DUMMY "true")
80+
endif()
81+
82+
prepare_commands()
83+
prepare_output()
84+
85+
set(DEPENDS "${ARG_DEPENDS}")
86+
set(COMMENT "${ARG_COMMENT}")
87+
set(PRE_BUILD "${ARG_PRE_BUILD}")
88+
set(PRE_LINK "${ARG_PRE_LINK}")
89+
set(POST_BUILD "${ARG_POST_BUILD}")
90+
set(TARGET "${ARG_TARGET}")
91+
if(PRE_BUILD)
92+
set(STEP "PRE_BUILD")
93+
elseif(PRE_LINK)
94+
set(STEP "PRE_LINK")
95+
elseif(POST_BUILD)
96+
set(STEP "POST_BUILD")
97+
endif()
98+
set(NAME "${TARGET}_${STEP}")
99+
100+
set(OUTPUT "${OUTPUT}" PARENT_SCOPE)
101+
set(DEPENDS "${DEPENDS}" PARENT_SCOPE)
102+
set(COMMENT "${COMMENT}" PARENT_SCOPE)
103+
set(PRE_BUILD "${PRE_BUILD}" PARENT_SCOPE)
104+
set(PRE_LINK "${PRE_LINK}" PARENT_SCOPE)
105+
set(POST_BUILD "${POST_BUILD}" PARENT_SCOPE)
106+
set(TARGET "${TARGET}" PARENT_SCOPE)
107+
set(COMMANDS "${COMMANDS}" PARENT_SCOPE)
108+
set(STEP "${STEP}" PARENT_SCOPE)
109+
set(NAME "${NAME}" PARENT_SCOPE)
110+
endfunction()
111+
112+
################################################################################
113+
# Add conditional custom command
114+
#
115+
# Generating Files
116+
# The first signature is for adding a custom command to produce an output:
117+
# add_custom_command_if(
118+
# <OUTPUT output1 [output2 ...]>
119+
# <COMMANDS>
120+
# <COMMAND condition command1 [args1...]>
121+
# [COMMAND condition command2 [args2...]]
122+
# [DEPENDS [depends...]]
123+
# [COMMENT comment]
124+
#
125+
# Build Events
126+
# add_custom_command_if(
127+
# <TARGET target>
128+
# <PRE_BUILD | PRE_LINK | POST_BUILD>
129+
# <COMMAND condition command1 [args1...]>
130+
# [COMMAND condition command2 [args2...]]
131+
# [COMMENT comment]
132+
#
133+
# Input:
134+
# output - Output files the command is expected to produce
135+
# condition - Generator expression for wrapping the command
136+
# command - Command-line(s) to execute at build time.
137+
# args - Command`s args
138+
# depends - Files on which the command depends
139+
# comment - Display the given message before the commands are executed at
140+
# build time.
141+
# PRE_BUILD - Run before any other rules are executed within the target
142+
# PRE_LINK - Run after sources have been compiled but before linking the
143+
# binary
144+
# POST_BUILD - Run after all other rules within the target have been
145+
# executed
146+
################################################################################
147+
function(add_custom_command_if)
148+
add_custom_command_if_parse_arguments(${ARGN})
149+
150+
if(OUTPUT AND TARGET)
151+
message(FATAL_ERROR "Wrong syntax. A TARGET and OUTPUT can not both be specified.")
152+
endif()
153+
154+
if(OUTPUT)
155+
add_custom_command(OUTPUT ${OUTPUT}
156+
${COMMANDS}
157+
DEPENDS ${DEPENDS}
158+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
159+
COMMENT ${COMMENT})
160+
elseif(TARGET)
161+
if(PRE_BUILD AND NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio")
162+
add_custom_target(
163+
${NAME}
164+
${COMMANDS}
165+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
166+
COMMENT ${COMMENT})
167+
add_dependencies(${TARGET} ${NAME})
168+
else()
169+
add_custom_command(
170+
TARGET ${TARGET}
171+
${STEP}
172+
${COMMANDS}
173+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
174+
COMMENT ${COMMENT})
175+
endif()
176+
else()
177+
message(FATAL_ERROR "Wrong syntax. A TARGET or OUTPUT must be specified.")
178+
endif()
179+
endfunction()
180+
181+
################################################################################
182+
# Use props file for a target and configs
183+
# use_props(<target> <configs...> <props_file>)
184+
# Inside <props_file> there are following variables:
185+
# PROPS_TARGET - <target>
186+
# PROPS_CONFIG - One of <configs...>
187+
# PROPS_CONFIG_U - Uppercase PROPS_CONFIG
188+
# Input:
189+
# target - Target to apply props file
190+
# configs - Build configurations to apply props file
191+
# props_file - CMake script
192+
################################################################################
193+
macro(use_props TARGET CONFIGS PROPS_FILE)
194+
set(PROPS_TARGET "${TARGET}")
195+
foreach(PROPS_CONFIG ${CONFIGS})
196+
string(TOUPPER "${PROPS_CONFIG}" PROPS_CONFIG_U)
197+
198+
get_filename_component(ABSOLUTE_PROPS_FILE "${PROPS_FILE}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
199+
if(EXISTS "${ABSOLUTE_PROPS_FILE}")
200+
include("${ABSOLUTE_PROPS_FILE}")
201+
else()
202+
message(WARNING "Corresponding cmake file from props \"${ABSOLUTE_PROPS_FILE}\" doesn't exist")
203+
endif()
204+
endforeach()
205+
endmacro()
206+
207+
################################################################################
208+
# Add compile options to source file
209+
# source_file_compile_options(<source_file> [compile_options...])
210+
# Input:
211+
# source_file - Source file
212+
# compile_options - Options to add to COMPILE_FLAGS property
213+
################################################################################
214+
function(source_file_compile_options SOURCE_FILE)
215+
if("${ARGC}" LESS_EQUAL "1")
216+
return()
217+
endif()
218+
219+
get_source_file_property(COMPILE_OPTIONS "${SOURCE_FILE}" COMPILE_OPTIONS)
220+
221+
if(COMPILE_OPTIONS)
222+
list(APPEND COMPILE_OPTIONS ${ARGN})
223+
else()
224+
set(COMPILE_OPTIONS "${ARGN}")
225+
endif()
226+
227+
set_source_files_properties("${SOURCE_FILE}" PROPERTIES COMPILE_OPTIONS "${COMPILE_OPTIONS}")
228+
endfunction()
229+
230+
################################################################################
231+
# Default properties of visual studio projects
232+
################################################################################
233+
#set(DEFAULT_CXX_PROPS "${CMAKE_CURRENT_LIST_DIR}/DefaultCXX.cmake")
234+
#set(DEFAULT_Fortran_PROPS "${CMAKE_CURRENT_LIST_DIR}/DefaultFortran.cmake")

0 commit comments

Comments
 (0)