Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codeblocks generation error #463

Open
ovenpasta opened this issue Feb 14, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@ovenpasta
Copy link

commented Feb 14, 2019

Hi, having problems with clion... but also with others...

clion-2018.3.4/bin/cmake/linux/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /home/aldo/prova1/Projucer
CMake Error at /home/aldo/FRUT/cmake/Reprojucer.cmake:1540 (message):
  You must call jucer_export_target("Code::Blocks (Linux)") before calling
  jucer_project_end().
Call Stack (most recent call first):
  CMakeLists.txt:742 (jucer_project_end)

Where did the string "Code::Blocks (Linux)" came from?

here is the official string for the generators:
https://cmake.org/cmake/help/latest/generator/CodeBlocks.html#codeblocks

I saw that the code in Reprojucer.cmake improperly uses that string to check for the generator
but it should be "CodeBlocks - Unix Makefiles"...

I've even succeded cross compiling to mingw64 using mxe cmake toolchain with some hacks to the Reprojucer.cmake script. Much painful!

@McMartin

This comment has been minimized.

Copy link
Owner

commented Feb 14, 2019

Hi @ovenpasta,

Thanks for giving a try to FRUT!


Where did the string "Code::Blocks (Linux)" came from?

Code::Blocks (Linux) is one of the Projucer export targets (also called "exporters") that Reprojucer.cmake supports. Reprojucer.cmake supports two of these export targets on Linux: Linux Makefile and Code::Blocks (Linux).


I saw that the code in Reprojucer.cmake improperly uses that string to check for the generator
but it should be "CodeBlocks - Unix Makefiles"...

I think you misunderstood what Reprojucer.cmake is doing. Let's consider the following .jucer project file (created with Projucer 5.4.2):

<?xml version="1.0" encoding="UTF-8"?>

<JUCERPROJECT id="HgTYRQ" name="LinuxOnlyApp" projectType="consoleapp" jucerVersion="5.4.2">
  <MAINGROUP id="xkAArJ" name="LinuxOnlyApp">
    <GROUP id="{9B88DEC0-3AE7-1B81-3370-F41E4B94E9A3}" name="Source">
      <FILE id="fLvRxG" name="Main.cpp" compile="1" resource="0" file="Source/Main.cpp"/>
    </GROUP>
  </MAINGROUP>
  <EXPORTFORMATS>
    <LINUX_MAKE targetFolder="Builds/LinuxMakefile" extraDefs="BUILD_WITH_MAKE=1">
      <CONFIGURATIONS>
        <CONFIGURATION isDebug="1" name="Debug"/>
        <CONFIGURATION isDebug="0" name="Release"/>
      </CONFIGURATIONS>
      <MODULEPATHS/>
    </LINUX_MAKE>
    <CODEBLOCKS_LINUX targetFolder="Builds/CodeBlocksLinux" extraDefs="BUILD_WITH_CODEBLOCKS=1">
      <CONFIGURATIONS>
        <CONFIGURATION isDebug="1" name="Debug"/>
        <CONFIGURATION isDebug="0" name="Release"/>
      </CONFIGURATIONS>
      <MODULEPATHS/>
    </CODEBLOCKS_LINUX>
  </EXPORTFORMATS>
  <MODULES/>
  <LIVE_SETTINGS>
    <WINDOWS/>
  </LIVE_SETTINGS>
  <JUCEOPTIONS JUCE_STRICT_REFCOUNTEDPOINTER="1"/>
</JUCERPROJECT>

When we use Jucer2Reprojucer to convert this .jucer project into a CMakeLists.txt file, we get:

# This file was generated by Jucer2Reprojucer from "LinuxOnlyApp.jucer"

cmake_minimum_required(VERSION 3.4)

project("LinuxOnlyApp")


list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../FRUT/cmake")
include(Reprojucer)


set(LinuxOnlyApp_jucer_FILE
  "${CMAKE_CURRENT_LIST_DIR}/LinuxOnlyApp.jucer"
)


jucer_project_begin(
  JUCER_VERSION "5.4.2"
  PROJECT_FILE "${LinuxOnlyApp_jucer_FILE}"
  PROJECT_ID "HgTYRQ"
)

jucer_project_settings(
  PROJECT_NAME "LinuxOnlyApp"
  PROJECT_VERSION "1.0.0"
  PROJECT_TYPE "Console Application"
  BUNDLE_IDENTIFIER "com.yourcompany.LinuxOnlyApp"
  CXX_LANGUAGE_STANDARD "C++14"
)

jucer_project_files("LinuxOnlyApp/Source"
# Compile   Xcode     Binary
#           Resource  Resource
  x         .         .         "Source/Main.cpp"
)

jucer_export_target(
  "Linux Makefile"
  EXTRA_PREPROCESSOR_DEFINITIONS
    "BUILD_WITH_MAKE=1"
)

jucer_export_target_configuration(
  "Linux Makefile"
  NAME "Debug"
  DEBUG_MODE ON
)

jucer_export_target_configuration(
  "Linux Makefile"
  NAME "Release"
  DEBUG_MODE OFF
)

jucer_export_target(
  "Code::Blocks (Linux)"
  EXTRA_PREPROCESSOR_DEFINITIONS
    "BUILD_WITH_CODEBLOCKS=1"
)

jucer_export_target_configuration(
  "Code::Blocks (Linux)"
  NAME "Debug"
  DEBUG_MODE ON
  ARCHITECTURE "64-bit (-m64)"
)

jucer_export_target_configuration(
  "Code::Blocks (Linux)"
  NAME "Release"
  DEBUG_MODE OFF
  ARCHITECTURE "64-bit (-m64)"
)

jucer_project_end()

Now, depending on the CMake generator (more precisely, the value of CMAKE_EXTRA_GENERATOR), Reprojucer.cmake will either consider the settings for the "Linux Makefile" export target or for the "Code::Blocks (Linux)" one. In your case, you are using the CodeBlocks - Unix Makefiles CMake generator, which sets CMAKE_EXTRA_GENERATOR to CodeBlocks, so Reprojucer.cmake only considers the settings for the "Code::Blocks (Linux)" export target. If your CMakeLists.txt file doesn't call jucer_export_target("Code::Blocks (Linux)" ...), then Reprojucer.cmake aborts.


I've even succeded cross compiling to mingw64 using mxe cmake toolchain with some hacks to the Reprojucer.cmake script. Much painful!

Reprojucer.cmake is meant, as its name suggests, to reproduce what Projucer does. It is not meant to be a generic CMake script that can handle any use cases. I guess you would be more interested in a FindJUCE.cmake module, that would allow you to do:

find_package(JUCE COMPONENTS juce_audio_utils)
add_executable(AudioPlayer ...)
target_link_libraries(AudioPlayer PRIVATE
  JUCE::juce_audio_basics::sources
  JUCE::juce_audio_devices::sources
  JUCE::juce_audio_formats::sources
  JUCE::juce_audio_processors::sources
  JUCE::juce_audio_utils::sources
  JUCE::juce_core::sources
  JUCE::juce_data_structures::sources
  JUCE::juce_events::sources
  JUCE::juce_graphics::sources
  JUCE::juce_gui_basics::sources
  JUCE::juce_gui_extra::sources
)

I am currently working on such a FindJUCE.cmake module, but it's not an easy task and it will take me quite some time until I can merge something like this in FRUT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.