summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorJohn W. Parent <45471568+johnwparent@users.noreply.github.com>2024-01-29 14:49:55 -0500
committerGitHub <noreply@github.com>2024-01-29 11:49:55 -0800
commitba45277640739fe1c24aede6241c16da19d73424 (patch)
tree4b55607ab4632e48acc15d9a8ad9a7c857d62a0b /var
parentf03ae39fd173c7d1b23d4b194ecaf65c4a0cd215 (diff)
downloadspack-ba45277640739fe1c24aede6241c16da19d73424.tar.gz
spack-ba45277640739fe1c24aede6241c16da19d73424.tar.bz2
spack-ba45277640739fe1c24aede6241c16da19d73424.tar.xz
spack-ba45277640739fe1c24aede6241c16da19d73424.zip
gl2ps package: build only one of shared/static on Windows (#36576)
gl2ps tries to build static and shared libs simultaneously with the same target name on the generator side. This causes a name clash issue for Ninja on Windows (where the extension is .lib in both cases). Add a variant on Windows to force building only one of shared or static, and patch the CMake build to enable use of this variant.
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/gl2ps/package.py13
-rw-r--r--var/spack/repos/builtin/packages/gl2ps/prevent-ninja-target-clash.patch49
2 files changed, 62 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/gl2ps/package.py b/var/spack/repos/builtin/packages/gl2ps/package.py
index 59fcebe431..da229fbb7c 100644
--- a/var/spack/repos/builtin/packages/gl2ps/package.py
+++ b/var/spack/repos/builtin/packages/gl2ps/package.py
@@ -31,6 +31,16 @@ class Gl2ps(CMakePackage):
depends_on("zlib-api", when="+zlib")
depends_on("texlive", type="build", when="+doc")
+ # gl2ps tries to build static and shared libs at once with the same
+ # target name. This causes ninja to fail the build
+ # This patch defines a new CL opt to toggle shared vs static
+ # and renames all lib target refs
+ # Patch derived from https://gitlab.onelab.info/gl2ps/gl2ps/-/issues/30
+ # and fixes a few additional places that solution misses.
+ with when("platform=windows"):
+ variant("shared", default=True, description="Enable building shared libraries")
+ patch("prevent-ninja-target-clash.patch")
+
def cmake_args(self):
spec = self.spec
options = [
@@ -48,6 +58,9 @@ class Gl2ps(CMakePackage):
if spec.satisfies("platform=darwin"):
options.append(self.define("CMAKE_MACOSX_RPATH", True))
+ if spec.satisfies("platform=windows"):
+ options.append(self.define_from_variant("BUILD_SHARED_LIBS", "shared"))
+
if "~doc" in spec:
# Make sure we don't look.
options.append(self.define("CMAKE_DISABLE_FIND_PACKAGE_LATEX", True))
diff --git a/var/spack/repos/builtin/packages/gl2ps/prevent-ninja-target-clash.patch b/var/spack/repos/builtin/packages/gl2ps/prevent-ninja-target-clash.patch
new file mode 100644
index 0000000000..88dda9adbc
--- /dev/null
+++ b/var/spack/repos/builtin/packages/gl2ps/prevent-ninja-target-clash.patch
@@ -0,0 +1,49 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 0001c4f..a2133de 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -49,6 +49,7 @@ project(gl2ps C)
+
+ option(ENABLE_ZLIB "Enable compression using ZLIB" ON)
+ option(ENABLE_PNG "Enable PNG support" ON)
++option(BUILD_SHARED_LIBS "Enable building shared libs" ON)
+
+ set(GL2PS_MAJOR_VERSION 1)
+ set(GL2PS_MINOR_VERSION 4)
+@@ -139,19 +140,17 @@ if(APPLE)
+ endif()
+
+ if(OPENGL_FOUND)
+- add_library(lib STATIC gl2ps.c gl2ps.h)
+- set_target_properties(lib PROPERTIES OUTPUT_NAME gl2ps)
++ add_library(gl2ps gl2ps.c gl2ps.h)
+
+- add_library(shared SHARED gl2ps.c gl2ps.h)
+- target_link_libraries(shared ${EXTERNAL_LIBRARIES})
+- set_target_properties(shared PROPERTIES OUTPUT_NAME gl2ps
++ target_link_libraries(gl2ps ${EXTERNAL_LIBRARIES})
++ set_target_properties(gl2ps PROPERTIES OUTPUT_NAME gl2ps
+ VERSION ${GL2PS_MAJOR_VERSION}.${GL2PS_MINOR_VERSION}.${GL2PS_PATCH_VERSION}
+ SOVERSION ${GL2PS_MAJOR_VERSION})
+ if(WIN32 OR CYGWIN)
+- set_target_properties(shared PROPERTIES
++ set_target_properties(gl2ps PROPERTIES
+ COMPILE_FLAGS "-DGL2PSDLL -DGL2PSDLL_EXPORTS")
+ endif()
+- install(TARGETS lib shared RUNTIME DESTINATION bin
++ install(TARGETS gl2ps RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib${LIB_SUFFIX}
+ ARCHIVE DESTINATION lib${LIB_SUFFIX})
+ endif()
+@@ -171,9 +170,9 @@ install(FILES ${CMAKE_SOURCE_DIR}/gl2psTestSimple.c DESTINATION ${GL2PS_DOC})
+
+ if(GLUT_FOUND)
+ add_executable(gl2psTest WIN32 gl2psTest.c)
+- target_link_libraries(gl2psTest lib ${EXTERNAL_LIBRARIES})
++ target_link_libraries(gl2psTest gl2ps ${EXTERNAL_LIBRARIES})
+ add_executable(gl2psTestSimple WIN32 gl2psTestSimple.c)
+- target_link_libraries(gl2psTestSimple lib ${EXTERNAL_LIBRARIES})
++ target_link_libraries(gl2psTestSimple gl2ps ${EXTERNAL_LIBRARIES})
+ endif()
+
+ find_package(LATEX)