Skip to content

Commit b036ecd

Browse files
committed
add WITH_TESTS option. Install plugins into
1 parent 8669268 commit b036ecd

File tree

4 files changed

+57
-51
lines changed

4 files changed

+57
-51
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- name: Install
4646
shell: bash -l {0}
4747
run: |
48-
pip install .
48+
pip install . --install-option="-DWITH_TESTS=ON"
4949
pdal --drivers
5050
5151
- name: Test
@@ -91,7 +91,7 @@ jobs:
9191
9292
call conda activate test
9393
where python
94-
python setup.py develop -- -G "Ninja"
94+
python setup.py develop -- -G "Ninja" -DWITH_TESTS=ON
9595
9696
- name: Test
9797
shell: cmd /C CALL "{0}"

pdal/CMakeLists.txt

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ include(${PROJECT_SOURCE_DIR}/macros.cmake NO_POLICY_SCOPE)
77
set(CMAKE_CXX_STANDARD 11)
88
set(CMAKE_CXX_STANDARD_REQUIRED ON)
99
set(CMAKE_CXX_EXTENSIONS OFF)
10+
option(WITH_TESTS "Enable tests" OFF)
1011
set(CMAKE_BUILD_TYPE "Release")
1112

12-
enable_testing()
1313

1414
# Python-finding settings
1515
set(Python3_FIND_STRATEGY "LOCATION")
@@ -95,13 +95,6 @@ PDAL_PYTHON_ADD_PLUGIN(numpy_reader reader numpy
9595
${PYTHON_LINK_LIBRARY}
9696
)
9797

98-
99-
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
100-
add_subdirectory(test/gtest)
101-
enable_testing()
102-
include_directories(test/gtest/include .. ${CMAKE_CURRENT_BINARY_DIR})
103-
104-
10598
PDAL_PYTHON_ADD_PLUGIN(python_filter filter python
10699
FILES
107100
./filters/PythonFilter.cpp
@@ -122,40 +115,52 @@ PDAL_PYTHON_ADD_PLUGIN(python_filter filter python
122115
${PYTHON_LINK_LIBRARY}
123116
)
124117

125-
PDAL_PYTHON_ADD_TEST(pdal_io_numpy_test
126-
FILES
127-
./test/NumpyReaderTest.cpp
128-
./test/Support.cpp
129-
./plang/Invocation.cpp
130-
./plang/Environment.cpp
131-
./plang/Redirector.cpp
132-
./plang/Script.cpp
133-
LINK_WITH
134-
${numpy_reader}
135-
${Python3_LIBRARIES}
136-
${PDAL_LIBRARIES}
137-
${CMAKE_DL_LIBS}
138-
SYSTEM_INCLUDES
139-
${PDAL_INCLUDE_DIRS}
140-
${Python3_INCLUDE_DIRS}
141-
${Python3_NumPy_INCLUDE_DIRS}
142-
)
143118

144-
PDAL_PYTHON_ADD_TEST(pdal_filters_python_test
145-
FILES
146-
./test/PythonFilterTest.cpp
147-
./test/Support.cpp
148-
./plang/Invocation.cpp
149-
./plang/Environment.cpp
150-
./plang/Redirector.cpp
151-
./plang/Script.cpp
152-
LINK_WITH
153-
${python_filter}
154-
${Python3_LIBRARIES}
155-
${PDAL_LIBRARIES}
156-
${CMAKE_DL_LIBS}
157-
SYSTEM_INCLUDES
158-
${PDAL_INCLUDE_DIRS}
159-
${Python3_INCLUDE_DIRS}
160-
${Python3_NumPy_INCLUDE_DIRS}
161-
)
119+
if (WITH_TESTS)
120+
enable_testing()
121+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
122+
add_subdirectory(test/gtest)
123+
enable_testing()
124+
include_directories(test/gtest/include .. ${CMAKE_CURRENT_BINARY_DIR})
125+
126+
127+
128+
129+
PDAL_PYTHON_ADD_TEST(pdal_io_numpy_test
130+
FILES
131+
./test/NumpyReaderTest.cpp
132+
./test/Support.cpp
133+
./plang/Invocation.cpp
134+
./plang/Environment.cpp
135+
./plang/Redirector.cpp
136+
./plang/Script.cpp
137+
LINK_WITH
138+
${numpy_reader}
139+
${Python3_LIBRARIES}
140+
${PDAL_LIBRARIES}
141+
${CMAKE_DL_LIBS}
142+
SYSTEM_INCLUDES
143+
${PDAL_INCLUDE_DIRS}
144+
${Python3_INCLUDE_DIRS}
145+
${Python3_NumPy_INCLUDE_DIRS}
146+
)
147+
148+
PDAL_PYTHON_ADD_TEST(pdal_filters_python_test
149+
FILES
150+
./test/PythonFilterTest.cpp
151+
./test/Support.cpp
152+
./plang/Invocation.cpp
153+
./plang/Environment.cpp
154+
./plang/Redirector.cpp
155+
./plang/Script.cpp
156+
LINK_WITH
157+
${python_filter}
158+
${Python3_LIBRARIES}
159+
${PDAL_LIBRARIES}
160+
${CMAKE_DL_LIBS}
161+
SYSTEM_INCLUDES
162+
${PDAL_INCLUDE_DIRS}
163+
${Python3_INCLUDE_DIRS}
164+
${Python3_NumPy_INCLUDE_DIRS}
165+
)
166+
endif (WITH_TESTS)

pdal/macros.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ macro(PDAL_PYTHON_ADD_PLUGIN _name _type _shortname)
9191
${WINSOCK_LIBRARY}
9292
)
9393
install(TARGETS ${${_name}}
94-
LIBRARY DESTINATION ${CMAKE_INSTALL_DIR}
94+
LIBRARY DESTINATION ${PROJECT_NAME}
9595
)
9696
if (APPLE)
9797
set_target_properties(${${_name}} PROPERTIES
@@ -109,7 +109,7 @@ macro(PDAL_PYTHON_ADD_TEST _name)
109109
set(WINSOCK_LIBRARY ws2_32)
110110
endif()
111111
add_executable(${_name} ${PDAL_PYTHON_ADD_TEST_FILES})
112-
112+
113113
pdal_python_target_compile_settings(${_name})
114114
target_include_directories(${_name} PRIVATE
115115
${PDAL_PYTHON_ADD_TEST_INCLUDES})

pdal/plang/Environment.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ Environment::Environment()
111111
// the return.
112112
auto initNumpy = []()
113113
{
114-
#undef NUMPY_IMPORT_ARRAY_RETVAL
115-
#define NUMPY_IMPORT_ARRAY_RETVAL
116-
import_array();
114+
// #undef NUMPY_IMPORT_ARRAY_RETVAL
115+
// #define NUMPY_IMPORT_ARRAY_RETVAL VOID
116+
_import_array();
117+
return ;
117118
};
118119

119120
if (!Py_IsInitialized())

0 commit comments

Comments
 (0)