10-parameterisable_lib_type

This page applies to v0.1-alpha
home > 0.1-alpha home

# This example demonstrates how to set up a lib so that it can be either static or dynamic without duplicating code or
# changing the app that depends on it.

extend_jdl do
  attr :lib_type, type: :choice do
    title "Lib type"
    items [:lib, :dll]
    default :lib
  end
end

target :AppWithStaticOrDynamicLib do
  type :console
  src 'main.cpp'
  deps [:StaticOrDynamicLib]
end

target :StaticOrDynamicLib, root: 'StaticOrDynamicLib' do
  type lib_type
  src ['.']
  inc ['include'], :export
  case type
  when :lib
    define ['SODL_STATIC'], :export
  when :dll
    define ['DLL_EXPORT']
  end
end

Generated using Redcarpet, CodeRay, Inter and FiraCode. css by Harry Denholm.