cmake: Space between if/else/elseif and condition

It just looks better IMO
pull/40/head
Ionel-Cristinel ANICHITEI 3 years ago
parent 9ee41d6dd1
commit dbbc8b82af

@ -22,17 +22,17 @@ project(
HOMEPAGE_URL https://github.com/bitdefender/bddisasm) HOMEPAGE_URL https://github.com/bitdefender/bddisasm)
# Use Release as the build type if no build type was specified and we're not using a multi-config generator . # Use Release as the build type if no build type was specified and we're not using a multi-config generator .
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type given. Will use 'Release'") message(STATUS "No build type given. Will use 'Release'")
set(CMAKE_BUILD_TYPE set(CMAKE_BUILD_TYPE
"Release" "Release"
CACHE STRING "Choose the type of build." FORCE) CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui. # Set the possible values of build type for cmake-gui.
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release") set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
endif() endif ()
# These are shared by bddisasm and bdshemu. # These are shared by bddisasm and bdshemu.
if(NOT MSVC) if (NOT MSVC)
set(BDDISASM_COMMON_COMPILE_OPTIONS set(BDDISASM_COMMON_COMPILE_OPTIONS
"$<$<CONFIG:Release>:-U_FORTIFY_SOURCE>" "$<$<CONFIG:Release>:-U_FORTIFY_SOURCE>"
"$<$<CONFIG:Release>:-D_FORTIFY_SOURCE=2>" "$<$<CONFIG:Release>:-D_FORTIFY_SOURCE=2>"
@ -65,9 +65,9 @@ if(NOT MSVC)
-gdwarf-4 -gdwarf-4
-grecord-gcc-switches -grecord-gcc-switches
-march=westmere) -march=westmere)
else() else ()
set(BDDISASM_COMMON_COMPILE_OPTIONS /W4 /WX) set(BDDISASM_COMMON_COMPILE_OPTIONS /W4 /WX)
endif() endif ()
set(BDDISASM_PUBLIC_HEADERS set(BDDISASM_PUBLIC_HEADERS
"inc/bddisasm.h" "inc/bddisasm.h"
@ -146,9 +146,9 @@ target_include_directories(bddisasm PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOU
target_link_libraries(bdshemu PUBLIC bddisasm) target_link_libraries(bdshemu PUBLIC bddisasm)
target_compile_options(bdshemu PRIVATE ${BDDISASM_COMMON_COMPILE_OPTIONS}) target_compile_options(bdshemu PRIVATE ${BDDISASM_COMMON_COMPILE_OPTIONS})
if(NOT MSVC) if (NOT MSVC)
target_compile_options(bdshemu PRIVATE -maes) target_compile_options(bdshemu PRIVATE -maes)
endif() endif ()
set_target_properties( set_target_properties(
bdshemu bdshemu
@ -159,21 +159,21 @@ set_target_properties(
add_library(bddisasm::bdshemu ALIAS bdshemu) add_library(bddisasm::bdshemu ALIAS bdshemu)
# If this is the master project (or if the user requested it) add disasmtool. # If this is the master project (or if the user requested it) add disasmtool.
if((${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) OR BDD_INCLUDE_TOOL) if ((${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) OR BDD_INCLUDE_TOOL)
if(WIN32) if (WIN32)
add_subdirectory(disasmtool) add_subdirectory(disasmtool)
else() else ()
add_subdirectory(disasmtool_lix) add_subdirectory(disasmtool_lix)
endif() endif ()
endif() endif ()
# If this is the master project (or if the user requested it) add isagenerator. # If this is the master project (or if the user requested it) add isagenerator.
if((${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) OR BDD_INCLUDE_ISAGENERATOR) if ((${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) OR BDD_INCLUDE_ISAGENERATOR)
add_subdirectory(isagenerator) add_subdirectory(isagenerator)
endif() endif ()
# If this is the master project add install and package targets. # If this is the master project add install and package targets.
if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) if (${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
set(BDDISASM_INSTALL_CMAKEDIR set(BDDISASM_INSTALL_CMAKEDIR
"${CMAKE_INSTALL_LIBDIR}/cmake/bddisasm" "${CMAKE_INSTALL_LIBDIR}/cmake/bddisasm"
CACHE STRING "Path to bddisasm cmake files.") CACHE STRING "Path to bddisasm cmake files.")
@ -227,13 +227,13 @@ if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
set(CPACK_PACKAGE_VENDOR "Bitdefender") set(CPACK_PACKAGE_VENDOR "Bitdefender")
if(NOT CPACK_GENERATOR) if (NOT CPACK_GENERATOR)
if(NOT WIN32) if (NOT WIN32)
set(CPACK_GENERATOR "DEB") set(CPACK_GENERATOR "DEB")
else() else ()
set(CPACK_GENERATOR "ZIP") set(CPACK_GENERATOR "ZIP")
endif() endif ()
endif() endif ()
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Bitdefender HVI Team <hvmi-oss@bitdefender.com>") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Bitdefender HVI Team <hvmi-oss@bitdefender.com>")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "") set(CPACK_DEBIAN_PACKAGE_DEPENDS "")
@ -241,4 +241,4 @@ if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
set(CPACK_DEBIAN_PACKAGE_SECTION "devel") set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
include(CPack) include(CPack)
endif() endif ()

@ -3,27 +3,27 @@ cmake_minimum_required(VERSION 3.16)
project(disasmtool LANGUAGES C) project(disasmtool LANGUAGES C)
# Use Release as the build type if no build type was specified and we're not using a multi-config generator . # Use Release as the build type if no build type was specified and we're not using a multi-config generator .
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type given. Will use 'Release'") message(STATUS "No build type given. Will use 'Release'")
set(CMAKE_BUILD_TYPE set(CMAKE_BUILD_TYPE
"Release" "Release"
CACHE STRING "Choose the type of build." FORCE) CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui. # Set the possible values of build type for cmake-gui.
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release") set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
endif() endif ()
add_executable(disasmtool disasmtool.c) add_executable(disasmtool disasmtool.c)
target_link_libraries(disasmtool PRIVATE bddisasm::bddisasm bddisasm::bdshemu) target_link_libraries(disasmtool PRIVATE bddisasm::bddisasm bddisasm::bdshemu)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
include(CheckIPOSupported) include(CheckIPOSupported)
check_ipo_supported(RESULT USE_IPO) check_ipo_supported(RESULT USE_IPO)
if(USE_IPO) if (USE_IPO)
set_target_properties(bddisasm PROPERTIES INTERPROCEDURAL_OPTIMIZATION True) set_target_properties(bddisasm PROPERTIES INTERPROCEDURAL_OPTIMIZATION True)
endif() endif ()
endif() endif ()
if(NOT MSVC) if (NOT MSVC)
target_compile_options( target_compile_options(
disasmtool disasmtool
PRIVATE -Wall PRIVATE -Wall
@ -55,6 +55,6 @@ if(NOT MSVC)
-gdwarf-4 -gdwarf-4
-grecord-gcc-switches -grecord-gcc-switches
-march=westmere) -march=westmere)
else() else ()
target_compile_options(disasmtool PRIVATE /W4 /WX) target_compile_options(disasmtool PRIVATE /W4 /WX)
endif() endif ()

@ -3,14 +3,14 @@ cmake_minimum_required(VERSION 3.12)
project(disasmtool LANGUAGES CXX) project(disasmtool LANGUAGES CXX)
# Use Release as the build type if no build type was specified and we're not using a multi-config generator . # Use Release as the build type if no build type was specified and we're not using a multi-config generator .
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type given. Will use 'Release'") message(STATUS "No build type given. Will use 'Release'")
set(CMAKE_BUILD_TYPE set(CMAKE_BUILD_TYPE
"Release" "Release"
CACHE STRING "Choose the type of build." FORCE) CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui. # Set the possible values of build type for cmake-gui.
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release") set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
endif() endif ()
add_executable(disasmtool disasmtool.cpp dumpers.cpp) add_executable(disasmtool disasmtool.cpp dumpers.cpp)
@ -43,20 +43,20 @@ target_compile_options(
find_package(RapidJSON QUIET) find_package(RapidJSON QUIET)
target_link_libraries(disasmtool PRIVATE bddisasm::bddisasm bddisasm::bdshemu) target_link_libraries(disasmtool PRIVATE bddisasm::bddisasm bddisasm::bdshemu)
if(RapidJSON_FOUND) if (RapidJSON_FOUND)
# :( https://github.com/satishbabariya/modern-cmake#good-boys-export-their-targets # :( https://github.com/satishbabariya/modern-cmake#good-boys-export-their-targets
target_include_directories(disasmtool PRIVATE ${RapidJSON_INCLUDE_DIRS}) target_include_directories(disasmtool PRIVATE ${RapidJSON_INCLUDE_DIRS})
target_sources(disasmtool PRIVATE rapidjson.cpp) target_sources(disasmtool PRIVATE rapidjson.cpp)
target_compile_definitions(disasmtool PRIVATE HAS_RAPIDJSON) target_compile_definitions(disasmtool PRIVATE HAS_RAPIDJSON)
endif() endif ()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
include(CheckIPOSupported) include(CheckIPOSupported)
check_ipo_supported(RESULT USE_IPO) check_ipo_supported(RESULT USE_IPO)
if(USE_IPO) if (USE_IPO)
set_target_properties(bddisasm PROPERTIES INTERPROCEDURAL_OPTIMIZATION True) set_target_properties(bddisasm PROPERTIES INTERPROCEDURAL_OPTIMIZATION True)
endif() endif ()
endif() endif ()
set_target_properties( set_target_properties(
disasmtool disasmtool

@ -5,10 +5,10 @@ project(isagenerator)
include(FindPython3) include(FindPython3)
find_package(Python3 COMPONENTS Interpreter) find_package(Python3 COMPONENTS Interpreter)
if(Python3_FOUND) if (Python3_FOUND)
add_custom_target( add_custom_target(
isagenerator isagenerator
COMMAND Python3::Interpreter generate_tables.py instructions COMMAND Python3::Interpreter generate_tables.py instructions
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}"
COMMENT "Generating instruction tables") COMMENT "Generating instruction tables")
endif(Python3_FOUND) endif (Python3_FOUND)

Loading…
Cancel
Save