Skip to content

Commit

Permalink
Reduce use of OMR_HOST_OS
Browse files Browse the repository at this point in the history
* prefer flags over string comparisons

Flag            | Replaces
:---            | :-------
OMR_OS_AIX      | OMR_HOST_OS STREQUAL "aix"
OMR_OS_BSD      | OMR_HOST_OS STREQUAL "bsd"
OMR_OS_LINUX    | OMR_HOST_OS STREQUAL "linux"
OMR_OS_OSX      | OMR_HOST_OS STREQUAL "osx"
OMR_OS_WINDOWS  | OMR_HOST_OS STREQUAL "win"
OMR_OS_ZOS      | OMR_HOST_OS STREQUAL "zos"

See OmrDetectSystemInformation.cmake.

Signed-off-by: Keith W. Campbell <[email protected]>
  • Loading branch information
keithc-ca committed Feb 24, 2021
1 parent ea18302 commit c06a44b
Show file tree
Hide file tree
Showing 20 changed files with 89 additions and 155 deletions.
10 changes: 5 additions & 5 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2017, 2020 IBM Corp. and others
# Copyright (c) 2017, 2021 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -208,11 +208,11 @@ set(OMRTHREAD_UNIX_DEFAULT OFF)
set(OMRTHREAD_AIX_DEFAULT OFF)
set(OMRTHREAD_ZOS_DEFAULT OFF)

if(OMR_HOST_OS STREQUAL "win")
if(OMR_OS_WINDOWS)
set(OMRTHREAD_WIN32_DEFAULT ON)
elseif(OMR_HOST_OS STREQUAL "aix")
elseif(OMR_OS_AIX)
set(OMRTHREAD_AIX_DEFAULT ON)
elseif(OMR_HOST_OS STREQUAL "zos")
elseif(OMR_OS_ZOS)
set(OMRTHREAD_ZOS_DEFAULT ON)
else()
set(OMRTHREAD_UNIX_DEFAULT ON)
Expand All @@ -236,7 +236,7 @@ set(OMR_OPT_CUDA OFF CACHE BOOL "Enable CUDA support in OMR. See also: OMR_CUDA_

set(OMR_SANITIZE OFF CACHE STRING "Sanitizer selection. Only has an effect on GNU or Clang")

if(OMR_HOST_OS STREQUAL "win")
if(OMR_OS_WINDOWS)
set(OMR_WINDOWS_NOMINMAX ON CACHE BOOL "Define NOMINMAX in every compilation unit; prevents Windows headers from polluting the global namespace with 'min' and 'max' macros.")
endif()

Expand Down
5 changes: 2 additions & 3 deletions cmake/modules/OmrPlatform.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2017, 2020 IBM Corp. and others
# Copyright (c) 2017, 2021 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -28,10 +28,9 @@ include(OmrAssert)
include(OmrDetectSystemInformation)
include(OmrUtility)


omr_detect_system_information()

if(NOT OMR_HOST_OS STREQUAL "zos")
if(NOT OMR_OS_ZOS)
enable_language(ASM)
endif()

Expand Down
10 changes: 5 additions & 5 deletions ddr/lib/ddr-scanner/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2017, 2020 IBM Corp. and others
# Copyright (c) 2017, 2021 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -31,7 +31,7 @@ target_link_libraries(omr_ddr_scanner
omr_ddr_ir
)

if(OMR_HOST_OS STREQUAL "win")
if(OMR_OS_WINDOWS)
find_package(DiaSDK REQUIRED)

target_sources(omr_ddr_scanner
Expand All @@ -43,7 +43,7 @@ if(OMR_HOST_OS STREQUAL "win")
PUBLIC
DiaSDK::diasdk
)
elseif(OMR_HOST_OS STREQUAL "linux")
elseif(OMR_OS_LINUX)
find_package(LibDwarf REQUIRED)

target_link_libraries(omr_ddr_scanner
Expand All @@ -56,14 +56,14 @@ elseif(OMR_HOST_OS STREQUAL "linux")
dwarf/DwarfFunctions.cpp
dwarf/DwarfScanner.cpp
)
elseif(OMR_HOST_OS STREQUAL "osx")
elseif(OMR_OS_OSX)
target_sources(omr_ddr_scanner
PRIVATE
dwarf/DwarfFunctions.cpp
dwarf/DwarfParser.cpp
dwarf/DwarfScanner.cpp
)
elseif(OMR_HOST_OS STREQUAL "aix")
elseif(OMR_OS_AIX)
target_sources(omr_ddr_scanner
PRIVATE
dwarf/AixSymbolTableParser.cpp
Expand Down
4 changes: 2 additions & 2 deletions fvtest/algotest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ target_link_libraries(omralgotest
target_include_directories(omralgotest PRIVATE ${CMAKE_CURRENT_BINARY_DIR})

#TODO hack to get building
if(OMR_HOST_OS STREQUAL "win")
if(OMR_OS_WINDOWS)
target_link_libraries(omralgotest
ws2_32
shell32
Expand All @@ -58,7 +58,7 @@ if(OMR_HOST_OS STREQUAL "win")
)
endif()

if(OMR_HOST_OS STREQUAL "zos")
if(OMR_OS_ZOS)
target_link_libraries(omralgotest j9a2e)
endif()

Expand Down
2 changes: 1 addition & 1 deletion fvtest/compilertest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ target_link_libraries(compilertest

set_property(TARGET compilertest PROPERTY FOLDER fvtest)

if (NOT OMR_HOST_OS STREQUAL "aix")
if (NOT OMR_OS_AIX)
omr_add_test(NAME CompilerTest COMMAND $<TARGET_FILE:compilertest> --gtest_output=xml:${CMAKE_CURRENT_BINARY_DIR}/compilertest-results.xml)
endif()
4 changes: 2 additions & 2 deletions fvtest/compilertriltest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS OFF)

# Add bigobj compiler options for TypeConversionTest.cpp under Windows
if(OMR_HOST_OS STREQUAL "win")
if(OMR_OS_WINDOWS)
add_compile_options(-bigobj)
endif()

Expand Down Expand Up @@ -64,7 +64,7 @@ target_link_libraries(comptest
tril
)

if(OMR_HOST_OS STREQUAL "zos")
if(OMR_OS_ZOS)
target_link_libraries(comptest j9a2e)
endif()

Expand Down
17 changes: 1 addition & 16 deletions fvtest/gctest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,7 @@ target_link_libraries(omrgctest
${OMR_PORT_LIB}
)

# TODO check linker flags from makefile are ported properly.
# Relevant section from makefile below
#ifeq (linux,$(OMR_HOST_OS))
#MODULE_SHARED_LIBS += rt pthread
#endif
#ifeq (osx,$(OMR_HOST_OS))
#MODULE_SHARED_LIBS += iconv pthread
#endif
#ifeq (aix,$(OMR_HOST_OS))
#MODULE_SHARED_LIBS += iconv perfstat
#endif
#ifeq (win,$(OMR_HOST_OS))
#MODULE_SHARED_LIBS += ws2_32 shell32 Iphlpapi psapi pdh
#endif

if(OMR_HOST_OS STREQUAL "zos")
if(OMR_OS_ZOS)
target_link_libraries(omrgctest j9a2e)
endif()

Expand Down
2 changes: 1 addition & 1 deletion fvtest/jitbuildertest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ omr_add_executable(jitbuildertest NOWARNINGS
)

if(OMR_HOST_ARCH STREQUAL "x86")
if(OMR_HOST_OS STREQUAL "linux" OR OMR_HOST_OS STREQUAL "osx")
if(OMR_OS_LINUX OR OMR_OS_OSX)
target_sources(jitbuildertest PRIVATE CallReturnTest.cpp)
endif()
endif()
Expand Down
12 changes: 5 additions & 7 deletions fvtest/omrGtestGlue/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2017, 2020 IBM Corp. and others
# Copyright (c) 2017, 2021 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -57,15 +57,13 @@ target_link_libraries(omrGtestGlue
omr_main_function
)

#TODO system thread library should be linked in a more generic way.
if(NOT OMR_HOST_OS STREQUAL "win")
if(NOT OMR_HOST_OS STREQUAL "zos")
target_link_libraries(omrGtest pthread)
endif()
# TODO system thread library should be linked in a more generic way.
if(NOT (OMR_OS_WINDOWS OR OMR_OS_ZOS))
target_link_libraries(omrGtest pthread)
endif()
#target_link_libraries(omrGtest INTERFACE omrGtestGlue)

if(OMR_HOST_OS STREQUAL "zos" OR OMR_HOST_OS STREQUAL "aix")
if(OMR_OS_AIX OR OMR_OS_ZOS)
list(APPEND OMR_GTEST_DEFINITIONS
-DGTEST_ENV_HAS_STD_TUPLE_
-D__IBMCPP_TR1__
Expand Down
12 changes: 6 additions & 6 deletions fvtest/porttest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ if(OMR_OPT_CUDA)
)
endif()

# TODO: Remove if(NOT OMR_HOST_OS STREQUAL "win") after OMRSOCK API is implemented on Windows.
if(NOT OMR_HOST_OS STREQUAL "win")
# TODO: Remove if(NOT OMR_OS_WINDOWS) after OMRSOCK API is implemented on Windows.
if(NOT OMR_OS_WINDOWS)
target_sources(omrporttest
PRIVATE
omrsockTest.cpp
Expand All @@ -85,13 +85,13 @@ target_link_libraries(omrporttest
${OMR_PORT_LIB}
)

if(OMR_HOST_OS STREQUAL "win")
if(OMR_OS_WINDOWS)
target_link_libraries(omrporttest
ws2_32
)
endif()

if(OMR_HOST_OS STREQUAL "zos")
if(OMR_OS_ZOS)
target_link_libraries(omrporttest
j9a2e
)
Expand All @@ -115,7 +115,7 @@ omr_add_exports(sltestlib
sl_test1_function
)

if(OMR_HOST_OS STREQUAL "aix")
if(OMR_OS_AIX)
omr_add_library(aixbaddep SHARED
aixbaddep/sltest.c
)
Expand All @@ -136,7 +136,7 @@ if(OMR_HOST_OS STREQUAL "aix")
)
endif()

if (NOT OMR_HOST_OS STREQUAL "aix" AND NOT OMR_HOST_OS STREQUAL "zos" AND NOT CMAKE_CROSSCOMPILING)
if (NOT (OMR_OS_AIX OR OMR_OS_ZOS OR CMAKE_CROSSCOMPILING))
omr_add_test(
NAME porttest
COMMAND $<TARGET_FILE:omrporttest> --gtest_output=xml:${CMAKE_CURRENT_BINARY_DIR}/omrporttest-results.xml --gtest_filter=${porttest_filter}
Expand Down
4 changes: 2 additions & 2 deletions fvtest/sigtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ omr_add_executable(omrsigtest
)

#TODO: hack for windows. These libraries should be linked on dependants
if(OMR_HOST_OS STREQUAL "win")
if(OMR_OS_WINDOWS)
target_link_libraries(omrsigtest
ws2_32
shell32
Expand All @@ -36,7 +36,7 @@ if(OMR_HOST_OS STREQUAL "win")
)
endif()

if(OMR_HOST_OS STREQUAL "zos")
if(OMR_OS_ZOS)
target_link_libraries(omrsigtest j9a2e)
endif()

Expand Down
5 changes: 2 additions & 3 deletions fvtest/threadextendedtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ omr_add_executable(omrthreadextendedtest
timeBaseTest.cpp
)


target_link_libraries(omrthreadextendedtest
omrGtestGlue
omrtestutil
Expand All @@ -37,12 +36,12 @@ target_link_libraries(omrthreadextendedtest
${OMR_PORT_LIB}
)

if(OMR_HOST_OS STREQUAL "zos")
if(OMR_OS_ZOS)
target_link_libraries(omrthreadextendedtest j9a2e)
endif()

set_property(TARGET omrthreadextendedtest PROPERTY FOLDER fvtest)

if (NOT OMR_HOST_OS STREQUAL "zos")
if(NOT OMR_OS_ZOS)
omr_add_test(NAME threadextendedtest COMMAND $<TARGET_FILE:omrthreadextendedtest> --gtest_output=xml:${CMAKE_CURRENT_BINARY_DIR}/omrthreadextendedtest-results.xml)
endif()
18 changes: 3 additions & 15 deletions fvtest/threadtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@ omr_add_executable(omrthreadtest
#OBJECTS += forkResetTest forkResetRWMutexTest
#endif


#ifeq (linux,$(OMR_HOST_OS))
#MODULE_SHARED_LIBS += rt pthread
#endif
#ifeq (osx,$(OMR_HOST_OS))
#MODULE_SHARED_LIBS += iconv pthread
#endif
#ifeq (aix,$(OMR_HOST_OS))
#MODULE_SHARED_LIBS += iconv perfstat
#endif


target_link_libraries(omrthreadtest
omrGtestGlue
omrtestutil
Expand All @@ -63,7 +51,7 @@ target_link_libraries(omrthreadtest
${OMR_PORT_LIB}
${OMR_THREAD_LIB}
)
if(OMR_HOST_OS STREQUAL "win")
if(OMR_OS_WINDOWS)
target_link_libraries(omrthreadtest
ws2_32
shell32
Expand All @@ -73,14 +61,14 @@ if(OMR_HOST_OS STREQUAL "win")
)
endif()

if(OMR_HOST_OS STREQUAL "zos")
if(OMR_OS_ZOS)
target_link_libraries(omrthreadtest j9a2e)
endif()

set_property(TARGET omrthreadtest PROPERTY FOLDER fvtest)

omr_add_test(NAME threadtest COMMAND $<TARGET_FILE:omrthreadtest> --gtest_output=xml:${CMAKE_CURRENT_BINARY_DIR}/omrthreadtest-results.xml)
omr_add_test(NAME threadSetAttrThreadWeightTest COMMAND $<TARGET_FILE:omrthreadtest> --gtest_output=xml:${CMAKE_CURRENT_BINARY_DIR}/omrthreadtest-results.xml --gtest_also_run_disabled_tests --gtest_filter=ThreadCreateTest.DISABLED_SetAttrThreadWeight)
if(OMR_HOST_OS STREQUAL "linux")
if(OMR_OS_LINUX)
omr_add_test(NAME threadRealtimeTest COMMAND $<TARGET_FILE:omrthreadtest> --gtest_output=xml:${CMAKE_CURRENT_BINARY_DIR}/omrthreadtest-results.xml --gtest_filter=ThreadCreateTest.* -realtime)
endif()
11 changes: 4 additions & 7 deletions fvtest/tril/tril/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2017, 2020 IBM Corp. and others
# Copyright (c) 2017, 2021 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -54,14 +54,11 @@ target_link_libraries(tril PUBLIC
${CMAKE_DL_LIBS}
)

#TODO system thread library should be linked in a more generic way.
if(NOT OMR_HOST_OS STREQUAL "win")
if(NOT OMR_HOST_OS STREQUAL "zos")
target_link_libraries(tril PUBLIC pthread)
endif()
# TODO system thread library should be linked in a more generic way.
if(NOT (OMR_OS_WINDOWS OR OMR_OS_ZOS))
target_link_libraries(tril PUBLIC pthread)
endif()


omr_add_executable(tril_dumper NOWARNINGS compiler.cpp)
target_link_libraries(tril_dumper tril)

Expand Down
2 changes: 1 addition & 1 deletion fvtest/utiltest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ target_include_directories(omrutiltest
$<TARGET_PROPERTY:omrGtestGlue,INTERFACE_INCLUDE_DIRECTORIES>
)

if(OMR_HOST_OS STREQUAL "zos")
if(OMR_OS_ZOS)
target_link_libraries(omrutiltest j9a2e)
endif()

Expand Down
14 changes: 3 additions & 11 deletions omrsigcompat/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2017, 2020 IBM Corp. and others
# Copyright (c) 2017, 2021 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -26,7 +26,7 @@ omr_add_library(omrsig SHARED
omrsig.cpp
)

if(OMR_HOST_OS STREQUAL "win")
if(OMR_OS_WINDOWS)
target_compile_definitions(omrsig PRIVATE -DMSVC_RUNTIME_DLL="${OMR_MSVC_CRT}")
endif()

Expand Down Expand Up @@ -76,17 +76,9 @@ target_compile_options(omrsig
if(OMR_HOST_OS MATCHES "linux|osx")
target_link_libraries(omrsig PRIVATE dl)
endif()
if(OMR_HOST_OS STREQUAL "zos")
if(OMR_OS_ZOS)
target_link_libraries(omrsig PRIVATE j9a2e)
endif()
#TODO ensure we are linking in the same way as source makefile:
#MODULE_STATIC_LIBS += omrutil
#ifneq (,$(findstring linux,$(OMR_HOST_OS)))
#MODULE_SHARED_LIBS += pthread
#endif
#ifneq (,$(findstring osx,$(OMR_HOST_OS)))
#MODULE_SHARED_LIBS += pthread
#endif

install(
TARGETS omrsig
Expand Down
Loading

0 comments on commit c06a44b

Please sign in to comment.