瀏覽代碼

CMake: Remove _RAYLIB suffix from -D{SHARED,STATIC}_RAYLIB

They were named so for compatibility with make, but make doesn't use
the anymore. I always forget whether it's SHARED_RAYLIB or
RAYLIB_SHARED...

For now, RAYLIB_SHARED and STATIC_RAYLIB may still be used,
but print a deprecation warning.
Ahmad Fatoum 7 年之前
父節點
當前提交
051040af2d
共有 3 個文件被更改,包括 20 次插入11 次删除
  1. 1 1
      .travis.yml
  2. 1 1
      appveyor.yml
  3. 18 9
      src/CMakeLists.txt

+ 1 - 1
.travis.yml

@@ -45,7 +45,7 @@ before_install:
 script:
 script:
   - mkdir build
   - mkdir build
   - cd build
   - cd build
-  - cmake -DMACOS_FATLIB=ON -DSTATIC_RAYLIB=ON -DSHARED_RAYLIB=ON -DBUILD_EXAMPLES=ON -DBUILD_GAMES=ON -DUSE_EXTERNAL_GLFW=IF_POSSIBLE ..
+  - cmake -DMACOS_FATLIB=ON -DSTATIC=ON -DSHARED=ON -DBUILD_EXAMPLES=ON -DBUILD_GAMES=ON -DUSE_EXTERNAL_GLFW=IF_POSSIBLE ..
   - make VERBOSE=1
   - make VERBOSE=1
   - make package
   - make package
 
 

+ 1 - 1
appveyor.yml

@@ -39,7 +39,7 @@ before_build:
   - cd build
   - cd build
 
 
 build_script:
 build_script:
-  - cmake -G %GENERATOR% -DSTATIC_RAYLIB=ON -DSHARED_RAYLIB=ON -DBUILD_EXAMPLES=%examples% -DBUILD_GAMES=%examples% ..
+  - cmake -G %GENERATOR% -DSTATIC=ON -DSHARED=ON -DBUILD_EXAMPLES=%examples% -DBUILD_GAMES=%examples% ..
   - cmake --build . --target install
   - cmake --build . --target install
 
 
 after_build:
 after_build:

+ 18 - 9
src/CMakeLists.txt

@@ -10,12 +10,21 @@ set(RAYLIB raylib)    # Name of the generated library
 # Shared library is always PIC. Static library should be PIC too if linked into a shared library
 # Shared library is always PIC. Static library should be PIC too if linked into a shared library
 set(WITH_PIC      OFF CACHE BOOL "Compile static library as position-independent code" OFF)
 set(WITH_PIC      OFF CACHE BOOL "Compile static library as position-independent code" OFF)
 # Build a static and/or shared raylib?
 # Build a static and/or shared raylib?
-set(SHARED_RAYLIB OFF CACHE BOOL "Build raylib as a dynamic library")
-set(STATIC_RAYLIB ON  CACHE BOOL "Build raylib as a static library")
+set(SHARED OFF CACHE BOOL "Build raylib as a dynamic library")
+set(STATIC ON  CACHE BOOL "Build raylib as a static library")
 set(MACOS_FATLIB  ON  CACHE BOOL "Build fat library for both i386 and x86_64 on macOS")
 set(MACOS_FATLIB  ON  CACHE BOOL "Build fat library for both i386 and x86_64 on macOS")
 
 
-if(NOT (STATIC_RAYLIB OR SHARED_RAYLIB))
-  message(FATAL_ERROR "Nothing to do if both -DSHARED_RAYLIB=OFF and -DSTATIC_RAYLIB=OFF...")
+if(NOT (STATIC OR SHARED))
+  message(FATAL_ERROR "Nothing to do if both -DSHARED=OFF and -DSTATIC=OFF...")
+endif()
+
+if(DEFINED SHARED_RAYLIB)
+  set(SHARED ${SHARED_RAYLIB})
+  message(DEPRECATION "-DSHARED_RAYLIB is deprecated. Please use -DSHARED instead.")
+endif()
+if(DEFINED STATIC_RAYLIB)
+  set(STATIC ${STATIC_RAYLIB})
+  message(DEPRECATION "-DSTATIC_RAYLIB is deprecated. Please use -DSTATIC instead.")
 endif()
 endif()
 
 
 # Platform
 # Platform
@@ -85,7 +94,7 @@ endif()
 
 
 if(MACOS_FATLIB)
 if(MACOS_FATLIB)
     if (CMAKE_OSX_ARCHITECTURES)
     if (CMAKE_OSX_ARCHITECTURES)
-        message(FATAL_ERROR "User supplied -DCMAKE_OSX_ARCHITECTURES overrides BUILD_MACOS_FATLIB=ON")
+        message(FATAL_ERROR "User supplied -DCMAKE_OSX_ARCHITECTURES overrides -DMACOS_FATLIB=ON")
     else()
     else()
         SET(CMAKE_OSX_ARCHITECTURES "x86_64;i386")
         SET(CMAKE_OSX_ARCHITECTURES "x86_64;i386")
     endif()
     endif()
@@ -94,7 +103,7 @@ endif()
 # Which platform?
 # Which platform?
 if(${PLATFORM} MATCHES "PLATFORM_DESKTOP")
 if(${PLATFORM} MATCHES "PLATFORM_DESKTOP")
 
 
-  if(${SHARED_RAYLIB})
+  if(${SHARED})
     add_library(${RAYLIB}_shared SHARED ${sources})
     add_library(${RAYLIB}_shared SHARED ${sources})
 
 
     target_compile_definitions(${RAYLIB}_shared
     target_compile_definitions(${RAYLIB}_shared
@@ -127,9 +136,9 @@ if(${PLATFORM} MATCHES "PLATFORM_DESKTOP")
         PUBLIC_HEADER DESTINATION include
         PUBLIC_HEADER DESTINATION include
       )
       )
     endif()
     endif()
-  endif(${SHARED_RAYLIB})
+  endif(${SHARED})
 
 
-  if(${STATIC_RAYLIB})
+  if(${STATIC})
     add_library(${RAYLIB} STATIC ${sources})
     add_library(${RAYLIB} STATIC ${sources})
 
 
     target_compile_definitions(${RAYLIB}
     target_compile_definitions(${RAYLIB}
@@ -147,7 +156,7 @@ if(${PLATFORM} MATCHES "PLATFORM_DESKTOP")
       ARCHIVE DESTINATION lib
       ARCHIVE DESTINATION lib
       PUBLIC_HEADER DESTINATION include
       PUBLIC_HEADER DESTINATION include
     )
     )
-  endif(${STATIC_RAYLIB})
+  endif(${STATIC})
 
 
   configure_file(../raylib.pc.in raylib.pc @ONLY)
   configure_file(../raylib.pc.in raylib.pc @ONLY)
   install(FILES ${CMAKE_BINARY_DIR}/release/raylib.pc DESTINATION lib/pkgconfig)
   install(FILES ${CMAKE_BINARY_DIR}/release/raylib.pc DESTINATION lib/pkgconfig)