Skip to content

Commit dd01445

Browse files
authored
Try to address comments in PR
1 parent 123e15c commit dd01445

File tree

3 files changed

+30
-59
lines changed

3 files changed

+30
-59
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
366366
else()
367367
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual -Wcast-qual -fno-strict-aliasing -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings")
368368
endif ()
369-
# Needed due an error which occurs when you compile gtest on emscripten
369+
# Needed due to an error which occurs when you compile gtest on emscripten
370370
if (EMSCRIPTEN)
371371
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
372372
endif()

cmake/modules/GoogleTest.cmake

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,62 +13,38 @@ if(WIN32)
1313
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL:PATH=${_gtest_byproduct_binary_dir}/lib/
1414
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=${_gtest_byproduct_binary_dir}/lib/
1515
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO:PATH=${_gtest_byproduct_binary_dir}/lib/
16-
-Dgtest_force_shared_crt=ON
17-
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config $<CONFIG>)
16+
-Dgtest_force_shared_crt=ON)
1817
elseif(APPLE)
1918
set(EXTRA_GTEST_OPTS -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT})
2019
endif()
2120

2221
include(ExternalProject)
23-
if(EMSCRIPTEN)
24-
25-
ExternalProject_Add(
26-
googletest
27-
GIT_REPOSITORY https://github.com/google/googletest.git
28-
GIT_SHALLOW 1
29-
GIT_TAG v1.15.2
30-
UPDATE_COMMAND ""
31-
# # Force separate output paths for debug and release builds to allow easy
32-
# # identification of correct lib in subsequent TARGET_LINK_LIBRARIES commands
33-
# CMAKE_ARGS -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=DebugLibs
34-
# -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=ReleaseLibs
35-
# -Dgtest_force_shared_crt=ON
36-
CONFIGURE_COMMAND emcmake cmake -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
22+
if (EMSCRIPTEN)
23+
set(CONFIGURE_COMMAND emcmake cmake -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
3724
-S ${CMAKE_BINARY_DIR}/unittests/googletest-prefix/src/googletest/
38-
-B ${CMAKE_BINARY_DIR}/unittests/googletest-prefix/src/googletest-build/
39-
BUILD_COMMAND emmake make
40-
# Disable install step
41-
INSTALL_COMMAND ""
42-
BUILD_BYPRODUCTS ${_gtest_byproducts}
43-
# Wrap download, configure and build steps in a script to log output
44-
LOG_DOWNLOAD ON
45-
LOG_CONFIGURE ON
46-
LOG_BUILD ON
47-
TIMEOUT 600
48-
)
49-
25+
-B ${CMAKE_BINARY_DIR}/unittests/googletest-prefix/src/googletest-build/)
26+
set(BUILD_COMMAND emmake make)
5027
else()
51-
52-
ExternalProject_Add(
53-
googletest
54-
GIT_REPOSITORY https://github.com/google/googletest.git
55-
GIT_SHALLOW 1
56-
GIT_TAG v1.15.2
57-
UPDATE_COMMAND ""
58-
# # Force separate output paths for debug and release builds to allow easy
59-
# # identification of correct lib in subsequent TARGET_LINK_LIBRARIES commands
60-
# CMAKE_ARGS -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=DebugLibs
61-
# -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=ReleaseLibs
62-
# -Dgtest_force_shared_crt=ON
63-
CMAKE_ARGS -G ${CMAKE_GENERATOR}
28+
set(CONFIGURE_COMMAND CMAKE_ARGS -G ${CMAKE_GENERATOR}
6429
-DCMAKE_BUILD_TYPE=$<CONFIG>
6530
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
6631
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
6732
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
6833
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
6934
-DCMAKE_AR=${CMAKE_AR}
7035
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
71-
${EXTRA_GTEST_OPTS}
36+
${EXTRA_GTEST_OPTS})
37+
set(BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config $<CONFIG>)
38+
endif()
39+
40+
ExternalProject_Add(
41+
googletest
42+
GIT_REPOSITORY https://github.com/google/googletest.git
43+
GIT_SHALLOW 1
44+
GIT_TAG v1.15.2
45+
UPDATE_COMMAND ""
46+
CONFIGURE_COMAND ${CONFIGURE_COMMAND}
47+
BUILD_COMMMAND ${BUILD_COMMAND}
7248
# Disable install step
7349
INSTALL_COMMAND ""
7450
BUILD_BYPRODUCTS ${_gtest_byproducts}

unittests/CppInterOp/CMakeLists.txt

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
set(LLVM_LINK_COMPONENTS
22
Support
33
)
4+
if (EMSCRIPTEN)
5+
# Omitting CUDATest.cpp since Emscripten build currently has no GPU support
6+
# For Emscripten builds linking to gtest_main will not suffice for gtest to run
7+
# the tests and an explictly main.cpp is needed
8+
set(EXTRA_TEST_SOURCE_FILES main.cpp)
9+
else()
10+
# Do not need main.cpp for native builds, but we do have GPU support for native builds
11+
set(EXTRA_TEST_SOURCE_FILES CUDATest.cpp)
12+
endif()
413

5-
if(EMSCRIPTEN)
614
add_cppinterop_unittest(CppInterOpTests
715
EnumReflectionTest.cpp
816
FunctionReflectionTest.cpp
@@ -12,21 +20,8 @@ add_cppinterop_unittest(CppInterOpTests
1220
TypeReflectionTest.cpp
1321
Utils.cpp
1422
VariableReflectionTest.cpp
15-
main.cpp
16-
)
17-
else()
18-
add_cppinterop_unittest(CppInterOpTests
19-
CUDATest.cpp
20-
EnumReflectionTest.cpp
21-
FunctionReflectionTest.cpp
22-
InterpreterTest.cpp
23-
JitTest.cpp
24-
ScopeReflectionTest.cpp
25-
TypeReflectionTest.cpp
26-
Utils.cpp
27-
VariableReflectionTest.cpp
23+
${EXTRA_TEST_SOURCE_FILES}
2824
)
29-
endif()
3025

3126

3227

@@ -67,7 +62,7 @@ export_executable_symbols(CppInterOpTests)
6762
unset(LLVM_LINK_COMPONENTS)
6863

6964
if(EMSCRIPTEN)
70-
add_cppinterop_unittest(DynamicLibraryManagerTests DynamicLibraryManagerTest.cpp main.cpp)
65+
add_cppinterop_unittest(DynamicLibraryManagerTests DynamicLibraryManagerTest.cpp ${EXTRA_TEST_SOURCE_FILES})
7166
else()
7267
add_cppinterop_unittest(DynamicLibraryManagerTests DynamicLibraryManagerTest.cpp)
7368
endif()

0 commit comments

Comments
 (0)