OpenSubdiv/python/CMakeLists.txt
manuelk 3ae50d1c50 Amending Apache license language & file headers.
New text:

     Copyright 2013 Pixar

     Licensed under the Apache License, Version 2.0 (the "Apache License")
     with the following modification; you may not use this file except in
     compliance with the Apache License and the following modification to it:
     Section 6. Trademarks. is deleted and replaced with:

     6. Trademarks. This License does not grant permission to use the trade
        names, trademarks, service marks, or product names of the Licensor
        and its affiliates, except as required to comply with Section 4(c) of
        the License and to reproduce the content of the NOTICE file.

     You may obtain a copy of the Apache License at

         http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the Apache License with the above modification is
     distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied. See the Apache License for the specific
     language governing permissions and limitations under the Apache License.
2013-09-26 12:04:57 -07:00

84 lines
3.2 KiB
CMake

#
# Copyright 2013 Pixar
#
# Licensed under the Apache License, Version 2.0 (the "Apache License")
# with the following modification; you may not use this file except in
# compliance with the Apache License and the following modification to it:
# Section 6. Trademarks. is deleted and replaced with:
#
# 6. Trademarks. This License does not grant permission to use the trade
# names, trademarks, service marks, or product names of the Licensor
# and its affiliates, except as required to comply with Section 4(c) of
# the License and to reproduce the content of the NOTICE file.
#
# You may obtain a copy of the Apache License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Apache License with the above modification is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the Apache License for the specific
# language governing permissions and limitations under the Apache License.
#
if(PYTHONINTERP_FOUND AND SWIG_FOUND)
message(STATUS "Python and SWIG found. Looking for numpy...")
execute_process(
COMMAND
${PYTHON_EXECUTABLE} -c "import numpy; print numpy.get_include()"
OUTPUT_VARIABLE NUMPY_INCLUDE_PATH
RESULT_VARIABLE NUMPY_ERR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NUMPY_ERR)
message(WARNING "Unable to import numpy.")
else()
message(STATUS "Numpy package has been located.")
set(PYCMD ${PYTHON_EXECUTABLE} setup.py build )
list(APPEND PYCMD --osddir=${LIBRARY_OUTPUT_PATH} )
list(APPEND PYCMD --build-platlib=${PROJECT_BINARY_DIR}/python )
list(APPEND PYCMD --build-temp=${PROJECT_BINARY_DIR}/temp )
# grab all compiler definitions and add '-D'
get_directory_property( TMP DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )
foreach(FLAG ${TMP})
list(APPEND SWIG_COMPILE_FLAGS "-D${FLAG}")
endforeach()
# append platform specific compiler flags
list(APPEND SWIG_COMPILE_FLAGS ${OSD_COMPILER_FLAGS})
list(APPEND PYCMD --cxxflags="${SWIG_COMPILE_FLAGS}" )
# add Swig -builtin optimization build flag
if(SWIG_VERSION VERSION_GREATER 2.0.4)
list(APPEND SWIG_OPTS "-builtin")
endif()
list(APPEND PYCMD --swigopts="${SWIG_OPTS}" )
add_custom_command(
OUTPUT
${CURRENT_BINARY_DIR}/osd
COMMAND
${PYCMD}
WORKING_DIRECTORY
${CMAKE_SOURCE_DIR}/python
DEPENDS
osd_static_cpu
osd_dynamic_cpu
COMMENT
"Building Python bindings with distutils"
)
add_custom_target(python ALL
DEPENDS
${CURRENT_BINARY_DIR}/osd
)
install(CODE "execute_process(
WORKING_DIRECTORY
../python
COMMAND
${PYCMD} install --user)"
)
endif()
endif()