Setting the CPU Frequency (STM32F411CU, HAL or libopencm3)

I have started to play with PlatformIO and have a working blinking LED in two projects, one with HAL, another with libopencm3.
Both of them use this to blink (so clock changes would be visible):

while(true) {
gpio_toggle(LEDPORT, LEDPIN); //Using API function gpio_toggle()
for (i = 0; i<1000000; i++)
asm(“nop”);
}

None of the projects sets the clock explicitly in main.c or elswhere. So I have tried to edit platform.ini:
board_build.f_cpu = 18000000L
build_flags = -D HSE_VALUE=12000000U
build_flags = -D SYS_CLOCK=12000000L
None of these settings changed the blinking frequency.

Is it possible to change the clock (PLL, divider, …) in HAL or libopencm3 projects? What am I doing wrong?
Thanks

Hi!
for libopencm3 use functions like
rcc_clock_setup_pll(&rcc_hse_25mhz_3v3[RCC_CLOCK_3V3_168MHZ]); or configure pll manually with code

Thanks, that worked for libopencm3.
I will have to make own ‘rcc_hse’ define to set more options, but it’s straight forward.

static RCC_ClkInitTypeDef rccClkInstance =
{
    .ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2,
    .SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK,
    .AHBCLKDivider = RCC_SYSCLK_DIV1,
    .APB1CLKDivider = RCC_HCLK_DIV1,
    .APB2CLKDivider = RCC_HCLK_DIV1,
};

static RCC_OscInitTypeDef clock_setup = {
    .OscillatorType = RCC_OSCILLATORTYPE_HSE,
    .HSEState = RCC_CR_HSEON,
    .PLL = {       //100MHz with external 25MHz quarz
        .PLLState = RCC_PLL_ON,
        .PLLSource = RCC_PLLSOURCE_HSE,
        .PLLM = 25,
        .PLLN = 400,
        .PLLP = RCC_PLLP_DIV4,
    }
};

void main()
{
	HAL_Init();
	if(HAL_RCC_OscConfig(&clock_setup) != HAL_OK) Error_Handler();
	if(HAL_RCC_ClockConfig(&rccClkInstance, FLASH_LATENCY_2) != HAL_OK) Error_Handler();
	...
}

works as initialisation using HAL manually (without using STM32CubeMX).
I was falsely thinking that PlatformIO configures the chip on it own, because of existing .ini flags.