Skip to content

Commit 96a7652

Browse files
committed
cmake: small tidy
1 parent 02f4b32 commit 96a7652

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

CMakeLists.txt

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if (NOT bits EQUAL 32)
2929
endif()
3030

3131
cmake_dependent_option(RACERS_USE_DX6 "Build with internal DirectX 6 SDK" ON "CMAKE_SIZEOF_VOID_P EQUAL 4" OFF)
32-
if(RACERS_USE_DX6)
32+
if (RACERS_USE_DX6)
3333
include_directories("${PROJECT_SOURCE_DIR}/3rdparty/dx6/inc")
3434
link_directories("${PROJECT_SOURCE_DIR}/3rdparty/dx6/lib")
3535
foreach(name d3dim d3drm d3dxof ddraw ddraw16 dinput dplayx dsetup dsound dxguid)
@@ -47,7 +47,7 @@ if (MSVC)
4747
endif()
4848

4949
function(add_cxx_warning WARNING)
50-
if(RACERS_WERROR)
50+
if (RACERS_WERROR)
5151
set(compiler_option "-Werror=${WARNING}")
5252
else()
5353
set(compiler_option "-W${WARNING}")
@@ -56,15 +56,15 @@ function(add_cxx_warning WARNING)
5656

5757
cmake_push_check_state(RESET)
5858
set(CMAKE_REQUIRED_FLAGS "${compiler_option} ")
59-
if(MSVC)
59+
if (MSVC)
6060
string(APPEND CMAKE_REQUIRED_FLAGS "/WX")
6161
else()
6262
string(APPEND CMAKE_REQUIRED_FLAGS "-Werror")
6363
endif()
6464
check_cxx_source_compiles("int main() { return 0; }" ${varname})
6565
cmake_pop_check_state()
6666

67-
if(${varname})
67+
if (${varname})
6868
add_compile_options(${compiler_option})
6969
endif()
7070
endfunction()
@@ -286,11 +286,11 @@ add_custom_target(game DEPENDS legoracers goldp)
286286
# --- Modern compiler compatibility ---
287287
if (MSVC)
288288
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "15")
289-
set_property(TARGET goldp legoracers common_goldp common_legoracers APPEND PROPERTY COMPILE_DEFINITIONS "_CRT_SECURE_NO_WARNINGS")
289+
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
290290
endif()
291291
# Visual Studio 2017 version 15.7 needs "/Zc:__cplusplus" for __cplusplus
292292
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "19.14.26428")
293-
set_property(TARGET goldp legoracers common_goldp common_legoracers APPEND PROPERTY COMPILE_OPTIONS "-Zc:__cplusplus")
293+
add_compile_options(-Zc:__cplusplus)
294294
endif()
295295
endif()
296296

@@ -318,10 +318,8 @@ if (MSVC_FOR_DECOMP)
318318
endif()
319319

320320
# LegoRacers.exe links to MSVCRT.dll (/MD), GolDP.dll has embedded its runtime library (/MT)
321-
set_property(TARGET legoracers PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
322-
set_property(TARGET goldp PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
323-
set_property(TARGET common_legoracers PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
324-
set_property(TARGET common_goldp PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
321+
set_property(TARGET legoracers common_legoracers PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
322+
set_property(TARGET goldp common_goldp PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
325323

326324
# Embed debug information (/Z7) for Debug and RelWithDebInfo configuration type
327325
set_property(TARGET goldp legoracers common_goldp common_legoracers PROPERTY MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>")
@@ -348,16 +346,16 @@ if (MSVC_FOR_DECOMP)
348346
endif()
349347

350348
find_program(CLANGFORMAT_BIN NAMES clang-format)
351-
if(EXISTS "${CLANGFORMAT_BIN}")
349+
if (EXISTS "${CLANGFORMAT_BIN}")
352350
execute_process(COMMAND "${CLANGFORMAT_BIN}" --version
353351
OUTPUT_VARIABLE "CLANGFORMAT_VERSION_OUTPUT"
354352
RESULT_VARIABLE "CLANGFORMAT_RESULT"
355353
)
356-
if(CLANGFORMAT_RESULT EQUAL 0 AND CLANGFORMAT_VERSION_OUTPUT MATCHES "version ([0-9\\.]+)")
354+
if (CLANGFORMAT_RESULT EQUAL 0 AND CLANGFORMAT_VERSION_OUTPUT MATCHES "version ([0-9\\.]+)")
357355
set(CLANGFORMAT_VERSION "${CMAKE_MATCH_1}")
358356
set(CLANGFORMAT_VERSION_REQUIRED "17.0")
359357
message(DEBUG "Found clang-format version ${CLANGFORMAT_VERSION} (needs ${CLANGFORMAT_VERSION_REQUIRED}")
360-
if(CLANGFORMAT_VERSION VERSION_GREATER_EQUAL "${CLANGFORMAT_VERSION_REQUIRED}")
358+
if (CLANGFORMAT_VERSION VERSION_GREATER_EQUAL "${CLANGFORMAT_VERSION_REQUIRED}")
361359
file(GLOB_RECURSE racers_sources
362360
"${PROJECT_SOURCE_DIR}/LEGORacers/*.cpp"
363361
"${PROJECT_SOURCE_DIR}/LEGORacers/*.h"
@@ -375,7 +373,7 @@ endif()
375373

376374
find_library(CLANG_LIBRARY NAMES "clang" DOC "libclang from host (NOT target) system")
377375
find_package(Python3 COMPONENTS Interpreter QUIET)
378-
if(CLANG_LIBRARY AND TARGET Python3::Interpreter)
376+
if (CLANG_LIBRARY AND TARGET Python3::Interpreter)
379377
add_custom_target(ncc
380378
Python3::Interpreter "${PROJECT_SOURCE_DIR}/tools/ncc/ncc.py"
381379
--clang-lib "${CLANG_LIBRARY}"

0 commit comments

Comments
 (0)