diff --git a/cmake-d/UseDub/DubToCMake.d b/cmake-d/UseDub/DubToCMake.d index 5478851..a5b3fd2 100644 --- a/cmake-d/UseDub/DubToCMake.d +++ b/cmake-d/UseDub/DubToCMake.d @@ -21,6 +21,7 @@ int main(string[] args) string json = readText(dubFile); JSONValue root = parseJSON(json); + string target = root["targetName"].str; string cmake = q"< cmake_minimum_required(VERSION 2.8) @@ -46,31 +47,31 @@ if(APP_MAIN_FILE) else(APP_MAIN_FILE) add_library(%1$s ${SRC_FILES}) endif(APP_MAIN_FILE) ->".format(root["targetName"].str); +>".format(target); break; case "none": break; case "executable": cmake ~= q"< add_executable(%s ${SRC_FILES} ${APP_MAIN_FILE}) ->".format(root["targetName"].str); +>".format(target); break; case "library": cmake ~= q"< add_library(%s ${SRC_FILES}) ->".format(root["targetName"].str); +>".format(target); break; case "sourceLibrary": break; case "staticLibrary": cmake ~= q"< add_library(%s STATIC ${SRC_FILES}) ->".format(root["targetName"].str); +>".format(target); break; case "dynamicLibrary": cmake ~= q"< add_library(%s SHARED ${SRC_FILES}) ->".format(root["targetName"].str); +>".format(target); break; default: assert(false, "Unknown targetType"); @@ -84,9 +85,9 @@ add_library(%s SHARED ${SRC_FILES}) { cmake ~= "DubProject_Add(%s %s)\n".format(dependency, version_.str); } + cmake ~= "\nadd_dependencies(%s %-(%s %))\n".format(target, root["dependencies"].object.keys); } - std.file.write(cmakeFile, cmake); return 0; diff --git a/cmake-d/UseDub/DubUrl.d b/cmake-d/UseDub/DubUrl.d index 6c6e839..2947894 100644 --- a/cmake-d/UseDub/DubUrl.d +++ b/cmake-d/UseDub/DubUrl.d @@ -94,24 +94,31 @@ int main(string[] args) } else { - stderr.writefln("No version tagged '%s' found.", packageVersion); + stderr.writefln("%s has no version tagged %s.", root["name"].str, packageVersion); return -1; } } else { - auto nodes = root["versions"].array.filter!(a => SemVer(a["version"].str).valid).array; - auto maxVersion = nodes.map!(a => SemVer(a["version"].str)).array.maxSatisfying(versionRange); + string nodeVersionString(JSONValue node) + { + auto ver = node["version"].str; + ver.skipOver('~'); + return ver; + } + + auto nodes = root["versions"].array.filter!(a => SemVer(nodeVersionString(a)).valid).array; + auto maxVersion = nodes.map!(a => SemVer(nodeVersionString(a))).array.maxSatisfying(versionRange); if (maxVersion.valid) { - auto range = nodes.find!((a, b) => SemVer(a["version"].str) == b)(maxVersion); + auto range = nodes.find!((a, b) => SemVer(nodeVersionString(a)) == b)(maxVersion); assert(!range.empty); node = range[0]; } else { - stderr.writefln("No version '%s' found.", versionRange); + stderr.writefln("%s has no version %s.", root["name"].str, versionRange); return -1; } }