SFML community forums

General => General discussions => Topic started by: OniLinkPlus on September 07, 2011, 06:25:38 am

Title: Premake
Post by: OniLinkPlus on September 07, 2011, 06:25:38 am
You don't have to use it. Just want you to look at it. I think it looks far superior to CMake (imo). Might be a good idea. Looks like it's far easier to grasp.
Title: Premake
Post by: Klaim on September 07, 2011, 01:57:44 pm
I'm watching it because I think it could be a better alternative than CMake in some context, like games.

My current CMake project uses Qt so until the Qt scripts are fixed in Premake I can't test Premake with this project.

However, I have another simple game project that might be a perfect test case fore Premake.
Title: Premake
Post by: ratzlaff on September 07, 2011, 11:17:24 pm
I am watching it as well, looks to be easier to set up than cmake and I like that it is using some other language (lua) for setup instead of inventing another.
Title: Premake
Post by: Grimshaw on September 08, 2011, 01:34:28 am
I would be really interested in this, if anyone here with a sounding word tells me i should :)
Title: Premake
Post by: Hiura on September 08, 2011, 10:43:46 am
I just had a quick look at premake and I'm not so positive about it.

It seems too young and not adapted to be used for a large project. (Maybe I'm wrong but the quick start examples are not so encouraging.)
Moreover I would not be able to create OS X frameworks with premake.

Another pro (at least it works for me) to stick with cmake is : laziness. I would mean to rewrite everything (that currently work, btw).
And so it would postpone SFML 2.0 release date.  :wink:
Title: Premake
Post by: Laurent on September 08, 2011, 10:59:58 am
Quote
And so it would postpone SFML 2.0 release date

It could be changed after SFML 2.0 is out, since it doesn't involve changing the API.

I'd like to evaluate it, or even try to convert SFML, but I'm afraid I won't have the time to do it.
Title: Premake
Post by: omeg on September 08, 2011, 11:15:19 am
Don't fix something that ain't broken imo. ;) Is there any problem with CMake? If not, leave it.
Title: Premake
Post by: ratzlaff on September 08, 2011, 06:40:07 pm
With cmake, I cannot generate a project for someone else without requiring them to also install cmake. (If there is a way to do this, then I am unaware of it) That is the largest problem I have with it.
Title: Premake
Post by: OniLinkPlus on September 08, 2011, 10:45:38 pm
Quote from: "omeg"
Don't fix something that ain't broken imo. ;) Is there any problem with CMake? If not, leave it.
It has no good documentation. Anywhere. That's the biggest complaint everyone has.
Title: Premake
Post by: Klaim on September 09, 2011, 08:54:04 pm
Quote from: "omeg"
Don't fix something that ain't broken imo. ;) Is there any problem with CMake? If not, leave it.


I agree.

However, I have personally some problems with CMake so if it was my project I would have invested some time :D

Maybe if me or someone else can try the conversion, it would help Laurent. I can't until next year TT__TT but maybe I'll be able to help later.
Title: Premake
Post by: CodeRarity on September 10, 2011, 05:58:12 pm
Quote from: "omeg"
Don't fix something that ain't broken imo. ;) Is there any problem with CMake? If not, leave it.


http://industriousone.com/debugdir

Works in Visual Studios. Enough said*.

EDIT: on that note, CMake may have no intention of adding this, judging by the way the write about it here (http://www.vtk.org/Wiki/CMake_FAQ#Can_CMake_set_the_Debugging.2FWorking_Directory_property_in_Visual_Studio_projects.3F). This may not be relevant for SFML except for the examples, but it'd be nice for SFML to use Premake as well as my own projects.

*Not really, I had more to say.
Title: Premake
Post by: Richy19 on September 10, 2011, 06:16:28 pm
you could always give the premake script and the cmake together.
Title: Premake
Post by: CodeRarity on September 10, 2011, 07:48:24 pm
It'd be a lot of work to update both build systems though.
Title: Premake
Post by: Svenstaro on September 11, 2011, 01:17:13 pm
I feel rather comfortable in CMake and the script language is really the only thing I dislike. It is easy to make a cross-platform project with CMake and it has a lot of Find* scripts to locate things on various systems even when cross-compiling.

Premake might have all that but seriously, CMake works and isn't broken. What is the issue here?
Title: Premake
Post by: CodeRarity on September 11, 2011, 03:00:50 pm
Quote from: "Svenstaro"
I feel rather comfortable in CMake and the script language is really the only thing I dislike. It is easy to make a cross-platform project with CMake and it has a lot of Find* scripts to locate things on various systems even when cross-compiling.

Premake might have all that but seriously, CMake works and isn't broken. What is the issue here?


Was the build system in place before CMake broken? Probably not.
Title: Premake
Post by: Svenstaro on September 11, 2011, 09:36:53 pm
Quote from: "CodeRarity"
Quote from: "Svenstaro"
I feel rather comfortable in CMake and the script language is really the only thing I dislike. It is easy to make a cross-platform project with CMake and it has a lot of Find* scripts to locate things on various systems even when cross-compiling.

Premake might have all that but seriously, CMake works and isn't broken. What is the issue here?


Was the build system in place before CMake broken? Probably not.


It was. It was a bunch of project files and Makefiles all maintained manually and it probably was a PITA for Laurent to maintain. Also the Makefiles didn't allow for using system libs and they were a pain for cross-compiling.
Title: Premake
Post by: CodeRarity on September 12, 2011, 02:23:45 am
Quote
It was. It was a bunch of project files and Makefiles all maintained manually and it probably was a PITA for Laurent to maintain. Also the Makefiles didn't allow for using system libs and they were a pain for cross-compiling.

Quote
bro┬Ěken
adjective
1.
not functioning properly; out of working order.


Annoying, maybe not "broken". Even though it was hard to maintain, it did indeed function properly. CMake can be seen the same way, kind of annoying.

Code: [Select]
if os.get() ~= "windows" then
print "Your operating system is not yet supported."
return
end

solution "Sortmania"
function AddSFMLLinks()
links { "opengl32", "winmm", "freetype", "glew", "jpeg", "openal32", "sndfile" }

configuration { "gmake", "windows" }
libdirs { "sfml/extlibs/libs-mingw" }

if string.startswith(_ACTION, "vs") then
configuration { "x32", "vs*" }
libdirs { "sfml/extlibs/libs-msvc/x86" }

configuration { "x64", "vs*" }
libdirs { "sfml/extlibs/libs-msvc/x64" }
end
end

configurations { "Debug", "Release" }
if string.startswith(_ACTION, "vs") then
platforms { "x32", "x64" }
end

project "SFML"
kind "StaticLib"
language "C++"

includedirs { "sfml/include", "sfml/extlibs/headers", "sfml/extlibs/headers/AL", "sfml/extlibs/headers/jpeg", "sfml/src" }
files { "sfml/src/**.cpp" }
defines { "SFML_STATIC" }

configuration "Debug"
targetdir "Debug"
defines { "DEBUG" }
flags { "Symbols" }

configuration "Release"
targetdir "Release"
defines { "NDEBUG" }
flags { "Optimize" }

configuration "windows"
includedirs { "sfml/extlibs/headers/libsndfile/windows" }
excludes { "sfml/src/SFML/Window/OSX/**", "sfml/src/SFML/Window/Linux/**",
"sfml/src/SFML/System/Unix/**", "sfml/src/SFML/Network/Unix/**" }

project "Sortmania"
kind "WindowedApp"
language "C++"

includedirs { "src", "sfml/include" }
files { "src/**.cpp" }
defines { "SFML_STATIC" }
links { "SFML" }
AddSFMLLinks()

configuration "Debug"
targetdir "Debug"
defines { "DEBUG" }
flags { "Symbols" }

configuration "Release"
targetdir "Release"
defines { "NDEBUG" }
flags { "Optimize" }


I was able to get SFML into my Premake4 solution like this, just by guess and check. It's only static, and only works on Windows (tested on MinGW, haven't linked to a project yet but the output looked about right), but I'll probably add more as I compile it on those systems. Since it's not complete, it's probably not as long as a final product would be. But still, it's much shorter and more readable than CMake scripts, and therefore more maintainable.

EDIT: Works in Visual Studios 2010 Professional.

EDIT2: Oh, I fixed stuff. And I successfully linked it into an example. I'm just going to put my whole project file here, to make it really easy for  other people to adopt Premake.

EDIT3: I'm moving this into a new thread, because I want to share my work with the community without stealing this thread. I think I have made my point.
Title: Premake
Post by: Svenstaro on September 12, 2011, 04:12:03 am
Looks like we are splitting hairs and are playing build system golf. Here is mine:

Code: [Select]
cmake_minimum_required(VERSION 2.8)

project(sfml)
file(GLOB sfml_SRC
    src/SFML/Audio/*.cpp
    src/SFML/Window/*.cpp
    src/SFML/Window/Linux/*.cpp
    src/SFML/System/*.cpp
    src/SFML/System/Unix/*.cpp
    src/SFML/Graphics/*.cpp
    src/SFML/Network/*.cpp
    src/SFML/Network/Unix/*.cpp)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")

find_package(OpenAL REQUIRED)
find_package(OpenGL REQUIRED)
find_package(Freetype REQUIRED)
find_package(GLEW REQUIRED)
find_package(JPEG REQUIRED)
find_package(X11 REQUIRED)
find_package(ZLIB REQUIRED)
find_package(Sndfile REQUIRED)

include_directories(${OPENAL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR}
    ${FREETYPE_INCLUDE_DIRS} ${GLEW_INCLUDE_PATH} ${JPEG_INCLUDE_DIR}
    ${X11_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS} ${SNDFILE_INCLUDE_DIR})

include_directories(src include)

add_library(sfml SHARED ${sfml_SRC})
target_link_libraries(sfml ${OPENAL_LIBRARY} ${OPENGL_LIBRARIES}
    ${FREETYPE_LIBRARIES} ${GLEW_LIBRARY} ${JPEG_LIBRARIES} ${X11_LIBRARIES}
    ${ZLIB_LIBRARIES} ${SNDFILE_LIBRARIES})


Quote
$ wc -l CMakeLists.txt
34 CMakeLists.txt


Anyway, I think this is rather silly. Why don't you spend your resources helping other open-source projects that actually don't have any proper build system? libtcod comes to mind. There are probably many others.
Title: Premake
Post by: CodeRarity on September 12, 2011, 04:24:46 am
What about your FindXXXX.cmake files? And all the files in your /cmake/Modules path, for that matter?
Title: Premake
Post by: Svenstaro on September 12, 2011, 04:38:05 am
Well you provide those that CMake doesn't provide by itself. Or you could find things the raw way which is also what Premake4 seems to be doing. In that case you don't need FindX files, obviously.
Title: Premake
Post by: CodeRarity on September 12, 2011, 05:35:42 am
What my project files would look like if I did something similar to what you have done with CMake files (moving the code to FindXXX.cmake files, essentially):

Code: [Select]
dofile "sfml/sfml_static.lua"
solution "Sortmania"
   AddSFML()

   project "Sortmania"
      kind "WindowedApp"
      language "C++"

      includedirs { "src" }
      files { "src/**.cpp" }
      LinkSFML()

      configuration "Debug"
         defines { "DEBUG" }
         flags { "Symbols" }

      configuration "Release"
         flags { "Optimize" }


If you don't think that's short, readable and manageable, you shouldn't be programming.

Here's a list of other ways why people should use Premake over CMake:

-Easier to NOT use Premake
For example, if you are only making your project on Windows, and you are using Visual Studios, it might be better for you to just generate the project files and add those to your solution. With CMake, you actually have to edit the vcxproj files (to get rid of the build step) in Notepad to make it not run CMake every time. Then you get to go through and delete CMakeLists files and find all of the little things CMake left behind. In Premake, you generate it, and delete the lua file, and you're done.

-No junk files ("build directory")
I hate generating a project in CMake and having an entire folder of irrelevant trash. I just want the project files. This disgusts me.

-It uses a scripting langauge
A lot of programmers know Lua (especially in the game industry, where it is used in multiple game engines). If you want to start using CMake, you have to learn an entirely new language, that's not elegant or even reasonably readable at all.

-Documentation
Premake has a nice "Scripting with Premake" (http://industriousone.com/scripting-premake) tutorial section, in addition to pretty straightforward scripting reference (http://industriousone.com/scripting-reference). CMake has a generated, monolithic list of commands (http://www.cmake.org/cmake/help/cmake-2-8-docs.html).