From 786b291d9c6b784c7ce6ceef0e38a4ec76ea14db Mon Sep 17 00:00:00 2001 From: Nicky Date: Wed, 6 Apr 2022 16:32:52 +0200 Subject: Move CMake files to modernized cmake syntax, step 1. Change projects to cmake targetsto get rid of havig to hardcore include directories and link libraries in consumer projects. --- indra/cmake/PNG.cmake | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'indra/cmake/PNG.cmake') diff --git a/indra/cmake/PNG.cmake b/indra/cmake/PNG.cmake index 248a875a19..54b2438425 100644 --- a/indra/cmake/PNG.cmake +++ b/indra/cmake/PNG.cmake @@ -1,6 +1,11 @@ # -*- cmake -*- include(Prebuilt) +if( TARGET libpng::libpng ) + return() +endif() +create_target(libpng::libpng) + set(PNG_FIND_QUIETLY ON) set(PNG_FIND_REQUIRED ON) @@ -9,26 +14,9 @@ if (USESYSTEMLIBS) else (USESYSTEMLIBS) use_prebuilt_binary(libpng) if (WINDOWS) - set(PNG_LIBRARIES libpng16) - set(PNG_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/libpng16) - elseif(DARWIN) - set(PNG_LIBRARIES png16) - set(PNG_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/libpng16) + set_target_libraries(libpng::libpng libpng16) else() - # - # When we have updated static libraries in competition with older - # shared libraries and we want the former to win, we need to do some - # extra work. The *_PRELOAD_ARCHIVES settings are invoked early - # and will pull in the entire archive to the binary giving it - # priority in symbol resolution. Beware of cmake moving the - # achive load itself to another place on the link command line. If - # that happens, you can try something like -Wl,-lpng16 here to hide - # the archive. Also be aware that the linker will not tolerate a - # second whole-archive load of the archive. See viewer's - # CMakeLists.txt for more information. - # - set(PNG_PRELOAD_ARCHIVES -Wl,--whole-archive png16 -Wl,--no-whole-archive) set(PNG_LIBRARIES png16) - set(PNG_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/libpng16) endif() + set_target_include_dirs( libpng::libpng ${LIBS_PREBUILT_DIR}/include/libpng16) endif (USESYSTEMLIBS) -- cgit v1.2.3 From be71a255a0831b865bdd6a1a2c8b86ac710fd379 Mon Sep 17 00:00:00 2001 From: Nicky Date: Wed, 6 Apr 2022 22:37:09 +0200 Subject: Set PNG link targets for OSX and Linux --- indra/cmake/PNG.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/cmake/PNG.cmake') diff --git a/indra/cmake/PNG.cmake b/indra/cmake/PNG.cmake index 54b2438425..cf338ebe5e 100644 --- a/indra/cmake/PNG.cmake +++ b/indra/cmake/PNG.cmake @@ -16,7 +16,7 @@ else (USESYSTEMLIBS) if (WINDOWS) set_target_libraries(libpng::libpng libpng16) else() - set(PNG_LIBRARIES png16) + set_target_libraries(libpng::libpng png16 ) endif() set_target_include_dirs( libpng::libpng ${LIBS_PREBUILT_DIR}/include/libpng16) endif (USESYSTEMLIBS) -- cgit v1.2.3 From d3521b4462195cfe882b2cc8eb4e7c5e948c0fb6 Mon Sep 17 00:00:00 2001 From: Nicky Date: Wed, 13 Apr 2022 10:28:46 +0200 Subject: Remove obsolete and unmaintained USE_SYSTEMLIBS --- indra/cmake/PNG.cmake | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'indra/cmake/PNG.cmake') diff --git a/indra/cmake/PNG.cmake b/indra/cmake/PNG.cmake index cf338ebe5e..819904b6bd 100644 --- a/indra/cmake/PNG.cmake +++ b/indra/cmake/PNG.cmake @@ -6,17 +6,10 @@ if( TARGET libpng::libpng ) endif() create_target(libpng::libpng) -set(PNG_FIND_QUIETLY ON) -set(PNG_FIND_REQUIRED ON) - -if (USESYSTEMLIBS) - include(FindPNG) -else (USESYSTEMLIBS) - use_prebuilt_binary(libpng) - if (WINDOWS) - set_target_libraries(libpng::libpng libpng16) - else() - set_target_libraries(libpng::libpng png16 ) - endif() - set_target_include_dirs( libpng::libpng ${LIBS_PREBUILT_DIR}/include/libpng16) -endif (USESYSTEMLIBS) +use_prebuilt_binary(libpng) +if (WINDOWS) + set_target_libraries(libpng::libpng libpng16) +else() + set_target_libraries(libpng::libpng png16 ) +endif() +set_target_include_dirs( libpng::libpng ${LIBS_PREBUILT_DIR}/include/libpng16) -- cgit v1.2.3 From 241919e7f7986c11586a49bff53cf19c2c0e0ea6 Mon Sep 17 00:00:00 2001 From: Nicky Date: Wed, 13 Apr 2022 19:21:55 +0200 Subject: Rework cmake, the original plan was to maybe be able to use conan targets with the same name (that's why 3ps had names like apr::apr), but it's safer and saner to put the LL 3ps under the ll:: prefix. This also allows means it is possible to get rid of that bad "if( TRAGET ...) return() endif()" pattern and rather use include_guard(). --- indra/cmake/PNG.cmake | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'indra/cmake/PNG.cmake') diff --git a/indra/cmake/PNG.cmake b/indra/cmake/PNG.cmake index 819904b6bd..2838a6b667 100644 --- a/indra/cmake/PNG.cmake +++ b/indra/cmake/PNG.cmake @@ -1,15 +1,13 @@ # -*- cmake -*- include(Prebuilt) -if( TARGET libpng::libpng ) - return() -endif() -create_target(libpng::libpng) +include_guard() +create_target(ll::libpng) use_prebuilt_binary(libpng) if (WINDOWS) - set_target_libraries(libpng::libpng libpng16) + set_target_libraries(ll::libpng libpng16) else() - set_target_libraries(libpng::libpng png16 ) + set_target_libraries(ll::libpng png16 ) endif() -set_target_include_dirs( libpng::libpng ${LIBS_PREBUILT_DIR}/include/libpng16) +set_target_include_dirs( ll::libpng ${LIBS_PREBUILT_DIR}/include/libpng16) -- cgit v1.2.3 From 6d0bba9c03da0d8aca5e88fcb9289cb2f89f3467 Mon Sep 17 00:00:00 2001 From: Nicky Date: Sun, 17 Apr 2022 17:32:14 +0200 Subject: Switch over to standard target_link_libraries (cmake requirements are high enough now). --- indra/cmake/PNG.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/cmake/PNG.cmake') diff --git a/indra/cmake/PNG.cmake b/indra/cmake/PNG.cmake index 2838a6b667..ef4f492ec2 100644 --- a/indra/cmake/PNG.cmake +++ b/indra/cmake/PNG.cmake @@ -6,8 +6,8 @@ create_target(ll::libpng) use_prebuilt_binary(libpng) if (WINDOWS) - set_target_libraries(ll::libpng libpng16) + target_link_libraries(ll::libpng INTERFACE libpng16) else() - set_target_libraries(ll::libpng png16 ) + target_link_libraries(ll::libpng INTERFACE png16 ) endif() set_target_include_dirs( ll::libpng ${LIBS_PREBUILT_DIR}/include/libpng16) -- cgit v1.2.3 From e0cf0cdfd49e5a946dcd202a083fb23f01e4f1fe Mon Sep 17 00:00:00 2001 From: Nicky Date: Sun, 17 Apr 2022 18:04:57 +0200 Subject: Switch to target_include_directories All 3Ps include dirs are treated as SYSTEM, this will stop compilers stop emitting warnings from those files and greatly helps having high warning levels and not being swamped by warnings that come from external libraries. --- indra/cmake/PNG.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/cmake/PNG.cmake') diff --git a/indra/cmake/PNG.cmake b/indra/cmake/PNG.cmake index ef4f492ec2..5a8d3e197d 100644 --- a/indra/cmake/PNG.cmake +++ b/indra/cmake/PNG.cmake @@ -10,4 +10,4 @@ if (WINDOWS) else() target_link_libraries(ll::libpng INTERFACE png16 ) endif() -set_target_include_dirs( ll::libpng ${LIBS_PREBUILT_DIR}/include/libpng16) +target_include_directories( ll::libpng SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/libpng16) -- cgit v1.2.3 From 363f2df4fa22b3eb95ff4603d73b7a042f3fefd1 Mon Sep 17 00:00:00 2001 From: Nicky Date: Sun, 17 Apr 2022 18:28:55 +0200 Subject: Remove function create_target and instead directly use add_library --- indra/cmake/PNG.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/cmake/PNG.cmake') diff --git a/indra/cmake/PNG.cmake b/indra/cmake/PNG.cmake index 5a8d3e197d..672f963ea1 100644 --- a/indra/cmake/PNG.cmake +++ b/indra/cmake/PNG.cmake @@ -2,7 +2,7 @@ include(Prebuilt) include_guard() -create_target(ll::libpng) +add_library( ll::libpng INTERFACE IMPORTED ) use_prebuilt_binary(libpng) if (WINDOWS) -- cgit v1.2.3 From 2b151e0aefd54671e1be504269f10318d303dccb Mon Sep 17 00:00:00 2001 From: Nicky Date: Mon, 18 Apr 2022 18:11:43 +0200 Subject: Round one to support conan for 3P packages, this allows to build the viewer on Linux again. --- indra/cmake/PNG.cmake | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/cmake/PNG.cmake') diff --git a/indra/cmake/PNG.cmake b/indra/cmake/PNG.cmake index 672f963ea1..8e870f631f 100644 --- a/indra/cmake/PNG.cmake +++ b/indra/cmake/PNG.cmake @@ -4,6 +4,7 @@ include(Prebuilt) include_guard() add_library( ll::libpng INTERFACE IMPORTED ) +use_conan_binary(libpng) use_prebuilt_binary(libpng) if (WINDOWS) target_link_libraries(ll::libpng INTERFACE libpng16) -- cgit v1.2.3 From 3f31d0b5a70af4ebf746d40d478b4e948e904a87 Mon Sep 17 00:00:00 2001 From: Nicky Date: Sun, 17 Jul 2022 17:51:25 +0200 Subject: Be more explicit: Rename use_conan_binary to use_system_binary, this will allow us to reuse the macro for more than just conan. --- indra/cmake/PNG.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/cmake/PNG.cmake') diff --git a/indra/cmake/PNG.cmake b/indra/cmake/PNG.cmake index 8e870f631f..044262bc8d 100644 --- a/indra/cmake/PNG.cmake +++ b/indra/cmake/PNG.cmake @@ -4,7 +4,7 @@ include(Prebuilt) include_guard() add_library( ll::libpng INTERFACE IMPORTED ) -use_conan_binary(libpng) +use_system_binary(libpng) use_prebuilt_binary(libpng) if (WINDOWS) target_link_libraries(ll::libpng INTERFACE libpng16) -- cgit v1.2.3